ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/cms_cmssw.py
Revision: 1.21
Committed: Tue Jul 4 09:17:15 2006 UTC (18 years, 9 months ago) by slacapra
Content type: text/x-python
Branch: MAIN
Changes since 1.20: +28 -26 lines
Log Message:
splitting per events

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 slacapra 1.21 self.selectNoInput = 1
48 slacapra 1.9 else:
49     self.datasetPath = tmp
50 slacapra 1.21 self.selectNoInput = 0
51 slacapra 1.1 except KeyError:
52 gutsche 1.3 msg = "Error: datasetpath not defined "
53 slacapra 1.1 raise CrabException(msg)
54 gutsche 1.5
55     # ML monitoring
56     # split dataset path style: /PreProdR3Minbias/SIM/GEN-SIM
57 slacapra 1.9 if not self.datasetPath:
58     self.setParam_('dataset', 'None')
59     self.setParam_('owner', 'None')
60     else:
61     datasetpath_split = self.datasetPath.split("/")
62     self.setParam_('dataset', datasetpath_split[1])
63     self.setParam_('owner', datasetpath_split[-1])
64    
65 gutsche 1.8 self.setTaskid_()
66     self.setParam_('taskId', self.cfg_params['taskId'])
67 gutsche 1.5
68 slacapra 1.1 self.dataTiers = []
69    
70     ## now the application
71     try:
72     self.executable = cfg_params['CMSSW.executable']
73 gutsche 1.5 self.setParam_('exe', self.executable)
74 slacapra 1.1 log.debug(6, "CMSSW::CMSSW(): executable = "+self.executable)
75     msg = "Default executable cmsRun overridden. Switch to " + self.executable
76     log.debug(3,msg)
77     except KeyError:
78     self.executable = 'cmsRun'
79 gutsche 1.5 self.setParam_('exe', self.executable)
80 slacapra 1.1 msg = "User executable not defined. Use cmsRun"
81     log.debug(3,msg)
82     pass
83    
84     try:
85     self.pset = cfg_params['CMSSW.pset']
86     log.debug(6, "Cmssw::Cmssw(): PSet file = "+self.pset)
87     if (not os.path.exists(self.pset)):
88     raise CrabException("User defined PSet file "+self.pset+" does not exist")
89     except KeyError:
90     raise CrabException("PSet file missing. Cannot run cmsRun ")
91    
92     # output files
93     try:
94     self.output_file = []
95    
96     tmp = cfg_params['CMSSW.output_file']
97     if tmp != '':
98     tmpOutFiles = string.split(cfg_params['CMSSW.output_file'],',')
99     log.debug(7, 'cmssw::cmssw(): output files '+str(tmpOutFiles))
100     for tmp in tmpOutFiles:
101     tmp=string.strip(tmp)
102     self.output_file.append(tmp)
103     pass
104     else:
105     log.message("No output file defined: only stdout/err will be available")
106     pass
107     pass
108     except KeyError:
109     log.message("No output file defined: only stdout/err will be available")
110     pass
111    
112     # script_exe file as additional file in inputSandbox
113     try:
114 slacapra 1.10 self.scriptExe = cfg_params['USER.script_exe']
115     self.additional_inbox_files.append(self.scriptExe)
116     if self.scriptExe != '':
117     if not os.path.isfile(self.scriptExe):
118     msg ="WARNING. file "+self.scriptExe+" not found"
119     raise CrabException(msg)
120 slacapra 1.1 except KeyError:
121     pass
122    
123     ## additional input files
124     try:
125     tmpAddFiles = string.split(cfg_params['CMSSW.additional_input_files'],',')
126     for tmp in tmpAddFiles:
127 gutsche 1.3 if not os.path.exists(tmp):
128     raise CrabException("Additional input file not found: "+tmp)
129 slacapra 1.1 tmp=string.strip(tmp)
130     self.additional_inbox_files.append(tmp)
131     pass
132     pass
133     except KeyError:
134     pass
135    
136 slacapra 1.9 # files per job
137 slacapra 1.1 try:
138 gutsche 1.3 self.filesPerJob = int(cfg_params['CMSSW.files_per_jobs']) #Daniele
139 slacapra 1.9 self.selectFilesPerJob = 1
140 gutsche 1.3 except KeyError:
141 slacapra 1.9 self.filesPerJob = 0
142     self.selectFilesPerJob = 0
143 gutsche 1.3
144 slacapra 1.9 ## Events per job
145 gutsche 1.3 try:
146 slacapra 1.10 self.eventsPerJob =int( cfg_params['CMSSW.events_per_job'])
147 slacapra 1.9 self.selectEventsPerJob = 1
148 gutsche 1.3 except KeyError:
149 slacapra 1.9 self.eventsPerJob = -1
150     self.selectEventsPerJob = 0
151    
152 slacapra 1.10 # To be implemented
153     # ## number of jobs
154     # try:
155     # self.numberOfJobs =int( cfg_params['CMSSW.number_of_job'])
156     # self.selectNumberOfJobs = 1
157     # except KeyError:
158     # self.selectNumberOfJobs = 0
159    
160 slacapra 1.9 if (self.selectFilesPerJob == self.selectEventsPerJob):
161 slacapra 1.10 msg = 'Must define either files_per_jobs or events_per_job'
162 slacapra 1.9 raise CrabException(msg)
163    
164 slacapra 1.21 # if (self.selectNoInput and not self.datasetPath == None):
165     # msg = 'Splitting according to events_per_job available only with None as datasetpath'
166     # raise CrabException(msg)
167 slacapra 1.10
168 gutsche 1.3 try:
169 slacapra 1.1 self.total_number_of_events = int(cfg_params['CMSSW.total_number_of_events'])
170     except KeyError:
171 gutsche 1.3 msg = 'Must define total_number_of_events'
172 slacapra 1.1 raise CrabException(msg)
173    
174     CEBlackList = []
175     try:
176     tmpBad = string.split(cfg_params['EDG.ce_black_list'],',')
177     for tmp in tmpBad:
178     tmp=string.strip(tmp)
179     CEBlackList.append(tmp)
180     except KeyError:
181     pass
182    
183     self.reCEBlackList=[]
184     for bad in CEBlackList:
185     self.reCEBlackList.append(re.compile( bad ))
186    
187     common.logger.debug(5,'CEBlackList: '+str(CEBlackList))
188    
189     CEWhiteList = []
190     try:
191     tmpGood = string.split(cfg_params['EDG.ce_white_list'],',')
192     for tmp in tmpGood:
193     tmp=string.strip(tmp)
194     CEWhiteList.append(tmp)
195     except KeyError:
196     pass
197    
198     #print 'CEWhiteList: ',CEWhiteList
199     self.reCEWhiteList=[]
200     for Good in CEWhiteList:
201     self.reCEWhiteList.append(re.compile( Good ))
202    
203     common.logger.debug(5,'CEWhiteList: '+str(CEWhiteList))
204    
205 gutsche 1.3 self.PsetEdit = PsetManipulator.PsetManipulator(self.pset) #Daniele Pset
206    
207 slacapra 1.1 #DBSDLS-start
208     ## Initialize the variables that are extracted from DBS/DLS and needed in other places of the code
209     self.maxEvents=0 # max events available ( --> check the requested nb. of evts in Creator.py)
210     self.DBSPaths={} # all dbs paths requested ( --> input to the site local discovery script)
211     ## Perform the data location and discovery (based on DBS/DLS)
212 slacapra 1.9 ## SL: Don't if NONE is specified as input (pythia use case)
213     common.analisys_common_info['sites']=None
214     if self.datasetPath:
215     self.DataDiscoveryAndLocation(cfg_params)
216 slacapra 1.1 #DBSDLS-end
217    
218     self.tgzNameWithPath = self.getTarBall(self.executable)
219    
220 slacapra 1.10 # modify Pset
221     if (self.datasetPath): # standard job
222     self.PsetEdit.maxEvent(self.eventsPerJob) #Daniele
223     self.PsetEdit.inputModule("INPUT") #Daniele
224    
225     else: # pythia like job
226     self.PsetEdit.maxEvent(self.eventsPerJob) #Daniele
227     self.PsetEdit.pythiaSeed("INPUT") #Daniele
228     try:
229     self.sourceSeed = int(cfg_params['CMSSW.pythia_seed'])
230     except KeyError:
231     self.sourceSeed = 123456
232     common.logger.message("No seed given, will use "+str(self.sourceSeed))
233    
234     self.PsetEdit.psetWriter(self.configFilename())
235    
236 slacapra 1.9 ## Select Splitting
237 slacapra 1.21 if self.selectFilesPerJob or self.selectEventsPerJob: self.jobSplittingPerFiles()
238     elif self.selectNoInput: self.jobSplittingNoInput()
239 slacapra 1.9 else:
240     msg = 'Don\'t know how to split...'
241     raise CrabException(msg)
242 gutsche 1.5
243 gutsche 1.3
244 slacapra 1.1 def DataDiscoveryAndLocation(self, cfg_params):
245    
246 gutsche 1.3 common.logger.debug(10,"CMSSW::DataDiscoveryAndLocation()")
247    
248     datasetPath=self.datasetPath
249    
250     ## TODO
251     dataTiersList = ""
252     dataTiers = dataTiersList.split(',')
253 slacapra 1.1
254     ## Contact the DBS
255     try:
256 afanfani 1.4 self.pubdata=DataDiscovery_EDM.DataDiscovery_EDM(datasetPath, dataTiers, cfg_params)
257 slacapra 1.1 self.pubdata.fetchDBSInfo()
258    
259 gutsche 1.3 except DataDiscovery_EDM.NotExistingDatasetError, ex :
260 slacapra 1.1 msg = 'ERROR ***: failed Data Discovery in DBS : %s'%ex.getErrorMessage()
261     raise CrabException(msg)
262    
263 gutsche 1.3 except DataDiscovery_EDM.NoDataTierinProvenanceError, ex :
264 slacapra 1.1 msg = 'ERROR ***: failed Data Discovery in DBS : %s'%ex.getErrorMessage()
265     raise CrabException(msg)
266 gutsche 1.3 except DataDiscovery_EDM.DataDiscoveryError, ex:
267 slacapra 1.1 msg = 'ERROR ***: failed Data Discovery in DBS %s'%ex.getErrorMessage()
268     raise CrabException(msg)
269    
270     ## get list of all required data in the form of dbs paths (dbs path = /dataset/datatier/owner)
271 gutsche 1.3 ## self.DBSPaths=self.pubdata.getDBSPaths()
272     common.logger.message("Required data are :"+self.datasetPath)
273    
274     filesbyblock=self.pubdata.getFiles()
275 slacapra 1.21 # print filesbyblock
276 gutsche 1.3 self.AllInputFiles=filesbyblock.values()
277     self.files = self.AllInputFiles
278    
279 slacapra 1.1 ## get max number of events
280 gutsche 1.3 #common.logger.debug(10,"number of events for primary fileblocks %i"%self.pubdata.getMaxEvents())
281 slacapra 1.1 self.maxEvents=self.pubdata.getMaxEvents() ## self.maxEvents used in Creator.py
282     common.logger.message("\nThe number of available events is %s"%self.maxEvents)
283    
284     ## Contact the DLS and build a list of sites hosting the fileblocks
285     try:
286 gutsche 1.6 dataloc=DataLocation_EDM.DataLocation_EDM(filesbyblock.keys(),cfg_params)
287     dataloc.fetchDLSInfo()
288 gutsche 1.3 except DataLocation_EDM.DataLocationError , ex:
289 slacapra 1.1 msg = 'ERROR ***: failed Data Location in DLS \n %s '%ex.getErrorMessage()
290     raise CrabException(msg)
291    
292     allsites=dataloc.getSites()
293     common.logger.debug(5,"sites are %s"%allsites)
294     sites=self.checkBlackList(allsites)
295     common.logger.debug(5,"sites are (after black list) %s"%sites)
296     sites=self.checkWhiteList(sites)
297     common.logger.debug(5,"sites are (after white list) %s"%sites)
298    
299     if len(sites)==0:
300     msg = 'No sites hosting all the needed data! Exiting... '
301     raise CrabException(msg)
302 gutsche 1.3
303 slacapra 1.1 common.logger.message("List of Sites hosting the data : "+str(sites))
304     common.logger.debug(6, "List of Sites: "+str(sites))
305     common.analisys_common_info['sites']=sites ## used in SchedulerEdg.py in createSchScript
306 gutsche 1.5 self.setParam_('TargetCE', ','.join(sites))
307 slacapra 1.1 return
308 gutsche 1.3
309 slacapra 1.9 def jobSplittingPerFiles(self):
310     """
311     Perform job splitting based on number of files to be accessed per job
312 gutsche 1.3 """
313 slacapra 1.9 common.logger.debug(5,'Splitting per input files')
314 gutsche 1.3 common.logger.message('Required '+str(self.filesPerJob)+' files per job ')
315     common.logger.message('Required '+str(self.total_number_of_events)+' events in total ')
316 slacapra 1.19 common.logger.message('Available '+str(self.maxEvents)+' events in total ')
317 gutsche 1.3
318     ## TODO: SL need to have (from DBS) a detailed list of how many events per each file
319     n_tot_files = (len(self.files[0]))
320 fanzago 1.12 #print "n_tot_files = ", n_tot_files
321 gutsche 1.3 ## SL: this is wrong if the files have different number of events
322 fanzago 1.12 #print "self.maxEvents = ", self.maxEvents
323 gutsche 1.3 evPerFile = int(self.maxEvents)/n_tot_files
324 fanzago 1.12 #print "evPerFile = int(self.maxEvents)/n_tot_files = ", evPerFile
325    
326 gutsche 1.3 common.logger.debug(5,'Events per File '+str(evPerFile))
327    
328 slacapra 1.21 if self.selectFilesPerJob:
329     filesPerJob = self.filesPerJob
330     elif self.selectEventsPerJob:
331     # SL case if asked events per job
332     ## estimate the number of files per job to match the user requirement
333     #print self.eventsPerJob,evPerFile,float(self.eventsPerJob/evPerFile),self.eventsPerJob/evPerFile+0.5,int(self.eventsPerJob/evPerFile+0.5)
334     filesPerJob = int(float(self.eventsPerJob)/float(evPerFile)+0.5)
335     if (filesPerJob==0): filesPerJob=1
336     eventsPerJob=filesPerJob*evPerFile
337    
338 gutsche 1.3 ## if asked to process all events, do it
339     if self.total_number_of_events == -1:
340     self.total_number_of_events=self.maxEvents
341 slacapra 1.21 self.total_number_of_jobs = int(n_tot_files)*1/int(filesPerJob)
342     check = int(n_tot_files) - (int(self.total_number_of_jobs)*filesPerJob)
343 slacapra 1.16 if check > 0:
344     self.total_number_of_jobs = self.total_number_of_jobs + 1
345     common.logger.message('Warning: last job will be created with '+str(check)+' files')
346 slacapra 1.21 common.logger.message(str(self.total_number_of_jobs)+' jobs will be created, each for '+str(filesPerJob*evPerFile)+'events, for all available events: '+str(self.total_number_of_events))
347 gutsche 1.3
348     else:
349 slacapra 1.19 if self.total_number_of_events>self.maxEvents:
350     common.logger.message("Asked "+str(self.total_number_of_events)+" but only "+str(self.maxEvents)+" available.")
351     self.total_number_of_events=self.maxEvents
352    
353 fanzago 1.12 #print "self.total_number_of_events = ", self.total_number_of_events
354     #print "evPerFile = ", evPerFile
355 gutsche 1.3 self.total_number_of_files = int(self.total_number_of_events/evPerFile)
356 fanzago 1.12 #print "self.total_number_of_files = int(self.total_number_of_events/evPerFile) = " , self.total_number_of_files
357 slacapra 1.15
358     ## SL: round the number of files to be processed to the ceiling
359     rem = self.total_number_of_events - self.total_number_of_files*evPerFile
360     if rem>0:
361     self.total_number_of_files = self.total_number_of_files + 1
362    
363 gutsche 1.3 ## SL: if ask for less event than what is computed to be available on a
364     ## file, process the first file anyhow.
365     if self.total_number_of_files == 0:
366     self.total_number_of_files = self.total_number_of_files + 1
367     common.logger.debug(5,'N files '+str(self.total_number_of_files))
368    
369     check = 0
370    
371     ## Compute the number of jobs
372     #self.total_number_of_jobs = int(n_tot_files)*1/int(self.filesPerJob)
373 fanzago 1.12 #print "self.total_number_of_files = ", self.total_number_of_files
374     #print "self.filesPerJob = ", self.filesPerJob
375 slacapra 1.21 self.total_number_of_jobs = int(self.total_number_of_files/filesPerJob)
376 fanzago 1.12 #print "self.total_number_of_jobs = ", self.total_number_of_jobs
377 gutsche 1.3 common.logger.debug(5,'N jobs '+str(self.total_number_of_jobs))
378    
379     ## is there any remainder?
380 slacapra 1.21 check = int(self.total_number_of_files) - (int(self.total_number_of_jobs)*filesPerJob)
381 gutsche 1.3
382     common.logger.debug(5,'Check '+str(check))
383    
384 slacapra 1.21 common.logger.message(str(self.total_number_of_jobs)+' jobs will be created, each for '+str(filesPerJob*evPerFile)+' events, for a total of '+str((self.total_number_of_jobs-check)*filesPerJob*evPerFile + check*evPerFile)+' events')
385 gutsche 1.3 if check > 0:
386     self.total_number_of_jobs = self.total_number_of_jobs + 1
387     common.logger.message('Warning: last job will be created with '+str(check)+' files')
388    
389     pass
390    
391     list_of_lists = []
392 slacapra 1.21 for i in xrange(0, int(n_tot_files), filesPerJob):
393 slacapra 1.9 parString = "\\{"
394    
395 slacapra 1.21 params = self.files[0][i: i+filesPerJob]
396 slacapra 1.9 for i in range(len(params) - 1):
397     parString += '\\\"' + params[i] + '\\\"\,'
398    
399     parString += '\\\"' + params[len(params) - 1] + '\\\"\\}'
400 slacapra 1.17 #print parString
401     list_of_lists.append([parString])
402     #print list_of_lists
403 slacapra 1.9 pass
404    
405 slacapra 1.20
406    
407 slacapra 1.9 self.list_of_args = list_of_lists
408 slacapra 1.20 # print self.list_of_args[0]
409 slacapra 1.9 return
410    
411 slacapra 1.21 def jobSplittingNoInput(self):
412 slacapra 1.9 """
413     Perform job splitting based on number of event per job
414     """
415     common.logger.debug(5,'Splitting per events')
416     common.logger.message('Required '+str(self.eventsPerJob)+' events per job ')
417     common.logger.message('Required '+str(self.total_number_of_events)+' events in total ')
418    
419 slacapra 1.10 if (self.total_number_of_events < 0):
420     msg='Cannot split jobs per Events with "-1" as total number of events'
421     raise CrabException(msg)
422    
423 slacapra 1.9 self.total_number_of_jobs = int(self.total_number_of_events/self.eventsPerJob)
424 fanzago 1.12
425 slacapra 1.9 common.logger.debug(5,'N jobs '+str(self.total_number_of_jobs))
426    
427     # is there any remainder?
428     check = int(self.total_number_of_events) - (int(self.total_number_of_jobs)*self.eventsPerJob)
429    
430     common.logger.debug(5,'Check '+str(check))
431    
432 slacapra 1.21 common.logger.message(str(self.total_number_of_jobs)+' jobs will be created, each for '+str(self.eventsPerJob)+' for a total of '+str(self.total_number_of_jobs*self.eventsPerJob)+' events')
433 slacapra 1.9 if check > 0:
434     common.logger.message('Warning: asked '+self.total_number_of_events+' but will do only '+(int(self.total_number_of_jobs)*self.eventsPerJob))
435    
436    
437 slacapra 1.10 # argument is seed number.$i
438 slacapra 1.9 self.list_of_args = []
439     for i in range(self.total_number_of_jobs):
440 slacapra 1.20 self.list_of_args.append([(str(self.sourceSeed)+str(i))])
441 slacapra 1.17 #print self.list_of_args
442 gutsche 1.3
443     return
444    
445     def split(self, jobParams):
446    
447     common.jobDB.load()
448     #### Fabio
449     njobs = self.total_number_of_jobs
450 slacapra 1.9 arglist = self.list_of_args
451 gutsche 1.3 # create the empty structure
452     for i in range(njobs):
453     jobParams.append("")
454    
455     for job in range(njobs):
456 slacapra 1.17 jobParams[job] = arglist[job]
457     # print str(arglist[job])
458     # print jobParams[job]
459 gutsche 1.3 common.jobDB.setArguments(job, jobParams[job])
460    
461     common.jobDB.save()
462     return
463    
464     def getJobTypeArguments(self, nj, sched):
465 slacapra 1.17 result = ''
466     for i in common.jobDB.arguments(nj):
467     result=result+str(i)+" "
468     return result
469 gutsche 1.3
470     def numberOfJobs(self):
471     # Fabio
472     return self.total_number_of_jobs
473    
474 slacapra 1.1 def checkBlackList(self, allSites):
475     if len(self.reCEBlackList)==0: return allSites
476     sites = []
477     for site in allSites:
478     common.logger.debug(10,'Site '+site)
479     good=1
480     for re in self.reCEBlackList:
481     if re.search(site):
482     common.logger.message('CE in black list, skipping site '+site)
483     good=0
484     pass
485     if good: sites.append(site)
486     if len(sites) == 0:
487     common.logger.debug(3,"No sites found after BlackList")
488     return sites
489    
490 gutsche 1.3 def checkWhiteList(self, allSites):
491 slacapra 1.1
492 gutsche 1.3 if len(self.reCEWhiteList)==0: return allSites
493 slacapra 1.1 sites = []
494 gutsche 1.3 for site in allSites:
495 slacapra 1.1 good=0
496     for re in self.reCEWhiteList:
497     if re.search(site):
498     common.logger.debug(5,'CE in white list, adding site '+site)
499     good=1
500     if not good: continue
501     sites.append(site)
502     if len(sites) == 0:
503     common.logger.message("No sites found after WhiteList\n")
504     else:
505     common.logger.debug(5,"Selected sites via WhiteList are "+str(sites)+"\n")
506     return sites
507    
508     def getTarBall(self, exe):
509     """
510     Return the TarBall with lib and exe
511     """
512    
513     # if it exist, just return it
514     self.tgzNameWithPath = common.work_space.shareDir()+self.tgz_name
515     if os.path.exists(self.tgzNameWithPath):
516     return self.tgzNameWithPath
517    
518     # Prepare a tar gzipped file with user binaries.
519     self.buildTar_(exe)
520    
521     return string.strip(self.tgzNameWithPath)
522    
523     def buildTar_(self, executable):
524    
525     # First of all declare the user Scram area
526     swArea = self.scram.getSWArea_()
527     #print "swArea = ", swArea
528     swVersion = self.scram.getSWVersion()
529     #print "swVersion = ", swVersion
530     swReleaseTop = self.scram.getReleaseTop_()
531     #print "swReleaseTop = ", swReleaseTop
532    
533     ## check if working area is release top
534     if swReleaseTop == '' or swArea == swReleaseTop:
535     return
536    
537     filesToBeTarred = []
538     ## First find the executable
539     if (self.executable != ''):
540     exeWithPath = self.scram.findFile_(executable)
541     # print exeWithPath
542     if ( not exeWithPath ):
543     raise CrabException('User executable '+executable+' not found')
544    
545     ## then check if it's private or not
546     if exeWithPath.find(swReleaseTop) == -1:
547     # the exe is private, so we must ship
548     common.logger.debug(5,"Exe "+exeWithPath+" to be tarred")
549     path = swArea+'/'
550     exe = string.replace(exeWithPath, path,'')
551     filesToBeTarred.append(exe)
552     pass
553     else:
554     # the exe is from release, we'll find it on WN
555     pass
556    
557     ## Now get the libraries: only those in local working area
558     libDir = 'lib'
559     lib = swArea+'/' +libDir
560     common.logger.debug(5,"lib "+lib+" to be tarred")
561     if os.path.exists(lib):
562     filesToBeTarred.append(libDir)
563    
564 gutsche 1.3 ## Now check if module dir is present
565     moduleDir = 'module'
566     if os.path.isdir(swArea+'/'+moduleDir):
567     filesToBeTarred.append(moduleDir)
568    
569 slacapra 1.1 ## Now check if the Data dir is present
570     dataDir = 'src/Data/'
571     if os.path.isdir(swArea+'/'+dataDir):
572     filesToBeTarred.append(dataDir)
573    
574     ## Create the tar-ball
575     if len(filesToBeTarred)>0:
576     cwd = os.getcwd()
577     os.chdir(swArea)
578     tarcmd = 'tar zcvf ' + self.tgzNameWithPath + ' '
579     for line in filesToBeTarred:
580     tarcmd = tarcmd + line + ' '
581     cout = runCommand(tarcmd)
582     if not cout:
583     raise CrabException('Could not create tar-ball')
584     os.chdir(cwd)
585     else:
586     common.logger.debug(5,"No files to be to be tarred")
587    
588     return
589    
590     def wsSetupEnvironment(self, nj):
591     """
592     Returns part of a job script which prepares
593     the execution environment for the job 'nj'.
594     """
595     # Prepare JobType-independent part
596 gutsche 1.3 txt = ''
597    
598     ## OLI_Daniele at this level middleware already known
599    
600     txt += 'if [ $middleware == LCG ]; then \n'
601     txt += self.wsSetupCMSLCGEnvironment_()
602     txt += 'elif [ $middleware == OSG ]; then\n'
603     txt += ' time=`date -u +"%s"`\n'
604     txt += ' WORKING_DIR=$OSG_WN_TMP/cms_$time\n'
605     txt += ' echo "Creating working directory: $WORKING_DIR"\n'
606     txt += ' /bin/mkdir -p $WORKING_DIR\n'
607     txt += ' if [ ! -d $WORKING_DIR ] ;then\n'
608 gutsche 1.7 txt += ' echo "SET_CMS_ENV 10016 ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n'
609     txt += ' echo "JOB_EXIT_STATUS = 10016"\n'
610     txt += ' echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
611     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
612 gutsche 1.13 txt += ' rm -f $RUNTIME_AREA/$repo \n'
613     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
614     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
615 gutsche 1.3 txt += ' exit 1\n'
616     txt += ' fi\n'
617     txt += '\n'
618     txt += ' echo "Change to working directory: $WORKING_DIR"\n'
619     txt += ' cd $WORKING_DIR\n'
620     txt += self.wsSetupCMSOSGEnvironment_()
621     txt += 'fi\n'
622 slacapra 1.1
623     # Prepare JobType-specific part
624     scram = self.scram.commandName()
625     txt += '\n\n'
626     txt += 'echo "### SPECIFIC JOB SETUP ENVIRONMENT ###"\n'
627     txt += scram+' project CMSSW '+self.version+'\n'
628     txt += 'status=$?\n'
629     txt += 'if [ $status != 0 ] ; then\n'
630 gutsche 1.7 txt += ' echo "SET_EXE_ENV 10034 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n'
631 gutsche 1.3 txt += ' echo "JOB_EXIT_STATUS = 10034"\n'
632 gutsche 1.7 txt += ' echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n'
633 slacapra 1.1 txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
634 gutsche 1.13 txt += ' rm -f $RUNTIME_AREA/$repo \n'
635     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
636     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
637 gutsche 1.3 ## OLI_Daniele
638     txt += ' if [ $middleware == OSG ]; then \n'
639     txt += ' echo "Remove working directory: $WORKING_DIR"\n'
640     txt += ' cd $RUNTIME_AREA\n'
641     txt += ' /bin/rm -rf $WORKING_DIR\n'
642     txt += ' if [ -d $WORKING_DIR ] ;then\n'
643 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'
644     txt += ' echo "JOB_EXIT_STATUS = 10018"\n'
645     txt += ' echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n'
646     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
647 gutsche 1.13 txt += ' rm -f $RUNTIME_AREA/$repo \n'
648     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
649     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
650 gutsche 1.3 txt += ' fi\n'
651     txt += ' fi \n'
652     txt += ' exit 1 \n'
653 slacapra 1.1 txt += 'fi \n'
654     txt += 'echo "CMSSW_VERSION = '+self.version+'"\n'
655     txt += 'cd '+self.version+'\n'
656     ### needed grep for bug in scramv1 ###
657     txt += 'eval `'+scram+' runtime -sh | grep -v SCRAMRT_LSB_JOBNAME`\n'
658    
659     # Handle the arguments:
660     txt += "\n"
661 gutsche 1.7 txt += "## number of arguments (first argument always jobnumber)\n"
662 slacapra 1.1 txt += "\n"
663     txt += "narg=$#\n"
664 gutsche 1.3 txt += "if [ $narg -lt 2 ]\n"
665 slacapra 1.1 txt += "then\n"
666     txt += " echo 'SET_EXE_ENV 1 ==> ERROR Too few arguments' +$narg+ \n"
667 gutsche 1.3 txt += ' echo "JOB_EXIT_STATUS = 50113"\n'
668 gutsche 1.7 txt += ' echo "JobExitCode=50113" | tee -a $RUNTIME_AREA/$repo\n'
669 slacapra 1.1 txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
670 gutsche 1.13 txt += ' rm -f $RUNTIME_AREA/$repo \n'
671     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
672     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
673 gutsche 1.3 ## OLI_Daniele
674     txt += ' if [ $middleware == OSG ]; then \n'
675     txt += ' echo "Remove working directory: $WORKING_DIR"\n'
676     txt += ' cd $RUNTIME_AREA\n'
677     txt += ' /bin/rm -rf $WORKING_DIR\n'
678     txt += ' if [ -d $WORKING_DIR ] ;then\n'
679 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'
680     txt += ' echo "JOB_EXIT_STATUS = 50114"\n'
681     txt += ' echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n'
682     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
683 gutsche 1.13 txt += ' rm -f $RUNTIME_AREA/$repo \n'
684     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
685     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
686 gutsche 1.3 txt += ' fi\n'
687     txt += ' fi \n'
688 slacapra 1.1 txt += " exit 1\n"
689     txt += "fi\n"
690     txt += "\n"
691    
692     # Prepare job-specific part
693     job = common.job_list[nj]
694     pset = os.path.basename(job.configFilename())
695     txt += '\n'
696 slacapra 1.10 if (self.datasetPath): # standard job
697     txt += 'InputFiles=$2\n'
698     txt += 'echo "Inputfiles:<$InputFiles>"\n'
699     txt += 'sed "s#{\'INPUT\'}#$InputFiles#" $RUNTIME_AREA/'+pset+' > pset.cfg\n'
700     else: # pythia like job
701     txt += 'Seed=$2\n'
702     txt += 'echo "Seed: <$Seed>"\n'
703     txt += 'sed "s#INPUT#$Seed#" $RUNTIME_AREA/'+pset+' > pset.cfg\n'
704 slacapra 1.1
705     if len(self.additional_inbox_files) > 0:
706     for file in self.additional_inbox_files:
707     txt += 'if [ -e $RUNTIME_AREA/'+file+' ] ; then\n'
708     txt += ' cp $RUNTIME_AREA/'+file+' .\n'
709     txt += ' chmod +x '+file+'\n'
710     txt += 'fi\n'
711     pass
712    
713     txt += 'echo "### END JOB SETUP ENVIRONMENT ###"\n\n'
714    
715     txt += '\n'
716     txt += 'echo "***** cat pset.cfg *********"\n'
717     txt += 'cat pset.cfg\n'
718     txt += 'echo "****** end pset.cfg ********"\n'
719 gutsche 1.3 txt += '\n'
720     # txt += 'echo "***** cat pset1.cfg *********"\n'
721     # txt += 'cat pset1.cfg\n'
722     # txt += 'echo "****** end pset1.cfg ********"\n'
723     return txt
724    
725     def wsBuildExe(self, nj):
726     """
727     Put in the script the commands to build an executable
728     or a library.
729     """
730    
731     txt = ""
732    
733     if os.path.isfile(self.tgzNameWithPath):
734     txt += 'echo "tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'"\n'
735     txt += 'tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n'
736     txt += 'untar_status=$? \n'
737     txt += 'if [ $untar_status -ne 0 ]; then \n'
738     txt += ' echo "SET_EXE 1 ==> ERROR Untarring .tgz file failed"\n'
739     txt += ' echo "JOB_EXIT_STATUS = $untar_status" \n'
740 gutsche 1.7 txt += ' echo "JobExitCode=$untar_status" | tee -a $RUNTIME_AREA/$repo\n'
741 gutsche 1.3 txt += ' if [ $middleware == OSG ]; then \n'
742     txt += ' echo "Remove working directory: $WORKING_DIR"\n'
743     txt += ' cd $RUNTIME_AREA\n'
744     txt += ' /bin/rm -rf $WORKING_DIR\n'
745     txt += ' if [ -d $WORKING_DIR ] ;then\n'
746 gutsche 1.13 txt += ' echo "SET_EXE 50999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Untarring .tgz file failed"\n'
747     txt += ' echo "JOB_EXIT_STATUS = 50999"\n'
748     txt += ' echo "JobExitCode=50999" | tee -a $RUNTIME_AREA/$repo\n'
749     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
750     txt += ' rm -f $RUNTIME_AREA/$repo \n'
751     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
752     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
753 gutsche 1.3 txt += ' fi\n'
754     txt += ' fi \n'
755     txt += ' \n'
756 gutsche 1.7 txt += ' exit 1 \n'
757 gutsche 1.3 txt += 'else \n'
758     txt += ' echo "Successful untar" \n'
759     txt += 'fi \n'
760     pass
761    
762 slacapra 1.1 return txt
763    
764     def modifySteeringCards(self, nj):
765     """
766     modify the card provided by the user,
767     writing a new card into share dir
768     """
769    
770     def executableName(self):
771     return self.executable
772    
773     def executableArgs(self):
774 gutsche 1.3 return " -p pset.cfg"
775 slacapra 1.1
776     def inputSandbox(self, nj):
777     """
778     Returns a list of filenames to be put in JDL input sandbox.
779     """
780     inp_box = []
781     # dict added to delete duplicate from input sandbox file list
782     seen = {}
783     ## code
784     if os.path.isfile(self.tgzNameWithPath):
785     inp_box.append(self.tgzNameWithPath)
786     ## config
787     inp_box.append(common.job_list[nj].configFilename())
788     ## additional input files
789 gutsche 1.3 #for file in self.additional_inbox_files:
790     # inp_box.append(common.work_space.cwdDir()+file)
791 slacapra 1.1 return inp_box
792    
793     def outputSandbox(self, nj):
794     """
795     Returns a list of filenames to be put in JDL output sandbox.
796     """
797     out_box = []
798    
799     stdout=common.job_list[nj].stdout()
800     stderr=common.job_list[nj].stderr()
801    
802     ## User Declared output files
803     for out in self.output_file:
804     n_out = nj + 1
805     out_box.append(self.numberFile_(out,str(n_out)))
806     return out_box
807     return []
808    
809     def prepareSteeringCards(self):
810     """
811     Make initial modifications of the user's steering card file.
812     """
813     return
814    
815     def wsRenameOutput(self, nj):
816     """
817     Returns part of a job script which renames the produced files.
818     """
819    
820     txt = '\n'
821 gutsche 1.7 txt += '# directory content\n'
822     txt += 'ls \n'
823 slacapra 1.1 file_list = ''
824     for fileWithSuffix in self.output_file:
825     output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
826 gutsche 1.7 file_list=file_list+output_file_num+' '
827 slacapra 1.1 txt += '\n'
828 gutsche 1.7 txt += '# check output file\n'
829 slacapra 1.1 txt += 'ls '+fileWithSuffix+'\n'
830 fanzago 1.18 txt += 'ls_result=$?\n'
831     #txt += 'exe_result=$?\n'
832     txt += 'if [ $ls_result -ne 0 ] ; then\n'
833     txt += ' echo "ERROR: Problem with output file"\n'
834     #txt += ' echo "JOB_EXIT_STATUS = $exe_result"\n'
835     #txt += ' echo "JobExitCode=60302" | tee -a $RUNTIME_AREA/$repo\n'
836     #txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
837 gutsche 1.3 ### OLI_DANIELE
838 gutsche 1.7 if common.scheduler.boss_scheduler_name == 'condor_g':
839     txt += ' if [ $middleware == OSG ]; then \n'
840     txt += ' echo "prepare dummy output file"\n'
841     txt += ' echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n'
842     txt += ' fi \n'
843 slacapra 1.1 txt += 'else\n'
844     txt += ' cp '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
845     txt += 'fi\n'
846    
847 gutsche 1.7 txt += 'cd $RUNTIME_AREA\n'
848 slacapra 1.1 file_list=file_list[:-1]
849 slacapra 1.2 txt += 'file_list="'+file_list+'"\n'
850 fanzago 1.18 txt += 'cd $RUNTIME_AREA\n'
851 gutsche 1.3 ### 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 gutsche 1.7 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 gutsche 1.13 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 gutsche 1.3 txt += ' fi\n'
865     txt += 'fi\n'
866     txt += '\n'
867 slacapra 1.1 return txt
868    
869     def numberFile_(self, file, txt):
870     """
871     append _'txt' before last extension of a file
872     """
873     p = string.split(file,".")
874     # take away last extension
875     name = p[0]
876     for x in p[1:-1]:
877     name=name+"."+x
878     # add "_txt"
879     if len(p)>1:
880     ext = p[len(p)-1]
881     #result = name + '_' + str(txt) + "." + ext
882     result = name + '_' + txt + "." + ext
883     else:
884     #result = name + '_' + str(txt)
885     result = name + '_' + txt
886    
887     return result
888    
889     def getRequirements(self):
890     """
891     return job requirements to add to jdl files
892     """
893     req = ''
894 slacapra 1.10 if common.analisys_common_info['sw_version']:
895     req='Member("VO-cms-' + \
896     common.analisys_common_info['sw_version'] + \
897     '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
898 slacapra 1.1 if common.analisys_common_info['sites']:
899     if len(common.analisys_common_info['sites'])>0:
900     req = req + ' && ('
901     for i in range(len(common.analisys_common_info['sites'])):
902     req = req + 'other.GlueCEInfoHostName == "' \
903     + common.analisys_common_info['sites'][i] + '"'
904     if ( i < (int(len(common.analisys_common_info['sites']) - 1)) ):
905     req = req + ' || '
906     req = req + ')'
907     #print "req = ", req
908     return req
909 gutsche 1.3
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 gutsche 1.13 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 gutsche 1.7 txt += ' exit 1\n'
937 gutsche 1.3 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 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'
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 gutsche 1.13 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 gutsche 1.3 txt += ' fi\n'
950     txt += '\n'
951 gutsche 1.7 txt += ' exit 1\n'
952 gutsche 1.3 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 gutsche 1.13 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 gutsche 1.7 txt += ' exit 1\n'
976 gutsche 1.3 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 gutsche 1.13 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 gutsche 1.7 txt += ' exit 1\n'
987 gutsche 1.3 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 gutsche 1.13 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 gutsche 1.7 txt += ' exit 1\n'
1000 gutsche 1.3 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 gutsche 1.7 txt += ' echo "SET_CMS_ENV 10033 ==> ERROR OS unknown, LCG environment not initialized"\n'
1012 gutsche 1.3 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 gutsche 1.13 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 gutsche 1.7 txt += ' exit 1\n'
1019 gutsche 1.3 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 gutsche 1.5
1024     def setParam_(self, param, value):
1025     self._params[param] = value
1026    
1027     def getParams(self):
1028     return self._params
1029 gutsche 1.8
1030     def setTaskid_(self):
1031     self._taskId = self.cfg_params['taskId']
1032    
1033     def getTaskid(self):
1034     return self._taskId