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

Comparing COMP/CRAB/python/cms_cmssw.py (file contents):
Revision 1.128 by fanzago, Thu Oct 11 16:23:44 2007 UTC vs.
Revision 1.185 by ewv, Wed May 7 14:56:24 2008 UTC

# Line 5 | Line 5 | from crab_util import *
5   from BlackWhiteListParser import BlackWhiteListParser
6   import common
7   import Scram
8 + from LFNBaseName import *
9  
10   import os, string, glob
11  
# Line 13 | Line 14 | class Cmssw(JobType):
14          JobType.__init__(self, 'CMSSW')
15          common.logger.debug(3,'CMSSW::__init__')
16  
17 +        self.argsList = []
18 +
19          self._params = {}
20          self.cfg_params = cfg_params
18
21          # init BlackWhiteListParser
22          self.blackWhiteListParser = BlackWhiteListParser(cfg_params)
23  
24 <        try:
23 <            self.MaxTarBallSize = float(self.cfg_params['EDG.maxtarballsize'])
24 <        except KeyError:
25 <            self.MaxTarBallSize = 9.5
24 >        self.MaxTarBallSize = float(self.cfg_params.get('EDG.maxtarballsize',9.5))
25  
26          # number of jobs requested to be created, limit obj splitting
27          self.ncjobs = ncjobs
28  
29          log = common.logger
30 <        
30 >
31          self.scram = Scram.Scram(cfg_params)
32          self.additional_inbox_files = []
33          self.scriptExe = ''
34          self.executable = ''
35          self.executable_arch = self.scram.getArch()
36          self.tgz_name = 'default.tgz'
38        self.additional_tgz_name = 'additional.tgz'
37          self.scriptName = 'CMSSW.sh'
38 <        self.pset = ''      #scrip use case Da  
38 >        self.pset = ''      #scrip use case Da
39          self.datasetPath = '' #scrip use case Da
40  
41          # set FJR file name
42          self.fjrFileName = 'crab_fjr.xml'
43  
44          self.version = self.scram.getSWVersion()
45 <        
46 <        #
47 <        # Try to block creation in case of arch/version mismatch
48 <        #
49 <
50 <        a = string.split(self.version, "_")
51 <
52 <        if int(a[1]) == 1 and (int(a[2]) < 5 and self.executable_arch.find('slc4') == 0):
53 <            msg = "Error: CMS does not support %s with %s architecture"%(self.version, self.executable_arch)
54 <            raise CrabException(msg)
57 <        if int(a[1]) == 1 and (int(a[2]) >= 5 and self.executable_arch.find('slc3') == 0):
58 <            msg = "Error: CMS does not support %s with %s architecture"%(self.version, self.executable_arch)
45 >        version_array = self.version.split('_')
46 >        self.CMSSW_major = 0
47 >        self.CMSSW_minor = 0
48 >        self.CMSSW_patch = 0
49 >        try:
50 >            self.CMSSW_major = int(version_array[1])
51 >            self.CMSSW_minor = int(version_array[2])
52 >            self.CMSSW_patch = int(version_array[3])
53 >        except:
54 >            msg = "Cannot parse CMSSW version string: " + self.version + " for major and minor release number!"
55              raise CrabException(msg)
60        
61        common.taskDB.setDict('codeVersion',self.version)
62        self.setParam_('application', self.version)
56  
57          ### collect Data cards
58  
59 <        ## get DBS mode
60 <        try:
68 <            self.use_dbs_1 = int(self.cfg_params['CMSSW.use_dbs_1'])
69 <        except KeyError:
70 <            self.use_dbs_1 = 0
71 <            
72 <        try:
73 <            tmp =  cfg_params['CMSSW.datasetpath']
74 <            log.debug(6, "CMSSW::CMSSW(): datasetPath = "+tmp)
75 <            if string.lower(tmp)=='none':
76 <                self.datasetPath = None
77 <                self.selectNoInput = 1
78 <            else:
79 <                self.datasetPath = tmp
80 <                self.selectNoInput = 0
81 <        except KeyError:
82 <            msg = "Error: datasetpath not defined "  
59 >        if not cfg_params.has_key('CMSSW.datasetpath'):
60 >            msg = "Error: datasetpath not defined "
61              raise CrabException(msg)
62 <
63 <        # ML monitoring
64 <        # split dataset path style: /PreProdR3Minbias/SIM/GEN-SIM
65 <        if not self.datasetPath:
66 <            self.setParam_('dataset', 'None')
89 <            self.setParam_('owner', 'None')
62 >        tmp =  cfg_params['CMSSW.datasetpath']
63 >        log.debug(6, "CMSSW::CMSSW(): datasetPath = "+tmp)
64 >        if string.lower(tmp)=='none':
65 >            self.datasetPath = None
66 >            self.selectNoInput = 1
67          else:
68 <            try:
69 <                datasetpath_split = self.datasetPath.split("/")
93 <                # standard style
94 <                self.setParam_('datasetFull', self.datasetPath)
95 <                if self.use_dbs_1 == 1 :
96 <                    self.setParam_('dataset', datasetpath_split[1])
97 <                    self.setParam_('owner', datasetpath_split[-1])
98 <                else:
99 <                    self.setParam_('dataset', datasetpath_split[1])
100 <                    self.setParam_('owner', datasetpath_split[2])
101 <            except:
102 <                self.setParam_('dataset', self.datasetPath)
103 <                self.setParam_('owner', self.datasetPath)
104 <                
105 <        self.setTaskid_()
106 <        self.setParam_('taskId', self.cfg_params['taskId'])
68 >            self.datasetPath = tmp
69 >            self.selectNoInput = 0
70  
71          self.dataTiers = []
72  
73          ## now the application
74 <        try:
75 <            self.executable = cfg_params['CMSSW.executable']
113 <            self.setParam_('exe', self.executable)
114 <            log.debug(6, "CMSSW::CMSSW(): executable = "+self.executable)
115 <            msg = "Default executable cmsRun overridden. Switch to " + self.executable
116 <            log.debug(3,msg)
117 <        except KeyError:
118 <            self.executable = 'cmsRun'
119 <            self.setParam_('exe', self.executable)
120 <            msg = "User executable not defined. Use cmsRun"
121 <            log.debug(3,msg)
122 <            pass
74 >        self.executable = cfg_params.get('CMSSW.executable','cmsRun')
75 >        log.debug(6, "CMSSW::CMSSW(): executable = "+self.executable)
76  
77 <        try:
125 <            self.pset = cfg_params['CMSSW.pset']
126 <            log.debug(6, "Cmssw::Cmssw(): PSet file = "+self.pset)
127 <            if self.pset.lower() != 'none' :
128 <                if (not os.path.exists(self.pset)):
129 <                    raise CrabException("User defined PSet file "+self.pset+" does not exist")
130 <            else:
131 <                self.pset = None
132 <        except KeyError:
77 >        if not cfg_params.has_key('CMSSW.pset'):
78              raise CrabException("PSet file missing. Cannot run cmsRun ")
79 +        self.pset = cfg_params['CMSSW.pset']
80 +        log.debug(6, "Cmssw::Cmssw(): PSet file = "+self.pset)
81 +        if self.pset.lower() != 'none' :
82 +            if (not os.path.exists(self.pset)):
83 +                raise CrabException("User defined PSet file "+self.pset+" does not exist")
84 +        else:
85 +            self.pset = None
86  
87          # output files
88          ## stuff which must be returned always via sandbox
# Line 140 | Line 92 | class Cmssw(JobType):
92          self.output_file_sandbox.append(self.fjrFileName)
93  
94          # other output files to be returned via sandbox or copied to SE
95 <        try:
96 <            self.output_file = []
97 <            tmp = cfg_params['CMSSW.output_file']
98 <            if tmp != '':
99 <                tmpOutFiles = string.split(cfg_params['CMSSW.output_file'],',')
100 <                log.debug(7, 'cmssw::cmssw(): output files '+str(tmpOutFiles))
101 <                for tmp in tmpOutFiles:
102 <                    tmp=string.strip(tmp)
151 <                    self.output_file.append(tmp)
152 <                    pass
153 <            else:
154 <                log.message("No output file defined: only stdout/err and the CRAB Framework Job Report will be available\n")
95 >        self.output_file = []
96 >        tmp = cfg_params.get('CMSSW.output_file',None)
97 >        if tmp :
98 >            tmpOutFiles = string.split(tmp,',')
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 <            pass
157 <        except KeyError:
104 >        else:
105              log.message("No output file defined: only stdout/err and the CRAB Framework Job Report will be available\n")
106 <            pass
106 >        pass
107  
108          # script_exe file as additional file in inputSandbox
109 <        try:
110 <            self.scriptExe = cfg_params['USER.script_exe']
111 <            if self.scriptExe != '':
112 <               if not os.path.isfile(self.scriptExe):
113 <                  msg ="ERROR. file "+self.scriptExe+" not found"
114 <                  raise CrabException(msg)
168 <               self.additional_inbox_files.append(string.strip(self.scriptExe))
169 <        except KeyError:
170 <            self.scriptExe = ''
109 >        self.scriptExe = cfg_params.get('USER.script_exe',None)
110 >        if self.scriptExe :
111 >            if not os.path.isfile(self.scriptExe):
112 >                msg ="ERROR. file "+self.scriptExe+" not found"
113 >                raise CrabException(msg)
114 >            self.additional_inbox_files.append(string.strip(self.scriptExe))
115  
116          #CarlosDaniele
117          if self.datasetPath == None and self.pset == None and self.scriptExe == '' :
118 <           msg ="Error. script_exe  not defined"
119 <           raise CrabException(msg)
118 >            msg ="Error. script_exe  not defined"
119 >            raise CrabException(msg)
120  
121          ## additional input files
122 <        try:
122 >        if cfg_params.has_key('USER.additional_input_files'):
123              tmpAddFiles = string.split(cfg_params['USER.additional_input_files'],',')
124              for tmp in tmpAddFiles:
125                  tmp = string.strip(tmp)
# Line 199 | Line 143 | class Cmssw(JobType):
143                  pass
144              pass
145              common.logger.debug(5,"Additional input files: "+str(self.additional_inbox_files))
146 <        except KeyError:
203 <            pass
204 <
205 <        # files per job
206 <        try:
207 <            if (cfg_params['CMSSW.files_per_jobs']):
208 <                raise CrabException("files_per_jobs no longer supported.  Quitting.")
209 <        except KeyError:
210 <            pass
146 >        pass
147  
148          ## Events per job
149 <        try:
149 >        if cfg_params.has_key('CMSSW.events_per_job'):
150              self.eventsPerJob =int( cfg_params['CMSSW.events_per_job'])
151              self.selectEventsPerJob = 1
152 <        except KeyError:
152 >        else:
153              self.eventsPerJob = -1
154              self.selectEventsPerJob = 0
155 <    
155 >
156          ## number of jobs
157 <        try:
157 >        if cfg_params.has_key('CMSSW.number_of_jobs'):
158              self.theNumberOfJobs =int( cfg_params['CMSSW.number_of_jobs'])
159              self.selectNumberOfJobs = 1
160 <        except KeyError:
160 >        else:
161              self.theNumberOfJobs = 0
162              self.selectNumberOfJobs = 0
163  
164 <        try:
164 >        if cfg_params.has_key('CMSSW.total_number_of_events'):
165              self.total_number_of_events = int(cfg_params['CMSSW.total_number_of_events'])
166              self.selectTotalNumberEvents = 1
167 <        except KeyError:
167 >        else:
168              self.total_number_of_events = 0
169              self.selectTotalNumberEvents = 0
170  
171 <        if self.pset != None: #CarlosDaniele
171 >        if self.pset != None: #CarlosDaniele
172               if ( (self.selectTotalNumberEvents + self.selectEventsPerJob + self.selectNumberOfJobs) != 2 ):
173                   msg = 'Must define exactly two of total_number_of_events, events_per_job, or number_of_jobs.'
174                   raise CrabException(msg)
# Line 241 | Line 177 | class Cmssw(JobType):
177                   msg = 'Must specify  number_of_jobs.'
178                   raise CrabException(msg)
179  
180 <        ## source seed for pythia
181 <        try:
182 <            self.sourceSeed = int(cfg_params['CMSSW.pythia_seed'])
183 <        except KeyError:
184 <            self.sourceSeed = None
185 <            common.logger.debug(5,"No seed given")
180 >        ## New method of dealing with seeds
181 >        self.incrementSeeds = []
182 >        self.preserveSeeds = []
183 >        if cfg_params.has_key('CMSSW.preserve_seeds'):
184 >            tmpList = cfg_params['CMSSW.preserve_seeds'].split(',')
185 >            for tmp in tmpList:
186 >                tmp.strip()
187 >                self.preserveSeeds.append(tmp)
188 >        if cfg_params.has_key('CMSSW.increment_seeds'):
189 >            tmpList = cfg_params['CMSSW.increment_seeds'].split(',')
190 >            for tmp in tmpList:
191 >                tmp.strip()
192 >                self.incrementSeeds.append(tmp)
193 >
194 >        ## Old method of dealing with seeds
195 >        ## FUTURE: This is for old CMSSW and old CRAB. Can throw exceptions after a couple of CRAB releases and then
196 >        ## remove
197 >        self.sourceSeed = cfg_params.get('CMSSW.pythia_seed',None)
198 >        if self.sourceSeed:
199 >            print "pythia_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds."
200 >            self.incrementSeeds.append('sourceSeed')
201 >            self.incrementSeeds.append('theSource')
202 >
203 >        self.sourceSeedVtx = cfg_params.get('CMSSW.vtx_seed',None)
204 >        if self.sourceSeedVtx:
205 >            print "vtx_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds."
206 >            self.incrementSeeds.append('VtxSmeared')
207 >
208 >        self.sourceSeedG4 = cfg_params.get('CMSSW.g4_seed',None)
209 >        if self.sourceSeedG4:
210 >            print "g4_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds."
211 >            self.incrementSeeds.append('g4SimHits')
212 >
213 >        self.sourceSeedMix = cfg_params.get('CMSSW.mix_seed',None)
214 >        if self.sourceSeedMix:
215 >            print "mix_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds."
216 >            self.incrementSeeds.append('mix')
217  
218 <        try:
252 <            self.sourceSeedVtx = int(cfg_params['CMSSW.vtx_seed'])
253 <        except KeyError:
254 <            self.sourceSeedVtx = None
255 <            common.logger.debug(5,"No vertex seed given")
218 >        self.firstRun = cfg_params.get('CMSSW.first_run',None)
219  
257        try:
258            self.sourceSeedG4 = int(cfg_params['CMSSW.g4_seed'])
259        except KeyError:
260            self.sourceSeedG4 = None
261            common.logger.debug(5,"No g4 sim hits seed given")
262
263        try:
264            self.sourceSeedMix = int(cfg_params['CMSSW.mix_seed'])
265        except KeyError:
266            self.sourceSeedMix = None
267            common.logger.debug(5,"No mix seed given")
268
269        try:
270            self.firstRun = int(cfg_params['CMSSW.first_run'])
271        except KeyError:
272            self.firstRun = None
273            common.logger.debug(5,"No first run given")
220          if self.pset != None: #CarlosDaniele
221 <            ver = string.split(self.version,"_")
276 <            if (int(ver[1])>=1 and int(ver[2])>=5):
277 <                import PsetManipulator150 as pp
278 <            else:
279 <                import PsetManipulator as pp
221 >            import PsetManipulator as pp
222              PsetEdit = pp.PsetManipulator(self.pset) #Daniele Pset
223  
224 +        # Copy/return
225 +
226 +        self.copy_data = int(cfg_params.get('USER.copy_data',0))
227 +        self.return_data = int(cfg_params.get('USER.return_data',0))
228 +
229          #DBSDLS-start
230 <        ## Initialize the variables that are extracted from DBS/DLS and needed in other places of the code
230 >        ## Initialize the variables that are extracted from DBS/DLS and needed in other places of the code
231          self.maxEvents=0  # max events available   ( --> check the requested nb. of evts in Creator.py)
232          self.DBSPaths={}  # all dbs paths requested ( --> input to the site local discovery script)
233          self.jobDestination=[]  # Site destination(s) for each job (list of lists)
# Line 289 | Line 236 | class Cmssw(JobType):
236          blockSites = {}
237          if self.datasetPath:
238              blockSites = self.DataDiscoveryAndLocation(cfg_params)
239 <        #DBSDLS-end          
239 >        #DBSDLS-end
240 >
241  
294        self.tgzNameWithPath = self.getTarBall(self.executable)
295    
242          ## Select Splitting
243 <        if self.selectNoInput:
243 >        if self.selectNoInput:
244              if self.pset == None: #CarlosDaniele
245                  self.jobSplittingForScript()
246              else:
# Line 305 | Line 251 | class Cmssw(JobType):
251          # modify Pset
252          if self.pset != None: #CarlosDaniele
253              try:
254 <                if (self.datasetPath): # standard job
255 <                    # allow to processa a fraction of events in a file
256 <                    PsetEdit.inputModule("INPUT")
257 <                    PsetEdit.maxEvent("INPUTMAXEVENTS")
312 <                    PsetEdit.skipEvent("INPUTSKIPEVENTS")
313 <                else:  # pythia like job
314 <                    PsetEdit.maxEvent(self.eventsPerJob)
315 <                    if (self.firstRun):
316 <                        PsetEdit.pythiaFirstRun("INPUTFIRSTRUN")  #First Run
317 <                    if (self.sourceSeed) :
318 <                        PsetEdit.pythiaSeed("INPUT")
319 <                        if (self.sourceSeedVtx) :
320 <                            PsetEdit.vtxSeed("INPUTVTX")
321 <                        if (self.sourceSeedG4) :
322 <                            PsetEdit.g4Seed("INPUTG4")
323 <                        if (self.sourceSeedMix) :
324 <                            PsetEdit.mixSeed("INPUTMIX")
325 <                # add FrameworkJobReport to parameter-set
326 <                PsetEdit.addCrabFJR(self.fjrFileName)
254 >                # Add FrameworkJobReport to parameter-set, set max events.
255 >                # Reset later for data jobs by writeCFG which does all modifications
256 >                PsetEdit.addCrabFJR(self.fjrFileName) # FUTURE: Job report addition not needed by CMSSW>1.5
257 >                PsetEdit.maxEvent(self.eventsPerJob)
258                  PsetEdit.psetWriter(self.configFilename())
259              except:
260 <                msg='Error while manipuliating ParameterSet: exiting...'
260 >                msg='Error while manipulating ParameterSet: exiting...'
261                  raise CrabException(msg)
262 +        self.tgzNameWithPath = self.getTarBall(self.executable)
263  
264      def DataDiscoveryAndLocation(self, cfg_params):
265  
266          import DataDiscovery
335        import DataDiscovery_DBS2
267          import DataLocation
268          common.logger.debug(10,"CMSSW::DataDiscoveryAndLocation()")
269  
# Line 341 | Line 272 | class Cmssw(JobType):
272          ## Contact the DBS
273          common.logger.message("Contacting Data Discovery Services ...")
274          try:
275 <
345 <            if self.use_dbs_1 == 1 :
346 <                self.pubdata=DataDiscovery.DataDiscovery(datasetPath, cfg_params)
347 <            else :
348 <                self.pubdata=DataDiscovery_DBS2.DataDiscovery_DBS2(datasetPath, cfg_params)
275 >            self.pubdata=DataDiscovery.DataDiscovery(datasetPath, cfg_params)
276              self.pubdata.fetchDBSInfo()
277  
278          except DataDiscovery.NotExistingDatasetError, ex :
# Line 357 | Line 284 | class Cmssw(JobType):
284          except DataDiscovery.DataDiscoveryError, ex:
285              msg = 'ERROR ***: failed Data Discovery in DBS :  %s'%ex.getErrorMessage()
286              raise CrabException(msg)
360        except DataDiscovery_DBS2.NotExistingDatasetError_DBS2, ex :
361            msg = 'ERROR ***: failed Data Discovery in DBS : %s'%ex.getErrorMessage()
362            raise CrabException(msg)
363        except DataDiscovery_DBS2.NoDataTierinProvenanceError_DBS2, ex :
364            msg = 'ERROR ***: failed Data Discovery in DBS : %s'%ex.getErrorMessage()
365            raise CrabException(msg)
366        except DataDiscovery_DBS2.DataDiscoveryError_DBS2, ex:
367            msg = 'ERROR ***: failed Data Discovery in DBS :  %s'%ex.getErrorMessage()
368            raise CrabException(msg)
287  
288          self.filesbyblock=self.pubdata.getFiles()
289          self.eventsbyblock=self.pubdata.getEventsPerBlock()
290          self.eventsbyfile=self.pubdata.getEventsPerFile()
291  
292          ## get max number of events
293 <        self.maxEvents=self.pubdata.getMaxEvents() ##  self.maxEvents used in Creator.py
293 >        self.maxEvents=self.pubdata.getMaxEvents() ##  self.maxEvents used in Creator.py
294  
295          ## Contact the DLS and build a list of sites hosting the fileblocks
296          try:
# Line 381 | Line 299 | class Cmssw(JobType):
299          except DataLocation.DataLocationError , ex:
300              msg = 'ERROR ***: failed Data Location in DLS \n %s '%ex.getErrorMessage()
301              raise CrabException(msg)
302 <        
302 >
303  
304          sites = dataloc.getSites()
305          allSites = []
# Line 395 | Line 313 | class Cmssw(JobType):
313          common.logger.message("Requested dataset: " + datasetPath + " has " + str(self.maxEvents) + " events in " + str(len(self.filesbyblock.keys())) + " blocks.\n")
314  
315          return sites
316 <    
316 >
317 >  # to Be Removed  DS -- BL
318 >  #  def setArgsList(self, argsList):
319 >  #      self.argsList = argsList
320 >
321      def jobSplittingByBlocks(self, blockSites):
322          """
323          Perform job splitting. Jobs run over an integer number of files
# Line 445 | Line 367 | class Cmssw(JobType):
367              totalNumberOfJobs = 999999999
368          else :
369              totalNumberOfJobs = self.ncjobs
448            
370  
371          blocks = blockSites.keys()
372          blockCount = 0
# Line 465 | Line 386 | class Cmssw(JobType):
386              blockCount += 1
387              if block not in jobsOfBlock.keys() :
388                  jobsOfBlock[block] = []
389 <            
389 >
390              if self.eventsbyblock.has_key(block) :
391                  numEventsInBlock = self.eventsbyblock[block]
392                  common.logger.debug(5,'Events in Block File '+str(numEventsInBlock))
393 <            
393 >
394                  files = self.filesbyblock[block]
395                  numFilesInBlock = len(files)
396                  if (numFilesInBlock <= 0):
# Line 477 | Line 398 | class Cmssw(JobType):
398                  fileCount = 0
399  
400                  # ---- New block => New job ---- #
401 <                parString = "\\{"
401 >                parString = ""
402                  # counter for number of events in files currently worked on
403                  filesEventCount = 0
404                  # flag if next while loop should touch new file
405                  newFile = 1
406                  # job event counter
407                  jobSkipEventCount = 0
408 <            
408 >
409                  # ---- Iterate over the files in the block until we've met the requested ---- #
410                  # ---- total # of events or we've gone over all the files in this block  ---- #
411                  while ( (eventsRemaining > 0) and (fileCount < numFilesInBlock) and (jobCount < totalNumberOfJobs) ):
# Line 500 | Line 421 | class Cmssw(JobType):
421                              newFile = 0
422                          except KeyError:
423                              common.logger.message("File "+str(file)+" has unknown number of events: skipping")
503                        
424  
425 +                    eventsPerJobRequested = min(eventsPerJobRequested, eventsRemaining)
426                      # if less events in file remain than eventsPerJobRequested
427 <                    if ( filesEventCount - jobSkipEventCount < eventsPerJobRequested ) :
427 >                    if ( filesEventCount - jobSkipEventCount < eventsPerJobRequested):
428                          # if last file in block
429                          if ( fileCount == numFilesInBlock-1 ) :
430                              # end job using last file, use remaining events in block
431                              # close job and touch new file
432                              fullString = parString[:-2]
512                            fullString += '\\}'
433                              list_of_lists.append([fullString,str(-1),str(jobSkipEventCount)])
434                              common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(filesEventCount - jobSkipEventCount)+" events (last file in block).")
435                              self.jobDestination.append(blockSites[block])
# Line 522 | Line 442 | class Cmssw(JobType):
442                              eventsRemaining = eventsRemaining - filesEventCount + jobSkipEventCount
443                              jobSkipEventCount = 0
444                              # reset file
445 <                            parString = "\\{"
445 >                            parString = ""
446                              filesEventCount = 0
447                              newFile = 1
448                              fileCount += 1
# Line 534 | Line 454 | class Cmssw(JobType):
454                      elif ( filesEventCount - jobSkipEventCount == eventsPerJobRequested ) :
455                          # close job and touch new file
456                          fullString = parString[:-2]
537                        fullString += '\\}'
457                          list_of_lists.append([fullString,str(eventsPerJobRequested),str(jobSkipEventCount)])
458                          common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(eventsPerJobRequested)+" events.")
459                          self.jobDestination.append(blockSites[block])
# Line 546 | Line 465 | class Cmssw(JobType):
465                          eventsRemaining = eventsRemaining - eventsPerJobRequested
466                          jobSkipEventCount = 0
467                          # reset file
468 <                        parString = "\\{"
468 >                        parString = ""
469                          filesEventCount = 0
470                          newFile = 1
471                          fileCount += 1
472 <                        
472 >
473                      # if more events in file remain than eventsPerJobRequested
474                      else :
475                          # close job but don't touch new file
476                          fullString = parString[:-2]
558                        fullString += '\\}'
477                          list_of_lists.append([fullString,str(eventsPerJobRequested),str(jobSkipEventCount)])
478                          common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(eventsPerJobRequested)+" events.")
479                          self.jobDestination.append(blockSites[block])
# Line 570 | Line 488 | class Cmssw(JobType):
488                          jobSkipEventCount = eventsPerJobRequested - (filesEventCount - jobSkipEventCount - self.eventsbyfile[file])
489                          # remove all but the last file
490                          filesEventCount = self.eventsbyfile[file]
491 <                        parString = "\\{"
574 <                        parString += '\\\"' + file + '\\\"\,'
491 >                        parString = '\\\"' + file + '\\\"\,'
492                      pass # END if
493                  pass # END while (iterate over files in the block)
494          pass # END while (iterate over blocks in the dataset)
# Line 579 | Line 496 | class Cmssw(JobType):
496          if (eventsRemaining > 0 and jobCount < totalNumberOfJobs ):
497              common.logger.message("Could not run on all requested events because some blocks not hosted at allowed sites.")
498          common.logger.message(str(jobCount)+" job(s) can run on "+str(totalEventCount)+" events.\n")
499 <        
499 >
500          # screen output
501          screenOutput = "List of jobs and available destination sites:\n\n"
502  
# Line 591 | Line 508 | class Cmssw(JobType):
508          for block in blocks:
509              if block in jobsOfBlock.keys() :
510                  blockCounter += 1
511 <                screenOutput += "Block %5i: jobs %20s: sites: %s\n" % (blockCounter,spanRanges(jobsOfBlock[block]),','.join(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)))
511 >                screenOutput += "Block %5i: jobs %20s: sites: %s\n" % (blockCounter,spanRanges(jobsOfBlock[block]),
512 >                    ','.join(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)))
513                  if len(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)) == 0:
514 <                    noSiteBlock.append( spanRanges(jobsOfBlock[block]) )
514 >                    noSiteBlock.append( spanRanges(jobsOfBlock[block]) )
515                      bloskNoSite.append( blockCounter )
516 <        
516 >
517          common.logger.message(screenOutput)
518          if len(noSiteBlock) > 0 and len(bloskNoSite) > 0:
519              msg = 'WARNING: No sites are hosting any part of data for block:\n                '
# Line 611 | Line 529 | class Cmssw(JobType):
529              for range_jobs in noSiteBlock:
530                  msg += str(range_jobs) + virgola
531              msg += '\n               will not be submitted and this block of data can not be analyzed!\n'
532 +            if self.cfg_params.has_key('EDG.se_white_list'):
533 +                msg += 'WARNING: SE White List: '+self.cfg_params['EDG.se_white_list']+'\n'
534 +                msg += '(Hint: By whitelisting you force the job to run at this particular site(s).\n'
535 +                msg += 'Please check if the dataset is available at this site!)\n'
536 +            if self.cfg_params.has_key('EDG.ce_white_list'):
537 +                msg += 'WARNING: CE White List: '+self.cfg_params['EDG.ce_white_list']+'\n'
538 +                msg += '(Hint: By whitelisting you force the job to run at this particular site(s).\n'
539 +                msg += 'Please check if the dataset is available at this site!)\n'
540 +
541              common.logger.message(msg)
542  
543          self.list_of_args = list_of_lists
# Line 621 | Line 548 | class Cmssw(JobType):
548          Perform job splitting based on number of event per job
549          """
550          common.logger.debug(5,'Splitting per events')
551 <        common.logger.message('Required '+str(self.eventsPerJob)+' events per job ')
552 <        common.logger.message('Required '+str(self.theNumberOfJobs)+' jobs in total ')
553 <        common.logger.message('Required '+str(self.total_number_of_events)+' events in total ')
551 >
552 >        if (self.selectEventsPerJob):
553 >            common.logger.message('Required '+str(self.eventsPerJob)+' events per job ')
554 >        if (self.selectNumberOfJobs):
555 >            common.logger.message('Required '+str(self.theNumberOfJobs)+' jobs in total ')
556 >        if (self.selectTotalNumberEvents):
557 >            common.logger.message('Required '+str(self.total_number_of_events)+' events in total ')
558  
559          if (self.total_number_of_events < 0):
560              msg='Cannot split jobs per Events with "-1" as total number of events'
# Line 632 | Line 563 | class Cmssw(JobType):
563          if (self.selectEventsPerJob):
564              if (self.selectTotalNumberEvents):
565                  self.total_number_of_jobs = int(self.total_number_of_events/self.eventsPerJob)
566 <            elif(self.selectNumberOfJobs) :  
566 >            elif(self.selectNumberOfJobs) :
567                  self.total_number_of_jobs =self.theNumberOfJobs
568 <                self.total_number_of_events =int(self.theNumberOfJobs*self.eventsPerJob)
568 >                self.total_number_of_events =int(self.theNumberOfJobs*self.eventsPerJob)
569  
570          elif (self.selectNumberOfJobs) :
571              self.total_number_of_jobs = self.theNumberOfJobs
572              self.eventsPerJob = int(self.total_number_of_events/self.total_number_of_jobs)
573 <
573 >
574          common.logger.debug(5,'N jobs  '+str(self.total_number_of_jobs))
575  
576          # is there any remainder?
# Line 655 | Line 586 | class Cmssw(JobType):
586          self.list_of_args = []
587          for i in range(self.total_number_of_jobs):
588              ## Since there is no input, any site is good
589 <           # self.jobDestination.append(["Any"])
659 <            self.jobDestination.append([""]) #must be empty to write correctly the xml
589 >            self.jobDestination.append([""]) #must be empty to write correctly the xml
590              args=[]
591              if (self.firstRun):
592 <                    ## pythia first run
663 <                #self.list_of_args.append([(str(self.firstRun)+str(i))])
592 >                ## pythia first run
593                  args.append(str(self.firstRun)+str(i))
665            else:
666                ## no first run
667                #self.list_of_args.append([str(i)])
668                args.append(str(i))
669            if (self.sourceSeed):
670                args.append(str(self.sourceSeed)+str(i))
671                if (self.sourceSeedVtx):
672                    ## + vtx random seed
673                    args.append(str(self.sourceSeedVtx)+str(i))
674                if (self.sourceSeedG4):
675                    ## + G4 random seed
676                    args.append(str(self.sourceSeedG4)+str(i))
677                if (self.sourceSeedMix):    
678                    ## + Mix random seed
679                    args.append(str(self.sourceSeedMix)+str(i))
680                pass
681            pass
594              self.list_of_args.append(args)
683        pass
684            
685        # print self.list_of_args
595  
596          return
597  
# Line 711 | Line 620 | class Cmssw(JobType):
620          return
621  
622      def split(self, jobParams):
623 <
715 <        common.jobDB.load()
623 >
624          #### Fabio
625          njobs = self.total_number_of_jobs
626          arglist = self.list_of_args
627          # create the empty structure
628          for i in range(njobs):
629              jobParams.append("")
630 <        
630 >
631 >        listID=[]
632 >        listField=[]
633          for job in range(njobs):
634              jobParams[job] = arglist[job]
635 <            # print str(arglist[job])
636 <            # print jobParams[job]
637 <            common.jobDB.setArguments(job, jobParams[job])
638 <            common.logger.debug(5,"Job "+str(job)+" Destination: "+str(self.jobDestination[job]))
639 <            common.jobDB.setDestination(job, self.jobDestination[job])
635 >            listID.append(job+1)
636 >            job_ToSave ={}
637 >            concString = ' '
638 >            argu=''
639 >            if len(jobParams[job]):
640 >                argu +=   concString.join(jobParams[job] )
641 >            job_ToSave['arguments']= str(job+1)+' '+argu## new BL--DS
642 >            job_ToSave['dlsDestination']= self.jobDestination[job]## new BL--DS
643 >            #common._db.updateJob_(job,job_ToSave)## new BL--DS
644 >            listField.append(job_ToSave)
645 >            msg="Job "+str(job)+" Arguments:   "+str(job+1)+" "+argu+"\n"  \
646 >            +"                     Destination: "+str(self.jobDestination[job])
647 >            common.logger.debug(5,msg)
648 >            #common.logger.debug(5,"Job "+str(job)+" Destination: "+str(self.jobDestination[job]))
649 >        common._db.updateJob_(listID,listField)## new BL--DS
650 >        ## Pay Attention Here....DS--BL
651 >        self.argsList = (len(jobParams[0])+1)
652  
731        common.jobDB.save()
653          return
654 <    
734 <    def getJobTypeArguments(self, nj, sched):
735 <        result = ''
736 <        for i in common.jobDB.arguments(nj):
737 <            result=result+str(i)+" "
738 <        return result
739 <  
654 >
655      def numberOfJobs(self):
656          # Fabio
657          return self.total_number_of_jobs
# Line 745 | Line 660 | class Cmssw(JobType):
660          """
661          Return the TarBall with lib and exe
662          """
663 <        
663 >
664          # if it exist, just return it
665          #
666          # Marco. Let's start to use relative path for Boss XML files
# Line 768 | Line 683 | class Cmssw(JobType):
683          # print "swVersion = ", swVersion
684          swReleaseTop = self.scram.getReleaseTop_()
685          #print "swReleaseTop = ", swReleaseTop
686 <        
686 >
687          ## check if working area is release top
688          if swReleaseTop == '' or swArea == swReleaseTop:
689 +            common.logger.debug(3,"swArea = "+swArea+" swReleaseTop ="+swReleaseTop)
690              return
691  
692          import tarfile
# Line 781 | Line 697 | class Cmssw(JobType):
697                  exeWithPath = self.scram.findFile_(executable)
698                  if ( not exeWithPath ):
699                      raise CrabException('User executable '+executable+' not found')
700 <    
700 >
701                  ## then check if it's private or not
702                  if exeWithPath.find(swReleaseTop) == -1:
703                      # the exe is private, so we must ship
# Line 790 | Line 706 | class Cmssw(JobType):
706                      # distinguish case when script is in user project area or given by full path somewhere else
707                      if exeWithPath.find(path) >= 0 :
708                          exe = string.replace(exeWithPath, path,'')
709 <                        tar.add(path+exe,os.path.basename(executable))
709 >                        tar.add(path+exe,exe)
710                      else :
711                          tar.add(exeWithPath,os.path.basename(executable))
712                      pass
713                  else:
714                      # the exe is from release, we'll find it on WN
715                      pass
716 <    
716 >
717              ## Now get the libraries: only those in local working area
718              libDir = 'lib'
719              lib = swArea+'/' +libDir
720              common.logger.debug(5,"lib "+lib+" to be tarred")
721              if os.path.exists(lib):
722                  tar.add(lib,libDir)
723 <    
723 >
724              ## Now check if module dir is present
725              moduleDir = 'module'
726              module = swArea + '/' + moduleDir
# Line 813 | Line 729 | class Cmssw(JobType):
729  
730              ## Now check if any data dir(s) is present
731              swAreaLen=len(swArea)
732 +            self.dataExist = False
733              for root, dirs, files in os.walk(swArea):
734                  if "data" in dirs:
735 +                    self.dataExist=True
736                      common.logger.debug(5,"data "+root+"/data"+" to be tarred")
737                      tar.add(root+"/data",root[swAreaLen:]+"/data")
738  
739 <            ## Add ProdAgent dir to tar
740 <            paDir = 'ProdAgentApi'
741 <            pa = os.environ['CRABDIR'] + '/' + 'ProdAgentApi'
742 <            if os.path.isdir(pa):
743 <                tar.add(pa,paDir)
739 >            ### CMSSW ParameterSet
740 >            if not self.pset is None:
741 >                cfg_file = common.work_space.jobDir()+self.configFilename()
742 >                tar.add(cfg_file,self.configFilename())
743 >                common.logger.debug(5,"File added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
744 >
745  
746 <            ### FEDE FOR DBS PUBLICATION
828 <            ## Add PRODCOMMON dir to tar
746 >            ## Add ProdCommon dir to tar
747              prodcommonDir = 'ProdCommon'
748              prodcommonPath = os.environ['CRABDIR'] + '/' + 'ProdCommon'
749              if os.path.isdir(prodcommonPath):
750                  tar.add(prodcommonPath,prodcommonDir)
833            #############################    
834        
751              common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
752 +
753 +            ##### ML stuff
754 +            ML_file_list=['report.py', 'DashboardAPI.py', 'Logger.py', 'ProcInfo.py', 'apmon.py']
755 +            path=os.environ['CRABDIR'] + '/python/'
756 +            for file in ML_file_list:
757 +                tar.add(path+file,file)
758 +            common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
759 +
760 +            ##### Utils
761 +            Utils_file_list=['parseCrabFjr.py','writeCfg.py', 'JobReportErrorCode.py']
762 +            for file in Utils_file_list:
763 +                tar.add(path+file,file)
764 +            common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
765 +
766 +            ##### AdditionalFiles
767 +            for file in self.additional_inbox_files:
768 +                tar.add(file,string.split(file,'/')[-1])
769 +            common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
770 +
771              tar.close()
772          except :
773              raise CrabException('Could not create tar-ball')
# Line 843 | Line 778 | class Cmssw(JobType):
778              raise CrabException('Input sandbox size of ' + str(float(tarballinfo.st_size)/1024.0/1024.0) + ' MB is larger than the allowed ' + str(self.MaxTarBallSize) + ' MB input sandbox limit and not supported by the used GRID submission system. Please make sure that no unnecessary files are in all data directories in your local CMSSW project area as they are automatically packed into the input sandbox.')
779  
780          ## create tar-ball with ML stuff
846        self.MLtgzfile =  common.work_space.pathForTgz()+'share/MLfiles.tgz'
847        try:
848            tar = tarfile.open(self.MLtgzfile, "w:gz")
849            path=os.environ['CRABDIR'] + '/python/'
850            for file in ['report.py', 'DashboardAPI.py', 'Logger.py', 'ProcInfo.py', 'apmon.py', 'parseCrabFjr.py']:
851                tar.add(path+file,file)
852            common.logger.debug(5,"Files added to "+self.MLtgzfile+" : "+str(tar.getnames()))
853            tar.close()
854        except :
855            raise CrabException('Could not create ML files tar-ball')
856        
857        return
858        
859    def additionalInputFileTgz(self):
860        """
861        Put all additional files into a tar ball and return its name
862        """
863        import tarfile
864        tarName=  common.work_space.pathForTgz()+'share/'+self.additional_tgz_name
865        tar = tarfile.open(tarName, "w:gz")
866        for file in self.additional_inbox_files:
867            tar.add(file,string.split(file,'/')[-1])
868        common.logger.debug(5,"Files added to "+self.additional_tgz_name+" : "+str(tar.getnames()))
869        tar.close()
870        return tarName
781  
782 <    def wsSetupEnvironment(self, nj):
782 >    def wsSetupEnvironment(self, nj=0):
783          """
784          Returns part of a job script which prepares
785          the execution environment for the job 'nj'.
786          """
787 +        if (self.CMSSW_major >= 2 and self.CMSSW_minor >= 1) or (self.CMSSW_major >= 3):
788 +            psetName = 'pset.py'
789 +        else:
790 +            psetName = 'pset.cfg'
791          # Prepare JobType-independent part
792 <        txt = ''
793 <  
794 <        ## OLI_Daniele at this level  middleware already known
881 <
882 <        txt += 'if [ $middleware == LCG ]; then \n'
883 <        txt += '    echo "### First set SCRAM ARCH and BUILD_ARCH to ' + self.executable_arch + ' ###"\n'
884 <        txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
885 <        txt += '    export BUILD_ARCH='+self.executable_arch+'\n'
792 >        txt = '\n#Written by cms_cmssw::wsSetupEnvironment\n'
793 >        txt += 'echo ">>> setup environment"\n'
794 >        txt += 'if [ $middleware == LCG ]; then \n'
795          txt += self.wsSetupCMSLCGEnvironment_()
796          txt += 'elif [ $middleware == OSG ]; then\n'
797          txt += '    WORKING_DIR=`/bin/mktemp  -d $OSG_WN_TMP/cms_XXXXXXXXXXXX`\n'
798 <        txt += '    echo "Created working directory: $WORKING_DIR"\n'
799 <        txt += '    if [ ! -d $WORKING_DIR ] ;then\n'
800 <        txt += '        echo "SET_CMS_ENV 10016 ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n'
801 <        txt += '    echo "JOB_EXIT_STATUS = 10016"\n'
893 <        txt += '    echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
894 <        txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
895 <        txt += '        rm -f $RUNTIME_AREA/$repo \n'
896 <        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
897 <        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
898 <        txt += '        exit 1\n'
798 >        txt += '    if [ ! $? == 0 ] ;then\n'
799 >        txt += '        echo "ERROR ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n'
800 >        txt += '        job_exit_code=10016\n'
801 >        txt += '        func_exit\n'
802          txt += '    fi\n'
803 +        txt += '    echo ">>> Created working directory: $WORKING_DIR"\n'
804          txt += '\n'
805          txt += '    echo "Change to working directory: $WORKING_DIR"\n'
806          txt += '    cd $WORKING_DIR\n'
807 <        txt += self.wsSetupCMSOSGEnvironment_()
808 <        txt += '    echo "### Set SCRAM ARCH to ' + self.executable_arch + ' ###"\n'
809 <        txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
807 >        txt += '    echo ">>> current directory (WORKING_DIR): $WORKING_DIR"\n'
808 >        txt += self.wsSetupCMSOSGEnvironment_()
809 >        #txt += '    echo "### Set SCRAM ARCH to ' + self.executable_arch + ' ###"\n'
810 >        #txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
811          txt += 'fi\n'
812  
813          # Prepare JobType-specific part
814          scram = self.scram.commandName()
815          txt += '\n\n'
816 <        txt += 'echo "### SPECIFIC JOB SETUP ENVIRONMENT ###"\n'
816 >        txt += 'echo ">>> specific cmssw setup environment:"\n'
817 >        txt += 'echo "CMSSW_VERSION =  '+self.version+'"\n'
818          txt += scram+' project CMSSW '+self.version+'\n'
819          txt += 'status=$?\n'
820          txt += 'if [ $status != 0 ] ; then\n'
821 <        txt += '   echo "SET_EXE_ENV 10034 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n'
822 <        txt += '   echo "JOB_EXIT_STATUS = 10034"\n'
823 <        txt += '   echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n'
918 <        txt += '   dumpStatus $RUNTIME_AREA/$repo\n'
919 <        txt += '   rm -f $RUNTIME_AREA/$repo \n'
920 <        txt += '   echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
921 <        txt += '   echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
922 <        ## OLI_Daniele
923 <        txt += '    if [ $middleware == OSG ]; then \n'
924 <        txt += '        echo "Remove working directory: $WORKING_DIR"\n'
925 <        txt += '        cd $RUNTIME_AREA\n'
926 <        txt += '        /bin/rm -rf $WORKING_DIR\n'
927 <        txt += '        if [ -d $WORKING_DIR ] ;then\n'
928 <        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'
929 <        txt += '            echo "JOB_EXIT_STATUS = 10018"\n'
930 <        txt += '            echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n'
931 <        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
932 <        txt += '            rm -f $RUNTIME_AREA/$repo \n'
933 <        txt += '            echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
934 <        txt += '            echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
935 <        txt += '        fi\n'
936 <        txt += '    fi \n'
937 <        txt += '   exit 1 \n'
821 >        txt += '    echo "ERROR ==> CMSSW '+self.version+' not found on `hostname`" \n'
822 >        txt += '    job_exit_code=10034\n'
823 >        txt += '    func_exit\n'
824          txt += 'fi \n'
939        txt += 'echo "CMSSW_VERSION =  '+self.version+'"\n'
825          txt += 'cd '+self.version+'\n'
941        ########## FEDE FOR DBS2 ######################
826          txt += 'SOFTWARE_DIR=`pwd`\n'
827 <        txt += 'echo SOFTWARE_DIR=$SOFTWARE_DIR \n'
944 <        ###############################################
945 <        ### needed grep for bug in scramv1 ###
946 <        txt += scram+' runtime -sh\n'
827 >        txt += 'echo ">>> current directory (SOFTWARE_DIR): $SOFTWARE_DIR" \n'
828          txt += 'eval `'+scram+' runtime -sh | grep -v SCRAMRT_LSB_JOBNAME`\n'
829 <        txt += 'echo $PATH\n'
830 <
829 >        txt += 'if [ $? != 0 ] ; then\n'
830 >        txt += '    echo "ERROR ==> Problem with the command: "\n'
831 >        txt += '    echo "eval \`'+scram+' runtime -sh | grep -v SCRAMRT_LSB_JOBNAME \` at `hostname`"\n'
832 >        txt += '    job_exit_code=10034\n'
833 >        txt += '    func_exit\n'
834 >        txt += 'fi \n'
835          # Handle the arguments:
836          txt += "\n"
837          txt += "## number of arguments (first argument always jobnumber)\n"
838          txt += "\n"
839 < #        txt += "narg=$#\n"
955 <        txt += "if [ $nargs -lt 2 ]\n"
839 >        txt += "if [ $nargs -lt "+str(self.argsList)+" ]\n"
840          txt += "then\n"
841 <        txt += "    echo 'SET_EXE_ENV 1 ==> ERROR Too few arguments' +$nargs+ \n"
842 <        txt += '    echo "JOB_EXIT_STATUS = 50113"\n'
843 <        txt += '    echo "JobExitCode=50113" | tee -a $RUNTIME_AREA/$repo\n'
960 <        txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
961 <        txt += '    rm -f $RUNTIME_AREA/$repo \n'
962 <        txt += '    echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
963 <        txt += '    echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
964 <        ## OLI_Daniele
965 <        txt += '    if [ $middleware == OSG ]; then \n'
966 <        txt += '        echo "Remove working directory: $WORKING_DIR"\n'
967 <        txt += '        cd $RUNTIME_AREA\n'
968 <        txt += '        /bin/rm -rf $WORKING_DIR\n'
969 <        txt += '        if [ -d $WORKING_DIR ] ;then\n'
970 <        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'
971 <        txt += '            echo "JOB_EXIT_STATUS = 50114"\n'
972 <        txt += '            echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n'
973 <        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
974 <        txt += '            rm -f $RUNTIME_AREA/$repo \n'
975 <        txt += '            echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
976 <        txt += '            echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
977 <        txt += '        fi\n'
978 <        txt += '    fi \n'
979 <        txt += "    exit 1\n"
841 >        txt += "    echo 'ERROR ==> Too few arguments' +$nargs+ \n"
842 >        txt += '    job_exit_code=50113\n'
843 >        txt += "    func_exit\n"
844          txt += "fi\n"
845          txt += "\n"
846  
847          # Prepare job-specific part
848          job = common.job_list[nj]
849          ### FEDE FOR DBS OUTPUT PUBLICATION
850 <        if (self.datasetPath):
850 >        if (self.datasetPath):
851              txt += '\n'
852              txt += 'DatasetPath='+self.datasetPath+'\n'
853  
854              datasetpath_split = self.datasetPath.split("/")
855 <            
855 >
856              txt += 'PrimaryDataset='+datasetpath_split[1]+'\n'
857              txt += 'DataTier='+datasetpath_split[2]+'\n'
994            #txt += 'ProcessedDataset='+datasetpath_split[3]+'\n'
858              txt += 'ApplicationFamily=cmsRun\n'
859  
860          else:
861              txt += 'DatasetPath=MCDataTier\n'
862              txt += 'PrimaryDataset=null\n'
863              txt += 'DataTier=null\n'
1001            #txt += 'ProcessedDataset=null\n'
864              txt += 'ApplicationFamily=MCDataTier\n'
865 <        if self.pset != None: #CarlosDaniele
865 >        if self.pset != None:
866              pset = os.path.basename(job.configFilename())
867              txt += '\n'
868              txt += 'cp  $RUNTIME_AREA/'+pset+' .\n'
869              if (self.datasetPath): # standard job
870 <                #txt += 'InputFiles=$2\n'
871 <                txt += 'InputFiles=${args[1]}\n'
872 <                txt += 'MaxEvents=${args[2]}\n'
1011 <                txt += 'SkipEvents=${args[3]}\n'
870 >                txt += 'InputFiles=${args[1]}; export InputFiles\n'
871 >                txt += 'MaxEvents=${args[2]}; export MaxEvents\n'
872 >                txt += 'SkipEvents=${args[3]}; export SkipEvents\n'
873                  txt += 'echo "Inputfiles:<$InputFiles>"\n'
1013                txt += 'sed "s#{\'INPUT\'}#$InputFiles#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
874                  txt += 'echo "MaxEvents:<$MaxEvents>"\n'
1015                txt += 'sed "s#INPUTMAXEVENTS#$MaxEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
875                  txt += 'echo "SkipEvents:<$SkipEvents>"\n'
1017                txt += 'sed "s#INPUTSKIPEVENTS#$SkipEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
876              else:  # pythia like job
877 <                seedIndex=1
877 >                txt += 'PreserveSeeds='  + ','.join(self.preserveSeeds)  + '; export PreserveSeeds\n'
878 >                txt += 'IncrementSeeds=' + ','.join(self.incrementSeeds) + '; export IncrementSeeds\n'
879 >                txt += 'echo "PreserveSeeds: <$PreserveSeeds>"\n'
880 >                txt += 'echo "IncrementSeeds:<$IncrementSeeds>"\n'
881                  if (self.firstRun):
882 <                    txt += 'FirstRun=${args['+str(seedIndex)+']}\n'
882 >                    txt += 'FirstRun=${args[1]}; export FirstRun\n'
883                      txt += 'echo "FirstRun: <$FirstRun>"\n'
1023                    txt += 'sed "s#\<INPUTFIRSTRUN\>#$FirstRun#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
1024                    seedIndex=seedIndex+1
884  
885 <                if (self.sourceSeed):
1027 <                    txt += 'Seed=${args['+str(seedIndex)+']}\n'
1028 <                    txt += 'sed "s#\<INPUT\>#$Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
1029 <                    seedIndex=seedIndex+1
1030 <                    ## the following seeds are not always present
1031 <                    if (self.sourceSeedVtx):
1032 <                        txt += 'VtxSeed=${args['+str(seedIndex)+']}\n'
1033 <                        txt += 'echo "VtxSeed: <$VtxSeed>"\n'
1034 <                        txt += 'sed "s#\<INPUTVTX\>#$VtxSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
1035 <                        seedIndex += 1
1036 <                    if (self.sourceSeedG4):
1037 <                        txt += 'G4Seed=${args['+str(seedIndex)+']}\n'
1038 <                        txt += 'echo "G4Seed: <$G4Seed>"\n'
1039 <                        txt += 'sed "s#\<INPUTG4\>#$G4Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
1040 <                        seedIndex += 1
1041 <                    if (self.sourceSeedMix):
1042 <                        txt += 'mixSeed=${args['+str(seedIndex)+']}\n'
1043 <                        txt += 'echo "MixSeed: <$mixSeed>"\n'
1044 <                        txt += 'sed "s#\<INPUTMIX\>#$mixSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
1045 <                        seedIndex += 1
1046 <                    pass
1047 <                pass
1048 <            txt += 'mv -f '+pset+' pset.cfg\n'
885 >            txt += 'mv -f ' + pset + ' ' + psetName + '\n'
886  
1050        if len(self.additional_inbox_files) > 0:
1051            txt += 'if [ -e $RUNTIME_AREA/'+self.additional_tgz_name+' ] ; then\n'
1052            txt += '  tar xzvf $RUNTIME_AREA/'+self.additional_tgz_name+'\n'
1053            txt += 'fi\n'
1054            pass
887  
888 <        if self.pset != None: #CarlosDaniele
889 <            txt += 'echo "### END JOB SETUP ENVIRONMENT ###"\n\n'
1058 <        
888 >        if self.pset != None:
889 >            # FUTURE: Can simply for 2_1_x and higher
890              txt += '\n'
891 <            txt += 'echo "***** cat pset.cfg *********"\n'
892 <            txt += 'cat pset.cfg\n'
893 <            txt += 'echo "****** end pset.cfg ********"\n'
891 >            txt += 'echo "***** cat ' + psetName + ' *********"\n'
892 >            txt += 'cat ' + psetName + '\n'
893 >            txt += 'echo "****** end ' + psetName + ' ********"\n'
894              txt += '\n'
895 <            ### FEDE FOR DBS OUTPUT PUBLICATION
1065 <            txt += 'PSETHASH=`EdmConfigHash < pset.cfg` \n'
895 >            txt += 'PSETHASH=`edmConfigHash < ' + psetName + '` \n'
896              txt += 'echo "PSETHASH = $PSETHASH" \n'
1067            ##############
897              txt += '\n'
1069            # txt += 'echo "***** cat pset1.cfg *********"\n'
1070            # txt += 'cat pset1.cfg\n'
1071            # txt += 'echo "****** end pset1.cfg ********"\n'
898          return txt
899  
900 <    def wsBuildExe(self, nj=0):
900 >    def wsUntarSoftware(self, nj=0):
901          """
902          Put in the script the commands to build an executable
903          or a library.
904          """
905  
906 <        txt = ""
906 >        txt = '\n#Written by cms_cmssw::wsUntarSoftware\n'
907  
908          if os.path.isfile(self.tgzNameWithPath):
909 <            txt += 'echo "tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'"\n'
909 >            txt += 'echo ">>> tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+' :" \n'
910              txt += 'tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n'
911 +            txt += 'ls -Al \n'
912              txt += 'untar_status=$? \n'
913              txt += 'if [ $untar_status -ne 0 ]; then \n'
914 <            txt += '   echo "SET_EXE 1 ==> ERROR Untarring .tgz file failed"\n'
915 <            txt += '   echo "JOB_EXIT_STATUS = $untar_status" \n'
916 <            txt += '   echo "JobExitCode=$untar_status" | tee -a $RUNTIME_AREA/$repo\n'
1090 <            txt += '   if [ $middleware == OSG ]; then \n'
1091 <            txt += '       echo "Remove working directory: $WORKING_DIR"\n'
1092 <            txt += '       cd $RUNTIME_AREA\n'
1093 <            txt += '       /bin/rm -rf $WORKING_DIR\n'
1094 <            txt += '       if [ -d $WORKING_DIR ] ;then\n'
1095 <            txt += '           echo "SET_EXE 50999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Untarring .tgz file failed"\n'
1096 <            txt += '           echo "JOB_EXIT_STATUS = 50999"\n'
1097 <            txt += '           echo "JobExitCode=50999" | tee -a $RUNTIME_AREA/$repo\n'
1098 <            txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1099 <            txt += '           rm -f $RUNTIME_AREA/$repo \n'
1100 <            txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1101 <            txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1102 <            txt += '       fi\n'
1103 <            txt += '   fi \n'
1104 <            txt += '   \n'
1105 <            txt += '   exit 1 \n'
914 >            txt += '   echo "ERROR ==> Untarring .tgz file failed"\n'
915 >            txt += '   job_exit_code=$untar_status\n'
916 >            txt += '   func_exit\n'
917              txt += 'else \n'
918              txt += '   echo "Successful untar" \n'
919              txt += 'fi \n'
920              txt += '\n'
921 <            txt += 'echo "Include ProdAgentApi and PRODCOMMON in PYTHONPATH"\n'
921 >            txt += 'echo ">>> Include ProdCommon in PYTHONPATH:"\n'
922              txt += 'if [ -z "$PYTHONPATH" ]; then\n'
923 <            #### FEDE FOR DBS OUTPUT PUBLICATION
1113 <            txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdAgentApi:$SOFTWARE_DIR/ProdCommon\n'
1114 <            #txt += '   export PYTHONPATH=`pwd`/ProdAgentApi:`pwd`/ProdCommon\n'
1115 <            #txt += '   export PYTHONPATH=ProdAgentApi\n'
923 >            txt += '   export PYTHONPATH=$RUNTIME_AREA/ProdCommon\n'
924              txt += 'else\n'
925 <            txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdAgentApi:$SOFTWARE_DIR/ProdCommon:${PYTHONPATH}\n'
1118 <            #txt += '   export PYTHONPATH=`pwd`/ProdAgentApi:`pwd`/ProdCommon:${PYTHONPATH}\n'
1119 <            #txt += '   export PYTHONPATH=ProdAgentApi:${PYTHONPATH}\n'
925 >            txt += '   export PYTHONPATH=$RUNTIME_AREA/ProdCommon:${PYTHONPATH}\n'
926              txt += 'echo "PYTHONPATH=$PYTHONPATH"\n'
1121            ###################  
927              txt += 'fi\n'
928              txt += '\n'
929  
930              pass
931 <        
931 >
932 >        return txt
933 >
934 >    def wsBuildExe(self, nj=0):
935 >        """
936 >        Put in the script the commands to build an executable
937 >        or a library.
938 >        """
939 >
940 >        txt = '\n#Written by cms_cmssw::wsBuildExe\n'
941 >        txt += 'echo ">>> moving CMSSW software directories in `pwd`" \n'
942 >
943 >        txt += 'rm -r lib/ module/ \n'
944 >        txt += 'mv $RUNTIME_AREA/lib/ . \n'
945 >        txt += 'mv $RUNTIME_AREA/module/ . \n'
946 >        if self.dataExist == True: txt += 'mv $RUNTIME_AREA/src/ . \n'
947 >        if len(self.additional_inbox_files)>0:
948 >            for file in self.additional_inbox_files:
949 >                txt += 'mv $RUNTIME_AREA/'+file+' . \n'
950 >        txt += 'mv $RUNTIME_AREA/ProdCommon/ . \n'
951 >
952 >        txt += 'if [ -z "$PYTHONPATH" ]; then\n'
953 >        txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdCommon\n'
954 >        txt += 'else\n'
955 >        txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdCommon:${PYTHONPATH}\n'
956 >        txt += 'echo "PYTHONPATH=$PYTHONPATH"\n'
957 >        txt += 'fi\n'
958 >        txt += '\n'
959 >
960          return txt
961  
962      def modifySteeringCards(self, nj):
963          """
964 <        modify the card provided by the user,
964 >        modify the card provided by the user,
965          writing a new card into share dir
966          """
967 <        
967 >
968      def executableName(self):
969          if self.scriptExe: #CarlosDaniele
970              return "sh "
# Line 1139 | Line 972 | class Cmssw(JobType):
972              return self.executable
973  
974      def executableArgs(self):
975 +        # FUTURE: This function tests the CMSSW version. Can be simplified as we drop support for old versions
976          if self.scriptExe:#CarlosDaniele
977              return   self.scriptExe + " $NJob"
978          else:
979 <            # if >= CMSSW_1_5_X, add -e
980 <            version_array = self.scram.getSWVersion().split('_')
981 <            major = 0
982 <            minor = 0
983 <            try:
984 <                major = int(version_array[1])
985 <                minor = int(version_array[2])
986 <            except:
1153 <                msg = "Cannot parse CMSSW version string: " + "_".join(version_array) + " for major and minor release number!"  
1154 <                raise CrabException(msg)
1155 <            if major >= 1 and minor >= 5 :
1156 <                return " -e -p pset.cfg"
979 >            ex_args = ""
980 >            # FUTURE: This tests the CMSSW version. Can remove code as versions deprecated
981 >            # Framework job report
982 >            if (self.CMSSW_major >= 1 and self.CMSSW_minor >= 5) or (self.CMSSW_major >= 2):
983 >                ex_args += " -j $RUNTIME_AREA/crab_fjr_$NJob.xml"
984 >            # Type of config file
985 >            if self.CMSSW_major >= 2 :
986 >                ex_args += " -p pset.py"
987              else:
988 <                return " -p pset.cfg"
988 >                ex_args += " -p pset.cfg"
989 >            return ex_args
990  
991      def inputSandbox(self, nj):
992          """
# Line 1167 | Line 998 | class Cmssw(JobType):
998          ## code
999          if os.path.isfile(self.tgzNameWithPath):
1000              inp_box.append(self.tgzNameWithPath)
1001 <        if os.path.isfile(self.MLtgzfile):
1002 <            inp_box.append(self.MLtgzfile)
1172 <        ## config
1173 <        if not self.pset is None:
1174 <            inp_box.append(common.work_space.pathForTgz() + 'job/' + self.configFilename())
1175 <        ## additional input files
1176 <        tgz = self.additionalInputFileTgz()
1177 <        inp_box.append(tgz)
1001 >        wrapper = os.path.basename(str(common._db.queryTask('scriptName')))
1002 >        inp_box.append(common.work_space.pathForTgz() +'job/'+ wrapper)
1003          return inp_box
1004  
1005      def outputSandbox(self, nj):
# Line 1185 | Line 1010 | class Cmssw(JobType):
1010  
1011          ## User Declared output files
1012          for out in (self.output_file+self.output_file_sandbox):
1013 <            n_out = nj + 1
1013 >            n_out = nj + 1
1014              out_box.append(self.numberFile_(out,str(n_out)))
1015          return out_box
1016  
# Line 1200 | Line 1025 | class Cmssw(JobType):
1025          Returns part of a job script which renames the produced files.
1026          """
1027  
1028 <        txt = '\n'
1029 <        txt += '# directory content\n'
1028 >        txt = '\n#Written by cms_cmssw::wsRenameOutput\n'
1029 >        txt += 'echo ">>> current directory (SOFTWARE_DIR): $SOFTWARE_DIR" \n'
1030 >        txt += 'echo ">>> current directory content:"\n'
1031          txt += 'ls \n'
1032 +        txt += '\n'
1033  
1207        txt += 'output_exit_status=0\n'
1208        
1209        for fileWithSuffix in (self.output_file_sandbox):
1210            output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1211            txt += '\n'
1212            txt += '# check output file\n'
1213            txt += 'if [ -e ./'+fileWithSuffix+' ] ; then\n'
1214            txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA\n'
1215            txt += '    cp $RUNTIME_AREA/'+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1216            txt += 'else\n'
1217            txt += '    exit_status=60302\n'
1218            txt += '    echo "ERROR: Problem with output file '+fileWithSuffix+'"\n'
1219            if common.scheduler.boss_scheduler_name == 'condor_g':
1220                txt += '    if [ $middleware == OSG ]; then \n'
1221                txt += '        echo "prepare dummy output file"\n'
1222                txt += '        echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n'
1223                txt += '    fi \n'
1224            txt += 'fi\n'
1225        
1034          for fileWithSuffix in (self.output_file):
1035              output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1036              txt += '\n'
1037              txt += '# check output file\n'
1038              txt += 'if [ -e ./'+fileWithSuffix+' ] ; then\n'
1039 <            txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA\n'
1040 <            txt += '    cp $RUNTIME_AREA/'+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1039 >            if (self.copy_data == 1):  # For OSG nodes, file is in $WORKING_DIR, should not be moved to $RUNTIME_AREA
1040 >                txt += '    mv '+fileWithSuffix+' '+output_file_num+'\n'
1041 >                txt += '    ln -s `pwd`/'+output_file_num+' $RUNTIME_AREA/'+fileWithSuffix+'\n'
1042 >            else:
1043 >                txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1044 >                txt += '    ln -s $RUNTIME_AREA/'+output_file_num+' $RUNTIME_AREA/'+fileWithSuffix+'\n'
1045              txt += 'else\n'
1046 <            txt += '    exit_status=60302\n'
1047 <            txt += '    echo "ERROR: Problem with output file '+fileWithSuffix+'"\n'
1048 <            txt += '    echo "JOB_EXIT_STATUS = $exit_status"\n'
1237 <            txt += '    output_exit_status=$exit_status\n'
1238 <            if common.scheduler.boss_scheduler_name == 'condor_g':
1046 >            txt += '    job_exit_code=60302\n'
1047 >            txt += '    echo "WARNING: Output file '+fileWithSuffix+' not found"\n'
1048 >            if common.scheduler.name().upper() == 'CONDOR_G':
1049                  txt += '    if [ $middleware == OSG ]; then \n'
1050                  txt += '        echo "prepare dummy output file"\n'
1051                  txt += '        echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n'
# Line 1244 | Line 1054 | class Cmssw(JobType):
1054          file_list = []
1055          for fileWithSuffix in (self.output_file):
1056               file_list.append(self.numberFile_(fileWithSuffix, '$NJob'))
1057 <            
1057 >
1058          txt += 'file_list="'+string.join(file_list,' ')+'"\n'
1059 +        txt += '\n'
1060 +        txt += 'echo ">>> current directory (SOFTWARE_DIR): $SOFTWARE_DIR" \n'
1061 +        txt += 'echo ">>> current directory content:"\n'
1062 +        txt += 'ls \n'
1063 +        txt += '\n'
1064          txt += 'cd $RUNTIME_AREA\n'
1065 +        txt += 'echo ">>> current directory (RUNTIME_AREA):  $RUNTIME_AREA"\n'
1066          return txt
1067  
1068      def numberFile_(self, file, txt):
# Line 1264 | Line 1080 | class Cmssw(JobType):
1080              result = name + '_' + txt + "." + ext
1081          else:
1082              result = name + '_' + txt
1083 <        
1083 >
1084          return result
1085  
1086      def getRequirements(self, nj=[]):
1087          """
1088 <        return job requirements to add to jdl files
1088 >        return job requirements to add to jdl files
1089          """
1090          req = ''
1091          if self.version:
# Line 1284 | Line 1100 | class Cmssw(JobType):
1100                   '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
1101  
1102          req = req + ' && (other.GlueHostNetworkAdapterOutboundIP)'
1103 +        if common.scheduler.name() == "glitecoll":
1104 +            req += ' && other.GlueCEStateStatus == "Production" '
1105  
1106          return req
1107  
1108      def configFilename(self):
1109          """ return the config filename """
1110 <        return self.name()+'.cfg'
1110 >        # FUTURE: Can remove cfg mode for CMSSW >= 2_1_x
1111 >        if (self.CMSSW_major >= 2 and self.CMSSW_minor >= 1) or (self.CMSSW_major >= 3):
1112 >          return self.name()+'.py'
1113 >        else:
1114 >          return self.name()+'.cfg'
1115  
1294    ### OLI_DANIELE
1116      def wsSetupCMSOSGEnvironment_(self):
1117          """
1118          Returns part of a job script which is prepares
1119          the execution environment and which is common for all CMS jobs.
1120          """
1121 <        txt = '\n'
1122 <        txt += '   echo "### SETUP CMS OSG  ENVIRONMENT ###"\n'
1123 <        txt += '   if [ -f $GRID3_APP_DIR/cmssoft/cmsset_default.sh ] ;then\n'
1124 <        txt += '      # Use $GRID3_APP_DIR/cmssoft/cmsset_default.sh to setup cms software\n'
1125 <        txt += '       export SCRAM_ARCH='+self.executable_arch+'\n'
1126 <        txt += '       source $GRID3_APP_DIR/cmssoft/cmsset_default.sh '+self.version+'\n'
1306 <        txt += '   elif [ -f $OSG_APP/cmssoft/cms/cmsset_default.sh ] ;then\n'
1121 >        txt = '\n#Written by cms_cmssw::wsSetupCMSOSGEnvironment_\n'
1122 >        txt += '    echo ">>> setup CMS OSG environment:"\n'
1123 >        txt += '    echo "set SCRAM ARCH to ' + self.executable_arch + '"\n'
1124 >        txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
1125 >        txt += '    echo "SCRAM_ARCH = $SCRAM_ARCH"\n'
1126 >        txt += '    if [ -f $OSG_APP/cmssoft/cms/cmsset_default.sh ] ;then\n'
1127          txt += '      # Use $OSG_APP/cmssoft/cms/cmsset_default.sh to setup cms software\n'
1128 <        txt += '       export SCRAM_ARCH='+self.executable_arch+'\n'
1129 <        txt += '       source $OSG_APP/cmssoft/cms/cmsset_default.sh '+self.version+'\n'
1130 <        txt += '   else\n'
1131 <        txt += '       echo "SET_CMS_ENV 10020 ==> ERROR $GRID3_APP_DIR/cmssoft/cmsset_default.sh and $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1132 <        txt += '       echo "JOB_EXIT_STATUS = 10020"\n'
1133 <        txt += '       echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1314 <        txt += '       dumpStatus $RUNTIME_AREA/$repo\n'
1315 <        txt += '       rm -f $RUNTIME_AREA/$repo \n'
1316 <        txt += '       echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1317 <        txt += '       echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1318 <        txt += '       exit 1\n'
1319 <        txt += '\n'
1320 <        txt += '       echo "Remove working directory: $WORKING_DIR"\n'
1321 <        txt += '       cd $RUNTIME_AREA\n'
1322 <        txt += '       /bin/rm -rf $WORKING_DIR\n'
1323 <        txt += '       if [ -d $WORKING_DIR ] ;then\n'
1324 <        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/cms/cmsset_default.sh file not found"\n'
1325 <        txt += '           echo "JOB_EXIT_STATUS = 10017"\n'
1326 <        txt += '           echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n'
1327 <        txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1328 <        txt += '           rm -f $RUNTIME_AREA/$repo \n'
1329 <        txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1330 <        txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1331 <        txt += '       fi\n'
1332 <        txt += '\n'
1333 <        txt += '       exit 1\n'
1334 <        txt += '   fi\n'
1128 >        txt += '        source $OSG_APP/cmssoft/cms/cmsset_default.sh '+self.version+'\n'
1129 >        txt += '    else\n'
1130 >        txt += '        echo "ERROR ==> $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1131 >        txt += '        job_exit_code=10020\n'
1132 >        txt += '        func_exit\n'
1133 >        txt += '    fi\n'
1134          txt += '\n'
1135 <        txt += '   echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1136 <        txt += '   echo " END SETUP CMS OSG  ENVIRONMENT "\n'
1135 >        txt += '    echo "==> setup cms environment ok"\n'
1136 >        txt += '    echo "SCRAM_ARCH = $SCRAM_ARCH"\n'
1137  
1138          return txt
1139 <
1139 >
1140      ### OLI_DANIELE
1141      def wsSetupCMSLCGEnvironment_(self):
1142          """
1143          Returns part of a job script which is prepares
1144          the execution environment and which is common for all CMS jobs.
1145          """
1146 <        txt  = '   \n'
1147 <        txt += '   echo " ### SETUP CMS LCG  ENVIRONMENT ### "\n'
1148 <        txt += '   if [ ! $VO_CMS_SW_DIR ] ;then\n'
1149 <        txt += '       echo "SET_CMS_ENV 10031 ==> ERROR CMS software dir not found on WN `hostname`"\n'
1150 <        txt += '       echo "JOB_EXIT_STATUS = 10031" \n'
1151 <        txt += '       echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n'
1152 <        txt += '       dumpStatus $RUNTIME_AREA/$repo\n'
1153 <        txt += '       rm -f $RUNTIME_AREA/$repo \n'
1154 <        txt += '       echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1155 <        txt += '       echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1156 <        txt += '       exit 1\n'
1157 <        txt += '   else\n'
1158 <        txt += '       echo "Sourcing environment... "\n'
1159 <        txt += '       if [ ! -s $VO_CMS_SW_DIR/cmsset_default.sh ] ;then\n'
1160 <        txt += '           echo "SET_CMS_ENV 10020 ==> ERROR cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
1161 <        txt += '           echo "JOB_EXIT_STATUS = 10020"\n'
1162 <        txt += '           echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1163 <        txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1164 <        txt += '           rm -f $RUNTIME_AREA/$repo \n'
1165 <        txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1166 <        txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1167 <        txt += '           exit 1\n'
1168 <        txt += '       fi\n'
1169 <        txt += '       echo "sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1170 <        txt += '       source $VO_CMS_SW_DIR/cmsset_default.sh\n'
1171 <        txt += '       result=$?\n'
1172 <        txt += '       if [ $result -ne 0 ]; then\n'
1374 <        txt += '           echo "SET_CMS_ENV 10032 ==> ERROR problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1375 <        txt += '           echo "JOB_EXIT_STATUS = 10032"\n'
1376 <        txt += '           echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n'
1377 <        txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1378 <        txt += '           rm -f $RUNTIME_AREA/$repo \n'
1379 <        txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1380 <        txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1381 <        txt += '           exit 1\n'
1382 <        txt += '       fi\n'
1383 <        txt += '   fi\n'
1384 <        txt += '   \n'
1385 <        txt += '   echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1386 <        txt += '   echo "### END SETUP CMS LCG ENVIRONMENT ###"\n'
1146 >        txt = '\n#Written by cms_cmssw::wsSetupCMSLCGEnvironment_\n'
1147 >        txt += '    echo ">>> setup CMS LCG environment:"\n'
1148 >        txt += '    echo "set SCRAM ARCH and BUILD_ARCH to ' + self.executable_arch + ' ###"\n'
1149 >        txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
1150 >        txt += '    export BUILD_ARCH='+self.executable_arch+'\n'
1151 >        txt += '    if [ ! $VO_CMS_SW_DIR ] ;then\n'
1152 >        txt += '        echo "ERROR ==> CMS software dir not found on WN `hostname`"\n'
1153 >        txt += '        job_exit_code=10031\n'
1154 >        txt += '        func_exit\n'
1155 >        txt += '    else\n'
1156 >        txt += '        echo "Sourcing environment... "\n'
1157 >        txt += '        if [ ! -s $VO_CMS_SW_DIR/cmsset_default.sh ] ;then\n'
1158 >        txt += '            echo "ERROR ==> cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
1159 >        txt += '            job_exit_code=10020\n'
1160 >        txt += '            func_exit\n'
1161 >        txt += '        fi\n'
1162 >        txt += '        echo "sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1163 >        txt += '        source $VO_CMS_SW_DIR/cmsset_default.sh\n'
1164 >        txt += '        result=$?\n'
1165 >        txt += '        if [ $result -ne 0 ]; then\n'
1166 >        txt += '            echo "ERROR ==> problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1167 >        txt += '            job_exit_code=10032\n'
1168 >        txt += '            func_exit\n'
1169 >        txt += '        fi\n'
1170 >        txt += '    fi\n'
1171 >        txt += '    \n'
1172 >        txt += '    echo "==> setup cms environment ok"\n'
1173          return txt
1174  
1175 <    ### FEDE FOR DBS OUTPUT PUBLICATION
1175 >    ### FEDE FOR DBS OUTPUT PUBLICATION
1176      def modifyReport(self, nj):
1177          """
1178 <        insert the part of the script that modifies the FrameworkJob Report
1178 >        insert the part of the script that modifies the FrameworkJob Report
1179          """
1180  
1181 <        txt = ''
1182 <        try:
1183 <            publish_data = int(self.cfg_params['USER.publish_data'])          
1398 <        except KeyError:
1399 <            publish_data = 0
1400 <        if (publish_data == 1):  
1401 <            txt += 'echo "Modify Job Report" \n'
1402 <            #txt += 'chmod a+x $RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n'
1403 <            ################ FEDE FOR DBS2 #############################################
1404 <            txt += 'chmod a+x $SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n'
1405 <            #############################################################################
1406 <            #try:
1407 <            #    publish_data = int(self.cfg_params['USER.publish_data'])          
1408 <            #except KeyError:
1409 <            #    publish_data = 0
1410 <
1411 <            txt += 'if [ -z "$SE" ]; then\n'
1412 <            txt += '    SE="" \n'
1413 <            txt += 'fi \n'
1414 <            txt += 'if [ -z "$SE_PATH" ]; then\n'
1415 <            txt += '    SE_PATH="" \n'
1416 <            txt += 'fi \n'
1417 <            txt += 'echo "SE = $SE"\n'
1418 <            txt += 'echo "SE_PATH = $SE_PATH"\n'
1419 <
1420 <        #if (publish_data == 1):  
1421 <            #processedDataset = self.cfg_params['USER.processed_datasetname']
1181 >        txt = '\n#Written by cms_cmssw::modifyReport\n'
1182 >        publish_data = int(self.cfg_params.get('USER.publish_data',0))
1183 >        if (publish_data == 1):
1184              processedDataset = self.cfg_params['USER.publish_data_name']
1185 <            txt += 'ProcessedDataset='+processedDataset+'\n'
1186 <            #### LFN=/store/user/<user>/processedDataset_PSETHASH
1187 <            txt += 'if [ "$SE_PATH" == "" ]; then\n'
1188 <            #### FEDE: added slash in LFN ##############
1185 >            LFNBaseName = LFNBase(processedDataset)
1186 >
1187 >            txt += 'if [ $copy_exit_status -eq 0 ]; then\n'
1188 >            txt += '    FOR_LFN=%s_${PSETHASH}/\n'%(LFNBaseName)
1189 >            txt += 'else\n'
1190              txt += '    FOR_LFN=/copy_problems/ \n'
1191 <            txt += 'else \n'
1192 <            txt += '    tmp=`echo $SE_PATH | awk -F \'store\' \'{print$2}\'` \n'
1193 <            #####  FEDE TO BE CHANGED, BECAUSE STORE IS HARDCODED!!!! ########
1194 <            txt += '    FOR_LFN=/store$tmp \n'
1195 <            txt += 'fi \n'
1191 >            txt += '    SE=""\n'
1192 >            txt += '    SE_PATH=""\n'
1193 >            txt += 'fi\n'
1194 >
1195 >            txt += 'echo ">>> Modify Job Report:" \n'
1196 >            txt += 'chmod a+x $SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py\n'
1197 >            txt += 'ProcessedDataset='+processedDataset+'\n'
1198              txt += 'echo "ProcessedDataset = $ProcessedDataset"\n'
1199 +            txt += 'echo "SE = $SE"\n'
1200 +            txt += 'echo "SE_PATH = $SE_PATH"\n'
1201              txt += 'echo "FOR_LFN = $FOR_LFN" \n'
1202              txt += 'echo "CMSSW_VERSION = $CMSSW_VERSION"\n\n'
1203 <            #txt += 'echo "$RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n'
1204 <            txt += 'echo "$SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n'
1438 <            txt += '$SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH\n'
1439 <            #txt += '$RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH\n'
1440 <      
1203 >            txt += 'echo "$SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py $RUNTIME_AREA/crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n'
1204 >            txt += '$SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py $RUNTIME_AREA/crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH\n'
1205              txt += 'modifyReport_result=$?\n'
1442            txt += 'echo modifyReport_result = $modifyReport_result\n'
1206              txt += 'if [ $modifyReport_result -ne 0 ]; then\n'
1207 <            txt += '    exit_status=1\n'
1208 <            txt += '    echo "ERROR: Problem with ModifyJobReport"\n'
1207 >            txt += '    modifyReport_result=70500\n'
1208 >            txt += '    job_exit_code=$modifyReport_result\n'
1209 >            txt += '    echo "ModifyReportResult=$modifyReport_result" | tee -a $RUNTIME_AREA/$repo\n'
1210 >            txt += '    echo "WARNING: Problem with ModifyJobReport"\n'
1211              txt += 'else\n'
1212 <            txt += '    mv NewFrameworkJobReport.xml crab_fjr_$NJob.xml\n'
1212 >            txt += '    mv NewFrameworkJobReport.xml $RUNTIME_AREA/crab_fjr_$NJob.xml\n'
1213              txt += 'fi\n'
1449        else:
1450            txt += 'echo "no data publication required"\n'
1451            #txt += 'ProcessedDataset=no_data_to_publish \n'
1452            #### FEDE: added slash in LFN ##############
1453            #txt += 'FOR_LFN=/local/ \n'
1454            #txt += 'echo "ProcessedDataset = $ProcessedDataset"\n'
1455            #txt += 'echo "FOR_LFN = $FOR_LFN" \n'
1456        return txt
1457
1458    def cleanEnv(self):
1459        ### OLI_DANIELE
1460        txt = ''
1461        txt += 'if [ $middleware == OSG ]; then\n'  
1462        txt += '    cd $RUNTIME_AREA\n'
1463        txt += '    echo "Remove working directory: $WORKING_DIR"\n'
1464        txt += '    /bin/rm -rf $WORKING_DIR\n'
1465        txt += '    if [ -d $WORKING_DIR ] ;then\n'
1466        txt += '              echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
1467        txt += '              echo "JOB_EXIT_STATUS = 60999"\n'
1468        txt += '              echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
1469        txt += '              dumpStatus $RUNTIME_AREA/$repo\n'
1470        txt += '        rm -f $RUNTIME_AREA/$repo \n'
1471        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1472        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1473        txt += '    fi\n'
1474        txt += 'fi\n'
1475        txt += '\n'
1214          return txt
1215  
1216      def setParam_(self, param, value):
# Line 1481 | Line 1219 | class Cmssw(JobType):
1219      def getParams(self):
1220          return self._params
1221  
1484    def setTaskid_(self):
1485        self._taskId = self.cfg_params['taskId']
1486        
1487    def getTaskid(self):
1488        return self._taskId
1489
1222      def uniquelist(self, old):
1223          """
1224          remove duplicates from a list
# Line 1496 | Line 1228 | class Cmssw(JobType):
1228              nd[e]=0
1229          return nd.keys()
1230  
1231 <
1500 <    def checkOut(self, limit):
1231 >    def outList(self):
1232          """
1233          check the dimension of the output files
1234          """
1235 <        txt = 'echo "*****************************************"\n'
1236 <        txt += 'echo "** Starting output sandbox limit check **"\n'
1506 <        txt += 'echo "*****************************************"\n'
1507 <        allOutFiles = ""
1235 >        txt = ''
1236 >        txt += 'echo ">>> list of expected files on output sandbox"\n'
1237          listOutFiles = []
1238 <        for fileOut in (self.output_file+self.output_file_sandbox):
1239 <             if fileOut.find('crab_fjr') == -1:
1240 <                 allOutFiles = allOutFiles + " " + self.numberFile_(fileOut, '$NJob')
1241 <                 listOutFiles.append(self.numberFile_(fileOut, '$NJob'))
1242 <        txt += 'echo "OUTPUT files: '+str(allOutFiles)+'";\n'
1243 <        txt += 'ls -gGhrta;\n'
1244 <        txt += 'sum=0;\n'
1245 <        txt += 'for file in '+str(allOutFiles)+' ; do\n'
1246 <        txt += '    if [ -e $file ]; then\n'
1247 <        txt += '        tt=`ls -gGrta $file | awk \'{ print $3 }\'`\n'
1248 <        txt += '        sum=`expr $sum + $tt`\n'
1249 <        txt += '    else\n'
1250 <        txt += '        echo "WARNING: output file $file not found!"\n'
1251 <        txt += '    fi\n'
1252 <        txt += 'done\n'
1524 <        txt += 'echo "Total Output dimension: $sum";\n'
1525 <        txt += 'limit='+str(limit)+';\n'
1526 <        txt += 'echo "OUTPUT FILES LIMIT SET TO: $limit";\n'
1527 <        txt += 'if [ $limit -lt $sum ]; then\n'
1528 <        txt += '    echo "WARNING: output files have to big size - something will be lost;"\n'
1529 <        txt += '    echo "         checking the output file sizes..."\n'
1530 <        """
1531 <        txt += '    dim=0;\n'
1532 <        txt += '    exclude=0;\n'
1533 <        txt += '    for files in '+str(allOutFiles)+' ; do\n'
1534 <        txt += '        sumTemp=0;\n'
1535 <        txt += '        for file2 in '+str(allOutFiles)+' ; do\n'
1536 <        txt += '            if [ $file != $file2 ]; then\n'
1537 <        txt += '                tt=`ls -gGrta $file2 | awk \'{ print $3 }\';`\n'
1538 <        txt += '                sumTemp=`expr $sumTemp + $tt`;\n'
1539 <        txt += '            fi\n'
1540 <        txt += '        done\n'
1541 <        txt += '        if [ $sumTemp -lt $limit ]; then\n'
1542 <        txt += '            if [ $dim -lt $sumTemp ]; then\n'
1543 <        txt += '                dim=$sumTemp;\n'
1544 <        txt += '                exclude=$file;\n'
1545 <        txt += '            fi\n'
1546 <        txt += '        fi\n'
1547 <        txt += '    done\n'
1548 <        txt += '    echo "Dimension calculated: $dim"; echo "File to exclude: $exclude";\n'
1549 <        """
1550 <        txt += '    tot=0;\n'
1551 <        txt += '    for file2 in '+str(allOutFiles)+' ; do\n'
1552 <        txt += '        tt=`ls -gGrta $file2 | awk \'{ print $3 }\';`\n'
1553 <        txt += '        tot=`expr $tot + $tt`;\n'
1554 <        txt += '        if [ $limit -lt $tot ]; then\n'
1555 <        txt += '            tot=`expr $tot - $tt`;\n'
1556 <        txt += '            fileLast=$file;\n'
1557 <        txt += '            break;\n'
1558 <        txt += '        fi\n'
1559 <        txt += '    done\n'
1560 <        txt += '    echo "Dimension calculated: $tot"; echo "First file to exclude: $file";\n'
1561 <        txt += '    flag=0;\n'    
1562 <        txt += '    for filess in '+str(allOutFiles)+' ; do\n'
1563 <        txt += '        if [ $fileLast = $filess ]; then\n'
1564 <        txt += '            flag=1;\n'
1565 <        txt += '        fi\n'
1566 <        txt += '        if [ $flag -eq 1 ]; then\n'
1567 <        txt += '            rm -f $filess;\n'
1568 <        txt += '        fi\n'
1569 <        txt += '    done\n'
1570 <        txt += '    ls -agGhrt;\n'
1571 <        txt += '    echo "WARNING: output files are too big in dimension: can not put in the output_sandbox.";\n'
1572 <        txt += '    echo "JOB_EXIT_STATUS = 70000";\n'
1573 <        txt += '    exit_status=70000;\n'
1574 <        txt += 'else'
1575 <        txt += '    echo "Total Output dimension $sum is fine.";\n'
1576 <        txt += 'fi\n'
1577 <        txt += 'echo "*****************************************"\n'
1578 <        txt += 'echo "*** Ending output sandbox limit check ***"\n'
1579 <        txt += 'echo "*****************************************"\n'
1238 >        stdout = 'CMSSW_$NJob.stdout'
1239 >        stderr = 'CMSSW_$NJob.stderr'
1240 >        if (self.return_data == 1):
1241 >            for file in (self.output_file+self.output_file_sandbox):
1242 >                listOutFiles.append(self.numberFile_(file, '$NJob'))
1243 >            listOutFiles.append(stdout)
1244 >            listOutFiles.append(stderr)
1245 >        else:
1246 >            for file in (self.output_file_sandbox):
1247 >                listOutFiles.append(self.numberFile_(file, '$NJob'))
1248 >            listOutFiles.append(stdout)
1249 >            listOutFiles.append(stderr)
1250 >        txt += 'echo "output files: '+string.join(listOutFiles,' ')+'"\n'
1251 >        txt += 'filesToCheck="'+string.join(listOutFiles,' ')+'"\n'
1252 >        txt += 'export filesToCheck\n'
1253          return txt

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines