ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/cms_orca_pubdb.py
Revision: 1.9
Committed: Thu Aug 3 22:44:40 2006 UTC (18 years, 8 months ago) by gutsche
Content type: text/x-python
Branch: MAIN
Changes since 1.8: +21 -17 lines
Log Message:
Commit for Malina: Handled block-splitting for CMSSW and CE->SE in .jdl files

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     import PubDB
7     import orcarcBuilder
8     import orcarcBuilderOld
9     import Scram
10     import TarBall
11    
12     import os, string, re
13     import math
14    
15     class Orca_pubdb(JobType):
16     def __init__(self, cfg_params):
17 slacapra 1.2 JobType.__init__(self, 'ORCA_PUBDB')
18 slacapra 1.1 common.logger.debug(3,'ORCA_pubdb::__init__')
19    
20     self.analisys_common_info = {}
21     # Marco.
22     self._params = {}
23     self.cfg_params = cfg_params
24    
25     log = common.logger
26    
27     self.scram = Scram.Scram(cfg_params)
28     scramArea = ''
29     self.additional_inbox_files = []
30     self.scriptExe = ''
31    
32     self.version = self.scram.getSWVersion()
33     self.setParam_('application', self.version)
34     common.analisys_common_info['sw_version'] = self.version
35     common.analisys_common_info['copy_input_data'] = 0
36    
37     self.total_number_of_jobs = 0
38     self.job_number_of_events = 0
39    
40     ### collect Data cards
41     try:
42     self.owner = cfg_params['ORCA.owner']
43     self.setParam_('owner', self.owner)
44     log.debug(6, "Orca::Orca(): owner = "+self.owner)
45     self.dataset = cfg_params['ORCA.dataset']
46     self.setParam_('dataset', self.dataset)
47     log.debug(6, "Orca::Orca(): dataset = "+self.dataset)
48     except KeyError:
49     msg = "Error: owner and/or dataset not defined "
50     raise CrabException(msg)
51    
52     self.dataTiers = []
53     try:
54     tmpDataTiers = string.split(cfg_params['ORCA.data_tier'],',')
55     for tmp in tmpDataTiers:
56     tmp=string.strip(tmp)
57     self.dataTiers.append(tmp)
58     pass
59     pass
60     except KeyError:
61     pass
62     log.debug(6, "Orca_pubdb::Orca_pubdb(): dataTiers = "+str(self.dataTiers))
63    
64     ## now the application
65     try:
66     self.executable = cfg_params['ORCA.executable']
67     log.debug(6, "Orca_pubdb::Orca_pubdb(): executable = "+self.executable)
68     self.setParam_('exe', self.executable)
69     except KeyError:
70     msg = "Error: executable not defined "
71     raise CrabException(msg)
72    
73     try:
74     self.orcarc_file = cfg_params['ORCA.orcarc_file']
75     log.debug(6, "Orca_pubdb::Orca_pubdb(): orcarc file = "+self.orcarc_file)
76     if (not os.path.exists(self.orcarc_file)):
77     raise CrabException("User defined .orcarc file "+self.orcarc_file+" does not exist")
78     except KeyError:
79     log.message("Using empty orcarc file")
80     self.orcarc_file = ''
81    
82     # output files
83     try:
84     self.output_file = []
85    
86     tmp = cfg_params['ORCA.output_file']
87     if tmp != '':
88     tmpOutFiles = string.split(cfg_params['ORCA.output_file'],',')
89     log.debug(7, 'Orca_pubdb::Orca_pubdb(): output files '+str(tmpOutFiles))
90     for tmp in tmpOutFiles:
91     tmp=string.strip(tmp)
92     self.output_file.append(tmp)
93     pass
94    
95     else:
96     log.message("No output file defined: only stdout/err will be available")
97     pass
98     pass
99     except KeyError:
100     log.message("No output file defined: only stdout/err will be available")
101     pass
102    
103     # script_exe file as additional file in inputSandbox
104     try:
105     self.scriptExe = cfg_params['ORCA.script_exe']
106     self.additional_inbox_files.append(self.scriptExe)
107     except KeyError:
108     pass
109     if self.scriptExe != '':
110     if os.path.isfile(self.scriptExe):
111     pass
112     else:
113     log.message("WARNING. file "+self.scriptExe+" not found")
114     sys.exit()
115    
116     ## additional input files
117     try:
118     tmpAddFiles = string.split(cfg_params['USER.additional_input_files'],',')
119     for tmp in tmpAddFiles:
120     tmp=string.strip(tmp)
121     self.additional_inbox_files.append(tmp)
122     pass
123     pass
124     except KeyError:
125     pass
126    
127     try:
128 slacapra 1.3 self.total_number_of_events = int(cfg_params['ORCA.total_number_of_events'])
129 slacapra 1.1 except KeyError:
130     msg = 'Must define total_number_of_events and job_number_of_events'
131     raise CrabException(msg)
132    
133     try:
134 slacapra 1.3 self.first_event = int(cfg_params['ORCA.first_event'])
135 slacapra 1.1 except KeyError:
136     self.first_event = 0
137     pass
138     log.debug(6, "Orca_pubdb::Orca_pubdb(): total number of events = "+`self.total_number_of_events`)
139     #log.debug(6, "Orca_pubdb::Orca_pubdb(): events per job = "+`self.job_number_of_events`)
140     log.debug(6, "Orca_pubdb::Orca_pubdb(): first event = "+`self.first_event`)
141    
142     self.maxEvents=0 # max events available in any PubDB
143     self.connectPubDB(cfg_params)
144    
145     # [-- self.checkNevJobs() --]
146    
147     self.TarBaller = TarBall.TarBall(self.executable, self.scram)
148     self.tgzNameWithPath = self.TarBaller.prepareTarBall()
149    
150     try:
151     self.ML = int(cfg_params['USER.activate_monalisa'])
152     except KeyError:
153     self.ML = 0
154     pass
155    
156     self.setTaskid_()
157     self.setParam_('taskId', self.cfg_params['taskId'])
158    
159     return
160    
161     def split(self, jobParams):
162     """
163     This method returns the list of specific job type items
164     needed to run the jobs
165     """
166     common.jobDB.load()
167     njobs = self.total_number_of_jobs
168     # create the empty structure
169     for i in range(njobs):
170     jobParams.append("")
171    
172     # fill the both the list and the DB (part of the code taken from jobsToDB)
173     firstEvent = self.first_event
174     lastJobsNumberOfEvents = self.job_number_of_events
175     # last jobs is different...
176     for job in range(njobs-1):
177 slacapra 1.7 jobParams[job] = [str(firstEvent), str(lastJobsNumberOfEvents)]
178 slacapra 1.1 common.jobDB.setArguments(job, jobParams[job])
179 gutsche 1.9 common.jobDB.setDestination(job, self.sites
180 slacapra 1.1 firstEvent += self.job_number_of_events
181    
182     # this is the last job
183     lastJobsNumberOfEvents = (self.total_number_of_events + self.first_event) - firstEvent
184     status = common.jobDB.status(njobs - 1)
185 slacapra 1.7 jobParams[njobs - 1] = [str(firstEvent), str(lastJobsNumberOfEvents)]
186 slacapra 1.1 common.jobDB.setArguments(njobs - 1, jobParams[njobs - 1])
187    
188     if (lastJobsNumberOfEvents!=self.job_number_of_events):
189     common.logger.message(str(self.total_number_of_jobs-1)+' jobs will be created for '+str(self.job_number_of_events)+' events each plus 1 for '+str(lastJobsNumberOfEvents)+' events for a total of '+str(self.job_number_of_events*(self.total_number_of_jobs-1)+lastJobsNumberOfEvents)+' events')
190     else:
191     common.logger.message(str(self.total_number_of_jobs)+' jobs will be created for '+str(self.job_number_of_events)+' events each for a total of '+str(self.job_number_of_events*(self.total_number_of_jobs-1)+lastJobsNumberOfEvents)+' events')
192    
193     common.jobDB.save()
194     return
195    
196     def getJobTypeArguments(self, nj, sched):
197     params = common.jobDB.arguments(nj)
198    
199     if sched=="EDG" or sched=="GRID":
200     parString = "" + str(params[0])+' '+str(params[1])
201     elif sched=="BOSS":
202     parString = "" + str(params[0])+' '+str(params[1])
203     elif sched=="CONDOR":
204 gutsche 1.9 parString = "" + str(params[0])+' '+str(params[1])+' '+common.jobDB.destination(nj
205 slacapra 1.1 else:
206     return ""
207     return parString
208    
209     def numberOfJobs(self):
210     first_event = self.first_event
211     maxAvailableEvents = int(self.maxEvents)
212     common.logger.debug(1,"Available events: "+str(maxAvailableEvents))
213    
214     if first_event>=maxAvailableEvents:
215     raise CrabException('First event is bigger than maximum number of available events!')
216    
217     try:
218     n = self.total_number_of_events
219     if n == 'all': n = '-1'
220     if n == '-1':
221     tot_num_events = (maxAvailableEvents - first_event)
222     common.logger.debug(1,"Analysing all available events "+str(tot_num_events))
223     else:
224     if maxAvailableEvents<(int(n)+ first_event): # + self.first_event):
225     raise CrabException('(First event + total events)='+str(int(n)+first_event)+' is bigger than maximum number of available events '+str(maxAvailableEvents)+' !! Use "total_number_of_events=-1" to analyze to whole dataset')
226     tot_num_events = int(n)
227     except KeyError:
228     common.logger.message("total_number_of_events not defined, set it to maximum available")
229     tot_num_events = (maxAvailableEvents - first_event)
230     pass
231     common.logger.message("Total number of events to be analyzed: "+str(self.total_number_of_events))
232    
233    
234     # read user directives
235     eventPerJob=0
236     try:
237 slacapra 1.3 eventPerJob = self.cfg_params['ORCA.job_number_of_events']
238 slacapra 1.1 except KeyError:
239     pass
240    
241     jobsPerTask=0
242     try:
243 slacapra 1.3 jobsPerTask = int(self.cfg_params['ORCA.total_number_of_jobs'])
244 slacapra 1.1 except KeyError:
245     pass
246    
247     # If both the above set, complain and use event per jobs
248     if eventPerJob>0 and jobsPerTask>0:
249     msg = 'Warning. '
250     msg += 'job_number_of_events and total_number_of_jobs are both defined '
251     msg += 'Using job_number_of_events.'
252     common.logger.message(msg)
253     jobsPerTask = 0
254     if eventPerJob==0 and jobsPerTask==0:
255     msg = 'Warning. '
256     msg += 'job_number_of_events and total_number_of_jobs are not defined '
257     msg += 'Creating just one job for all events.'
258     common.logger.message(msg)
259     jobsPerTask = 1
260    
261     # first case: events per job defined
262     if eventPerJob>0:
263     n=eventPerJob
264     #if n == 'all' or n == '-1' or (int(n)>self.total_number_of_events and self.total_number_of_events>0):
265     if n == 'all' or n == '-1' or (int(n)>tot_num_events and tot_num_events>0):
266     common.logger.message("Asking more events than available: set it to maximum available")
267     job_num_events = tot_num_events
268     tot_num_jobs = 1
269     else:
270     job_num_events = int(n)
271     tot_num_jobs = int((tot_num_events-1)/job_num_events)+1
272    
273     elif jobsPerTask>0:
274     common.logger.debug(2,"total number of events: "+str(tot_num_events)+" JobPerTask "+str(jobsPerTask))
275     job_num_events = int(math.floor((tot_num_events)/jobsPerTask))
276     tot_num_jobs = jobsPerTask
277    
278     # should not happen...
279     else:
280     raise CrabException('Something wrong with splitting')
281    
282     common.logger.debug(2,"total number of events: "+str(tot_num_events)+" events per job: "+str(job_num_events))
283    
284     #used by jobsToDB for logs
285     self.job_number_of_events = job_num_events
286     self.total_number_of_jobs = tot_num_jobs
287     return tot_num_jobs
288    
289    
290     def jobsToDB(self, nJobs):
291     """
292     Fill the DB with proper entries for ORCA-DBS-DLS
293     """
294    
295     firstEvent = self.first_event
296     lastJobsNumberOfEvents = self.job_number_of_events
297    
298     # last jobs is different...
299     for job in range(nJobs-1):
300     common.jobDB.setFirstEvent(job, firstEvent)
301     common.jobDB.setMaxEvents(job, self.job_number_of_events)
302     firstEvent=firstEvent+self.job_number_of_events
303    
304     # this is the last job
305     common.jobDB.setFirstEvent(nJobs-1, firstEvent)
306     lastJobsNumberOfEvents= (self.total_number_of_events+self.first_event)-firstEvent
307     common.jobDB.setMaxEvents(nJobs-1, lastJobsNumberOfEvents)
308    
309     if (lastJobsNumberOfEvents!=self.job_number_of_events):
310     common.logger.message(str(self.total_number_of_jobs-1)+' jobs will be created for '+str(self.job_number_of_events)+' events each plus 1 for '+str(lastJobsNumberOfEvents)+' events for a total of '+str(self.job_number_of_events*(self.total_number_of_jobs-1)+lastJobsNumberOfEvents)+' events')
311     else:
312     common.logger.message(str(self.total_number_of_jobs)+' jobs will be created for '+str(self.job_number_of_events)+' events each for a total of '+str(self.job_number_of_events*(self.total_number_of_jobs-1)+lastJobsNumberOfEvents)+' events')
313    
314     return
315    
316    
317     def wsSetupEnvironment(self, nj):
318     """
319     Returns part of a job script which prepares
320     the execution environment for the job 'nj'.
321     """
322    
323     # Prepare JobType-independent part
324     txt = ''
325    
326     ## OLI_Daniele at this level middleware already known
327    
328     txt += 'if [ $middleware == LCG ]; then \n'
329     txt += self.wsSetupCMSLCGEnvironment_()
330     txt += 'elif [ $middleware == OSG ]; then\n'
331     txt += ' time=`date -u +"%s"`\n'
332     txt += ' WORKING_DIR=$OSG_WN_TMP/cms_$time\n'
333     txt += ' echo "Creating working directory: $WORKING_DIR"\n'
334     txt += ' /bin/mkdir -p $WORKING_DIR\n'
335     txt += ' if [ ! -d $WORKING_DIR ] ;then\n'
336     txt += ' echo "SET_CMS_ENV 10016 ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n'
337     txt += ' echo "JOB_EXIT_STATUS = 10016"\n'
338     txt += ' echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
339     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
340 gutsche 1.4 txt += ' rm -f $RUNTIME_AREA/$repo \n'
341     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
342     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
343 slacapra 1.1 txt += ' exit 1\n'
344     txt += ' fi\n'
345     txt += '\n'
346     txt += ' echo "Change to working directory: $WORKING_DIR"\n'
347     txt += ' cd $WORKING_DIR\n'
348     txt += self.wsSetupCMSOSGEnvironment_()
349     txt += 'fi\n'
350    
351     # Prepare JobType-specific part
352     scram = self.scram.commandName()
353     txt += '\n\n'
354     txt += 'echo "### SPECIFIC JOB SETUP ENVIRONMENT ###"\n'
355     txt += scram+' project ORCA '+self.version+'\n'
356     txt += 'status=$?\n'
357     txt += 'if [ $status != 0 ] ; then\n'
358     txt += ' echo "SET_EXE_ENV 10034 ==>ERROR ORCA '+self.version+' not found on `hostname`" \n'
359     txt += ' echo "JOB_EXIT_STATUS = 10034"\n'
360     txt += ' echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n'
361     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
362 gutsche 1.4 txt += ' rm -f $RUNTIME_AREA/$repo \n'
363     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
364     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
365 slacapra 1.1
366     ## OLI_Daniele
367     txt += ' if [ $middleware == OSG ]; then \n'
368     txt += ' \n'
369     txt += ' echo "Remove working directory: $WORKING_DIR"\n'
370     txt += ' cd $RUNTIME_AREA\n'
371     txt += ' /bin/rm -rf $WORKING_DIR\n'
372     txt += ' if [ -d $WORKING_DIR ] ;then\n'
373 gutsche 1.4 txt += ' echo "SET_CMS_ENV 10018 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after ORCA not found on `hostname`"\n'
374 slacapra 1.1 txt += ' echo "JOB_EXIT_STATUS = 10018"\n'
375     txt += ' echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n'
376     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
377 gutsche 1.4 txt += ' rm -f $RUNTIME_AREA/$repo \n'
378     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
379     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
380 slacapra 1.1 txt += ' fi\n'
381     txt += ' fi \n'
382     txt += ' \n'
383     txt += ' exit 1\n'
384     txt += 'fi \n'
385     txt += 'echo "ORCA_VERSION = '+self.version+'"\n'
386     txt += 'cd '+self.version+'\n'
387     ### needed grep for bug in scramv1 ###
388    
389     #txt += 'eval `'+scram+' runtime -sh | grep -v SCRAMRT_LSB_JOBNAME`\n'
390    
391     # Handle the arguments:
392     txt += "\n"
393 mkirn 1.8 # txt += "## ARGUMNETS: $1 Job Number\n"
394     # txt += "## ARGUMNETS: $2 First Event for this job\n"
395     # txt += "## ARGUMNETS: $3 Max Event for this job\n"
396     txt += "## ARGUMENTS: ${args[0]} Job Number\n"
397     txt += "## ARGUMENTS: ${args[1]} First Event for this job\n"
398     txt += "## ARGUMENTS: ${args[2]} Max Event for this job\n"
399 slacapra 1.1 txt += "\n"
400 mkirn 1.8 # txt += "narg=$#\n"
401     # txt += "NJob=$1\n"
402     # txt += "FirstEvent=$2\n"
403     # txt += "MaxEvents=$3\n"
404     txt += "NJob=${args[0]}\n"
405     txt += "FirstEvent=${args[1]}\n"
406     txt += "MaxEvents=${args[2]}\n"
407     txt += "if [ $nargs -lt 3 ]\n"
408 slacapra 1.1 txt += "then\n"
409 mkirn 1.8 txt += " echo 'SET_EXE_ENV 50113 ==> ERROR Too few arguments' +$nargs+ \n"
410 slacapra 1.1 txt += ' echo "JOB_EXIT_STATUS = 50113"\n'
411     txt += ' echo "JobExitCode=50113" | tee -a $RUNTIME_AREA/$repo\n'
412     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
413 gutsche 1.4 txt += ' rm -f $RUNTIME_AREA/$repo \n'
414     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
415     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
416 slacapra 1.1
417     ## OLI_Daniele
418     txt += ' if [ $middleware == OSG ]; then \n'
419     txt += ' echo "Remove working directory: $WORKING_DIR"\n'
420     txt += ' cd $RUNTIME_AREA\n'
421     txt += ' /bin/rm -rf $WORKING_DIR\n'
422     txt += ' if [ -d $WORKING_DIR ] ;then\n'
423     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'
424     txt += ' echo "JOB_EXIT_STATUS = 50114"\n'
425     txt += ' echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n'
426     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
427 gutsche 1.4 txt += ' rm -f $RUNTIME_AREA/$repo \n'
428     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
429     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
430 slacapra 1.1 txt += ' fi\n'
431     txt += ' fi \n'
432     txt += ' \n'
433     txt += " exit 1\n"
434     txt += "fi\n"
435     txt += "\n"
436    
437     # Prepare job-specific part
438     job = common.job_list[nj]
439     orcarc = os.path.basename(job.configFilename())
440     txt += '\n'
441     txt += 'cp $RUNTIME_AREA/'+orcarc+' .orcarc\n'
442     txt += 'if [ -e $RUNTIME_AREA/orcarc_$CE ] ; then\n'
443     txt += ' cat $RUNTIME_AREA/orcarc_$CE .orcarc >> .orcarc_tmp\n'
444     txt += ' mv .orcarc_tmp .orcarc\n'
445     txt += 'fi\n'
446     txt += 'if [ -e $RUNTIME_AREA/init_$CE.sh ] ; then\n'
447     txt += ' cp $RUNTIME_AREA/init_$CE.sh init.sh\n'
448     txt += 'fi\n'
449    
450     if len(self.additional_inbox_files) > 0:
451     for file in self.additional_inbox_files:
452     file = os.path.basename(file)
453     txt += 'if [ -e $RUNTIME_AREA/'+file+' ] ; then\n'
454     txt += ' cp $RUNTIME_AREA/'+file+' .\n'
455     txt += ' chmod +x '+file+'\n'
456     txt += 'fi\n'
457     pass
458    
459     txt += '\n'
460     txt += 'chmod +x ./init.sh\n'
461     txt += './init.sh\n'
462     txt += 'exitStatus=$?\n'
463     txt += 'if [ $exitStatus != 0 ] ; then\n'
464     txt += ' echo "SET_EXE_ENV 20001 ==> ERROR StageIn init script failed"\n'
465     txt += ' echo "JOB_EXIT_STATUS = $exitStatus" \n'
466     txt += ' echo "JobExitCode=20001" | tee -a $RUNTIME_AREA/$repo\n'
467     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
468 gutsche 1.4 txt += ' rm -f $RUNTIME_AREA/$repo \n'
469     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
470     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
471 slacapra 1.1
472     ### OLI_DANIELE
473     txt += ' if [ $middleware == OSG ]; then \n'
474     txt += ' echo "Remove working directory: $WORKING_DIR"\n'
475     txt += ' cd $RUNTIME_AREA\n'
476     txt += ' /bin/rm -rf $WORKING_DIR\n'
477     txt += ' if [ -d $WORKING_DIR ] ;then\n'
478     txt += ' echo "SET_EXE 10012 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after StageIn init script failed"\n'
479     txt += ' echo "JOB_EXIT_STATUS = 10012"\n'
480     txt += ' echo "JobExitCode=10012" | tee -a $RUNTIME_AREA/$repo\n'
481     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
482 gutsche 1.4 txt += ' rm -f $RUNTIME_AREA/$repo \n'
483     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
484     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
485 slacapra 1.1 txt += ' fi\n'
486     txt += ' fi \n'
487     txt += ' exit 1\n'
488     txt += 'fi\n'
489     txt += "echo 'SET_EXE_ENV 0 ==> job setup ok'\n"
490     txt += 'echo "### END JOB SETUP ENVIRONMENT ###"\n\n'
491    
492     txt += 'echo "FirstEvent=$FirstEvent" >> .orcarc\n'
493     txt += 'echo "MaxEvents=$MaxEvents" >> .orcarc\n'
494     if self.ML:
495     txt += 'echo "MonalisaJobId=$NJob" >> .orcarc\n'
496    
497     txt += '\n'
498     txt += 'echo "***** cat .orcarc *********"\n'
499     txt += 'cat .orcarc\n'
500     txt += 'echo "****** end .orcarc ********"\n'
501     return txt
502    
503     def wsBuildExe(self, nj):
504     """
505     Put in the script the commands to build an executable
506     or a library.
507     """
508    
509     txt = ""
510    
511     if os.path.isfile(self.tgzNameWithPath):
512     txt += 'echo "tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'"\n'
513     txt += 'tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n'
514     txt += 'untar_status=$? \n'
515     txt += 'if [ $untar_status -ne 0 ]; then \n'
516     txt += ' echo "SET_EXE 1 ==> ERROR Untarring .tgz file failed"\n'
517     txt += ' echo "JOB_EXIT_STATUS = $untar_status" \n'
518     txt += ' echo "JobExitCode=$untar_status" | tee -a $repo\n'
519    
520     ### OLI_DANIELE
521     txt += ' if [ $middleware == OSG ]; then \n'
522     txt += ' echo "Remove working directory: $WORKING_DIR"\n'
523     txt += ' cd $RUNTIME_AREA\n'
524     txt += ' /bin/rm -rf $WORKING_DIR\n'
525     txt += ' if [ -d $WORKING_DIR ] ;then\n'
526     txt += ' echo "SET_EXE 50999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Untarring .tgz file failed"\n'
527     txt += ' echo "JOB_EXIT_STATUS = 50999"\n'
528     txt += ' echo "JobExitCode=50999" | tee -a $RUNTIME_AREA/$repo\n'
529     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
530 gutsche 1.4 txt += ' rm -f $RUNTIME_AREA/$repo \n'
531     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
532     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
533 slacapra 1.1 txt += ' fi\n'
534     txt += ' fi \n'
535     txt += ' \n'
536     txt += ' exit 1 \n'
537     txt += 'else \n'
538     txt += ' echo "Successful untar" \n'
539     txt += 'fi \n'
540     # TODO: what does this code do here ?
541     # SL check that lib/Linux__... is present
542     txt += 'mkdir -p lib/${SCRAM_ARCH} \n'
543     pass
544     txt += 'eval `'+self.scram.commandName()+' runtime -sh |grep -v SCRAMRT_LSB_JOBNAME`'+'\n'
545    
546     return txt
547    
548     def wsRenameOutput(self, nj):
549     """
550     Returns part of a job script which renames the produced files.
551     """
552    
553     txt = '\n'
554     txt += '# directory content\n'
555     txt += 'ls \n'
556     file_list = ''
557     for fileWithSuffix in self.output_file:
558     output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
559     file_list=file_list+output_file_num+' '
560     txt += '\n'
561     txt += 'ls '+fileWithSuffix+'\n'
562 fanzago 1.6 #txt += 'exe_result=$?\n'
563     txt += 'ls_result=$?\n'
564     #txt += 'if [ $exe_result -ne 0 ] ; then\n'
565     txt += 'if [ $ls_result -ne 0 ] ; then\n'
566     txt += ' echo "ERROR: Problem with output file"\n'
567     #txt += ' echo "ERROR: No output file to manage"\n'
568     #txt += ' echo "JOB_EXIT_STATUS = $exe_result"\n'
569     #txt += ' echo "JobExitCode=60302" | tee -a $RUNTIME_AREA/$repo\n'
570     #txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
571     # txt += 'exe_result=$?\n'
572     # txt += 'if [ $exe_result -ne 0 ] ; then\n'
573     # txt += ' echo "ERROR: No output file to manage"\n'
574     # txt += ' echo "JOB_EXIT_STATUS = $exe_result"\n'
575     # txt += ' echo "JobExitCode=60302" | tee -a $RUNTIME_AREA/$repo\n'
576     # txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
577     # txt += ' rm -f $RUNTIME_AREA/$repo \n'
578     # txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
579     # txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
580 gutsche 1.4
581 slacapra 1.1 ### OLI_DANIELE
582     if common.scheduler.boss_scheduler_name == 'condor_g':
583     txt += ' if [ $middleware == OSG ]; then \n'
584     txt += ' echo "prepare dummy output file"\n'
585     txt += ' echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n'
586     txt += ' fi \n'
587     txt += 'else\n'
588     txt += ' cp '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
589     txt += 'fi\n'
590    
591     pass
592    
593    
594     txt += 'cd $RUNTIME_AREA\n'
595     file_list=file_list[:-1]
596     txt += 'file_list="'+file_list+'"\n'
597     ### OLI_DANIELE
598     txt += 'if [ $middleware == OSG ]; then\n'
599     txt += ' cd $RUNTIME_AREA\n'
600     txt += ' echo "Remove working directory: $WORKING_DIR"\n'
601     txt += ' /bin/rm -rf $WORKING_DIR\n'
602     txt += ' if [ -d $WORKING_DIR ] ;then\n'
603     txt += ' echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
604     txt += ' echo "JOB_EXIT_STATUS = 60999"\n'
605     txt += ' echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
606     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
607 gutsche 1.4 txt += ' rm -f $RUNTIME_AREA/$repo \n'
608     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
609     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
610 slacapra 1.1 txt += ' fi\n'
611     txt += 'fi\n'
612     txt += '\n'
613    
614     return txt
615    
616     def executableName(self):
617     if self.scriptExe != '':
618     return "./" + os.path.basename(self.scriptExe)
619     else:
620     return self.executable
621    
622     def connectPubDB(self, cfg_params):
623    
624     fun = "Orca_pubdb::connectPubDB()"
625    
626     self.allOrcarcs = []
627     # first check if the info from PubDB have been already processed
628     if os.path.exists(common.work_space.shareDir()+'PubDBSummaryFile') :
629     common.logger.debug(6, fun+": info from PubDB has been already processed -- use it")
630     f = open( common.work_space.shareDir()+'PubDBSummaryFile', 'r' )
631     for i in f.readlines():
632     a=string.split(i,' ')
633     self.allOrcarcs.append(orcarcBuilderOld.constructFromFile(a[0:-1]))
634     pass
635     for o in self.allOrcarcs:
636     # o.dump()
637     if o.Nevents >= self.maxEvents:
638     self.maxEvents= o.Nevents
639     pass
640     pass
641     pass
642    
643     else: # PubDB never queried
644     common.logger.debug(6, fun+": PubDB was never queried -- do it")
645     # New PubDB class by SL
646     try:
647     self.pubdb = PubDB.PubDB(self.owner,
648     self.dataset,
649     self.dataTiers,
650     cfg_params)
651     except PubDB.RefDBmapError:
652     msg = 'ERROR ***: accessing PubDB'
653     raise CrabException(msg)
654    
655     ## extract info from pubDB (grouped by PubDB version :
656     ## pubDBData contains a list of info for the new-style PubDBs,
657     ## and a list of info for the old-style PubDBs )
658     self.pubDBData = self.pubdb.getAllPubDBData()
659    
660     ## check and exit if no data are published in any PubDB
661     nodata=1
662     for PubDBversion in self.pubDBData.keys():
663     if len(self.pubDBData[PubDBversion])>0:
664     nodata=0
665     if (nodata):
666     msg = 'Owner '+self.owner+' Dataset '+ self.dataset+ ' not published in any PubDB with asked dataTiers '+string.join(self.dataTiers,'-')+' ! '
667     raise CrabException(msg)
668    
669     ## logging PubDB content for debugging
670     for PubDBversion in self.pubDBData.keys():
671     common.logger.debug(6, fun+": PubDB "+PubDBversion+" info ("+`len(self.pubDBData[PubDBversion])`+"):\/")
672     for aa in self.pubDBData[PubDBversion]:
673     common.logger.debug(6, "---------- start of a PubDB")
674     for bb in aa:
675     if common.logger.debugLevel() >= 6 :
676     common.logger.debug(6, str(bb.dump()))
677     pass
678     pass
679     common.logger.debug(6, "----------- end of a PubDB")
680     common.logger.debug(6, fun+": End of PubDB "+PubDBversion+" info\n")
681    
682    
683     ## building orcarc : switch between info from old and new-style PubDB
684     currDir = os.getcwd()
685     os.chdir(common.work_space.jobDir())
686    
687     tmpOrcarcList=[]
688     for PubDBversion in self.pubDBData.keys():
689     if len(self.pubDBData[PubDBversion])>0 :
690     #print (" PubDB-style : %s"%(PubDBversion))
691     if PubDBversion=='newPubDB' :
692     self.builder = orcarcBuilder.orcarcBuilder(cfg_params)
693     else :
694     self.builder = orcarcBuilderOld.orcarcBuilderOld()
695     tmpAllOrcarcs = self.builder.createOrcarcAndInit(self.pubDBData[PubDBversion])
696     tmpOrcarcList.append(tmpAllOrcarcs)
697     #print 'version ',PubDBversion,' tmpAllOrcarcs ', tmpAllOrcarcs
698    
699     #print tmpOrcarcList
700     os.chdir(currDir)
701    
702     self.maxEvents=0
703     for tmpAllOrcarcs in tmpOrcarcList:
704     for o in tmpAllOrcarcs:
705     numEvReq=self.total_number_of_events
706     if ((numEvReq == '-1') | (numEvReq <= o.Nevents)):
707     self.allOrcarcs.append(o)
708     if (int(o.Nevents) >= self.maxEvents):
709     self.maxEvents= int(o.Nevents)
710     pass
711     pass
712     pass
713    
714     # set maximum number of event available
715    
716     # I save to a file self.allOrcarcs
717    
718     PubDBSummaryFile = open(common.work_space.shareDir()+'PubDBSummaryFile','w')
719     for o in self.allOrcarcs:
720     for d in o.content():
721     PubDBSummaryFile.write(d)
722     PubDBSummaryFile.write(' ')
723     pass
724     PubDBSummaryFile.write('\n')
725     pass
726     PubDBSummaryFile.close()
727     ### fede
728     #for o in self.allOrcarcs:
729     # o.dump()
730     pass
731    
732     # build a list of sites
733     ces= []
734     for o in self.allOrcarcs:
735     ces.append(o.CE)
736     pass
737    
738     if len(ces)==0:
739     msg = 'No PubDBs publish correct catalogs or enough events! '
740     msg += `self.total_number_of_events`
741     raise CrabException(msg)
742    
743     common.logger.debug(6, "List of CEs: "+str(ces))
744 gutsche 1.9 self.sites = ces
745 slacapra 1.1 self.setParam_('TargetCE', ','.join(ces))
746    
747     return
748    
749     def nJobs(self):
750     # TODO: should not be here !
751     # JobType should have no internal knowledge about submitted jobs
752     # One possibility is to use len(common.job_list).
753     """ return the number of job to be created """
754     return len(common.job_list)
755    
756     def prepareSteeringCards(self):
757     """
758     modify the orcarc card provided by the user,
759     writing a new card into share dir
760     """
761     infile = ''
762     try:
763     infile = open(self.orcarc_file,'r')
764     except:
765     self.orcarc_file = 'empty.orcarc'
766     cmd='touch '+self.orcarc_file
767     runCommand(cmd)
768     infile = open(self.orcarc_file,'r')
769    
770     outfile = open(common.work_space.jobDir()+self.name()+'.orcarc', 'w')
771    
772     inline=infile.readlines()
773     ### remove from user card these lines ###
774     wordRemove=['InputFileCatalogURL', 'InputCollections', 'FirstEvent', 'MaxEvents', 'TFileAdaptor', 'MonRecAlisaBuilder']
775     for line in inline:
776     word = string.strip(string.split(line,'=')[0])
777    
778     if word not in wordRemove:
779     outfile.write(line)
780     else:
781     continue
782     pass
783    
784     outfile.write('\n\n##### The following cards have been created by CRAB: DO NOT TOUCH #####\n')
785     outfile.write('TFileAdaptor = true\n')
786    
787     outfile.write('MonRecAlisaBuilder=false\n')
788    
789     outfile.write('InputCollections=/System/'+self.owner+'/'+self.dataset+'/'+self.dataset+'\n')
790    
791     infile.close()
792     outfile.close()
793     return
794    
795     def modifySteeringCards(self, nj):
796     """
797     Creates steering cards file modifying a template file
798     """
799     return
800    
801     def cardsBaseName(self):
802     """
803     Returns name of user orcarc card-file
804     """
805     return os.path.split (self.orcarc_file)[1]
806    
807     ### content of input_sanbdox ...
808     def inputSandbox(self, nj):
809     """
810     Returns a list of filenames to be put in JDL input sandbox.
811     """
812     inp_box = []
813     # dict added to delete duplicate from input sandbox file list
814     seen = {}
815     ## code
816     if os.path.isfile(self.tgzNameWithPath):
817     inp_box.append(self.tgzNameWithPath)
818     ## orcarc
819     for o in self.allOrcarcs:
820     for f in o.fileList():
821     if (f not in seen.keys()):
822     inp_box.append(common.work_space.jobDir()+f)
823     seen[f] = 1
824    
825     ## config
826     inp_box.append(common.job_list[nj].configFilename())
827     ## additional input files
828     #inp_box = inp_box + self.additional_inbox_files
829     return inp_box
830    
831     ### and of output_sandbox
832     def outputSandbox(self, nj):
833     """
834     Returns a list of filenames to be put in JDL output sandbox.
835     """
836     out_box = []
837    
838     stdout=common.job_list[nj].stdout()
839     stderr=common.job_list[nj].stderr()
840     #out_box.append(stdout)
841     #out_box.append(stderr)
842    
843     ## User Declared output files
844     for out in self.output_file:
845     n_out = nj + 1
846     #FEDE
847     #out_box.append(self.version+'/'+self.numberFile_(out,str(n_out)))
848     out_box.append(self.numberFile_(out,str(n_out)))
849     return out_box
850    
851 gutsche 1.9 def getRequirements(self, nj):
852 slacapra 1.1 """
853     return job requirements to add to jdl files
854     """
855     req = ''
856 gutsche 1.9
857     if common.analisys_common_info['sw_version']:
858     req='Member("VO-cms-' + \
859     common.analisys_common_info['sw_version'] + \
860     '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
861    
862     sites = common.jobDB.destination(nj)
863    
864     if len(sites)>0:
865     req = req + ' && ('
866     for site in sites:
867     req = req + 'other.GlueCEInfoHostName == "' + site + '" || '
868     pass
869     # remove last ||
870     req = req[0:-4]
871     req = req + ')'
872    
873 slacapra 1.1 return req
874    
875     def numberFile_(self, file, txt):
876     """
877     append _'txt' before last extension of a file
878     """
879     p = string.split(file,".")
880     # take away last extension
881     name = p[0]
882     for x in p[1:-1]:
883     name=name+"."+x
884     # add "_txt"
885     if len(p)>1:
886     ext = p[len(p)-1]
887     #result = name + '_' + str(txt) + "." + ext
888     result = name + '_' + txt + "." + ext
889     else:
890     #result = name + '_' + str(txt)
891     result = name + '_' + txt
892    
893     return result
894    
895    
896     def stdOut(self):
897     return self.stdOut_
898    
899     def stdErr(self):
900     return self.stdErr_
901    
902     # marco
903     def setParam_(self, param, value):
904     self._params[param] = value
905    
906     def getParams(self):
907     return self._params
908    
909     def setTaskid_(self):
910     self._taskId = self.cfg_params['taskId']
911    
912     def getTaskid(self):
913     return self._taskId
914     # marco
915    
916     def configFilename(self):
917     """ return the config filename """
918     return self.name()+'.orcarc'
919    
920     ### OLI_DANIELE
921     def wsSetupCMSOSGEnvironment_(self):
922     """
923     Returns part of a job script which is prepares
924     the execution environment and which is common for all CMS jobs.
925     """
926     txt = '\n'
927     txt += ' echo "### SETUP CMS OSG ENVIRONMENT ###"\n'
928     txt += ' if [ -f $GRID3_APP_DIR/cmssoft/cmsset_default.sh ] ;then\n'
929     txt += ' # Use $GRID3_APP_DIR/cmssoft/cmsset_default.sh to setup cms software\n'
930     txt += ' source $GRID3_APP_DIR/cmssoft/cmsset_default.sh '+self.version+'\n'
931     txt += ' elif [ -f $OSG_APP/cmssoft/cmsset_default.sh ] ;then\n'
932     txt += ' # Use $OSG_APP/cmssoft/cmsset_default.sh to setup cms software\n'
933     txt += ' source $OSG_APP/cmssoft/cmsset_default.sh '+self.version+'\n'
934     txt += ' else\n'
935 fanzago 1.6 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'
936     txt += ' echo "JOB_EXIT_STATUS = 10020"\n'
937     txt += ' echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
938     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
939     txt += ' rm -f $RUNTIME_AREA/$repo \n'
940     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
941     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
942     txt += ' exit 1\n'
943 slacapra 1.1 txt += '\n'
944     txt += ' echo "Remove working directory: $WORKING_DIR"\n'
945     txt += ' cd $RUNTIME_AREA\n'
946     txt += ' /bin/rm -rf $WORKING_DIR\n'
947     txt += ' if [ -d $WORKING_DIR ] ;then\n'
948     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'
949     txt += ' echo "JOB_EXIT_STATUS = 10017"\n'
950     txt += ' echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n'
951     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
952 gutsche 1.4 txt += ' rm -f $RUNTIME_AREA/$repo \n'
953     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
954     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
955 slacapra 1.1 txt += ' fi\n'
956     txt += '\n'
957     txt += ' exit 1\n'
958     txt += ' fi\n'
959     txt += '\n'
960     txt += ' echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
961     txt += ' echo " END SETUP CMS OSG ENVIRONMENT "\n'
962    
963     return txt
964    
965     ### OLI_DANIELE
966     def wsSetupCMSLCGEnvironment_(self):
967     """
968     Returns part of a job script which is prepares
969     the execution environment and which is common for all CMS jobs.
970     """
971     txt = ' \n'
972     txt += ' echo " ### SETUP CMS LCG ENVIRONMENT ### "\n'
973     txt += ' echo "JOB_EXIT_STATUS = 0"\n'
974     txt += ' if [ ! $VO_CMS_SW_DIR ] ;then\n'
975     txt += ' echo "SET_CMS_ENV 10031 ==> ERROR CMS software dir not found on WN `hostname`"\n'
976     txt += ' echo "JOB_EXIT_STATUS = 10031" \n'
977     txt += ' echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n'
978     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
979 gutsche 1.4 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 slacapra 1.1 txt += ' exit 1\n'
983     txt += ' else\n'
984     txt += ' echo "Sourcing environment... "\n'
985     txt += ' if [ ! -s $VO_CMS_SW_DIR/cmsset_default.sh ] ;then\n'
986     txt += ' echo "SET_CMS_ENV 10020 ==> ERROR cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
987     txt += ' echo "JOB_EXIT_STATUS = 10020"\n'
988     txt += ' echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
989     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
990 gutsche 1.4 txt += ' rm -f $RUNTIME_AREA/$repo \n'
991     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
992     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
993 slacapra 1.1 txt += ' exit 1\n'
994     txt += ' fi\n'
995     txt += ' echo "sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
996     txt += ' source $VO_CMS_SW_DIR/cmsset_default.sh\n'
997     txt += ' result=$?\n'
998     txt += ' if [ $result -ne 0 ]; then\n'
999     txt += ' echo "SET_CMS_ENV 10032 ==> ERROR problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1000     txt += ' echo "JOB_EXIT_STATUS = 10032"\n'
1001     txt += ' echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n'
1002     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
1003 gutsche 1.4 txt += ' rm -f $RUNTIME_AREA/$repo \n'
1004     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1005     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1006 slacapra 1.1 txt += ' exit 1\n'
1007     txt += ' fi\n'
1008     txt += ' fi\n'
1009     txt += ' \n'
1010     txt += ' string=`cat /etc/redhat-release`\n'
1011     txt += ' echo $string\n'
1012     txt += ' if [[ $string = *alhalla* ]]; then\n'
1013     txt += ' echo "SCRAM_ARCH= $SCRAM_ARCH"\n'
1014     txt += ' elif [[ $string = *Enterprise* ]] || [[ $string = *cientific* ]]; then\n'
1015     txt += ' export SCRAM_ARCH=slc3_ia32_gcc323\n'
1016     txt += ' echo "SCRAM_ARCH= $SCRAM_ARCH"\n'
1017     txt += ' else\n'
1018     txt += ' echo "SET_CMS_ENV 1 ==> ERROR OS unknown, LCG environment not initialized"\n'
1019     txt += ' echo "JOB_EXIT_STATUS = 10033"\n'
1020     txt += ' echo "JobExitCode=10033" | tee -a $RUNTIME_AREA/$repo\n'
1021     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
1022 gutsche 1.4 txt += ' rm -f $RUNTIME_AREA/$repo \n'
1023     txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1024     txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1025 slacapra 1.1 txt += ' exit 1\n'
1026     txt += ' fi\n'
1027     txt += ' echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1028     txt += ' echo "### END SETUP CMS LCG ENVIRONMENT ###"\n'
1029     return txt
1030