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

Comparing COMP/CRAB/python/cms_cmssw.py (file contents):
Revision 1.2 by slacapra, Wed Apr 26 15:31:06 2006 UTC vs.
Revision 1.17 by slacapra, Wed Jun 28 13:39:03 2006 UTC

# Line 3 | Line 3 | from crab_logger import Logger
3   from crab_exceptions import *
4   from crab_util import *
5   import common
6 + import PsetManipulator  
7  
8 < import DataDiscovery
9 < import DataLocation
8 > import DBSInfo_EDM
9 > import DataDiscovery_EDM
10 > import DataLocation_EDM
11   import Scram
12  
13   import os, string, re
# Line 16 | Line 18 | class Cmssw(JobType):
18          common.logger.debug(3,'CMSSW::__init__')
19  
20          self.analisys_common_info = {}
21 <
21 >        # Marco.
22 >        self._params = {}
23 >        self.cfg_params = cfg_params
24          log = common.logger
25          
26          self.scram = Scram.Scram(cfg_params)
# Line 26 | Line 30 | class Cmssw(JobType):
30          self.executable = ''
31          self.tgz_name = 'default.tgz'
32  
33 +
34          self.version = self.scram.getSWVersion()
35 +        self.setParam_('application', self.version)
36          common.analisys_common_info['sw_version'] = self.version
37 +        ### FEDE
38 +        common.analisys_common_info['copy_input_data'] = 0
39 +        common.analisys_common_info['events_management'] = 1
40  
41          ### collect Data cards
42          try:
43 <            self.owner = cfg_params['CMSSW.owner']
44 <            log.debug(6, "CMSSW::CMSSW(): owner = "+self.owner)
45 <            self.dataset = cfg_params['CMSSW.dataset']
46 <            log.debug(6, "CMSSW::CMSSW(): dataset = "+self.dataset)
43 >            tmp =  cfg_params['CMSSW.datasetpath']
44 >            log.debug(6, "CMSSW::CMSSW(): datasetPath = "+tmp)
45 >            if string.lower(tmp)=='none':
46 >                self.datasetPath = None
47 >            else:
48 >                self.datasetPath = tmp
49          except KeyError:
50 <            msg = "Error: owner and/or dataset not defined "
50 >            msg = "Error: datasetpath not defined "  
51              raise CrabException(msg)
52  
53 +        # ML monitoring
54 +        # split dataset path style: /PreProdR3Minbias/SIM/GEN-SIM
55 +        if not self.datasetPath:
56 +            self.setParam_('dataset', 'None')
57 +            self.setParam_('owner', 'None')
58 +        else:
59 +            datasetpath_split = self.datasetPath.split("/")
60 +            self.setParam_('dataset', datasetpath_split[1])
61 +            self.setParam_('owner', datasetpath_split[-1])
62 +
63 +        self.setTaskid_()
64 +        self.setParam_('taskId', self.cfg_params['taskId'])
65 +
66          self.dataTiers = []
43        try:
44            tmpDataTiers = string.split(cfg_params['CMSSW.data_tier'],',')
45            for tmp in tmpDataTiers:
46                tmp=string.strip(tmp)
47                self.dataTiers.append(tmp)
48                pass
49            pass
50        except KeyError:
51            pass
52        log.debug(6, "Cmssw::Cmssw(): dataTiers = "+str(self.dataTiers))
67  
68          ## now the application
69          try:
70              self.executable = cfg_params['CMSSW.executable']
71 +            self.setParam_('exe', self.executable)
72              log.debug(6, "CMSSW::CMSSW(): executable = "+self.executable)
73              msg = "Default executable cmsRun overridden. Switch to " + self.executable
74              log.debug(3,msg)
75          except KeyError:
76              self.executable = 'cmsRun'
77 +            self.setParam_('exe', self.executable)
78              msg = "User executable not defined. Use cmsRun"
79              log.debug(3,msg)
80              pass
# Line 83 | Line 99 | class Cmssw(JobType):
99                      tmp=string.strip(tmp)
100                      self.output_file.append(tmp)
101                      pass
86
102              else:
103                  log.message("No output file defined: only stdout/err will be available")
104                  pass
# Line 94 | Line 109 | class Cmssw(JobType):
109  
110          # script_exe file as additional file in inputSandbox
111          try:
112 <           self.scriptExe = cfg_params['CMSSW.script_exe']
113 <           self.additional_inbox_files.append(self.scriptExe)
112 >            self.scriptExe = cfg_params['USER.script_exe']
113 >            self.additional_inbox_files.append(self.scriptExe)
114 >            if self.scriptExe != '':
115 >               if not os.path.isfile(self.scriptExe):
116 >                  msg ="WARNING. file "+self.scriptExe+" not found"
117 >                  raise CrabException(msg)
118          except KeyError:
119             pass
101        if self.scriptExe != '':
102           if os.path.isfile(self.scriptExe):
103              pass
104           else:
105              log.message("WARNING. file "+self.scriptExe+" not found")
106              sys.exit()
120                    
121          ## additional input files
122          try:
123              tmpAddFiles = string.split(cfg_params['CMSSW.additional_input_files'],',')
124              for tmp in tmpAddFiles:
125 +                if not os.path.exists(tmp):
126 +                    raise CrabException("Additional input file not found: "+tmp)
127                  tmp=string.strip(tmp)
128                  self.additional_inbox_files.append(tmp)
129                  pass
# Line 116 | Line 131 | class Cmssw(JobType):
131          except KeyError:
132              pass
133  
134 +        # files per job
135 +        try:
136 +            self.filesPerJob = int(cfg_params['CMSSW.files_per_jobs']) #Daniele
137 +            self.selectFilesPerJob = 1
138 +        except KeyError:
139 +            self.filesPerJob = 0
140 +            self.selectFilesPerJob = 0
141 +
142 +        ## Events per job
143 +        try:
144 +            self.eventsPerJob =int( cfg_params['CMSSW.events_per_job'])
145 +            self.selectEventsPerJob = 1
146 +        except KeyError:
147 +            self.eventsPerJob = -1
148 +            self.selectEventsPerJob = 0
149 +    
150 +        # To be implemented
151 +        # ## number of jobs
152 +        # try:
153 +        #     self.numberOfJobs =int( cfg_params['CMSSW.number_of_job'])
154 +        #     self.selectNumberOfJobs = 1
155 +        # except KeyError:
156 +        #     self.selectNumberOfJobs = 0
157 +
158 +        if (self.selectFilesPerJob == self.selectEventsPerJob):
159 +            msg = 'Must define either files_per_jobs or events_per_job'
160 +            raise CrabException(msg)
161 +
162 +        if (self.selectEventsPerJob  and not self.datasetPath == None):
163 +            msg = 'Splitting according to events_per_job available only with None as datasetpath'
164 +            raise CrabException(msg)
165 +    
166          try:
167              self.total_number_of_events = int(cfg_params['CMSSW.total_number_of_events'])
168          except KeyError:
169 <            msg = 'Must define total_number_of_events and job_number_of_events'
169 >            msg = 'Must define total_number_of_events'
170              raise CrabException(msg)
124            
125 #Marco: FirstEvent is nolonger used inside PSet
126 #        try:
127 #            self.first = int(cfg_params['CMSSW.first_event'])
128 #        except KeyError:
129 #            self.first = 0
130 #            pass
131 #        log.debug(6, "Orca::Orca(): total number of events = "+`self.total_number_of_events`)
132        #log.debug(6, "Orca::Orca(): events per job = "+`self.job_number_of_events`)
133 #        log.debug(6, "Orca::Orca(): first event = "+`self.first`)
171          
172          CEBlackList = []
173          try:
# Line 150 | Line 187 | class Cmssw(JobType):
187          CEWhiteList = []
188          try:
189              tmpGood = string.split(cfg_params['EDG.ce_white_list'],',')
153            #tmpGood = ['cern']
190              for tmp in tmpGood:
191                  tmp=string.strip(tmp)
156                #if (tmp == 'cnaf'): tmp = 'webserver' ########## warning: temp. patch
192                  CEWhiteList.append(tmp)
193          except KeyError:
194              pass
# Line 165 | Line 200 | class Cmssw(JobType):
200  
201          common.logger.debug(5,'CEWhiteList: '+str(CEWhiteList))
202  
203 +        self.PsetEdit = PsetManipulator.PsetManipulator(self.pset) #Daniele Pset
204 +
205          #DBSDLS-start
206          ## Initialize the variables that are extracted from DBS/DLS and needed in other places of the code
207          self.maxEvents=0  # max events available   ( --> check the requested nb. of evts in Creator.py)
208          self.DBSPaths={}  # all dbs paths requested ( --> input to the site local discovery script)
209          ## Perform the data location and discovery (based on DBS/DLS)
210 <        self.DataDiscoveryAndLocation(cfg_params)
210 >        ## SL: Don't if NONE is specified as input (pythia use case)
211 >        common.analisys_common_info['sites']=None
212 >        if self.datasetPath:
213 >            self.DataDiscoveryAndLocation(cfg_params)
214          #DBSDLS-end          
215  
216          self.tgzNameWithPath = self.getTarBall(self.executable)
217  
218 +        # modify Pset
219 +        if (self.datasetPath): # standard job
220 +            self.PsetEdit.maxEvent(self.eventsPerJob) #Daniele  
221 +            self.PsetEdit.inputModule("INPUT") #Daniele
222 +
223 +        else:  # pythia like job
224 +            self.PsetEdit.maxEvent(self.eventsPerJob) #Daniele  
225 +            self.PsetEdit.pythiaSeed("INPUT") #Daniele
226 +            try:
227 +                self.sourceSeed = int(cfg_params['CMSSW.pythia_seed'])
228 +            except KeyError:
229 +                self.sourceSeed = 123456
230 +                common.logger.message("No seed given, will use "+str(self.sourceSeed))
231 +        
232 +        self.PsetEdit.psetWriter(self.configFilename())
233 +    
234 +        ## Select Splitting
235 +        if self.selectFilesPerJob: self.jobSplittingPerFiles()
236 +        elif self.selectEventsPerJob: self.jobSplittingPerEvents()
237 +        else:
238 +            msg = 'Don\'t know how to split...'
239 +            raise CrabException(msg)
240 +
241 +
242      def DataDiscoveryAndLocation(self, cfg_params):
243  
244 <        fun = "CMSSW::DataDiscoveryAndLocation()"
244 >        common.logger.debug(10,"CMSSW::DataDiscoveryAndLocation()")
245 >
246 >        datasetPath=self.datasetPath
247 >
248 >        ## TODO
249 >        dataTiersList = ""
250 >        dataTiers = dataTiersList.split(',')
251  
252          ## Contact the DBS
253          try:
254 <            self.pubdata=DataDiscovery.DataDiscovery(self.owner,
185 <                                                     self.dataset,
186 <                                                     self.dataTiers,
187 <                                                     cfg_params)
254 >            self.pubdata=DataDiscovery_EDM.DataDiscovery_EDM(datasetPath, dataTiers, cfg_params)
255              self.pubdata.fetchDBSInfo()
256  
257 <        except DataDiscovery.NotExistingDatasetError, ex :
257 >        except DataDiscovery_EDM.NotExistingDatasetError, ex :
258              msg = 'ERROR ***: failed Data Discovery in DBS : %s'%ex.getErrorMessage()
259              raise CrabException(msg)
260  
261 <        except DataDiscovery.NoDataTierinProvenanceError, ex :
261 >        except DataDiscovery_EDM.NoDataTierinProvenanceError, ex :
262              msg = 'ERROR ***: failed Data Discovery in DBS : %s'%ex.getErrorMessage()
263              raise CrabException(msg)
264 <        except DataDiscovery.DataDiscoveryError, ex:
264 >        except DataDiscovery_EDM.DataDiscoveryError, ex:
265              msg = 'ERROR ***: failed Data Discovery in DBS  %s'%ex.getErrorMessage()
266              raise CrabException(msg)
267  
268          ## get list of all required data in the form of dbs paths  (dbs path = /dataset/datatier/owner)
269 <        self.DBSPaths=self.pubdata.getDBSPaths()
270 <        common.logger.message("Required data are : ")
271 <        for path in self.DBSPaths:
272 <            common.logger.message(" --> "+path )
269 >        ## self.DBSPaths=self.pubdata.getDBSPaths()
270 >        common.logger.message("Required data are :"+self.datasetPath)
271 >
272 >        filesbyblock=self.pubdata.getFiles()
273 >        self.AllInputFiles=filesbyblock.values()
274 >        self.files = self.AllInputFiles        
275 >
276 >        ## TEMP
277 >    #    self.filesTmp = filesbyblock.values()
278 >    #    self.files = []
279 >    #    locPath='rfio:cmsbose2.bo.infn.it:/flatfiles/SE00/cms/fanfani/ProdTest/'
280 >    #    locPath=''
281 >    #    tmp = []
282 >    #    for file in self.filesTmp[0]:
283 >    #        tmp.append(locPath+file)
284 >    #    self.files.append(tmp)
285 >        ## END TEMP
286  
287          ## get max number of events
288 <        common.logger.debug(10,"number of events for primary fileblocks %i"%self.pubdata.getMaxEvents())
288 >        #common.logger.debug(10,"number of events for primary fileblocks %i"%self.pubdata.getMaxEvents())
289          self.maxEvents=self.pubdata.getMaxEvents() ##  self.maxEvents used in Creator.py
290          common.logger.message("\nThe number of available events is %s"%self.maxEvents)
291  
212        ## get fileblocks corresponding to the required data
213        fb=self.pubdata.getFileBlocks()
214        common.logger.debug(5,"fileblocks are %s"%fb)
215
292          ## Contact the DLS and build a list of sites hosting the fileblocks
293          try:
294 <            dataloc=DataLocation.DataLocation(self.pubdata.getFileBlocks(),cfg_params)
294 >            dataloc=DataLocation_EDM.DataLocation_EDM(filesbyblock.keys(),cfg_params)
295              dataloc.fetchDLSInfo()
296 <        except DataLocation.DataLocationError , ex:
296 >        except DataLocation_EDM.DataLocationError , ex:
297              msg = 'ERROR ***: failed Data Location in DLS \n %s '%ex.getErrorMessage()
298              raise CrabException(msg)
299          
# Line 231 | Line 307 | class Cmssw(JobType):
307          if len(sites)==0:
308              msg = 'No sites hosting all the needed data! Exiting... '
309              raise CrabException(msg)
310 +
311          common.logger.message("List of Sites hosting the data : "+str(sites))
312          common.logger.debug(6, "List of Sites: "+str(sites))
313          common.analisys_common_info['sites']=sites    ## used in SchedulerEdg.py in createSchScript
314 +        self.setParam_('TargetCE', ','.join(sites))
315 +        return
316 +    
317 +    def jobSplittingPerFiles(self):
318 +        """
319 +        Perform job splitting based on number of files to be accessed per job
320 +        """
321 +        common.logger.debug(5,'Splitting per input files')
322 +        common.logger.message('Required '+str(self.filesPerJob)+' files per job ')
323 +        common.logger.message('Required '+str(self.total_number_of_events)+' events in total ')
324 +
325 +        ## TODO: SL need to have (from DBS) a detailed list of how many events per each file
326 +        n_tot_files = (len(self.files[0]))
327 +        #print "n_tot_files = ", n_tot_files
328 +        ## SL: this is wrong if the files have different number of events
329 +        #print "self.maxEvents = ", self.maxEvents
330 +        evPerFile = int(self.maxEvents)/n_tot_files
331 +        #print "evPerFile = int(self.maxEvents)/n_tot_files =  ", evPerFile
332 +
333 +        common.logger.debug(5,'Events per File '+str(evPerFile))
334 +
335 +        ## if asked to process all events, do it
336 +        if self.total_number_of_events == -1:
337 +            self.total_number_of_events=self.maxEvents
338 +            self.total_number_of_jobs = int(n_tot_files)*1/int(self.filesPerJob)
339 +            check = int(n_tot_files) - (int(self.total_number_of_jobs)*self.filesPerJob)
340 +            if check > 0:
341 +                self.total_number_of_jobs =  self.total_number_of_jobs + 1
342 +                common.logger.message('Warning: last job will be created with '+str(check)+' files')
343 +            common.logger.message(str(self.total_number_of_jobs)+' jobs will be created for all available events '+str(self.total_number_of_events)+' events')
344 +        
345 +        else:
346 +            #print "self.total_number_of_events = ", self.total_number_of_events
347 +            #print "evPerFile = ", evPerFile
348 +            self.total_number_of_files = int(self.total_number_of_events/evPerFile)
349 +            #print "self.total_number_of_files = int(self.total_number_of_events/evPerFile) = " , self.total_number_of_files
350 +
351 +            ## SL: round the number of files to be processed to the ceiling
352 +            rem = self.total_number_of_events - self.total_number_of_files*evPerFile
353 +            if rem>0:
354 +                self.total_number_of_files = self.total_number_of_files + 1
355 +
356 +            ## SL: if ask for less event than what is computed to be available on a
357 +            ##     file, process the first file anyhow.
358 +            if self.total_number_of_files == 0:
359 +                self.total_number_of_files = self.total_number_of_files + 1
360 +                
361 +
362 +            common.logger.debug(5,'N files  '+str(self.total_number_of_files))
363 +
364 +            check = 0
365 +            
366 +            ## Compute the number of jobs
367 +            #self.total_number_of_jobs = int(n_tot_files)*1/int(self.filesPerJob)
368 +            #print "self.total_number_of_files = ", self.total_number_of_files
369 +            #print "self.filesPerJob = ", self.filesPerJob
370 +            self.total_number_of_jobs = int(self.total_number_of_files/self.filesPerJob)
371 +            #print "self.total_number_of_jobs = ", self.total_number_of_jobs
372 +            common.logger.debug(5,'N jobs  '+str(self.total_number_of_jobs))
373 +
374 +            ## is there any remainder?
375 +            check = int(self.total_number_of_files) - (int(self.total_number_of_jobs)*self.filesPerJob)
376 +
377 +            common.logger.debug(5,'Check  '+str(check))
378 +
379 +            if check > 0:
380 +                self.total_number_of_jobs =  self.total_number_of_jobs + 1
381 +                common.logger.message('Warning: last job will be created with '+str(check)+' files')
382 +
383 +            common.logger.message(str(self.total_number_of_jobs)+' jobs will be created for a total of '+str((self.total_number_of_jobs-check)*self.filesPerJob*evPerFile + check*evPerFile)+' events')
384 +            pass
385 +
386 +        list_of_lists = []
387 +        for i in xrange(0, int(n_tot_files), self.filesPerJob):
388 +            parString = "\\{"
389 +            
390 +            params = self.files[0][i: i+self.filesPerJob]
391 +            for i in range(len(params) - 1):
392 +                parString += '\\\"' + params[i] + '\\\"\,'
393 +            
394 +            parString += '\\\"' + params[len(params) - 1] + '\\\"\\}'
395 +            #print parString
396 +            list_of_lists.append([parString])
397 +            #print list_of_lists
398 +            pass
399 +
400 +        self.list_of_args = list_of_lists
401 + #        print self.list_of_args
402 +        return
403 +
404 +    def jobSplittingPerEvents(self):
405 +        """
406 +        Perform job splitting based on number of event per job
407 +        """
408 +        common.logger.debug(5,'Splitting per events')
409 +        common.logger.message('Required '+str(self.eventsPerJob)+' events per job ')
410 +        common.logger.message('Required '+str(self.total_number_of_events)+' events in total ')
411 +
412 +        if (self.total_number_of_events < 0):
413 +            msg='Cannot split jobs per Events with "-1" as total number of events'
414 +            raise CrabException(msg)
415 +
416 +        self.total_number_of_jobs = int(self.total_number_of_events/self.eventsPerJob)
417 +
418 +        # print "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
419 +        # print "self.total_number_of_events = ", self.total_number_of_events
420 +        # print "self.eventsPerJob = ", self.eventsPerJob
421 +        # print "self.total_number_of_jobs = ", self.total_number_of_jobs
422 +        # print "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
423 +        
424 +        common.logger.debug(5,'N jobs  '+str(self.total_number_of_jobs))
425 +
426 +        # is there any remainder?
427 +        check = int(self.total_number_of_events) - (int(self.total_number_of_jobs)*self.eventsPerJob)
428 +
429 +        common.logger.debug(5,'Check  '+str(check))
430 +
431 +        if check > 0:
432 +            common.logger.message('Warning: asked '+self.total_number_of_events+' but will do only '+(int(self.total_number_of_jobs)*self.eventsPerJob))
433 +
434 +        common.logger.message(str(self.total_number_of_jobs)+' jobs will be created for a total of '+str(self.total_number_of_jobs*self.eventsPerJob)+' events')
435 +
436 +        # argument is seed number.$i
437 +        self.list_of_args = []
438 +        for i in range(self.total_number_of_jobs):
439 +            self.list_of_args.append([int(str(self.sourceSeed)+str(i))])
440 +        #print self.list_of_args
441 +
442          return
443 +
444 +    def split(self, jobParams):
445 +
446 +        common.jobDB.load()
447 +        #### Fabio
448 +        njobs = self.total_number_of_jobs
449 +        arglist = self.list_of_args
450 +        # create the empty structure
451 +        for i in range(njobs):
452 +            jobParams.append("")
453          
454 +        for job in range(njobs):
455 +            jobParams[job] = arglist[job]
456 +            # print str(arglist[job])
457 +            # print jobParams[job]
458 +            common.jobDB.setArguments(job, jobParams[job])
459 +
460 +        common.jobDB.save()
461 +        return
462 +    
463 +    def getJobTypeArguments(self, nj, sched):
464 +        result = ''
465 +        for i in common.jobDB.arguments(nj):
466 +            result=result+str(i)+" "
467 +        return result
468 +  
469 +    def numberOfJobs(self):
470 +        # Fabio
471 +        return self.total_number_of_jobs
472 +
473      def checkBlackList(self, allSites):
474          if len(self.reCEBlackList)==0: return allSites
475          sites = []
# Line 252 | Line 486 | class Cmssw(JobType):
486              common.logger.debug(3,"No sites found after BlackList")
487          return sites
488  
489 <    def checkWhiteList(self, allsites):
489 >    def checkWhiteList(self, allSites):
490  
491 <        if len(self.reCEWhiteList)==0: return pubDBUrls
491 >        if len(self.reCEWhiteList)==0: return allSites
492          sites = []
493 <        for site in allsites:
260 <            #print 'connecting to the URL ',url
493 >        for site in allSites:
494              good=0
495              for re in self.reCEWhiteList:
496                  if re.search(site):
# Line 327 | Line 560 | class Cmssw(JobType):
560          if os.path.exists(lib):
561              filesToBeTarred.append(libDir)
562  
563 +        ## Now check if module dir is present
564 +        moduleDir = 'module'
565 +        if os.path.isdir(swArea+'/'+moduleDir):
566 +            filesToBeTarred.append(moduleDir)
567 +
568          ## Now check if the Data dir is present
569          dataDir = 'src/Data/'
570          if os.path.isdir(swArea+'/'+dataDir):
# Line 354 | Line 592 | class Cmssw(JobType):
592          the execution environment for the job 'nj'.
593          """
594          # Prepare JobType-independent part
595 <        txt = self.wsSetupCMSEnvironment_()
595 >        txt = ''
596 >  
597 >        ## OLI_Daniele at this level  middleware already known
598 >
599 >        txt += 'if [ $middleware == LCG ]; then \n'
600 >        txt += self.wsSetupCMSLCGEnvironment_()
601 >        txt += 'elif [ $middleware == OSG ]; then\n'
602 >        txt += '    time=`date -u +"%s"`\n'
603 >        txt += '    WORKING_DIR=$OSG_WN_TMP/cms_$time\n'
604 >        txt += '    echo "Creating working directory: $WORKING_DIR"\n'
605 >        txt += '    /bin/mkdir -p $WORKING_DIR\n'
606 >        txt += '    if [ ! -d $WORKING_DIR ] ;then\n'
607 >        txt += '        echo "SET_CMS_ENV 10016 ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n'
608 >        txt += '        echo "JOB_EXIT_STATUS = 10016"\n'
609 >        txt += '        echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
610 >        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
611 >        txt += '        rm -f $RUNTIME_AREA/$repo \n'
612 >        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
613 >        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
614 >        txt += '        exit 1\n'
615 >        txt += '    fi\n'
616 >        txt += '\n'
617 >        txt += '    echo "Change to working directory: $WORKING_DIR"\n'
618 >        txt += '    cd $WORKING_DIR\n'
619 >        txt += self.wsSetupCMSOSGEnvironment_()
620 >        txt += 'fi\n'
621  
622          # Prepare JobType-specific part
623          scram = self.scram.commandName()
# Line 363 | Line 626 | class Cmssw(JobType):
626          txt += scram+' project CMSSW '+self.version+'\n'
627          txt += 'status=$?\n'
628          txt += 'if [ $status != 0 ] ; then\n'
629 <        txt += '   echo "SET_EXE_ENV 1 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n'
630 <        txt += '   echo "JOB_EXIT_STATUS = 5"\n'
631 <        txt += '   echo "SanityCheckCode = 5" | tee -a $RUNTIME_AREA/$repo\n'
629 >        txt += '   echo "SET_EXE_ENV 10034 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n'
630 >        txt += '   echo "JOB_EXIT_STATUS = 10034"\n'
631 >        txt += '   echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n'
632          txt += '   dumpStatus $RUNTIME_AREA/$repo\n'
633 <        txt += '   exit 5 \n'
633 >        txt += '   rm -f $RUNTIME_AREA/$repo \n'
634 >        txt += '   echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
635 >        txt += '   echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
636 >        ## OLI_Daniele
637 >        txt += '    if [ $middleware == OSG ]; then \n'
638 >        txt += '        echo "Remove working directory: $WORKING_DIR"\n'
639 >        txt += '        cd $RUNTIME_AREA\n'
640 >        txt += '        /bin/rm -rf $WORKING_DIR\n'
641 >        txt += '        if [ -d $WORKING_DIR ] ;then\n'
642 >        txt += '            echo "SET_CMS_ENV 10018 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after CMSSW CMSSW_0_6_1 not found on `hostname`"\n'
643 >        txt += '            echo "JOB_EXIT_STATUS = 10018"\n'
644 >        txt += '            echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n'
645 >        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
646 >        txt += '            rm -f $RUNTIME_AREA/$repo \n'
647 >        txt += '            echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
648 >        txt += '            echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
649 >        txt += '        fi\n'
650 >        txt += '    fi \n'
651 >        txt += '   exit 1 \n'
652          txt += 'fi \n'
653          txt += 'echo "CMSSW_VERSION =  '+self.version+'"\n'
654          txt += 'cd '+self.version+'\n'
# Line 376 | Line 657 | class Cmssw(JobType):
657  
658          # Handle the arguments:
659          txt += "\n"
660 <        txt += "## ARGUMNETS: $1 Job Number\n"
380 <        # txt += "## ARGUMNETS: $2 First Event for this job\n"
381 <        # txt += "## ARGUMNETS: $3 Max Event for this job\n"
660 >        txt += "## number of arguments (first argument always jobnumber)\n"
661          txt += "\n"
662          txt += "narg=$#\n"
663 <        txt += "if [ $narg -lt 1 ]\n"
663 >        txt += "if [ $narg -lt 2 ]\n"
664          txt += "then\n"
665          txt += "    echo 'SET_EXE_ENV 1 ==> ERROR Too few arguments' +$narg+ \n"
666 <        txt += '    echo "JOB_EXIT_STATUS = 1"\n'
667 <        txt += '    echo "SanityCheckCode = 1" | tee -a $RUNTIME_AREA/$repo\n'
666 >        txt += '    echo "JOB_EXIT_STATUS = 50113"\n'
667 >        txt += '    echo "JobExitCode=50113" | tee -a $RUNTIME_AREA/$repo\n'
668          txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
669 +        txt += '    rm -f $RUNTIME_AREA/$repo \n'
670 +        txt += '    echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
671 +        txt += '    echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
672 +        ## OLI_Daniele
673 +        txt += '    if [ $middleware == OSG ]; then \n'
674 +        txt += '        echo "Remove working directory: $WORKING_DIR"\n'
675 +        txt += '        cd $RUNTIME_AREA\n'
676 +        txt += '        /bin/rm -rf $WORKING_DIR\n'
677 +        txt += '        if [ -d $WORKING_DIR ] ;then\n'
678 +        txt += '            echo "SET_EXE_ENV 50114 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Too few arguments for CRAB job wrapper"\n'
679 +        txt += '            echo "JOB_EXIT_STATUS = 50114"\n'
680 +        txt += '            echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n'
681 +        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
682 +        txt += '            rm -f $RUNTIME_AREA/$repo \n'
683 +        txt += '            echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
684 +        txt += '            echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
685 +        txt += '        fi\n'
686 +        txt += '    fi \n'
687          txt += "    exit 1\n"
688          txt += "fi\n"
689          txt += "\n"
393        txt += "NJob=$1\n"
394        # txt += "FirstEvent=$2\n"
395        # txt += "MaxEvents=$3\n"
690  
691          # Prepare job-specific part
692          job = common.job_list[nj]
693          pset = os.path.basename(job.configFilename())
694          txt += '\n'
695 <        txt += 'cp $RUNTIME_AREA/'+pset+' pset.cfg\n'
696 <        # txt += 'if [ -e $RUNTIME_AREA/orcarc_$CE ] ; then\n'
697 <        # txt += '  cat $RUNTIME_AREA/orcarc_$CE .orcarc >> .orcarc_tmp\n'
698 <        # txt += '  mv .orcarc_tmp .orcarc\n'
699 <        # txt += 'fi\n'
700 <        # txt += 'if [ -e $RUNTIME_AREA/init_$CE.sh ] ; then\n'
701 <        # txt += '  cp $RUNTIME_AREA/init_$CE.sh init.sh\n'
702 <        # txt += 'fi\n'
695 >        if (self.datasetPath): # standard job
696 >            txt += 'InputFiles=$2\n'
697 >            txt += 'echo "Inputfiles:<$InputFiles>"\n'
698 >            txt += 'sed "s#{\'INPUT\'}#$InputFiles#" $RUNTIME_AREA/'+pset+' > pset.cfg\n'
699 >        else:  # pythia like job
700 >            txt += 'Seed=$2\n'
701 >            txt += 'echo "Seed: <$Seed>"\n'
702 >            txt += 'sed "s#INPUT#$Seed#" $RUNTIME_AREA/'+pset+' > pset.cfg\n'
703  
704          if len(self.additional_inbox_files) > 0:
705              for file in self.additional_inbox_files:
# Line 415 | Line 709 | class Cmssw(JobType):
709                  txt += 'fi\n'
710              pass
711  
418        # txt += '\n'
419        # txt += 'chmod +x ./init.sh\n'
420        # txt += './init.sh\n'
421        # txt += 'exitStatus=$?\n'
422        # txt += 'if [ $exitStatus != 0 ] ; then\n'
423        # txt += '  echo "SET_EXE_ENV 1 ==> ERROR StageIn init script failed"\n'
424        # txt += '  echo "JOB_EXIT_STATUS = $exitStatus" \n'
425        # txt += '  echo "SanityCheckCode = $exitStatus" | tee -a $RUNTIME_AREA/$repo\n'
426        # txt += '  dumpStatus $RUNTIME_AREA/$repo\n'
427        # txt += '  exit $exitStatus\n'
428        # txt += 'fi\n'
429        # txt += "echo 'SET_EXE_ENV 0 ==> job setup ok'\n"
712          txt += 'echo "### END JOB SETUP ENVIRONMENT ###"\n\n'
713  
432        # txt += 'echo "FirstEvent=$FirstEvent" >> .orcarc\n'
433        # txt += 'echo "MaxEvents=$MaxEvents" >> .orcarc\n'
434        # if self.ML:
435        #     txt += 'echo "MonalisaJobId=$NJob" >> .orcarc\n'
436
714          txt += '\n'
715          txt += 'echo "***** cat pset.cfg *********"\n'
716          txt += 'cat pset.cfg\n'
717          txt += 'echo "****** end pset.cfg ********"\n'
718 +        txt += '\n'
719 +        # txt += 'echo "***** cat pset1.cfg *********"\n'
720 +        # txt += 'cat pset1.cfg\n'
721 +        # txt += 'echo "****** end pset1.cfg ********"\n'
722 +        return txt
723 +
724 +    def wsBuildExe(self, nj):
725 +        """
726 +        Put in the script the commands to build an executable
727 +        or a library.
728 +        """
729 +
730 +        txt = ""
731 +
732 +        if os.path.isfile(self.tgzNameWithPath):
733 +            txt += 'echo "tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'"\n'
734 +            txt += 'tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n'
735 +            txt += 'untar_status=$? \n'
736 +            txt += 'if [ $untar_status -ne 0 ]; then \n'
737 +            txt += '   echo "SET_EXE 1 ==> ERROR Untarring .tgz file failed"\n'
738 +            txt += '   echo "JOB_EXIT_STATUS = $untar_status" \n'
739 +            txt += '   echo "JobExitCode=$untar_status" | tee -a $RUNTIME_AREA/$repo\n'
740 +            txt += '   if [ $middleware == OSG ]; then \n'
741 +            txt += '       echo "Remove working directory: $WORKING_DIR"\n'
742 +            txt += '       cd $RUNTIME_AREA\n'
743 +            txt += '       /bin/rm -rf $WORKING_DIR\n'
744 +            txt += '       if [ -d $WORKING_DIR ] ;then\n'
745 +            txt += '           echo "SET_EXE 50999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Untarring .tgz file failed"\n'
746 +            txt += '           echo "JOB_EXIT_STATUS = 50999"\n'
747 +            txt += '           echo "JobExitCode=50999" | tee -a $RUNTIME_AREA/$repo\n'
748 +            txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
749 +            txt += '           rm -f $RUNTIME_AREA/$repo \n'
750 +            txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
751 +            txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
752 +            txt += '       fi\n'
753 +            txt += '   fi \n'
754 +            txt += '   \n'
755 +            txt += '   exit 1 \n'
756 +            txt += 'else \n'
757 +            txt += '   echo "Successful untar" \n'
758 +            txt += 'fi \n'
759 +            pass
760 +        
761          return txt
762  
763      def modifySteeringCards(self, nj):
# Line 450 | Line 770 | class Cmssw(JobType):
770          return self.executable
771  
772      def executableArgs(self):
773 <        return "-p pset.cfg"
773 >        return " -p pset.cfg"
774  
775      def inputSandbox(self, nj):
776          """
# Line 465 | Line 785 | class Cmssw(JobType):
785          ## config
786          inp_box.append(common.job_list[nj].configFilename())
787          ## additional input files
788 <        for file in self.additional_inbox_files:
789 <            inp_box.append(common.work_space.cwdDir()+file)
470 <        #print "sono inputSandbox, inp_box = ", inp_box
788 >        #for file in self.additional_inbox_files:
789 >        #    inp_box.append(common.work_space.cwdDir()+file)
790          return inp_box
791  
792      def outputSandbox(self, nj):
# Line 490 | Line 809 | class Cmssw(JobType):
809          """
810          Make initial modifications of the user's steering card file.
811          """
493        infile = open(self.pset,'r')
494            
495        outfile = open(common.work_space.jobDir()+self.name()+'.cfg', 'w')
496          
497        outfile.write('\n\n##### The following cards have been created by CRAB: DO NOT TOUCH #####\n')
498
499        outfile.write('InputCollections=/System/'+self.owner+'/'+self.dataset+'/'+self.dataset+'\n')
500
501        infile.close()
502        outfile.close()
812          return
813  
814      def wsRenameOutput(self, nj):
# Line 508 | Line 817 | class Cmssw(JobType):
817          """
818  
819          txt = '\n'
820 +        txt += '# directory content\n'
821 +        txt += 'ls \n'
822          file_list = ''
823          for fileWithSuffix in self.output_file:
824              output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
825              file_list=file_list+output_file_num+' '
826              txt += '\n'
827 <            txt += 'ls \n'
517 <            txt += '\n'
827 >            txt += '# check output file\n'
828              txt += 'ls '+fileWithSuffix+'\n'
829              txt += 'exe_result=$?\n'
830              txt += 'if [ $exe_result -ne 0 ] ; then\n'
831              txt += '   echo "ERROR: No output file to manage"\n'
832              txt += '   echo "JOB_EXIT_STATUS = $exe_result"\n'
833 <            txt += '   echo "SanityCheckCode = $exe_result" | tee -a $RUNTIME_AREA/$repo\n'
833 >            txt += '   echo "JobExitCode=60302" | tee -a $RUNTIME_AREA/$repo\n'
834              txt += '   dumpStatus $RUNTIME_AREA/$repo\n'
835 <            txt += '   exit $exe_result \n'
835 >            txt += '   rm -f $RUNTIME_AREA/$repo \n'
836 >            txt += '   echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
837 >            txt += '   echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
838 >            ### OLI_DANIELE
839 >            if common.scheduler.boss_scheduler_name == 'condor_g':
840 >                txt += '    if [ $middleware == OSG ]; then \n'
841 >                txt += '        echo "prepare dummy output file"\n'
842 >                txt += '        echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n'
843 >                txt += '    fi \n'
844              txt += 'else\n'
845              txt += '   cp '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
846              txt += 'fi\n'
529            txt += 'cd $RUNTIME_AREA\n'
530                      
531            pass
847        
848 +        txt += 'cd $RUNTIME_AREA\n'
849          file_list=file_list[:-1]
850          txt += 'file_list="'+file_list+'"\n'
851 +        ### OLI_DANIELE
852 +        txt += 'if [ $middleware == OSG ]; then\n'  
853 +        txt += '    cd $RUNTIME_AREA\n'
854 +        txt += '    echo "Remove working directory: $WORKING_DIR"\n'
855 +        txt += '    /bin/rm -rf $WORKING_DIR\n'
856 +        txt += '    if [ -d $WORKING_DIR ] ;then\n'
857 +        txt += '        echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
858 +        txt += '        echo "JOB_EXIT_STATUS = 60999"\n'
859 +        txt += '        echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
860 +        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
861 +        txt += '        rm -f $RUNTIME_AREA/$repo \n'
862 +        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
863 +        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
864 +        txt += '    fi\n'
865 +        txt += 'fi\n'
866 +        txt += '\n'
867          return txt
868  
869      def numberFile_(self, file, txt):
# Line 559 | Line 891 | class Cmssw(JobType):
891          return job requirements to add to jdl files
892          """
893          req = ''
894 +        if common.analisys_common_info['sw_version']:
895 +            req='Member("VO-cms-' + \
896 +                 common.analisys_common_info['sw_version'] + \
897 +                 '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
898          if common.analisys_common_info['sites']:
563            if common.analisys_common_info['sw_version']:
564                req='Member("VO-cms-' + \
565                     common.analisys_common_info['sw_version'] + \
566                     '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
899              if len(common.analisys_common_info['sites'])>0:
900                  req = req + ' && ('
901                  for i in range(len(common.analisys_common_info['sites'])):
# Line 574 | Line 906 | class Cmssw(JobType):
906              req = req + ')'
907          #print "req = ", req
908          return req
909 +
910 +    def configFilename(self):
911 +        """ return the config filename """
912 +        return self.name()+'.cfg'
913 +
914 +    ### OLI_DANIELE
915 +    def wsSetupCMSOSGEnvironment_(self):
916 +        """
917 +        Returns part of a job script which is prepares
918 +        the execution environment and which is common for all CMS jobs.
919 +        """
920 +        txt = '\n'
921 +        txt += '   echo "### SETUP CMS OSG  ENVIRONMENT ###"\n'
922 +        txt += '   if [ -f $GRID3_APP_DIR/cmssoft/cmsset_default.sh ] ;then\n'
923 +        txt += '      # Use $GRID3_APP_DIR/cmssoft/cmsset_default.sh to setup cms software\n'
924 +        txt += '       source $GRID3_APP_DIR/cmssoft/cmsset_default.sh '+self.version+'\n'
925 +        txt += '   elif [ -f $OSG_APP/cmssoft/cmsset_default.sh ] ;then\n'
926 +        txt += '      # Use $OSG_APP/cmssoft/cmsset_default.sh to setup cms software\n'
927 +        txt += '       source $OSG_APP/cmssoft/cmsset_default.sh '+self.version+'\n'
928 +        txt += '   else\n'
929 +        txt += '       echo "SET_CMS_ENV 10020 ==> ERROR $GRID3_APP_DIR/cmssoft/cmsset_default.sh and $OSG_APP/cmssoft/cmsset_default.sh file not found"\n'
930 +        txt += '       echo "JOB_EXIT_STATUS = 10020"\n'
931 +        txt += '       echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
932 +        txt += '       dumpStatus $RUNTIME_AREA/$repo\n'
933 +        txt += '       rm -f $RUNTIME_AREA/$repo \n'
934 +        txt += '       echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
935 +        txt += '       echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
936 +        txt += '       exit 1\n'
937 +        txt += '\n'
938 +        txt += '       echo "Remove working directory: $WORKING_DIR"\n'
939 +        txt += '       cd $RUNTIME_AREA\n'
940 +        txt += '       /bin/rm -rf $WORKING_DIR\n'
941 +        txt += '       if [ -d $WORKING_DIR ] ;then\n'
942 +        txt += '            echo "SET_CMS_ENV 10017 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after $GRID3_APP_DIR/cmssoft/cmsset_default.sh and $OSG_APP/cmssoft/cmsset_default.sh file not found"\n'
943 +        txt += '            echo "JOB_EXIT_STATUS = 10017"\n'
944 +        txt += '            echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n'
945 +        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
946 +        txt += '            rm -f $RUNTIME_AREA/$repo \n'
947 +        txt += '            echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
948 +        txt += '            echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
949 +        txt += '       fi\n'
950 +        txt += '\n'
951 +        txt += '       exit 1\n'
952 +        txt += '   fi\n'
953 +        txt += '\n'
954 +        txt += '   echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
955 +        txt += '   echo " END SETUP CMS OSG  ENVIRONMENT "\n'
956 +
957 +        return txt
958 +
959 +    ### OLI_DANIELE
960 +    def wsSetupCMSLCGEnvironment_(self):
961 +        """
962 +        Returns part of a job script which is prepares
963 +        the execution environment and which is common for all CMS jobs.
964 +        """
965 +        txt  = '   \n'
966 +        txt += '   echo " ### SETUP CMS LCG  ENVIRONMENT ### "\n'
967 +        txt += '   if [ ! $VO_CMS_SW_DIR ] ;then\n'
968 +        txt += '       echo "SET_CMS_ENV 10031 ==> ERROR CMS software dir not found on WN `hostname`"\n'
969 +        txt += '       echo "JOB_EXIT_STATUS = 10031" \n'
970 +        txt += '       echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n'
971 +        txt += '       dumpStatus $RUNTIME_AREA/$repo\n'
972 +        txt += '       rm -f $RUNTIME_AREA/$repo \n'
973 +        txt += '       echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
974 +        txt += '       echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
975 +        txt += '       exit 1\n'
976 +        txt += '   else\n'
977 +        txt += '       echo "Sourcing environment... "\n'
978 +        txt += '       if [ ! -s $VO_CMS_SW_DIR/cmsset_default.sh ] ;then\n'
979 +        txt += '           echo "SET_CMS_ENV 10020 ==> ERROR cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
980 +        txt += '           echo "JOB_EXIT_STATUS = 10020"\n'
981 +        txt += '           echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
982 +        txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
983 +        txt += '           rm -f $RUNTIME_AREA/$repo \n'
984 +        txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
985 +        txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
986 +        txt += '           exit 1\n'
987 +        txt += '       fi\n'
988 +        txt += '       echo "sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
989 +        txt += '       source $VO_CMS_SW_DIR/cmsset_default.sh\n'
990 +        txt += '       result=$?\n'
991 +        txt += '       if [ $result -ne 0 ]; then\n'
992 +        txt += '           echo "SET_CMS_ENV 10032 ==> ERROR problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
993 +        txt += '           echo "JOB_EXIT_STATUS = 10032"\n'
994 +        txt += '           echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n'
995 +        txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
996 +        txt += '           rm -f $RUNTIME_AREA/$repo \n'
997 +        txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
998 +        txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
999 +        txt += '           exit 1\n'
1000 +        txt += '       fi\n'
1001 +        txt += '   fi\n'
1002 +        txt += '   \n'
1003 +        txt += '   string=`cat /etc/redhat-release`\n'
1004 +        txt += '   echo $string\n'
1005 +        txt += '   if [[ $string = *alhalla* ]]; then\n'
1006 +        txt += '       echo "SCRAM_ARCH= $SCRAM_ARCH"\n'
1007 +        txt += '   elif [[ $string = *Enterprise* ]] || [[ $string = *cientific* ]]; then\n'
1008 +        txt += '       export SCRAM_ARCH=slc3_ia32_gcc323\n'
1009 +        txt += '       echo "SCRAM_ARCH= $SCRAM_ARCH"\n'
1010 +        txt += '   else\n'
1011 +        txt += '       echo "SET_CMS_ENV 10033 ==> ERROR OS unknown, LCG environment not initialized"\n'
1012 +        txt += '       echo "JOB_EXIT_STATUS = 10033"\n'
1013 +        txt += '       echo "JobExitCode=10033" | tee -a $RUNTIME_AREA/$repo\n'
1014 +        txt += '       dumpStatus $RUNTIME_AREA/$repo\n'
1015 +        txt += '       rm -f $RUNTIME_AREA/$repo \n'
1016 +        txt += '       echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1017 +        txt += '       echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1018 +        txt += '       exit 1\n'
1019 +        txt += '   fi\n'
1020 +        txt += '   echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1021 +        txt += '   echo "### END SETUP CMS LCG ENVIRONMENT ###"\n'
1022 +        return txt
1023 +
1024 +    def setParam_(self, param, value):
1025 +        self._params[param] = value
1026 +
1027 +    def getParams(self):
1028 +        return self._params
1029 +
1030 +    def setTaskid_(self):
1031 +        self._taskId = self.cfg_params['taskId']
1032 +        
1033 +    def getTaskid(self):
1034 +        return self._taskId

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines