ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/SchedulerEdg.py
(Generate patch)

Comparing COMP/CRAB/python/SchedulerEdg.py (file contents):
Revision 1.62 by slacapra, Tue Jun 20 15:37:51 2006 UTC vs.
Revision 1.102 by slacapra, Tue Oct 17 13:28:03 2006 UTC

# Line 23 | Line 23 | class SchedulerEdg(Scheduler):
23      def configure(self, cfg_params):
24  
25          try:
26 <            RB = cfg_params["EDG.rb"]
27 <            edgConfig = EdgConfig(RB)
28 <            self.edg_config = edgConfig.config()
29 <            self.edg_config_vo = edgConfig.configVO()
26 >            RB=cfg_params["EDG.rb"]
27 >            self.rb_param_file=self.rb_configure(RB)
28          except KeyError:
29 <            self.edg_config = ''
30 <            self.edg_config_vo = ''
33 <
29 >            self.rb_param_file=''
30 >            pass
31          try:
32              self.proxyServer = cfg_params["EDG.proxy_server"]
33          except KeyError:
34              self.proxyServer = 'myproxy.cern.ch'
35          common.logger.debug(5,'Setting myproxy server to '+self.proxyServer)
36  
37 +        try:
38 +            self.group = cfg_params["EDG.group"]
39 +        except KeyError:
40 +            self.group = None
41 +            
42 +        try:
43 +            self.role = cfg_params["EDG.role"]
44 +        except KeyError:
45 +            self.role = None
46 +            
47          try: self.LCG_version = cfg_params["EDG.lcg_version"]
48          except KeyError: self.LCG_version = '2'
49  
43        try: self.EDG_requirements = cfg_params['EDG.requirements']
44        except KeyError: self.EDG_requirements = ''
45
46        try: self.EDG_retry_count = cfg_params['EDG.retry_count']
47        except KeyError: self.EDG_retry_count = ''
48
50          try:
51              self.EDG_ce_black_list = cfg_params['EDG.ce_black_list']
51            #print "self.EDG_ce_black_list = ", self.EDG_ce_black_list
52          except KeyError:
53              self.EDG_ce_black_list  = ''
54  
55          try:
56              self.EDG_ce_white_list = cfg_params['EDG.ce_white_list']
57            #print "self.EDG_ce_white_list = ", self.EDG_ce_white_list
57          except KeyError: self.EDG_ce_white_list = ''
58  
59          try: self.VO = cfg_params['EDG.virtual_organization']
60          except KeyError: self.VO = 'cms'
61  
62 <        try: self.return_data = cfg_params['USER.return_data']
64 <        except KeyError: self.return_data = 1
65 <
66 <        try:
67 <             self.copy_input_data = common.analisys_common_info['copy_input_data']
68 <             #print "self.copy_input_data = ", self.copy_input_data
62 >        try: self.copy_input_data = cfg_params["USER.copy_input_data"]
63          except KeyError: self.copy_input_data = 0
64  
65 +        try: self.return_data = cfg_params['USER.return_data']
66 +        except KeyError: self.return_data = 0
67 +
68          try:
69              self.copy_data = cfg_params["USER.copy_data"]
70              if int(self.copy_data) == 1:
# Line 128 | Line 125 | class SchedulerEdg(Scheduler):
125  
126          try: self.EDG_requirements = cfg_params['EDG.requirements']
127          except KeyError: self.EDG_requirements = ''
128 <                                                                                                                                                            
128 >
129 >        try: self.EDG_addJdlParam = string.split(cfg_params['EDG.additional_jdl_parameters'],',')
130 >        except KeyError: self.EDG_addJdlParam = []
131 >
132          try: self.EDG_retry_count = cfg_params['EDG.retry_count']
133          except KeyError: self.EDG_retry_count = ''
134 <                                                                                                                                                            
134 >
135 >        try: self.EDG_shallow_retry_count= cfg_params['EDG.shallow_retry_count']
136 >        except KeyError: self.EDG_shallow_retry_count = ''
137 >
138          try: self.EDG_clock_time = cfg_params['EDG.max_wall_clock_time']
139          except KeyError: self.EDG_clock_time= ''
140 <                                                                                                                                                            
140 >
141          try: self.EDG_cpu_time = cfg_params['EDG.max_cpu_time']
142          except KeyError: self.EDG_cpu_time = ''
143  
# Line 158 | Line 161 | class SchedulerEdg(Scheduler):
161          except:
162              self._taskId = ''
163  
164 +        try: self.jobtypeName = cfg_params['CRAB.jobtype']
165 +        except KeyError: self.jobtypeName = ''
166 +
167 +        try: self.schedulerName = cfg_params['CRAB.scheduler']
168 +        except KeyError: self.scheduler = ''
169 +
170          return
171      
172  
173 +    def rb_configure(self, RB):
174 +        self.edg_config = ''
175 +        self.edg_config_vo = ''
176 +        self.rb_param_file = ''
177 +
178 +        edgConfig = EdgConfig(RB)
179 +        self.edg_config = edgConfig.config()
180 +        self.edg_config_vo = edgConfig.configVO()
181 +
182 +        if (self.edg_config and self.edg_config_vo != ''):
183 +            self.rb_param_file = 'RBconfig = "'+self.edg_config+'";\nRBconfigVO = "'+self.edg_config_vo+'";'
184 +            #print "rb_param_file = ", self.rb_param_file
185 +        return self.rb_param_file
186 +      
187 +
188      def sched_parameter(self):
189          """
190 <        Returns file with scheduler-specific parameters
190 >        Returns file with requirements and scheduler-specific parameters
191          """
192 <      
193 <        if (self.edg_config and self.edg_config_vo != ''):
194 <            self.param='sched_param.clad'
192 >        index = int(common.jobDB.nJobs()) - 1
193 >        job = common.job_list[index]
194 >        jbt = job.type()
195 >        
196 >        lastBlock=-1
197 >        first = []
198 >        for n in range(common.jobDB.nJobs()):
199 >            currBlock=common.jobDB.block(n)
200 >            if (currBlock!=lastBlock):
201 >                lastBlock = currBlock
202 >                first.append(n)
203 >  
204 >        req = ''
205 >        req = req + jbt.getRequirements()
206 >    
207 >        if self.EDG_requirements:
208 >            if (req == ' '):
209 >                req = req + self.EDG_requirements
210 >            else:
211 >                req = req +  ' && ' + self.EDG_requirements
212 >
213 >        if self.EDG_ce_white_list:
214 >            ce_white_list = string.split(self.EDG_ce_white_list,',')
215 >            for i in range(len(ce_white_list)):
216 >                if i == 0:
217 >                    if (req == ' '):
218 >                        req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
219 >                    else:
220 >                        req = req +  ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
221 >                    pass
222 >                else:
223 >                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
224 >            req = req + ')'
225 >        
226 >        if self.EDG_ce_black_list:
227 >            ce_black_list = string.split(self.EDG_ce_black_list,',')
228 >            for ce in ce_black_list:
229 >                if (req == ' '):
230 >                    req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
231 >                else:
232 >                    req = req +  ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))'
233 >                pass
234 >        if self.EDG_clock_time:
235 >            if (req == ' '):
236 >                req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
237 >            else:
238 >                req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
239 >
240 >        if self.EDG_cpu_time:
241 >            if (req == ' '):
242 >                req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
243 >            else:
244 >                req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
245 >                
246 >        for i in range(len(first)): # Add loop DS
247 >            self.param='sched_param_'+str(i)+'.clad'
248              param_file = open(common.work_space.shareDir()+'/'+self.param, 'w')
249 <            param_file.write('RBconfig = "'+self.edg_config+'";\n')  
250 <            param_file.write('RBconfigVO = "'+self.edg_config_vo+'";')
249 >
250 >            itr4=self.findSites_(first[i])
251 >            for arg in itr4:
252 >                req = req + ' && anyMatch(other.storage.CloseSEs, ('+str(arg)+'))'
253 >            param_file.write('Requirements = '+req +';\n')  
254 >  
255 >            if (self.rb_param_file != ''):
256 >                param_file.write(self.rb_param_file)  
257 >
258 >            if len(self.EDG_addJdlParam):
259 >                for p in self.EDG_addJdlParam:
260 >                    param_file.write(p)
261 >
262              param_file.close()  
263 <            return 1
176 <        else:
177 <            return 0
263 >
264  
265      def wsSetupEnvironment(self):
266          """
267          Returns part of a job script which does scheduler-specific work.
268          """
269          txt = ''
270 +        txt += '# strip arguments\n'
271 +        txt += 'echo "strip arguments"\n'
272 +        txt += 'args=("$@")\n'
273 +        txt += 'nargs=$#\n'
274 +        txt += 'shift $nargs\n'
275          txt += "# job number (first parameter for job wrapper)\n"
276 <        txt += "NJob=$1\n"
276 >        #txt += "NJob=$1\n"
277 >        txt += "NJob=${args[0]}\n"
278  
279          txt += '# job identification to DashBoard \n'
280 <        txt += 'echo "MonitorJobID=`echo ${NJob}_$EDG_WL_JOBID`" | tee -a $RUNTIME_AREA/$repo \n'
281 <        txt += 'echo "SyncGridJobId=`echo $EDG_WL_JOBID`" | tee -a $RUNTIME_AREA/$repo \n'
282 <        txt += 'echo "MonitorID=`echo ' + self._taskId + '`" | tee -a $RUNTIME_AREA/$repo\n'
280 >        txt += 'MonitorJobID=`echo ${NJob}_$EDG_WL_JOBID`\n'
281 >        txt += 'SyncGridJobId=`echo $EDG_WL_JOBID`\n'
282 >        txt += 'MonitorID=`echo ' + self._taskId + '`\n'
283 >        txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
284 >        txt += 'echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n'
285 >        txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
286  
287          txt += 'echo "middleware discovery " \n'
288 <        txt += 'if [ $VO_CMS_SW_DIR ]; then \n'
194 <        txt += '    middleware=LCG \n'
195 <        txt += '    echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
196 <        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
197 <        txt += '    echo "middleware =$middleware" \n'
198 <        txt += 'elif [ $GRID3_APP_DIR ]; then\n'
288 >        txt += 'if [ $GRID3_APP_DIR ]; then\n'
289          txt += '    middleware=OSG \n'
290          txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
291          txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
# Line 205 | Line 295 | class SchedulerEdg(Scheduler):
295          txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
296          txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
297          txt += '    echo "middleware =$middleware" \n'
298 +        txt += 'elif [ $VO_CMS_SW_DIR ]; then \n'
299 +        txt += '    middleware=LCG \n'
300 +        txt += '    echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
301 +        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
302 +        txt += '    echo "middleware =$middleware" \n'
303          txt += 'else \n'
304          txt += '    echo "SET_CMS_ENV 10030 ==> middleware not identified" \n'
305          txt += '    echo "JOB_EXIT_STATUS = 10030" \n'
306          txt += '    echo "JobExitCode=10030" | tee -a $RUNTIME_AREA/$repo \n'
307          txt += '    dumpStatus $RUNTIME_AREA/$repo \n'
308 +        txt += '    rm -f $RUNTIME_AREA/$repo \n'
309 +        txt += '    echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
310 +        txt += '    echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
311          txt += '    exit 1 \n'
312          txt += 'fi \n'
313  
314          txt += '# report first time to DashBoard \n'
315          txt += 'dumpStatus $RUNTIME_AREA/$repo \n'
316 <
316 >        txt += 'rm -f $RUNTIME_AREA/$repo \n'
317 >        txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
318 >        txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
319 >        
320          txt += '\n\n'
321  
322          if int(self.copy_data) == 1:
# Line 228 | Line 329 | class SchedulerEdg(Scheduler):
329                txt += 'echo "SE_PATH = $SE_PATH"\n'
330  
331          txt += 'export VO='+self.VO+'\n'
332 <        ### FEDE: add some line for LFC catalog setting
332 >        ### add some line for LFC catalog setting
333          txt += 'if [ $middleware == LCG ]; then \n'
334          txt += '    if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
335          txt += '        export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
# Line 281 | Line 382 | class SchedulerEdg(Scheduler):
382          txt += '        echo "JOB_EXIT_STATUS = 10099" \n'
383          txt += '        echo "JobExitCode=10099" | tee -a $RUNTIME_AREA/$repo \n'
384          txt += '        dumpStatus $RUNTIME_AREA/$repo \n'
385 +        txt += '        rm -f $RUNTIME_AREA/$repo \n'
386 +        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
387 +        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
388          txt += '        exit 1 \n'
389          txt += '    fi \n'
390          txt += 'fi \n'
# Line 292 | Line 396 | class SchedulerEdg(Scheduler):
396          Copy input data from SE to WN    
397          """
398          txt = ''
399 <        try:
400 <            self.copy_input_data = common.analisys_common_info['copy_input_data']
297 <            #print "self.copy_input_data = ", self.copy_input_data
298 <        except KeyError: self.copy_input_data = 0
299 <        if int(self.copy_input_data) == 1:
399 >        if not self.copy_input_data: return txt
400 >
401          ## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG)
402 <           txt += 'if [ $middleware == OSG ]; then\n'
403 <           txt += '   #\n'
404 <           txt += '   #   Copy Input Data from SE to this WN deactivated in OSG mode\n'
405 <           txt += '   #\n'
406 <           txt += '   echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n'
407 <           txt += 'elif [ $middleware == LCG ]; then \n'
408 <           txt += '   #\n'
409 <           txt += '   #   Copy Input Data from SE to this WN\n'
410 <           txt += '   #\n'
411 < ### changed by georgia (put a loop copying more than one input files per jobs)          
412 <           txt += '   for input_file in $cur_file_list \n'
413 <           txt += '   do \n'
414 <           txt += '    lcg-cp --vo $VO lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n'
415 <           txt += '    copy_input_exit_status=$?\n'
416 <           txt += '    echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n'
417 <           txt += '    if [ $copy_input_exit_status -ne 0 ]; then \n'
418 <           txt += '       echo "Problems with copying to WN" \n'
419 <           txt += '    else \n'
420 <           txt += '       echo "input copied into WN" \n'
421 <           txt += '    fi \n'
422 <           txt += '   done \n'
423 < ### copy a set of PU ntuples (same for each jobs -- but accessed randomly)
424 <           txt += '   for file in $cur_pu_list \n'
425 <           txt += '   do \n'
426 <           txt += '    lcg-cp --vo $VO lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
427 <           txt += '    copy_input_exit_status=$?\n'
428 <           txt += '    echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
429 <           txt += '    if [ $copy_input_pu_exit_status -ne 0 ]; then \n'
430 <           txt += '       echo "Problems with copying pu to WN" \n'
431 <           txt += '    else \n'
432 <           txt += '       echo "input pu files copied into WN" \n'
433 <           txt += '    fi \n'
434 <           txt += '   done \n'
435 <           txt += '   \n'
436 <           txt += '   ### Check SCRATCH space available on WN : \n'
437 <           txt += '   df -h \n'
438 <           txt += 'fi \n'
402 >        txt += 'if [ $middleware == OSG ]; then\n'
403 >        txt += '   #\n'
404 >        txt += '   #   Copy Input Data from SE to this WN deactivated in OSG mode\n'
405 >        txt += '   #\n'
406 >        txt += '   echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n'
407 >        txt += 'elif [ $middleware == LCG ]; then \n'
408 >        txt += '   #\n'
409 >        txt += '   #   Copy Input Data from SE to this WN\n'
410 >        txt += '   #\n'
411 >        ### changed by georgia (put a loop copying more than one input files per jobs)          
412 >        txt += '   for input_file in $cur_file_list \n'
413 >        txt += '   do \n'
414 >        txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n'
415 >        txt += '      copy_input_exit_status=$?\n'
416 >        txt += '      echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n'
417 >        txt += '      if [ $copy_input_exit_status -ne 0 ]; then \n'
418 >        txt += '         echo "Problems with copying to WN" \n'
419 >        txt += '      else \n'
420 >        txt += '         echo "input copied into WN" \n'
421 >        txt += '      fi \n'
422 >        txt += '   done \n'
423 >        ### copy a set of PU ntuples (same for each jobs -- but accessed randomly)
424 >        txt += '   for file in $cur_pu_list \n'
425 >        txt += '   do \n'
426 >        txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
427 >        txt += '      copy_input_pu_exit_status=$?\n'
428 >        txt += '      echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
429 >        txt += '      if [ $copy_input_pu_exit_status -ne 0 ]; then \n'
430 >        txt += '         echo "Problems with copying pu to WN" \n'
431 >        txt += '      else \n'
432 >        txt += '         echo "input pu files copied into WN" \n'
433 >        txt += '      fi \n'
434 >        txt += '   done \n'
435 >        txt += '   \n'
436 >        txt += '   ### Check SCRATCH space available on WN : \n'
437 >        txt += '   df -h \n'
438 >        txt += 'fi \n'
439            
440          return txt
441  
# Line 348 | Line 449 | class SchedulerEdg(Scheduler):
449             txt += '#\n'
450             txt += '#   Copy output to SE = $SE\n'
451             txt += '#\n'
452 <           txt += 'if [ $exe_result -eq 0 ]; then\n'
452 >           txt += '    if [ $middleware == OSG ]; then\n'
453 >           txt += '        echo "X509_USER_PROXY = $X509_USER_PROXY"\n'
454 >           txt += '        echo "source $OSG_APP/glite/setup_glite_ui.sh"\n'
455 >           txt += '        source $OSG_APP/glite/setup_glite_ui.sh\n'
456 >           txt += '        export X509_CERT_DIR=$OSG_APP/glite/etc/grid-security/certificates\n'
457 >           txt += '        echo "export X509_CERT_DIR=$X509_CERT_DIR"\n'
458 >           txt += '    fi \n'
459 >
460             txt += '    for out_file in $file_list ; do\n'
461 <           txt += '        echo "Trying to copy output file to $SE "\n'
462 <           ## OLI_Daniele globus-* for OSG, lcg-* for LCG
463 <           txt += '        if [ $middleware == OSG ]; then\n'
464 <           txt += '           echo "globus-url-copy file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
465 <           txt += '           copy_exit_status=`globus-url-copy file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
466 <           #txt += '           exitstring=`globus-url-copy file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
467 <           txt += '        elif [ $middleware == LCG ]; then \n'
468 <           txt += '           echo "lcg-cp --vo cms -t 1200 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
469 <           txt += '           copy_exit_status=`lcg-cp --vo cms -t 1200 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
470 <           #txt += '           exitstring=`lcg-cp --vo cms -t 30 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
471 <           txt += '        fi \n'
472 <           #txt += '        copy_exit_status=$?\n'
365 <           txt += '        echo "COPY_EXIT_STATUS = $copy_exit_status"\n'
461 >           txt += '        echo "Trying to copy output file to $SE using srmcp"\n'
462 >           txt += '        echo "mkdir -p $HOME/.srmconfig"\n'
463 >           txt += '        mkdir -p $HOME/.srmconfig\n'
464 >           txt += '        if [ $middleware == LCG ]; then\n'
465 >           txt += '           echo "srmcp -retry_num 3 -retry_timeout 480000 file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
466 >           txt += '           exitstring=`srmcp -retry_num 3 -retry_timeout 480000 file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
467 >           txt += '        elif [ $middleware == OSG ]; then\n'
468 >           txt += '           echo "srmcp -retry_num 3 -retry_timeout 240000 -x509_user_trusted_certificates $X509_CERT_DIR file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
469 >           txt += '           exitstring=`srmcp -retry_num 3 -retry_timeout 240000 -x509_user_trusted_certificates $X509_CERT_DIR file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
470 >           txt += '        fi \n'
471 >           txt += '        copy_exit_status=$?\n'
472 >           txt += '        echo "COPY_EXIT_STATUS for srmcp = $copy_exit_status"\n'
473             txt += '        echo "STAGE_OUT = $copy_exit_status"\n'
474 +
475             txt += '        if [ $copy_exit_status -ne 0 ]; then\n'
476 <           txt += '            echo "Problems with SE = $SE"\n'
476 >           txt += '            echo "Possible problem with SE = $SE"\n'
477             txt += '            echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
478             txt += '            echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
479 +           txt += '            echo "srmcp failed, attempting lcg-cp."\n'
480 +           if common.logger.debugLevel() >= 5:
481 +               txt += '            echo "lcg-cp --vo $VO -t 2400 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
482 +               txt += '            exitstring=`lcg-cp --vo $VO -t 2400 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
483 +           else:              
484 +               txt += '            echo "lcg-cp --vo $VO -t 2400 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
485 +               txt += '            exitstring=`lcg-cp --vo $VO -t 2400 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
486 +           txt += '            copy_exit_status=$?\n'
487 +           txt += '            echo "COPY_EXIT_STATUS for lcg-cp = $copy_exit_status"\n'
488 +           txt += '            echo "STAGE_OUT = $copy_exit_status"\n'
489 +
490 +           txt += '            if [ $copy_exit_status -ne 0 ]; then\n'
491 +           txt += '               echo "Problems with SE = $SE"\n'
492 +           txt += '               echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
493 +           txt += '               echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
494 +           txt += '               echo "srmcp and lcg-cp and failed!"\n'
495 +           txt += '            else\n'
496 +           txt += '               echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
497 +           txt += '               echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
498 +           txt += '               echo "output copied into $SE/$SE_PATH directory"\n'
499 +           txt += '               echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
500 +           txt += '               echo "lcg-cp succeeded"\n'
501 +           txt += '            fi\n'
502             txt += '        else\n'
503             txt += '            echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
504             txt += '            echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
505             txt += '            echo "output copied into $SE/$SE_PATH directory"\n'
506             txt += '            echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
507 +           txt += '            echo "srmcp succeeded"\n'
508             txt += '         fi\n'
509             txt += '     done\n'
378           txt += 'fi\n'
510          return txt
511  
512      def wsRegisterOutput(self):
# Line 395 | Line 526 | class SchedulerEdg(Scheduler):
526             txt += '#\n'
527             txt += '#  Register output to LFC\n'
528             txt += '#\n'
529 <           txt += '   if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n'
529 >           txt += '   if [ $copy_exit_status -eq 0 ]; then\n'
530             txt += '      for out_file in $file_list ; do\n'
531             txt += '         echo "Trying to register the output file into LFC"\n'
532 <           txt += '         echo "lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file"\n'
533 <           txt += '         lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file 2>&1 \n'
532 >           txt += '         echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1"\n'
533 >           txt += '         lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1 \n'
534             txt += '         register_exit_status=$?\n'
535             txt += '         echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
536             txt += '         echo "STAGE_OUT = $register_exit_status"\n'
537             txt += '         if [ $register_exit_status -ne 0 ]; then \n'
538             txt += '            echo "Problems with the registration to LFC" \n'
539             txt += '            echo "Try with srm protocol" \n'
540 <           txt += '            echo "lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file"\n'
541 <           txt += '            lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file 2>&1 \n'
540 >           txt += '            echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1"\n'
541 >           txt += '            lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1 \n'
542             txt += '            register_exit_status=$?\n'
543             txt += '            echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
544             txt += '            echo "STAGE_OUT = $register_exit_status"\n'
# Line 419 | Line 550 | class SchedulerEdg(Scheduler):
550             txt += '         fi \n'
551             txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
552             txt += '      done\n'
553 <           txt += '   elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n'
553 >           txt += '   else \n'
554             txt += '      echo "Trying to copy output file to CloseSE"\n'
555             txt += '      CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n'
556             txt += '      for out_file in $file_list ; do\n'
557 <           txt += '         echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file" \n'
558 <           txt += '         lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file 2>&1 \n'
557 >           txt += '         echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://$RUNTIME_AREA/$out_file 2>&1" \n'
558 >           txt += '         lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://$RUNTIME_AREA/$out_file 2>&1 \n'
559             txt += '         register_exit_status=$?\n'
560             txt += '         echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
561             txt += '         echo "STAGE_OUT = $register_exit_status"\n'
562             txt += '         if [ $register_exit_status -ne 0 ]; then \n'
563 <           txt += '            echo "Problems with CloseSE" \n'
563 >           txt += '            echo "Problems with CloseSE or Catalog" \n'
564             txt += '         else \n'
565             txt += '            echo "The program was successfully executed"\n'
566             txt += '            echo "SE = $CLOSE_SE"\n'
# Line 437 | Line 568 | class SchedulerEdg(Scheduler):
568             txt += '         fi \n'
569             txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
570             txt += '      done\n'
440           txt += '   else\n'
441           txt += '      echo "Problem with the executable"\n'
571             txt += '   fi \n'
572 +           txt += '   exit_status=$register_exit_status\n'
573             txt += 'fi \n'
574          return txt
575  
# Line 453 | Line 583 | class SchedulerEdg(Scheduler):
583          cmd_out = runCommand(cmd)
584          return cmd_out
585  
456    def listMatch(self, nj):
457        """
458        Check the compatibility of available resources
459        """
460        self.checkProxy()
461        jdl = common.job_list[nj].jdlFilename()
462        cmd = 'edg-job-list-match ' + self.configOpt_() + jdl
463        cmd_out = runCommand(cmd,0,10)
464        if not cmd_out:
465            raise CrabException("ERROR: "+cmd+" failed!")
466
467        return self.parseListMatch_(cmd_out, jdl)
468
469    def parseListMatch_(self, out, jdl):
470        """
471        Parse the f* output of edg-list-match and produce something sensible
472        """
473        reComment = re.compile( r'^\**$' )
474        reEmptyLine = re.compile( r'^$' )
475        reVO = re.compile( r'Selected Virtual Organisation name.*' )
476        reLine = re.compile( r'.*')
477        reCE = re.compile( r'(.*:.*)')
478        reCEId = re.compile( r'CEId.*')
479        reNO = re.compile( r'No Computing Element matching' )
480        reRB = re.compile( r'Connecting to host' )
481        next = 0
482        CEs=[]
483        Match=0
484
485        #print out
486        lines = reLine.findall(out)
487
488        i=0
489        CEs=[]
490        for line in lines:
491            string.strip(line)
492            #print line
493            if reNO.match( line ):
494                common.logger.debug(5,line)
495                return 0
496                pass
497            if reVO.match( line ):
498                VO =reVO.match( line ).group()
499                common.logger.debug(5,"VO "+VO)
500                pass
501
502            if reRB.match( line ):
503                RB = reRB.match(line).group()
504                common.logger.debug(5,"RB "+RB)
505                pass
506
507            if reCEId.search( line ):
508                for lineCE in lines[i:-1]:
509                    if reCE.match( lineCE ):
510                        CE = string.strip(reCE.search(lineCE).group(1))
511                        CEs.append(CE.split(':')[0])
512                        pass
513                    pass
514                pass
515            i=i+1
516            pass
517
518        common.logger.debug(5,"All CE :"+str(CEs))
519
520        sites = []
521        [sites.append(it) for it in CEs if not sites.count(it)]
522
523        common.logger.debug(5,"All Sites :"+str(sites))
524        common.logger.message("Matched Sites :"+str(sites))
525        return len(sites)
526
527    def noMatchFound_(self, jdl):
528        reReq = re.compile( r'Requirements' )
529        reString = re.compile( r'"\S*"' )
530        f = file(jdl,'r')
531        for line in f.readlines():
532            line= line.strip()
533            if reReq.match(line):
534                for req in reString.findall(line):
535                    if re.search("VO",req):
536                        common.logger.message( "SW required: "+req)
537                        continue
538                    if re.search('"\d+',req):
539                        common.logger.message("Other req  : "+req)
540                        continue
541                    common.logger.message( "CE required: "+req)
542                break
543            pass
544        raise CrabException("No compatible resources found!")
545
546    def submit(self, nj):
547        """
548        Submit one EDG job.
549        """
550
551        self.checkProxy()
552        jid = None
553        jdl = common.job_list[nj].jdlFilename()
554
555        cmd = 'edg-job-submit ' + self.configOpt_() + jdl
556        cmd_out = runCommand(cmd)
557        if cmd_out != None:
558            reSid = re.compile( r'https.+' )
559            jid = reSid.search(cmd_out).group()
560            pass
561        return jid
562
563    def resubmit(self, nj_list):
564        """
565        Prepare jobs to be submit
566        """
567        return
568
586      def getExitStatus(self, id):
587          return self.getStatusAttribute_(id, 'exit_code')
588  
# Line 588 | Line 605 | class SchedulerEdg(Scheduler):
605          # Instance of the Status class provided by LB API
606          jobStat = Status()
607          st = 0
608 +        #print id, level, attr, self.states.index(attr)
609          jobStat.getStatus(id, level)
610 +        #print jobStat.loadStatus(st)
611          err, apiMsg = jobStat.get_error()
612          if err:
613              common.logger.debug(5,'Error caught' + apiMsg)
# Line 597 | Line 616 | class SchedulerEdg(Scheduler):
616              for i in range(len(self.states)):
617                  # Fill an hash table with all information retrieved from LB API
618                  hstates[ self.states[i] ] = jobStat.loadStatus(st)[i]
619 <            result = jobStat.loadStatus(st)[ self.states.index(attr) ]
619 >                #print i, jobStat.loadStatus(st)[i]
620 >            result = jobStat.loadStatus(st)[self.states.index(attr)]
621 >            #print str(result)
622              return result
623  
624      def queryDetailedStatus(self, id):
# Line 606 | Line 627 | class SchedulerEdg(Scheduler):
627          cmd_out = runCommand(cmd)
628          return cmd_out
629  
630 <    def getOutput(self, id):
630 >    ##### FEDE ######        
631 >    def findSites_(self, n):
632 >        itr4 =[]
633 >        sites = common.jobDB.destination(n)
634 >        if len(sites)>0 and sites[0]=="Any":
635 >            return itr4
636 >        itr = ''
637 >        if sites != [""]:#CarlosDaniele
638 >            for site in sites:
639 >                #itr = itr + 'target.GlueSEUniqueID==&quot;'+site+'&quot; || '
640 >                itr = itr + 'target.GlueSEUniqueID=="'+site+'" || '
641 >            itr = itr[0:-4]
642 >            itr4.append( itr )
643 >        return itr4
644 >
645 >    def createXMLSchScript(self, nj, argsList):
646 >   # def createXMLSchScript(self, nj):
647 >      
648          """
649 <        Get output for a finished job with id.
612 <        Returns the name of directory with results.
649 >        Create a XML-file for BOSS4.
650          """
651 <
615 <        self.checkProxy()
616 <        cmd = 'edg-job-get-output --dir ' + common.work_space.resDir() + ' ' + id
617 <        cmd_out = runCommand(cmd)
618 <
619 <        # Determine the output directory name
620 <        dir = common.work_space.resDir()
621 <        dir += os.environ['USER']
622 <        dir += '_' + os.path.basename(id)
623 <        return dir
624 <
625 <    def cancel(self, id):
626 <        """ Cancel the EDG job with id """
627 <        self.checkProxy()
628 <        cmd = 'edg-job-cancel --noint ' + id
629 <        cmd_out = runCommand(cmd)
630 <        return cmd_out
631 <
632 <    def createSchScript(self, nj):
651 >  #      job = common.job_list[nj]
652          """
653 <        Create a JDL-file for EDG.
653 >        INDY
654 >        [begin] FIX-ME:
655 >        I would pass jobType instead of job
656          """
657 <
658 <        job = common.job_list[nj]
657 >        index = nj - 1
658 >        job = common.job_list[index]
659          jbt = job.type()
639        inp_sandbox = jbt.inputSandbox(nj)
640        out_sandbox = jbt.outputSandbox(nj)
641        inp_storage_subdir = ''
660          
661 <        title = '# This JDL was generated by '+\
662 <                common.prog_name+' (version '+common.prog_version_str+')\n'
661 >        inp_sandbox = jbt.inputSandbox(index)
662 >        out_sandbox = jbt.outputSandbox(index)
663 >        """
664 >        [end] FIX-ME
665 >        """
666 >
667 >        
668 >        title = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n'
669          jt_string = ''
670 +        
671 +        xml_fname = str(self.jobtypeName)+'.xml'
672 +        xml = open(common.work_space.shareDir()+'/'+xml_fname, 'a')
673 +
674 +        #TaskName  
675 +        dir = string.split(common.work_space.topDir(), '/')
676 +        taskName = dir[len(dir)-2]
677 +  
678 +        to_writeReq = ''
679 +        to_write = ''
680 +
681 +        req=' '
682 +        req = req + jbt.getRequirements()
683 +
684 +        if self.EDG_requirements:
685 +            if (req == ' '):
686 +                req = req + self.EDG_requirements
687 +            else:
688 +                req = req +  ' && ' + self.EDG_requirements
689 +        if self.EDG_ce_white_list:
690 +            ce_white_list = string.split(self.EDG_ce_white_list,',')
691 +            for i in range(len(ce_white_list)):
692 +                if i == 0:
693 +                    if (req == ' '):
694 +                        req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
695 +                    else:
696 +                        req = req +  ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
697 +                    pass
698 +                else:
699 +                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
700 +            req = req + ')'
701 +        
702 +        if self.EDG_ce_black_list:
703 +            ce_black_list = string.split(self.EDG_ce_black_list,',')
704 +            for ce in ce_black_list:
705 +                if (req == ' '):
706 +                    req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
707 +                else:
708 +                    req = req +  ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))'
709 +                pass
710 +        if self.EDG_clock_time:
711 +            if (req == ' '):
712 +                req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
713 +            else:
714 +                req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
715 +
716 +        if self.EDG_cpu_time:
717 +            if (req == ' '):
718 +                req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
719 +            else:
720 +                req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
721 +                                                                                          
722 +        if ( self.EDG_retry_count ):              
723 +            to_write = to_write + 'RetryCount = "'+self.EDG_retry_count+'"\n'
724 +            pass
725  
726 +        if ( self.EDG_shallow_retry_count ):              
727 +            to_write = to_write + 'ShallowRetryCount = "'+self.EDG_shallow_retry_count+'"\n'
728 +            pass
729 +
730 +        to_write = to_write + 'MyProxyServer = "&quot;' + self.proxyServer + '&quot;"\n'
731 +        to_write = to_write + 'VirtualOrganisation = "&quot;' + self.VO + '&quot;"\n'
732  
733 +        #TaskName  
734 +        dir = string.split(common.work_space.topDir(), '/')
735 +        taskName = dir[len(dir)-2]
736 +
737 +        xml.write(str(title))
738 +        xml.write('<task name="' +str(taskName)+'">\n')
739 +        xml.write(jt_string)
740          
741 <        SPL = inp_storage_subdir
742 <        if ( SPL and SPL[-1] != '/' ) : SPL = SPL + '/'
741 >        if (to_write != ''):
742 >            xml.write('<extraTags\n')
743 >            xml.write(to_write)
744 >            xml.write('/>\n')
745 >            pass
746  
747 <        jdl_fname = job.jdlFilename()
748 <        jdl = open(jdl_fname, 'w')
749 <        jdl.write(title)
747 >        xml.write('<iterator>\n')
748 >        xml.write('\t<iteratorRule name="ITR1">\n')
749 >        xml.write('\t\t<ruleElement> 1:'+ str(nj) + ' </ruleElement>\n')
750 >        xml.write('\t</iteratorRule>\n')
751 >        xml.write('\t<iteratorRule name="ITR2">\n')
752 >        for arg in argsList:
753 >            xml.write('\t\t<ruleElement> <![CDATA[\n'+ arg + '\n\t\t]]> </ruleElement>\n')
754 >            pass
755 >        xml.write('\t</iteratorRule>\n')
756 >        #print jobList
757 >        xml.write('\t<iteratorRule name="ITR3">\n')
758 >        xml.write('\t\t<ruleElement> 1:'+ str(nj) + ':1:6 </ruleElement>\n')
759 >        xml.write('\t</iteratorRule>\n')
760 >
761 >        '''
762 >        indy: here itr4
763 >        '''
764 >        
765  
766 <        script = job.scriptFilename()
767 <        jdl.write('Executable = "' + os.path.basename(script) +'";\n')
658 <        jdl.write(jt_string)
766 >        xml.write('<chain scheduler="'+str(self.schedulerName)+'">\n')
767 >        xml.write(jt_string)
768  
769 <        ### only one .sh  JDL has arguments:
769 >        #executable
770  
771 <        ### Fabio
772 <        jdl.write('Arguments = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "EDG") +'";\n')
773 <        inp_box = 'InputSandbox = { '
774 <        inp_box = inp_box + '"' + script + '",'
771 >        """
772 >        INDY
773 >        script depends on jobType: it should be probably get in a different way
774 >        """        
775 >        script = job.scriptFilename()
776 >        xml.write('<program>\n')
777 >        xml.write('<exec> ' + os.path.basename(script) +' </exec>\n')
778 >        xml.write(jt_string)
779 >    
780 >        xml.write('<args> <![CDATA[\n _ITR2_ \n]]> </args>\n')
781 >        xml.write('<program_types> crabjob </program_types>\n')
782 >        inp_box = script + ','
783  
784          if inp_sandbox != None:
785              for fl in inp_sandbox:
786 <                inp_box = inp_box + ' "' + fl + '",'
786 >                inp_box = inp_box + '' + fl + ','
787                  pass
788              pass
789  
790 <        #if common.use_jam:
791 <        #   inp_box = inp_box+' "'+common.bin_dir+'/'+common.run_jam+'",'
792 <
793 <        # Marco (VERY TEMPORARY ML STUFF)
794 <        inp_box = inp_box+' "' + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + '", "' +\
795 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + '", "'+\
679 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + '", "'+\
680 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + '", "'+\
681 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') + '"'
682 <        # End Marco
790 >        inp_box = inp_box + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + ',' +\
791 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + ','+\
792 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + ','+\
793 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + ','+\
794 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') + ','+\
795 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'parseCrabFjr.py')
796  
797          if (not jbt.additional_inbox_files == []):
798 <            inp_box = inp_box + ', '
798 >            inp_box = inp_box + ','
799              for addFile in jbt.additional_inbox_files:
800                  addFile = os.path.abspath(addFile)
801 <                inp_box = inp_box+' "'+addFile+'",'
801 >                inp_box = inp_box+''+addFile+','
802                  pass
803  
804          if inp_box[-1] == ',' : inp_box = inp_box[:-1]
805 <        inp_box = inp_box + ' };\n'
806 <        jdl.write(inp_box)
694 <
695 <        jdl.write('StdOutput     = "' + job.stdout() + '";\n')
696 <        jdl.write('StdError      = "' + job.stderr() + '";\n')
805 >        inp_box = '<infiles> <![CDATA[\n' + inp_box + '\n]]> </infiles>\n'
806 >        xml.write(inp_box)
807          
808 +        base = jbt.name()
809 +        stdout = base + '__ITR3_.stdout'
810 +        stderr = base + '__ITR3_.stderr'
811          
812 <        if job.stdout() == job.stderr():
813 <          out_box = 'OutputSandbox = { "' + \
814 <                    job.stdout() + '", ".BrokerInfo",'
815 <        else:
816 <          out_box = 'OutputSandbox = { "' + \
817 <                    job.stdout() + '", "' + \
705 <                    job.stderr() + '", ".BrokerInfo",'
812 >        xml.write('<stderr> ' + stderr + '</stderr>\n')
813 >        xml.write('<stdout> ' + stdout + '</stdout>\n')
814 >        
815 >
816 >        out_box = stdout + ',' + \
817 >                  stderr + ',.BrokerInfo,'
818  
819 +        """
820          if int(self.return_data) == 1:
821              if out_sandbox != None:
822                  for fl in out_sandbox:
823 <                    out_box = out_box + ' "' + fl + '",'
823 >                    out_box = out_box + '' + fl + ','
824                      pass
825                  pass
826              pass
827 <                                                                                                                                                            
715 <        if out_box[-1] == ',' : out_box = out_box[:-1]
716 <        out_box = out_box + ' };'
717 <        jdl.write(out_box+'\n')
718 <
827 >        """
828  
829 <        req='Requirements = '
830 <        noreq=req
831 <        req = req + jbt.getRequirements()
832 <        #### and USER REQUIREMENT
833 <        if self.EDG_requirements:
834 <            if (req != noreq):
835 <                req = req +  ' && '
727 <            req = req + self.EDG_requirements
728 <        #### FEDE #####
729 <        if self.EDG_ce_white_list:
730 <            ce_white_list = string.split(self.EDG_ce_white_list,',')
731 <            #print "req = ", req
732 <            for i in range(len(ce_white_list)):
733 <                if i == 0:
734 <                    if (req != noreq):
735 <                        req = req +  ' && '
736 <                    req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
737 <                    pass
738 <                else:
739 <                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
740 <            req = req + ')'
741 <        
742 <        if self.EDG_ce_black_list:
743 <            ce_black_list = string.split(self.EDG_ce_black_list,',')
744 <            for ce in ce_black_list:
745 <                if (req != noreq):
746 <                    req = req +  ' && '
747 <                req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
829 >        """
830 >        INDY
831 >        something similar should be also done for infiles (if it makes sense!)
832 >        """
833 >        if int(self.return_data) == 1:
834 >            for fl in jbt.output_file:
835 >                out_box = out_box + '' + jbt.numberFile_(fl, '_ITR1_') + ','
836                  pass
837 +            pass
838  
839 <        ###############
840 <        clockTime=480
841 <        if self.EDG_clock_time:
842 <            clockTime= self.EDG_clock_time
843 <        if (req != noreq):
755 <            req = req + ' && '
756 <        req = req + '((other.GlueCEPolicyMaxWallClockTime == 0) || (other.GlueCEPolicyMaxWallClockTime>='+str(clockTime)+'))'
839 >        if out_box[-1] == ',' : out_box = out_box[:-1]
840 >        out_box = '<outfiles> <![CDATA[\n' + out_box + '\n]]></outfiles>\n'
841 >        xml.write(out_box)
842 >
843 >        xml.write('<BossAttr> crabjob.INTERNAL_ID=_ITR1_ </BossAttr>\n')
844  
845 <        cpuTime=1000
846 <        if self.EDG_cpu_time:
760 <            cpuTime=self.EDG_cpu_time
761 <        if (req != noreq):
762 <            req = req + ' && '
763 <        req = req + '((other.GlueCEPolicyMaxCPUTime == 0) || (other.GlueCEPolicyMaxCPUTime>='+str(cpuTime)+'))'
764 <
765 <        if (req != noreq):
766 <            req = req + ';\n'
767 <            jdl.write(req)
768 <                                                                                                                                                            
769 <        jdl.write('VirtualOrganisation = "' + self.VO + '";\n')
845 >        xml.write('</program>\n')
846 >        xml.write('</chain>\n')
847  
848 <        if ( self.EDG_retry_count ):              
849 <            jdl.write('RetryCount = '+self.EDG_retry_count+';\n')
773 <            pass
848 >        xml.write('</iterator>\n')
849 >        xml.write('</task>\n')
850  
851 <        jdl.write('MyProxyServer = "' + self.proxyServer + '";\n')
851 >        xml.close()
852 >      
853  
777        jdl.close()
854          return
855  
856      def checkProxy(self):
# Line 787 | Line 863 | class SchedulerEdg(Scheduler):
863  
864          minTimeLeftServer = 100 # in hours
865  
790        #cmd = 'voms-proxy-info -exists -valid '+str(minTimeLeft)+':00'
791        #cmd = 'voms-proxy-info -timeleft'
866          mustRenew = 0
867 <        timeLeftLocal = runCommand('voms-proxy-info -timeleft')
867 >        timeLeftLocal = runCommand('voms-proxy-info -timeleft 2>/dev/null')
868          timeLeftServer = -999
869          if not timeLeftLocal or int(timeLeftLocal) <= 0 or not isInt(timeLeftLocal):
870              mustRenew = 1
871          else:
872 <            timeLeftServer = runCommand('voms-proxy-info -actimeleft | head -1')
872 >            timeLeftServer = runCommand('voms-proxy-info -actimeleft 2>/dev/null | head -1')
873              if not timeLeftServer or not isInt(timeLeftServer):
874                  mustRenew = 1
875              elif timeLeftLocal<minTimeLeft or timeLeftServer<minTimeLeft:
# Line 804 | Line 878 | class SchedulerEdg(Scheduler):
878          pass
879  
880          if mustRenew:
881 <            common.logger.message( "No valid proxy found or remaining time of validity of already existing proxy shorter than 10 hours!\n Creating a user proxy with default length of 96h\n")
882 <            cmd = 'voms-proxy-init -voms cms -valid 96:00'
881 >            common.logger.message( "No valid proxy found or remaining time of validity of already existing proxy shorter than 10 hours!\n Creating a user proxy with default length of 192h\n")
882 >            cmd = 'voms-proxy-init -voms '+self.VO
883 >            if self.group:
884 >                cmd += ':/'+self.VO+'/'+self.group
885 >            if self.role:
886 >                cmd += '/role='+self.role
887 >            cmd += ' -valid 192:00'
888              try:
889                  # SL as above: damn it!
890 +                common.logger.debug(10,cmd)
891                  out = os.system(cmd)
892                  if (out>0): raise CrabException("Unable to create a valid proxy!\n")
893              except:
894                  msg = "Unable to create a valid proxy!\n"
895                  raise CrabException(msg)
816            # cmd = 'grid-proxy-info -timeleft'
817            # cmd_out = runCommand(cmd,0,20)
896              pass
897  
898          ## now I do have a voms proxy valid, and I check the myproxy server

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines