submitting jobs: clean pre- postprocess scripts
authorMaciej Tronowski <mtro@man.poznan.pl>
Thu, 23 Apr 2015 12:18:04 +0000 (14:18 +0200)
committerMaciej Tronowski <mtro@man.poznan.pl>
Thu, 23 Apr 2015 12:18:04 +0000 (14:18 +0200)
qcg/forms.py

index c1fda14..35b34d7 100644 (file)
@@ -118,7 +118,7 @@ class JobDescriptionForm(forms.Form):
 
     application = forms.ChoiceField(choices=APPLICATION_CHOICES, label=u"Aplikacja", required=False)  # TODO choices
     master_file = forms.CharField(label=u"Plik główny", max_length=500, required=False)  # TODO grid ftp
-    executable = forms.CharField(label=u"Plik wykonywalny", max_length=500, required=False)  # TODO grid ftp
+    executable = forms.CharField(label=u"Plik wykonywalny", max_length=500, required=False)
     script = forms.CharField(label=u"Skrypt", widget=forms.Textarea(attrs={'rows': 2, 'cols': 40}), required=False)  # TODO saving to grid ftp
     arguments = forms.MultipleChoiceField(label=u"Argumenty", required=False)
     note = forms.CharField(label=u"Opis", widget=forms.Textarea(attrs={'rows': 2, 'cols': 40}), required=False)
@@ -135,9 +135,9 @@ class JobDescriptionForm(forms.Form):
     modules = forms.MultipleChoiceField(label=u"Moduły", choices=MODULES_CHOICES, required=False)  # TODO choices
     reservation = forms.CharField(label=u"Rezerwacja", max_length=100, required=False)
 
-    # TODO grid ftp
     input = forms.CharField(label=u"Standardowe wejście", max_length=500, required=False)
     stage_in = forms.MultipleChoiceField(label=u"Stage in", required=False)
+    # TODO stage_out (?)
     # stage_out = forms.MultipleChoiceField(label=u"Stage out", required=False)
 
     monitoring = forms.BooleanField(label=u"Portal QCG-Monitoring", required=False)
@@ -152,11 +152,11 @@ class JobDescriptionForm(forms.Form):
     preprocess_type = forms.ChoiceField(label=u"Preprocessing", choices=Process.CHOICES, required=False,
                                         initial=Process.NONE, widget=forms.RadioSelect)
     preprocess_cmd = forms.CharField(label=u"Polecenie", max_length=1000, required=False)
-    preprocess_script = forms.CharField(label=u"Skrypt", max_length=500, required=False)  # TODO grid ftp
+    preprocess_script = forms.CharField(label=u"Skrypt", max_length=500, required=False)
     postprocess_type = forms.ChoiceField(label=u"Postprocessing", choices=Process.CHOICES, required=False,
                                          initial=Process.NONE, widget=forms.RadioSelect)
     postprocess_cmd = forms.CharField(label=u"Polecenie", max_length=1000, required=False)
-    postprocess_script = forms.CharField(label=u"Skrypt", max_length=500, required=False)  # TODO grid ftp
+    postprocess_script = forms.CharField(label=u"Skrypt", max_length=500, required=False)
     native = forms.MultipleChoiceField(label=u"Opcje systemu kolejkowego", required=False)
     persistent = forms.BooleanField(label=u"Trwałe", required=False)
 
@@ -196,21 +196,34 @@ class JobDescriptionForm(forms.Form):
         else:
             data['postprocess'] = ''
 
+        return data
+
     def clean_application(self):
         return self.cleaned_data['application'].split('/', 1) if self.cleaned_data['application'] else ''
 
     def clean_executable(self):
-        return 'gsiftp://' + self.cleaned_data['executable'] if self.cleaned_data['executable'] else ''
+        return self._gsiftp_suffix(self.cleaned_data['executable'])
 
     def clean_nodes(self):
         return map(int, self.cleaned_data['nodes'].split(':', 2)) if self.cleaned_data['nodes'] else ''
 
     def clean_input(self):
-        return 'gsiftp://' + self.cleaned_data['input'] if self.cleaned_data['input'] else ''
+        return self._gsiftp_suffix(self.cleaned_data['input'])
 
     def clean_stage_in(self):
         return ['gsiftp://' + item for item in self.cleaned_data['stage_in']]
 
+    def clean_preprocess_script(self):
+        return self._gsiftp_suffix(self.cleaned_data['preprocess_script'])
+
+    def clean_postprocess_script(self):
+        return self._gsiftp_suffix(self.cleaned_data['postprocess_script'])
+
+    @staticmethod
+    def _gsiftp_suffix(url):
+        return 'gsiftp://' + url if url else ''
+
+
 class EnvForm(forms.Form):
     name = forms.CharField(label=u"Nazwa", max_length=100, validators=[env_name_validator],
                            widget=forms.TextInput(attrs={'placeholder': u'Nazwa'}))