ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/cms_cmssw.py
Revision: 1.19
Committed: Wed Jun 28 16:21:22 2006 UTC (18 years, 10 months ago) by slacapra
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_1_2_0_pre8
Changes since 1.18: +5 -4 lines
Log Message:
fix probem if ask more events than available

File Contents

# User Rev Content
1 slacapra 1.1 from JobType import JobType
2     from crab_logger import Logger
3     from crab_exceptions import *
4     from crab_util import *
5     import common
6 gutsche 1.3 import PsetManipulator
7 slacapra 1.1
8 gutsche 1.3 import DBSInfo_EDM
9     import DataDiscovery_EDM
10     import DataLocation_EDM
11 slacapra 1.1 import Scram
12    
13     import os, string, re
14    
15     class Cmssw(JobType):
16     def __init__(self, cfg_params):
17     JobType.__init__(self, 'CMSSW')
18     common.logger.debug(3,'CMSSW::__init__')
19    
20     self.analisys_common_info = {}
21 gutsche 1.3 # Marco.
22     self._params = {}
23     self.cfg_params = cfg_params
24 slacapra 1.1 log = common.logger
25    
26     self.scram = Scram.Scram(cfg_params)
27     scramArea = ''
28     self.additional_inbox_files = []
29     self.scriptExe = ''
30     self.executable = ''
31     self.tgz_name = 'default.tgz'
32    
33 gutsche 1.3
34 slacapra 1.1 self.version = self.scram.getSWVersion()
35 gutsche 1.5 self.setParam_('application', self.version)
36 slacapra 1.1 common.analisys_common_info['sw_version'] = self.version
37 gutsche 1.3 ### FEDE
38     common.analisys_common_info['copy_input_data'] = 0
39     common.analisys_common_info['events_management'] = 1
40 slacapra 1.1
41     ### collect Data cards
42     try:
43 slacapra 1.9 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 slacapra 1.1 except KeyError:
50 gutsche 1.3 msg = "Error: datasetpath not defined "
51 slacapra 1.1 raise CrabException(msg)
52 gutsche 1.5
53     # ML monitoring
54     # split dataset path style: /PreProdR3Minbias/SIM/GEN-SIM
55 slacapra 1.9 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 gutsche 1.8 self.setTaskid_()
64     self.setParam_('taskId', self.cfg_params['taskId'])
65 gutsche 1.5
66 slacapra 1.1 self.dataTiers = []
67    
68     ## now the application
69     try:
70     self.executable = cfg_params['CMSSW.executable']
71 gutsche 1.5 self.setParam_('exe', self.executable)
72 slacapra 1.1 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 gutsche 1.5 self.setParam_('exe', self.executable)
78 slacapra 1.1 msg = "User executable not defined. Use cmsRun"
79     log.debug(3,msg)
80     pass
81    
82     try:
83     self.pset = cfg_params['CMSSW.pset']
84     log.debug(6, "Cmssw::Cmssw(): PSet file = "+self.pset)
85     if (not os.path.exists(self.pset)):
86     raise CrabException("User defined PSet file "+self.pset+" does not exist")
87     except KeyError:
88     raise CrabException("PSet file missing. Cannot run cmsRun ")
89    
90     # output files
91     try:
92     self.output_file = []
93    
94     tmp = cfg_params['CMSSW.output_file']
95     if tmp != '':
96     tmpOutFiles = string.split(cfg_params['CMSSW.output_file'],',')
97     log.debug(7, 'cmssw::cmssw(): output files '+str(tmpOutFiles))
98     for tmp in tmpOutFiles:
99     tmp=string.strip(tmp)
100     self.output_file.append(tmp)
101     pass
102     else:
103     log.message("No output file defined: only stdout/err will be available")
104     pass
105     pass
106     except KeyError:
107     log.message("No output file defined: only stdout/err will be available")
108     pass
109    
110     # script_exe file as additional file in inputSandbox
111     try:
112 slacapra 1.10 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 slacapra 1.1 except KeyError:
119     pass
120    
121     ## additional input files
122     try:
123     tmpAddFiles = string.split(cfg_params['CMSSW.additional_input_files'],',')
124     for tmp in tmpAddFiles:
125 gutsche 1.3 if not os.path.exists(tmp):
126     raise CrabException("Additional input file not found: "+tmp)
127 slacapra 1.1 tmp=string.strip(tmp)
128     self.additional_inbox_files.append(tmp)
129     pass
130     pass
131     except KeyError:
132     pass
133    
134 slacapra 1.9 # files per job
135 slacapra 1.1 try:
136 gutsche 1.3 self.filesPerJob = int(cfg_params['CMSSW.files_per_jobs']) #Daniele
137 slacapra 1.9 self.selectFilesPerJob = 1
138 gutsche 1.3 except KeyError:
139 slacapra 1.9 self.filesPerJob = 0
140     self.selectFilesPerJob = 0
141 gutsche 1.3
142 slacapra 1.9 ## Events per job
143 gutsche 1.3 try:
144 slacapra 1.10 self.eventsPerJob =int( cfg_params['CMSSW.events_per_job'])
145 slacapra 1.9 self.selectEventsPerJob = 1
146 gutsche 1.3 except KeyError:
147 slacapra 1.9 self.eventsPerJob = -1
148     self.selectEventsPerJob = 0
149    
150 slacapra 1.10 # 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 slacapra 1.9 if (self.selectFilesPerJob == self.selectEventsPerJob):
159 slacapra 1.10 msg = 'Must define either files_per_jobs or events_per_job'
160 slacapra 1.9 raise CrabException(msg)
161    
162 slacapra 1.10 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 gutsche 1.3 try:
167 slacapra 1.1 self.total_number_of_events = int(cfg_params['CMSSW.total_number_of_events'])
168     except KeyError:
169 gutsche 1.3 msg = 'Must define total_number_of_events'
170 slacapra 1.1 raise CrabException(msg)
171    
172     CEBlackList = []
173     try:
174     tmpBad = string.split(cfg_params['EDG.ce_black_list'],',')
175     for tmp in tmpBad:
176     tmp=string.strip(tmp)
177     CEBlackList.append(tmp)
178     except KeyError:
179     pass
180    
181     self.reCEBlackList=[]
182     for bad in CEBlackList:
183     self.reCEBlackList.append(re.compile( bad ))
184    
185     common.logger.debug(5,'CEBlackList: '+str(CEBlackList))
186    
187     CEWhiteList = []
188     try:
189     tmpGood = string.split(cfg_params['EDG.ce_white_list'],',')
190     for tmp in tmpGood:
191     tmp=string.strip(tmp)
192     CEWhiteList.append(tmp)
193     except KeyError:
194     pass
195    
196     #print 'CEWhiteList: ',CEWhiteList
197     self.reCEWhiteList=[]
198     for Good in CEWhiteList:
199     self.reCEWhiteList.append(re.compile( Good ))
200    
201     common.logger.debug(5,'CEWhiteList: '+str(CEWhiteList))
202    
203 gutsche 1.3 self.PsetEdit = PsetManipulator.PsetManipulator(self.pset) #Daniele Pset
204    
205 slacapra 1.1 #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 slacapra 1.9 ## 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 slacapra 1.1 #DBSDLS-end
215    
216     self.tgzNameWithPath = self.getTarBall(self.executable)
217    
218 slacapra 1.10 # 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 slacapra 1.9 ## 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 gutsche 1.5
241 gutsche 1.3
242 slacapra 1.1 def DataDiscoveryAndLocation(self, cfg_params):
243    
244 gutsche 1.3 common.logger.debug(10,"CMSSW::DataDiscoveryAndLocation()")
245    
246     datasetPath=self.datasetPath
247    
248     ## TODO
249     dataTiersList = ""
250     dataTiers = dataTiersList.split(',')
251 slacapra 1.1
252     ## Contact the DBS
253     try:
254 afanfani 1.4 self.pubdata=DataDiscovery_EDM.DataDiscovery_EDM(datasetPath, dataTiers, cfg_params)
255 slacapra 1.1 self.pubdata.fetchDBSInfo()
256    
257 gutsche 1.3 except DataDiscovery_EDM.NotExistingDatasetError, ex :
258 slacapra 1.1 msg = 'ERROR ***: failed Data Discovery in DBS : %s'%ex.getErrorMessage()
259     raise CrabException(msg)
260    
261 gutsche 1.3 except DataDiscovery_EDM.NoDataTierinProvenanceError, ex :
262 slacapra 1.1 msg = 'ERROR ***: failed Data Discovery in DBS : %s'%ex.getErrorMessage()
263     raise CrabException(msg)
264 gutsche 1.3 except DataDiscovery_EDM.DataDiscoveryError, ex:
265 slacapra 1.1 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 gutsche 1.3 ## 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 slacapra 1.1
287     ## get max number of events
288 gutsche 1.3 #common.logger.debug(10,"number of events for primary fileblocks %i"%self.pubdata.getMaxEvents())
289 slacapra 1.1 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    
292     ## Contact the DLS and build a list of sites hosting the fileblocks
293     try:
294 gutsche 1.6 dataloc=DataLocation_EDM.DataLocation_EDM(filesbyblock.keys(),cfg_params)
295     dataloc.fetchDLSInfo()
296 gutsche 1.3 except DataLocation_EDM.DataLocationError , ex:
297 slacapra 1.1 msg = 'ERROR ***: failed Data Location in DLS \n %s '%ex.getErrorMessage()
298     raise CrabException(msg)
299    
300     allsites=dataloc.getSites()
301     common.logger.debug(5,"sites are %s"%allsites)
302     sites=self.checkBlackList(allsites)
303     common.logger.debug(5,"sites are (after black list) %s"%sites)
304     sites=self.checkWhiteList(sites)
305     common.logger.debug(5,"sites are (after white list) %s"%sites)
306    
307     if len(sites)==0:
308     msg = 'No sites hosting all the needed data! Exiting... '
309     raise CrabException(msg)
310 gutsche 1.3
311 slacapra 1.1 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 gutsche 1.5 self.setParam_('TargetCE', ','.join(sites))
315 slacapra 1.1 return
316 gutsche 1.3
317 slacapra 1.9 def jobSplittingPerFiles(self):
318     """
319     Perform job splitting based on number of files to be accessed per job
320 gutsche 1.3 """
321 slacapra 1.9 common.logger.debug(5,'Splitting per input files')
322 gutsche 1.3 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 slacapra 1.19 common.logger.message('Available '+str(self.maxEvents)+' events in total ')
325 gutsche 1.3
326     ## TODO: SL need to have (from DBS) a detailed list of how many events per each file
327     n_tot_files = (len(self.files[0]))
328 fanzago 1.12 #print "n_tot_files = ", n_tot_files
329 gutsche 1.3 ## SL: this is wrong if the files have different number of events
330 fanzago 1.12 #print "self.maxEvents = ", self.maxEvents
331 gutsche 1.3 evPerFile = int(self.maxEvents)/n_tot_files
332 fanzago 1.12 #print "evPerFile = int(self.maxEvents)/n_tot_files = ", evPerFile
333    
334 gutsche 1.3 common.logger.debug(5,'Events per File '+str(evPerFile))
335    
336     ## if asked to process all events, do it
337     if self.total_number_of_events == -1:
338     self.total_number_of_events=self.maxEvents
339     self.total_number_of_jobs = int(n_tot_files)*1/int(self.filesPerJob)
340 slacapra 1.16 check = int(n_tot_files) - (int(self.total_number_of_jobs)*self.filesPerJob)
341     if check > 0:
342     self.total_number_of_jobs = self.total_number_of_jobs + 1
343     common.logger.message('Warning: last job will be created with '+str(check)+' files')
344 gutsche 1.3 common.logger.message(str(self.total_number_of_jobs)+' jobs will be created for all available events '+str(self.total_number_of_events)+' events')
345    
346     else:
347 slacapra 1.19 if self.total_number_of_events>self.maxEvents:
348     common.logger.message("Asked "+str(self.total_number_of_events)+" but only "+str(self.maxEvents)+" available.")
349     self.total_number_of_events=self.maxEvents
350    
351 fanzago 1.12 #print "self.total_number_of_events = ", self.total_number_of_events
352     #print "evPerFile = ", evPerFile
353 gutsche 1.3 self.total_number_of_files = int(self.total_number_of_events/evPerFile)
354 fanzago 1.12 #print "self.total_number_of_files = int(self.total_number_of_events/evPerFile) = " , self.total_number_of_files
355 slacapra 1.15
356     ## SL: round the number of files to be processed to the ceiling
357     rem = self.total_number_of_events - self.total_number_of_files*evPerFile
358     if rem>0:
359     self.total_number_of_files = self.total_number_of_files + 1
360    
361 gutsche 1.3 ## SL: if ask for less event than what is computed to be available on a
362     ## file, process the first file anyhow.
363     if self.total_number_of_files == 0:
364     self.total_number_of_files = self.total_number_of_files + 1
365     common.logger.debug(5,'N files '+str(self.total_number_of_files))
366    
367     check = 0
368    
369     ## Compute the number of jobs
370     #self.total_number_of_jobs = int(n_tot_files)*1/int(self.filesPerJob)
371 fanzago 1.12 #print "self.total_number_of_files = ", self.total_number_of_files
372     #print "self.filesPerJob = ", self.filesPerJob
373 gutsche 1.3 self.total_number_of_jobs = int(self.total_number_of_files/self.filesPerJob)
374 fanzago 1.12 #print "self.total_number_of_jobs = ", self.total_number_of_jobs
375 gutsche 1.3 common.logger.debug(5,'N jobs '+str(self.total_number_of_jobs))
376    
377     ## is there any remainder?
378     check = int(self.total_number_of_files) - (int(self.total_number_of_jobs)*self.filesPerJob)
379    
380     common.logger.debug(5,'Check '+str(check))
381    
382     if check > 0:
383     self.total_number_of_jobs = self.total_number_of_jobs + 1
384     common.logger.message('Warning: last job will be created with '+str(check)+' files')
385    
386 slacapra 1.15 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')
387 gutsche 1.3 pass
388    
389     list_of_lists = []
390     for i in xrange(0, int(n_tot_files), self.filesPerJob):
391 slacapra 1.9 parString = "\\{"
392    
393     params = self.files[0][i: i+self.filesPerJob]
394     for i in range(len(params) - 1):
395     parString += '\\\"' + params[i] + '\\\"\,'
396    
397     parString += '\\\"' + params[len(params) - 1] + '\\\"\\}'
398 slacapra 1.17 #print parString
399     list_of_lists.append([parString])
400     #print list_of_lists
401 slacapra 1.9 pass
402    
403     self.list_of_args = list_of_lists
404 slacapra 1.17 # print self.list_of_args
405 slacapra 1.9 return
406    
407     def jobSplittingPerEvents(self):
408     """
409     Perform job splitting based on number of event per job
410     """
411     common.logger.debug(5,'Splitting per events')
412     common.logger.message('Required '+str(self.eventsPerJob)+' events per job ')
413     common.logger.message('Required '+str(self.total_number_of_events)+' events in total ')
414    
415 slacapra 1.10 if (self.total_number_of_events < 0):
416     msg='Cannot split jobs per Events with "-1" as total number of events'
417     raise CrabException(msg)
418    
419 slacapra 1.9 self.total_number_of_jobs = int(self.total_number_of_events/self.eventsPerJob)
420 fanzago 1.12
421 slacapra 1.9 common.logger.debug(5,'N jobs '+str(self.total_number_of_jobs))
422    
423     # is there any remainder?
424     check = int(self.total_number_of_events) - (int(self.total_number_of_jobs)*self.eventsPerJob)
425    
426     common.logger.debug(5,'Check '+str(check))
427    
428     if check > 0:
429     common.logger.message('Warning: asked '+self.total_number_of_events+' but will do only '+(int(self.total_number_of_jobs)*self.eventsPerJob))
430    
431     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')
432    
433 slacapra 1.10 # argument is seed number.$i
434 slacapra 1.9 self.list_of_args = []
435     for i in range(self.total_number_of_jobs):
436 slacapra 1.17 self.list_of_args.append([int(str(self.sourceSeed)+str(i))])
437     #print self.list_of_args
438 gutsche 1.3
439     return
440    
441     def split(self, jobParams):
442    
443     common.jobDB.load()
444     #### Fabio
445     njobs = self.total_number_of_jobs
446 slacapra 1.9 arglist = self.list_of_args
447 gutsche 1.3 # create the empty structure
448     for i in range(njobs):
449     jobParams.append("")
450    
451     for job in range(njobs):
452 slacapra 1.17 jobParams[job] = arglist[job]
453     # print str(arglist[job])
454     # print jobParams[job]
455 gutsche 1.3 common.jobDB.setArguments(job, jobParams[job])
456    
457     common.jobDB.save()
458     return
459    
460     def getJobTypeArguments(self, nj, sched):
461 slacapra 1.17 result = ''
462     for i in common.jobDB.arguments(nj):
463     result=result+str(i)+" "
464     return result
465 gutsche 1.3
466     def numberOfJobs(self):
467     # Fabio
468     return self.total_number_of_jobs
469    
470 slacapra 1.1 def checkBlackList(self, allSites):
471     if len(self.reCEBlackList)==0: return allSites
472     sites = []
473     for site in allSites:
474     common.logger.debug(10,'Site '+site)
475     good=1
476     for re in self.reCEBlackList:
477     if re.search(site):
478     common.logger.message('CE in black list, skipping site '+site)
479     good=0
480     pass
481     if good: sites.append(site)
482     if len(sites) == 0:
483     common.logger.debug(3,"No sites found after BlackList")
484     return sites
485    
486 gutsche 1.3 def checkWhiteList(self, allSites):
487 slacapra 1.1
488 gutsche 1.3 if len(self.reCEWhiteList)==0: return allSites
489 slacapra 1.1 sites = []
490 gutsche 1.3 for site in allSites:
491 slacapra 1.1 good=0
492     for re in self.reCEWhiteList:
493     if re.search(site):
494     common.logger.debug(5,'CE in white list, adding site '+site)
495     good=1
496     if not good: continue
497     sites.append(site)
498     if len(sites) == 0:
499     common.logger.message("No sites found after WhiteList\n")
500     else:
501     common.logger.debug(5,"Selected sites via WhiteList are "+str(sites)+"\n")
502     return sites
503    
504     def getTarBall(self, exe):
505     """
506     Return the TarBall with lib and exe
507     """
508    
509     # if it exist, just return it
510     self.tgzNameWithPath = common.work_space.shareDir()+self.tgz_name
511     if os.path.exists(self.tgzNameWithPath):
512     return self.tgzNameWithPath
513    
514     # Prepare a tar gzipped file with user binaries.
515     self.buildTar_(exe)
516    
517     return string.strip(self.tgzNameWithPath)
518    
519     def buildTar_(self, executable):
520    
521     # First of all declare the user Scram area
522     swArea = self.scram.getSWArea_()
523     #print "swArea = ", swArea
524     swVersion = self.scram.getSWVersion()
525     #print "swVersion = ", swVersion
526     swReleaseTop = self.scram.getReleaseTop_()
527     #print "swReleaseTop = ", swReleaseTop
528    
529     ## check if working area is release top
530     if swReleaseTop == '' or swArea == swReleaseTop:
531     return
532    
533     filesToBeTarred = []
534     ## First find the executable
535     if (self.executable != ''):
536     exeWithPath = self.scram.findFile_(executable)
537     # print exeWithPath
538     if ( not exeWithPath ):
539     raise CrabException('User executable '+executable+' not found')
540    
541     ## then check if it's private or not
542     if exeWithPath.find(swReleaseTop) == -1:
543     # the exe is private, so we must ship
544     common.logger.debug(5,"Exe "+exeWithPath+" to be tarred")
545     path = swArea+'/'
546     exe = string.replace(exeWithPath, path,'')
547     filesToBeTarred.append(exe)
548     pass
549     else:
550     # the exe is from release, we'll find it on WN
551     pass
552    
553     ## Now get the libraries: only those in local working area
554     libDir = 'lib'
555     lib = swArea+'/' +libDir
556     common.logger.debug(5,"lib "+lib+" to be tarred")
557     if os.path.exists(lib):
558     filesToBeTarred.append(libDir)
559    
560 gutsche 1.3 ## Now check if module dir is present
561     moduleDir = 'module'
562     if os.path.isdir(swArea+'/'+moduleDir):
563     filesToBeTarred.append(moduleDir)
564    
565 slacapra 1.1 ## Now check if the Data dir is present
566     dataDir = 'src/Data/'
567     if os.path.isdir(swArea+'/'+dataDir):
568     filesToBeTarred.append(dataDir)
569    
570     ## Create the tar-ball
571     if len(filesToBeTarred)>0:
572     cwd = os.getcwd()
573     os.chdir(swArea)
574     tarcmd = 'tar zcvf ' + self.tgzNameWithPath + ' '
575     for line in filesToBeTarred:
576     tarcmd = tarcmd + line + ' '
577     cout = runCommand(tarcmd)
578     if not cout:
579     raise CrabException('Could not create tar-ball')
580     os.chdir(cwd)
581     else:
582     common.logger.debug(5,"No files to be to be tarred")
583    
584     return
585    
586     def wsSetupEnvironment(self, nj):
587     """
588     Returns part of a job script which prepares
589     the execution environment for the job 'nj'.
590     """
591     # Prepare JobType-independent part
592 gutsche 1.3 txt = ''
593    
594     ## OLI_Daniele at this level middleware already known
595    
596     txt += 'if [ $middleware == LCG ]; then \n'
597     txt += self.wsSetupCMSLCGEnvironment_()
598     txt += 'elif [ $middleware == OSG ]; then\n'
599     txt += ' time=`date -u +"%s"`\n'
600     txt += ' WORKING_DIR=$OSG_WN_TMP/cms_$time\n'
601     txt += ' echo "Creating working directory: $WORKING_DIR"\n'
602     txt += ' /bin/mkdir -p $WORKING_DIR\n'
603     txt += ' if [ ! -d $WORKING_DIR ] ;then\n'
604 gutsche 1.7 txt += ' echo "SET_CMS_ENV 10016 ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n'
605     txt += ' echo "JOB_EXIT_STATUS = 10016"\n'
606     txt += ' echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
607     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
608 gutsche 1.13 txt += ' rm -f $RUNTIME_AREA/$repo \n'
609     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
610     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
611 gutsche 1.3 txt += ' exit 1\n'
612     txt += ' fi\n'
613     txt += '\n'
614     txt += ' echo "Change to working directory: $WORKING_DIR"\n'
615     txt += ' cd $WORKING_DIR\n'
616     txt += self.wsSetupCMSOSGEnvironment_()
617     txt += 'fi\n'
618 slacapra 1.1
619     # Prepare JobType-specific part
620     scram = self.scram.commandName()
621     txt += '\n\n'
622     txt += 'echo "### SPECIFIC JOB SETUP ENVIRONMENT ###"\n'
623     txt += scram+' project CMSSW '+self.version+'\n'
624     txt += 'status=$?\n'
625     txt += 'if [ $status != 0 ] ; then\n'
626 gutsche 1.7 txt += ' echo "SET_EXE_ENV 10034 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n'
627 gutsche 1.3 txt += ' echo "JOB_EXIT_STATUS = 10034"\n'
628 gutsche 1.7 txt += ' echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n'
629 slacapra 1.1 txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
630 gutsche 1.13 txt += ' rm -f $RUNTIME_AREA/$repo \n'
631     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
632     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
633 gutsche 1.3 ## OLI_Daniele
634     txt += ' if [ $middleware == OSG ]; then \n'
635     txt += ' echo "Remove working directory: $WORKING_DIR"\n'
636     txt += ' cd $RUNTIME_AREA\n'
637     txt += ' /bin/rm -rf $WORKING_DIR\n'
638     txt += ' if [ -d $WORKING_DIR ] ;then\n'
639 gutsche 1.7 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'
640     txt += ' echo "JOB_EXIT_STATUS = 10018"\n'
641     txt += ' echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n'
642     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
643 gutsche 1.13 txt += ' rm -f $RUNTIME_AREA/$repo \n'
644     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
645     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
646 gutsche 1.3 txt += ' fi\n'
647     txt += ' fi \n'
648     txt += ' exit 1 \n'
649 slacapra 1.1 txt += 'fi \n'
650     txt += 'echo "CMSSW_VERSION = '+self.version+'"\n'
651     txt += 'cd '+self.version+'\n'
652     ### needed grep for bug in scramv1 ###
653     txt += 'eval `'+scram+' runtime -sh | grep -v SCRAMRT_LSB_JOBNAME`\n'
654    
655     # Handle the arguments:
656     txt += "\n"
657 gutsche 1.7 txt += "## number of arguments (first argument always jobnumber)\n"
658 slacapra 1.1 txt += "\n"
659     txt += "narg=$#\n"
660 gutsche 1.3 txt += "if [ $narg -lt 2 ]\n"
661 slacapra 1.1 txt += "then\n"
662     txt += " echo 'SET_EXE_ENV 1 ==> ERROR Too few arguments' +$narg+ \n"
663 gutsche 1.3 txt += ' echo "JOB_EXIT_STATUS = 50113"\n'
664 gutsche 1.7 txt += ' echo "JobExitCode=50113" | tee -a $RUNTIME_AREA/$repo\n'
665 slacapra 1.1 txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
666 gutsche 1.13 txt += ' rm -f $RUNTIME_AREA/$repo \n'
667     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
668     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
669 gutsche 1.3 ## OLI_Daniele
670     txt += ' if [ $middleware == OSG ]; then \n'
671     txt += ' echo "Remove working directory: $WORKING_DIR"\n'
672     txt += ' cd $RUNTIME_AREA\n'
673     txt += ' /bin/rm -rf $WORKING_DIR\n'
674     txt += ' if [ -d $WORKING_DIR ] ;then\n'
675 gutsche 1.7 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'
676     txt += ' echo "JOB_EXIT_STATUS = 50114"\n'
677     txt += ' echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n'
678     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
679 gutsche 1.13 txt += ' rm -f $RUNTIME_AREA/$repo \n'
680     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
681     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
682 gutsche 1.3 txt += ' fi\n'
683     txt += ' fi \n'
684 slacapra 1.1 txt += " exit 1\n"
685     txt += "fi\n"
686     txt += "\n"
687    
688     # Prepare job-specific part
689     job = common.job_list[nj]
690     pset = os.path.basename(job.configFilename())
691     txt += '\n'
692 slacapra 1.10 if (self.datasetPath): # standard job
693     txt += 'InputFiles=$2\n'
694     txt += 'echo "Inputfiles:<$InputFiles>"\n'
695     txt += 'sed "s#{\'INPUT\'}#$InputFiles#" $RUNTIME_AREA/'+pset+' > pset.cfg\n'
696     else: # pythia like job
697     txt += 'Seed=$2\n'
698     txt += 'echo "Seed: <$Seed>"\n'
699     txt += 'sed "s#INPUT#$Seed#" $RUNTIME_AREA/'+pset+' > pset.cfg\n'
700 slacapra 1.1
701     if len(self.additional_inbox_files) > 0:
702     for file in self.additional_inbox_files:
703     txt += 'if [ -e $RUNTIME_AREA/'+file+' ] ; then\n'
704     txt += ' cp $RUNTIME_AREA/'+file+' .\n'
705     txt += ' chmod +x '+file+'\n'
706     txt += 'fi\n'
707     pass
708    
709     txt += 'echo "### END JOB SETUP ENVIRONMENT ###"\n\n'
710    
711     txt += '\n'
712     txt += 'echo "***** cat pset.cfg *********"\n'
713     txt += 'cat pset.cfg\n'
714     txt += 'echo "****** end pset.cfg ********"\n'
715 gutsche 1.3 txt += '\n'
716     # txt += 'echo "***** cat pset1.cfg *********"\n'
717     # txt += 'cat pset1.cfg\n'
718     # txt += 'echo "****** end pset1.cfg ********"\n'
719     return txt
720    
721     def wsBuildExe(self, nj):
722     """
723     Put in the script the commands to build an executable
724     or a library.
725     """
726    
727     txt = ""
728    
729     if os.path.isfile(self.tgzNameWithPath):
730     txt += 'echo "tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'"\n'
731     txt += 'tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n'
732     txt += 'untar_status=$? \n'
733     txt += 'if [ $untar_status -ne 0 ]; then \n'
734     txt += ' echo "SET_EXE 1 ==> ERROR Untarring .tgz file failed"\n'
735     txt += ' echo "JOB_EXIT_STATUS = $untar_status" \n'
736 gutsche 1.7 txt += ' echo "JobExitCode=$untar_status" | tee -a $RUNTIME_AREA/$repo\n'
737 gutsche 1.3 txt += ' if [ $middleware == OSG ]; then \n'
738     txt += ' echo "Remove working directory: $WORKING_DIR"\n'
739     txt += ' cd $RUNTIME_AREA\n'
740     txt += ' /bin/rm -rf $WORKING_DIR\n'
741     txt += ' if [ -d $WORKING_DIR ] ;then\n'
742 gutsche 1.13 txt += ' echo "SET_EXE 50999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Untarring .tgz file failed"\n'
743     txt += ' echo "JOB_EXIT_STATUS = 50999"\n'
744     txt += ' echo "JobExitCode=50999" | tee -a $RUNTIME_AREA/$repo\n'
745     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
746     txt += ' rm -f $RUNTIME_AREA/$repo \n'
747     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
748     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
749 gutsche 1.3 txt += ' fi\n'
750     txt += ' fi \n'
751     txt += ' \n'
752 gutsche 1.7 txt += ' exit 1 \n'
753 gutsche 1.3 txt += 'else \n'
754     txt += ' echo "Successful untar" \n'
755     txt += 'fi \n'
756     pass
757    
758 slacapra 1.1 return txt
759    
760     def modifySteeringCards(self, nj):
761     """
762     modify the card provided by the user,
763     writing a new card into share dir
764     """
765    
766     def executableName(self):
767     return self.executable
768    
769     def executableArgs(self):
770 gutsche 1.3 return " -p pset.cfg"
771 slacapra 1.1
772     def inputSandbox(self, nj):
773     """
774     Returns a list of filenames to be put in JDL input sandbox.
775     """
776     inp_box = []
777     # dict added to delete duplicate from input sandbox file list
778     seen = {}
779     ## code
780     if os.path.isfile(self.tgzNameWithPath):
781     inp_box.append(self.tgzNameWithPath)
782     ## config
783     inp_box.append(common.job_list[nj].configFilename())
784     ## additional input files
785 gutsche 1.3 #for file in self.additional_inbox_files:
786     # inp_box.append(common.work_space.cwdDir()+file)
787 slacapra 1.1 return inp_box
788    
789     def outputSandbox(self, nj):
790     """
791     Returns a list of filenames to be put in JDL output sandbox.
792     """
793     out_box = []
794    
795     stdout=common.job_list[nj].stdout()
796     stderr=common.job_list[nj].stderr()
797    
798     ## User Declared output files
799     for out in self.output_file:
800     n_out = nj + 1
801     out_box.append(self.numberFile_(out,str(n_out)))
802     return out_box
803     return []
804    
805     def prepareSteeringCards(self):
806     """
807     Make initial modifications of the user's steering card file.
808     """
809     return
810    
811     def wsRenameOutput(self, nj):
812     """
813     Returns part of a job script which renames the produced files.
814     """
815    
816     txt = '\n'
817 gutsche 1.7 txt += '# directory content\n'
818     txt += 'ls \n'
819 slacapra 1.1 file_list = ''
820     for fileWithSuffix in self.output_file:
821     output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
822 gutsche 1.7 file_list=file_list+output_file_num+' '
823 slacapra 1.1 txt += '\n'
824 gutsche 1.7 txt += '# check output file\n'
825 slacapra 1.1 txt += 'ls '+fileWithSuffix+'\n'
826 fanzago 1.18 txt += 'ls_result=$?\n'
827     #txt += 'exe_result=$?\n'
828     txt += 'if [ $ls_result -ne 0 ] ; then\n'
829     txt += ' echo "ERROR: Problem with output file"\n'
830     #txt += ' echo "JOB_EXIT_STATUS = $exe_result"\n'
831     #txt += ' echo "JobExitCode=60302" | tee -a $RUNTIME_AREA/$repo\n'
832     #txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
833 gutsche 1.3 ### OLI_DANIELE
834 gutsche 1.7 if common.scheduler.boss_scheduler_name == 'condor_g':
835     txt += ' if [ $middleware == OSG ]; then \n'
836     txt += ' echo "prepare dummy output file"\n'
837     txt += ' echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n'
838     txt += ' fi \n'
839 slacapra 1.1 txt += 'else\n'
840     txt += ' cp '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
841     txt += 'fi\n'
842    
843 gutsche 1.7 txt += 'cd $RUNTIME_AREA\n'
844 slacapra 1.1 file_list=file_list[:-1]
845 slacapra 1.2 txt += 'file_list="'+file_list+'"\n'
846 fanzago 1.18 txt += 'cd $RUNTIME_AREA\n'
847 gutsche 1.3 ### OLI_DANIELE
848     txt += 'if [ $middleware == OSG ]; then\n'
849     txt += ' cd $RUNTIME_AREA\n'
850     txt += ' echo "Remove working directory: $WORKING_DIR"\n'
851     txt += ' /bin/rm -rf $WORKING_DIR\n'
852     txt += ' if [ -d $WORKING_DIR ] ;then\n'
853 gutsche 1.7 txt += ' echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
854     txt += ' echo "JOB_EXIT_STATUS = 60999"\n'
855     txt += ' echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
856     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
857 gutsche 1.13 txt += ' rm -f $RUNTIME_AREA/$repo \n'
858     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
859     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
860 gutsche 1.3 txt += ' fi\n'
861     txt += 'fi\n'
862     txt += '\n'
863 slacapra 1.1 return txt
864    
865     def numberFile_(self, file, txt):
866     """
867     append _'txt' before last extension of a file
868     """
869     p = string.split(file,".")
870     # take away last extension
871     name = p[0]
872     for x in p[1:-1]:
873     name=name+"."+x
874     # add "_txt"
875     if len(p)>1:
876     ext = p[len(p)-1]
877     #result = name + '_' + str(txt) + "." + ext
878     result = name + '_' + txt + "." + ext
879     else:
880     #result = name + '_' + str(txt)
881     result = name + '_' + txt
882    
883     return result
884    
885     def getRequirements(self):
886     """
887     return job requirements to add to jdl files
888     """
889     req = ''
890 slacapra 1.10 if common.analisys_common_info['sw_version']:
891     req='Member("VO-cms-' + \
892     common.analisys_common_info['sw_version'] + \
893     '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
894 slacapra 1.1 if common.analisys_common_info['sites']:
895     if len(common.analisys_common_info['sites'])>0:
896     req = req + ' && ('
897     for i in range(len(common.analisys_common_info['sites'])):
898     req = req + 'other.GlueCEInfoHostName == "' \
899     + common.analisys_common_info['sites'][i] + '"'
900     if ( i < (int(len(common.analisys_common_info['sites']) - 1)) ):
901     req = req + ' || '
902     req = req + ')'
903     #print "req = ", req
904     return req
905 gutsche 1.3
906     def configFilename(self):
907     """ return the config filename """
908     return self.name()+'.cfg'
909    
910     ### OLI_DANIELE
911     def wsSetupCMSOSGEnvironment_(self):
912     """
913     Returns part of a job script which is prepares
914     the execution environment and which is common for all CMS jobs.
915     """
916     txt = '\n'
917     txt += ' echo "### SETUP CMS OSG ENVIRONMENT ###"\n'
918     txt += ' if [ -f $GRID3_APP_DIR/cmssoft/cmsset_default.sh ] ;then\n'
919     txt += ' # Use $GRID3_APP_DIR/cmssoft/cmsset_default.sh to setup cms software\n'
920     txt += ' source $GRID3_APP_DIR/cmssoft/cmsset_default.sh '+self.version+'\n'
921     txt += ' elif [ -f $OSG_APP/cmssoft/cmsset_default.sh ] ;then\n'
922     txt += ' # Use $OSG_APP/cmssoft/cmsset_default.sh to setup cms software\n'
923     txt += ' source $OSG_APP/cmssoft/cmsset_default.sh '+self.version+'\n'
924     txt += ' else\n'
925     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'
926     txt += ' echo "JOB_EXIT_STATUS = 10020"\n'
927     txt += ' echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
928     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
929 gutsche 1.13 txt += ' rm -f $RUNTIME_AREA/$repo \n'
930     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
931     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
932 gutsche 1.7 txt += ' exit 1\n'
933 gutsche 1.3 txt += '\n'
934     txt += ' echo "Remove working directory: $WORKING_DIR"\n'
935     txt += ' cd $RUNTIME_AREA\n'
936     txt += ' /bin/rm -rf $WORKING_DIR\n'
937     txt += ' if [ -d $WORKING_DIR ] ;then\n'
938 gutsche 1.7 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'
939     txt += ' echo "JOB_EXIT_STATUS = 10017"\n'
940     txt += ' echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n'
941     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
942 gutsche 1.13 txt += ' rm -f $RUNTIME_AREA/$repo \n'
943     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
944     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
945 gutsche 1.3 txt += ' fi\n'
946     txt += '\n'
947 gutsche 1.7 txt += ' exit 1\n'
948 gutsche 1.3 txt += ' fi\n'
949     txt += '\n'
950     txt += ' echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
951     txt += ' echo " END SETUP CMS OSG ENVIRONMENT "\n'
952    
953     return txt
954    
955     ### OLI_DANIELE
956     def wsSetupCMSLCGEnvironment_(self):
957     """
958     Returns part of a job script which is prepares
959     the execution environment and which is common for all CMS jobs.
960     """
961     txt = ' \n'
962     txt += ' echo " ### SETUP CMS LCG ENVIRONMENT ### "\n'
963     txt += ' if [ ! $VO_CMS_SW_DIR ] ;then\n'
964     txt += ' echo "SET_CMS_ENV 10031 ==> ERROR CMS software dir not found on WN `hostname`"\n'
965     txt += ' echo "JOB_EXIT_STATUS = 10031" \n'
966     txt += ' echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n'
967     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
968 gutsche 1.13 txt += ' rm -f $RUNTIME_AREA/$repo \n'
969     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
970     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
971 gutsche 1.7 txt += ' exit 1\n'
972 gutsche 1.3 txt += ' else\n'
973     txt += ' echo "Sourcing environment... "\n'
974     txt += ' if [ ! -s $VO_CMS_SW_DIR/cmsset_default.sh ] ;then\n'
975     txt += ' echo "SET_CMS_ENV 10020 ==> ERROR cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
976     txt += ' echo "JOB_EXIT_STATUS = 10020"\n'
977     txt += ' echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
978     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
979 gutsche 1.13 txt += ' rm -f $RUNTIME_AREA/$repo \n'
980     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
981     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
982 gutsche 1.7 txt += ' exit 1\n'
983 gutsche 1.3 txt += ' fi\n'
984     txt += ' echo "sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
985     txt += ' source $VO_CMS_SW_DIR/cmsset_default.sh\n'
986     txt += ' result=$?\n'
987     txt += ' if [ $result -ne 0 ]; then\n'
988     txt += ' echo "SET_CMS_ENV 10032 ==> ERROR problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
989     txt += ' echo "JOB_EXIT_STATUS = 10032"\n'
990     txt += ' echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n'
991     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
992 gutsche 1.13 txt += ' rm -f $RUNTIME_AREA/$repo \n'
993     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
994     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
995 gutsche 1.7 txt += ' exit 1\n'
996 gutsche 1.3 txt += ' fi\n'
997     txt += ' fi\n'
998     txt += ' \n'
999     txt += ' string=`cat /etc/redhat-release`\n'
1000     txt += ' echo $string\n'
1001     txt += ' if [[ $string = *alhalla* ]]; then\n'
1002     txt += ' echo "SCRAM_ARCH= $SCRAM_ARCH"\n'
1003     txt += ' elif [[ $string = *Enterprise* ]] || [[ $string = *cientific* ]]; then\n'
1004     txt += ' export SCRAM_ARCH=slc3_ia32_gcc323\n'
1005     txt += ' echo "SCRAM_ARCH= $SCRAM_ARCH"\n'
1006     txt += ' else\n'
1007 gutsche 1.7 txt += ' echo "SET_CMS_ENV 10033 ==> ERROR OS unknown, LCG environment not initialized"\n'
1008 gutsche 1.3 txt += ' echo "JOB_EXIT_STATUS = 10033"\n'
1009     txt += ' echo "JobExitCode=10033" | tee -a $RUNTIME_AREA/$repo\n'
1010     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
1011 gutsche 1.13 txt += ' rm -f $RUNTIME_AREA/$repo \n'
1012     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1013     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1014 gutsche 1.7 txt += ' exit 1\n'
1015 gutsche 1.3 txt += ' fi\n'
1016     txt += ' echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1017     txt += ' echo "### END SETUP CMS LCG ENVIRONMENT ###"\n'
1018     return txt
1019 gutsche 1.5
1020     def setParam_(self, param, value):
1021     self._params[param] = value
1022    
1023     def getParams(self):
1024     return self._params
1025 gutsche 1.8
1026     def setTaskid_(self):
1027     self._taskId = self.cfg_params['taskId']
1028    
1029     def getTaskid(self):
1030     return self._taskId