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.155 by slacapra, Tue Feb 12 15:20:47 2008 UTC vs.
Revision 1.264 by slacapra, Tue Dec 16 14:23:07 2008 UTC

# Line 2 | Line 2 | from JobType import JobType
2   from crab_logger import Logger
3   from crab_exceptions import *
4   from crab_util import *
5 < from BlackWhiteListParser import BlackWhiteListParser
5 > from WMCore.SiteScreening.BlackWhiteListParser import SEBlackWhiteListParser
6   import common
7   import Scram
8  
9   import os, string, glob
10  
11   class Cmssw(JobType):
12 <    def __init__(self, cfg_params, ncjobs):
12 >    def __init__(self, cfg_params, ncjobs,skip_blocks, isNew):
13          JobType.__init__(self, 'CMSSW')
14          common.logger.debug(3,'CMSSW::__init__')
15 <
15 >        self.skip_blocks = skip_blocks
16          self.argsList = []
17  
18          self._params = {}
19          self.cfg_params = cfg_params
20        # init BlackWhiteListParser
21        self.blackWhiteListParser = BlackWhiteListParser(cfg_params)
20  
21 <        self.MaxTarBallSize = float(self.cfg_params.get('EDG.maxtarballsize',9.5))
21 >        # init BlackWhiteListParser
22 >        seWhiteList = cfg_params.get('EDG.se_white_list',[])
23 >        seBlackList = cfg_params.get('EDG.se_black_list',[])
24 >        self.blackWhiteListParser = SEBlackWhiteListParser(seWhiteList, seBlackList, common.logger)
25 >
26 >        ### Temporary patch to automatically skip the ISB size check:
27 >        server=self.cfg_params.get('CRAB.server_name',None)
28 >        size = 9.5
29 >        if server or common.scheduler.name().upper() in ['LSF','CAF']: size = 99999
30 >        ### D.S.
31 >        self.MaxTarBallSize = float(self.cfg_params.get('EDG.maxtarballsize',size))
32  
33          # number of jobs requested to be created, limit obj splitting
34          self.ncjobs = ncjobs
# Line 33 | Line 41 | class Cmssw(JobType):
41          self.executable = ''
42          self.executable_arch = self.scram.getArch()
43          self.tgz_name = 'default.tgz'
36        self.additional_tgz_name = 'additional.tgz'
44          self.scriptName = 'CMSSW.sh'
45 <        self.pset = ''      #scrip use case Da
46 <        self.datasetPath = '' #scrip use case Da
45 >        self.pset = ''
46 >        self.datasetPath = ''
47  
48          # set FJR file name
49          self.fjrFileName = 'crab_fjr.xml'
50  
51          self.version = self.scram.getSWVersion()
52 <
53 <        #
54 <        # Try to block creation in case of arch/version mismatch
55 <        #
56 <
57 <        a = string.split(self.version, "_")
58 <
59 <        if int(a[1]) == 1 and (int(a[2]) < 5 and self.executable_arch.find('slc4') == 0):
60 <            msg = "Warning: You are using %s version of CMSSW  with %s architecture. \n--> Did you compile your libraries with SLC3? Otherwise you can find some problems running on SLC4 Grid nodes.\n"%(self.version, self.executable_arch)
61 <            common.logger.message(msg)
55 <        if int(a[1]) == 1 and (int(a[2]) >= 5 and self.executable_arch.find('slc3') == 0):
56 <            msg = "Error: CMS does not support %s with %s architecture"%(self.version, self.executable_arch)
52 >        version_array = self.version.split('_')
53 >        self.CMSSW_major = 0
54 >        self.CMSSW_minor = 0
55 >        self.CMSSW_patch = 0
56 >        try:
57 >            self.CMSSW_major = int(version_array[1])
58 >            self.CMSSW_minor = int(version_array[2])
59 >            self.CMSSW_patch = int(version_array[3])
60 >        except:
61 >            msg = "Cannot parse CMSSW version string: " + self.version + " for major and minor release number!"
62              raise CrabException(msg)
63  
59        common.taskDB.setDict('codeVersion',self.version)
60        self.setParam_('application', self.version)
61
64          ### collect Data cards
65  
66          if not cfg_params.has_key('CMSSW.datasetpath'):
67              msg = "Error: datasetpath not defined "
68              raise CrabException(msg)
69 +
70 +        ### Temporary: added to remove input file control in the case of PU
71 +        self.dataset_pu = cfg_params.get('CMSSW.dataset_pu', None)
72 +
73          tmp =  cfg_params['CMSSW.datasetpath']
74          log.debug(6, "CMSSW::CMSSW(): datasetPath = "+tmp)
75 <        if string.lower(tmp)=='none':
75 >
76 >        if tmp =='':
77 >            msg = "Error: datasetpath not defined "
78 >            raise CrabException(msg)
79 >        elif string.lower(tmp)=='none':
80              self.datasetPath = None
81              self.selectNoInput = 1
82          else:
83              self.datasetPath = tmp
84              self.selectNoInput = 0
85  
76        # ML monitoring
77        # split dataset path style: /PreProdR3Minbias/SIM/GEN-SIM
78        if not self.datasetPath:
79            self.setParam_('dataset', 'None')
80            self.setParam_('owner', 'None')
81        else:
82            ## SL what is supposed to fail here?
83            try:
84                datasetpath_split = self.datasetPath.split("/")
85                # standard style
86                self.setParam_('datasetFull', self.datasetPath)
87                self.setParam_('dataset', datasetpath_split[1])
88                self.setParam_('owner', datasetpath_split[2])
89            except:
90                self.setParam_('dataset', self.datasetPath)
91                self.setParam_('owner', self.datasetPath)
92
93        self.setParam_('taskId', common.taskDB.dict('taskId'))
94
86          self.dataTiers = []
87 <
87 >        self.debugWrap = ''
88 >        self.debug_wrapper = cfg_params.get('USER.debug_wrapper',False)
89 >        if self.debug_wrapper: self.debugWrap='--debug'
90          ## now the application
91 +        self.managedGenerators = ['madgraph','comphep']
92 +        self.generator = cfg_params.get('CMSSW.generator','pythia').lower()
93          self.executable = cfg_params.get('CMSSW.executable','cmsRun')
99        self.setParam_('exe', self.executable)
94          log.debug(6, "CMSSW::CMSSW(): executable = "+self.executable)
95  
96          if not cfg_params.has_key('CMSSW.pset'):
# Line 117 | Line 111 | class Cmssw(JobType):
111          self.output_file_sandbox.append(self.fjrFileName)
112  
113          # other output files to be returned via sandbox or copied to SE
114 +        outfileflag = False
115          self.output_file = []
116          tmp = cfg_params.get('CMSSW.output_file',None)
117          if tmp :
118 <            tmpOutFiles = string.split(tmp,',')
119 <            log.debug(7, 'cmssw::cmssw(): output files '+str(tmpOutFiles))
120 <            for tmp in tmpOutFiles:
121 <                tmp=string.strip(tmp)
127 <                self.output_file.append(tmp)
128 <                pass
129 <        else:
130 <            log.message("No output file defined: only stdout/err and the CRAB Framework Job Report will be available\n")
131 <        pass
118 >            self.output_file = [x.strip() for x in tmp.split(',')]
119 >            outfileflag = True #output found
120 >        #else:
121 >        #    log.message("No output file defined: only stdout/err and the CRAB Framework Job Report will be available\n")
122  
123          # script_exe file as additional file in inputSandbox
124          self.scriptExe = cfg_params.get('USER.script_exe',None)
125          if self.scriptExe :
126 <           if not os.path.isfile(self.scriptExe):
127 <              msg ="ERROR. file "+self.scriptExe+" not found"
128 <              raise CrabException(msg)
129 <           self.additional_inbox_files.append(string.strip(self.scriptExe))
126 >            if not os.path.isfile(self.scriptExe):
127 >                msg ="ERROR. file "+self.scriptExe+" not found"
128 >                raise CrabException(msg)
129 >            self.additional_inbox_files.append(string.strip(self.scriptExe))
130  
141        #CarlosDaniele
131          if self.datasetPath == None and self.pset == None and self.scriptExe == '' :
132 <           msg ="Error. script_exe  not defined"
133 <           raise CrabException(msg)
132 >            msg ="Error. script_exe  not defined"
133 >            raise CrabException(msg)
134 >
135 >        # use parent files...
136 >        self.useParent = self.cfg_params.get('CMSSW.use_parent',False)
137  
138          ## additional input files
139          if cfg_params.has_key('USER.additional_input_files'):
# Line 161 | Line 153 | class Cmssw(JobType):
153                      if not os.path.exists(file):
154                          raise CrabException("Additional input file not found: "+file)
155                      pass
164                    # fname = string.split(file, '/')[-1]
165                    # storedFile = common.work_space.pathForTgz()+'share/'+fname
166                    # shutil.copyfile(file, storedFile)
156                      self.additional_inbox_files.append(string.strip(file))
157                  pass
158              pass
# Line 189 | Line 178 | class Cmssw(JobType):
178          if cfg_params.has_key('CMSSW.total_number_of_events'):
179              self.total_number_of_events = int(cfg_params['CMSSW.total_number_of_events'])
180              self.selectTotalNumberEvents = 1
181 +            if self.selectNumberOfJobs  == 1:
182 +                if (self.total_number_of_events != -1) and int(self.total_number_of_events) < int(self.theNumberOfJobs):
183 +                    msg = 'Must specify at least one event per job. total_number_of_events > number_of_jobs '
184 +                    raise CrabException(msg)
185          else:
186              self.total_number_of_events = 0
187              self.selectTotalNumberEvents = 0
188  
189 <        if self.pset != None: #CarlosDaniele
189 >        if self.pset != None:
190               if ( (self.selectTotalNumberEvents + self.selectEventsPerJob + self.selectNumberOfJobs) != 2 ):
191                   msg = 'Must define exactly two of total_number_of_events, events_per_job, or number_of_jobs.'
192                   raise CrabException(msg)
# Line 202 | Line 195 | class Cmssw(JobType):
195                   msg = 'Must specify  number_of_jobs.'
196                   raise CrabException(msg)
197  
198 <        ## source seed for pythia
199 <        self.sourceSeed = cfg_params.get('CMSSW.pythia_seed',None)
198 >        ## New method of dealing with seeds
199 >        self.incrementSeeds = []
200 >        self.preserveSeeds = []
201 >        if cfg_params.has_key('CMSSW.preserve_seeds'):
202 >            tmpList = cfg_params['CMSSW.preserve_seeds'].split(',')
203 >            for tmp in tmpList:
204 >                tmp.strip()
205 >                self.preserveSeeds.append(tmp)
206 >        if cfg_params.has_key('CMSSW.increment_seeds'):
207 >            tmpList = cfg_params['CMSSW.increment_seeds'].split(',')
208 >            for tmp in tmpList:
209 >                tmp.strip()
210 >                self.incrementSeeds.append(tmp)
211  
212 +        ## FUTURE: Can remove in CRAB 2.4.0
213 +        self.sourceSeed    = cfg_params.get('CMSSW.pythia_seed',None)
214          self.sourceSeedVtx = cfg_params.get('CMSSW.vtx_seed',None)
215 <
210 <        self.sourceSeedG4 = cfg_params.get('CMSSW.g4_seed',None)
211 <
215 >        self.sourceSeedG4  = cfg_params.get('CMSSW.g4_seed',None)
216          self.sourceSeedMix = cfg_params.get('CMSSW.mix_seed',None)
217 +        if self.sourceSeed or self.sourceSeedVtx or self.sourceSeedG4 or self.sourceSeedMix:
218 +            msg = 'pythia_seed, vtx_seed, g4_seed, and mix_seed are no longer valid settings. You must use increment_seeds or preserve_seeds'
219 +            raise CrabException(msg)
220  
221          self.firstRun = cfg_params.get('CMSSW.first_run',None)
222  
216        if self.pset != None: #CarlosDaniele
217            import PsetManipulator as pp
218            PsetEdit = pp.PsetManipulator(self.pset) #Daniele Pset
219
223          # Copy/return
221
224          self.copy_data = int(cfg_params.get('USER.copy_data',0))
225          self.return_data = int(cfg_params.get('USER.return_data',0))
226  
# Line 234 | Line 236 | class Cmssw(JobType):
236              blockSites = self.DataDiscoveryAndLocation(cfg_params)
237          #DBSDLS-end
238  
237        self.tgzNameWithPath = self.getTarBall(self.executable)
238
239          ## Select Splitting
240          if self.selectNoInput:
241 <            if self.pset == None: #CarlosDaniele
241 >            if self.pset == None:
242                  self.jobSplittingForScript()
243              else:
244                  self.jobSplittingNoInput()
245 +        elif (cfg_params.get('CMSSW.noblockboundary',0)):
246 +            self.jobSplittingNoBlockBoundary(blockSites)
247          else:
248              self.jobSplittingByBlocks(blockSites)
249  
250 <        # modify Pset
251 <        if self.pset != None: #CarlosDaniele
252 <            try:
253 <                if (self.datasetPath): # standard job
254 <                    # allow to processa a fraction of events in a file
255 <                    PsetEdit.inputModule("INPUTFILE")
256 <                    PsetEdit.maxEvent(0)
257 <                    PsetEdit.skipEvent(0)
258 <                else:  # pythia like job
250 >        # modify Pset only the first time
251 >        if isNew:
252 >            if self.pset != None:
253 >                import PsetManipulator as pp
254 >                PsetEdit = pp.PsetManipulator(self.pset)
255 >                try:
256 >                    # Add FrameworkJobReport to parameter-set, set max events.
257 >                    # Reset later for data jobs by writeCFG which does all modifications
258 >                    PsetEdit.addCrabFJR(self.fjrFileName) # FUTURE: Job report addition not needed by CMSSW>1.5
259                      PsetEdit.maxEvent(self.eventsPerJob)
260 <                    if (self.firstRun):
261 <                        PsetEdit.pythiaFirstRun(0)  #First Run
262 <                    if (self.sourceSeed) :
263 <                        PsetEdit.pythiaSeed(0)
264 <                        if (self.sourceSeedVtx) :
265 <                            PsetEdit.vtxSeed(0)
266 <                        if (self.sourceSeedG4) :
267 <                            PsetEdit.g4Seed(0)
268 <                        if (self.sourceSeedMix) :
269 <                            PsetEdit.mixSeed(0)
270 <                # add FrameworkJobReport to parameter-set
271 <                PsetEdit.addCrabFJR(self.fjrFileName)
272 <                PsetEdit.psetWriter(self.configFilename())
273 <            except:
274 <                msg='Error while manipuliating ParameterSet: exiting...'
275 <                raise CrabException(msg)
260 >                    PsetEdit.psetWriter(self.configFilename())
261 >                    ## If present, add TFileService to output files
262 >                    if not int(cfg_params.get('CMSSW.skip_TFileService_output',0)):
263 >                        tfsOutput = PsetEdit.getTFileService()
264 >                        if tfsOutput:
265 >                            if tfsOutput in self.output_file:
266 >                                common.logger.debug(5,"Output from TFileService "+tfsOutput+" already in output files")
267 >                            else:
268 >                                outfileflag = True #output found
269 >                                self.output_file.append(tfsOutput)
270 >                                common.logger.message("Adding "+tfsOutput+" to output files (from TFileService)")
271 >                            pass
272 >                        pass
273 >                    ## If present and requested, add PoolOutputModule to output files
274 >                    if int(cfg_params.get('CMSSW.get_edm_output',0)):
275 >                        edmOutput = PsetEdit.getPoolOutputModule()
276 >                        if edmOutput:
277 >                            if edmOutput in self.output_file:
278 >                                common.logger.debug(5,"Output from PoolOutputModule "+edmOutput+" already in output files")
279 >                            else:
280 >                                self.output_file.append(edmOutput)
281 >                                common.logger.message("Adding "+edmOutput+" to output files (from PoolOutputModule)")
282 >                            pass
283 >                        pass
284 >                except CrabException:
285 >                    msg='Error while manipulating ParameterSet: exiting...'
286 >                    raise CrabException(msg)
287 >            ## Prepare inputSandbox TarBall (only the first time)
288 >            self.tgzNameWithPath = self.getTarBall(self.executable)
289  
290      def DataDiscoveryAndLocation(self, cfg_params):
291  
# Line 283 | Line 298 | class Cmssw(JobType):
298          ## Contact the DBS
299          common.logger.message("Contacting Data Discovery Services ...")
300          try:
301 <            self.pubdata=DataDiscovery.DataDiscovery(datasetPath, cfg_params)
301 >            self.pubdata=DataDiscovery.DataDiscovery(datasetPath, cfg_params,self.skip_blocks)
302              self.pubdata.fetchDBSInfo()
303  
304          except DataDiscovery.NotExistingDatasetError, ex :
# Line 299 | Line 314 | class Cmssw(JobType):
314          self.filesbyblock=self.pubdata.getFiles()
315          self.eventsbyblock=self.pubdata.getEventsPerBlock()
316          self.eventsbyfile=self.pubdata.getEventsPerFile()
317 +        self.parentFiles=self.pubdata.getParent()
318  
319          ## get max number of events
320 <        self.maxEvents=self.pubdata.getMaxEvents() ##  self.maxEvents used in Creator.py
320 >        self.maxEvents=self.pubdata.getMaxEvents()
321  
322          ## Contact the DLS and build a list of sites hosting the fileblocks
323          try:
324              dataloc=DataLocation.DataLocation(self.filesbyblock.keys(),cfg_params)
325              dataloc.fetchDLSInfo()
326 +
327          except DataLocation.DataLocationError , ex:
328              msg = 'ERROR ***: failed Data Location in DLS \n %s '%ex.getErrorMessage()
329              raise CrabException(msg)
330  
331  
332          sites = dataloc.getSites()
333 +        if len(sites)==0:
334 +            msg = 'ERROR ***: no location for any of the blocks of this dataset: \n %s \n'%datasetPath
335 +            msg += "Maybe the dataset is located only at T1's, where analysis jobs are not allowed\n"
336 +            msg += "Please check DataDiscovery page https://cmsweb.cern.ch/dbs_discovery/\n"
337 +            raise CrabException(msg)
338 +
339          allSites = []
340          listSites = sites.values()
341          for listSite in listSites:
# Line 325 | Line 348 | class Cmssw(JobType):
348  
349          return sites
350  
328    def setArgsList(self, argsList):
329        self.argsList = argsList
330
351      def jobSplittingByBlocks(self, blockSites):
352          """
353          Perform job splitting. Jobs run over an integer number of files
# Line 378 | Line 398 | class Cmssw(JobType):
398          else :
399              totalNumberOfJobs = self.ncjobs
400  
381
401          blocks = blockSites.keys()
402          blockCount = 0
403          # Backup variable in case self.maxEvents counted events in a non-included block
# Line 419 | Line 438 | class Cmssw(JobType):
438  
439                  # ---- Iterate over the files in the block until we've met the requested ---- #
440                  # ---- total # of events or we've gone over all the files in this block  ---- #
441 +                pString=''
442                  while ( (eventsRemaining > 0) and (fileCount < numFilesInBlock) and (jobCount < totalNumberOfJobs) ):
443                      file = files[fileCount]
444 +                    if self.useParent:
445 +                        parent = self.parentFiles[file]
446 +                        for f in parent :
447 +                            pString += '\\\"' + f + '\\\"\,'
448 +                        common.logger.debug(6, "File "+str(file)+" has the following parents: "+str(parent))
449 +                        common.logger.write("File "+str(file)+" has the following parents: "+str(parent))
450                      if newFile :
451                          try:
452                              numEventsInFile = self.eventsbyfile[file]
# Line 433 | Line 459 | class Cmssw(JobType):
459                          except KeyError:
460                              common.logger.message("File "+str(file)+" has unknown number of events: skipping")
461  
462 <
462 >                    eventsPerJobRequested = min(eventsPerJobRequested, eventsRemaining)
463                      # if less events in file remain than eventsPerJobRequested
464 <                    if ( filesEventCount - jobSkipEventCount < eventsPerJobRequested ) :
464 >                    if ( filesEventCount - jobSkipEventCount < eventsPerJobRequested):
465                          # if last file in block
466                          if ( fileCount == numFilesInBlock-1 ) :
467                              # end job using last file, use remaining events in block
468                              # close job and touch new file
469                              fullString = parString[:-2]
470 <                            list_of_lists.append([fullString,str(-1),str(jobSkipEventCount)])
470 >                            if self.useParent:
471 >                                fullParentString = pString[:-2]
472 >                                list_of_lists.append([fullString,fullParentString,str(-1),str(jobSkipEventCount)])
473 >                            else:
474 >                                list_of_lists.append([fullString,str(-1),str(jobSkipEventCount)])
475                              common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(filesEventCount - jobSkipEventCount)+" events (last file in block).")
476                              self.jobDestination.append(blockSites[block])
477                              common.logger.debug(5,"Job "+str(jobCount+1)+" Destination: "+str(self.jobDestination[jobCount]))
# Line 453 | Line 483 | class Cmssw(JobType):
483                              eventsRemaining = eventsRemaining - filesEventCount + jobSkipEventCount
484                              jobSkipEventCount = 0
485                              # reset file
486 +                            pString = ""
487                              parString = ""
488                              filesEventCount = 0
489                              newFile = 1
# Line 465 | Line 496 | class Cmssw(JobType):
496                      elif ( filesEventCount - jobSkipEventCount == eventsPerJobRequested ) :
497                          # close job and touch new file
498                          fullString = parString[:-2]
499 <                        list_of_lists.append([fullString,str(eventsPerJobRequested),str(jobSkipEventCount)])
499 >                        if self.useParent:
500 >                            fullParentString = pString[:-2]
501 >                            list_of_lists.append([fullString,fullParentString,str(eventsPerJobRequested),str(jobSkipEventCount)])
502 >                        else:
503 >                            list_of_lists.append([fullString,str(eventsPerJobRequested),str(jobSkipEventCount)])
504                          common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(eventsPerJobRequested)+" events.")
505                          self.jobDestination.append(blockSites[block])
506                          common.logger.debug(5,"Job "+str(jobCount+1)+" Destination: "+str(self.jobDestination[jobCount]))
# Line 476 | Line 511 | class Cmssw(JobType):
511                          eventsRemaining = eventsRemaining - eventsPerJobRequested
512                          jobSkipEventCount = 0
513                          # reset file
514 +                        pString = ""
515                          parString = ""
516                          filesEventCount = 0
517                          newFile = 1
# Line 485 | Line 521 | class Cmssw(JobType):
521                      else :
522                          # close job but don't touch new file
523                          fullString = parString[:-2]
524 <                        list_of_lists.append([fullString,str(eventsPerJobRequested),str(jobSkipEventCount)])
524 >                        if self.useParent:
525 >                            fullParentString = pString[:-2]
526 >                            list_of_lists.append([fullString,fullParentString,str(eventsPerJobRequested),str(jobSkipEventCount)])
527 >                        else:
528 >                            list_of_lists.append([fullString,str(eventsPerJobRequested),str(jobSkipEventCount)])
529                          common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(eventsPerJobRequested)+" events.")
530                          self.jobDestination.append(blockSites[block])
531                          common.logger.debug(5,"Job "+str(jobCount+1)+" Destination: "+str(self.jobDestination[jobCount]))
# Line 499 | Line 539 | class Cmssw(JobType):
539                          jobSkipEventCount = eventsPerJobRequested - (filesEventCount - jobSkipEventCount - self.eventsbyfile[file])
540                          # remove all but the last file
541                          filesEventCount = self.eventsbyfile[file]
542 <                        parString = ""
543 <                        parString += '\\\"' + file + '\\\"\,'
542 >                        if self.useParent:
543 >                            for f in parent : pString += '\\\"' + f + '\\\"\,'
544 >                        parString = '\\\"' + file + '\\\"\,'
545                      pass # END if
546                  pass # END while (iterate over files in the block)
547          pass # END while (iterate over blocks in the dataset)
# Line 520 | Line 561 | class Cmssw(JobType):
561          for block in blocks:
562              if block in jobsOfBlock.keys() :
563                  blockCounter += 1
564 <                screenOutput += "Block %5i: jobs %20s: sites: %s\n" % (blockCounter,spanRanges(jobsOfBlock[block]),','.join(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)))
564 >                screenOutput += "Block %5i: jobs %20s: sites: %s\n" % (blockCounter,spanRanges(jobsOfBlock[block]),
565 >                    ','.join(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)))
566                  if len(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)) == 0:
567                      noSiteBlock.append( spanRanges(jobsOfBlock[block]) )
568                      bloskNoSite.append( blockCounter )
# Line 554 | Line 596 | class Cmssw(JobType):
596          self.list_of_args = list_of_lists
597          return
598  
599 +    def jobSplittingNoBlockBoundary(self,blockSites):
600 +        """
601 +        """
602 +        # ---- Handle the possible job splitting configurations ---- #
603 +        if (self.selectTotalNumberEvents):
604 +            totalEventsRequested = self.total_number_of_events
605 +        if (self.selectEventsPerJob):
606 +            eventsPerJobRequested = self.eventsPerJob
607 +            if (self.selectNumberOfJobs):
608 +                totalEventsRequested = self.theNumberOfJobs * self.eventsPerJob
609 +
610 +        # If user requested all the events in the dataset
611 +        if (totalEventsRequested == -1):
612 +            eventsRemaining=self.maxEvents
613 +        # If user requested more events than are in the dataset
614 +        elif (totalEventsRequested > self.maxEvents):
615 +            eventsRemaining = self.maxEvents
616 +            common.logger.message("Requested "+str(self.total_number_of_events)+ " events, but only "+str(self.maxEvents)+" events are available.")
617 +        # If user requested less events than are in the dataset
618 +        else:
619 +            eventsRemaining = totalEventsRequested
620 +
621 +        # If user requested more events per job than are in the dataset
622 +        if (self.selectEventsPerJob and eventsPerJobRequested > self.maxEvents):
623 +            eventsPerJobRequested = self.maxEvents
624 +
625 +        # For user info at end
626 +        totalEventCount = 0
627 +
628 +        if (self.selectTotalNumberEvents and self.selectNumberOfJobs):
629 +            eventsPerJobRequested = int(eventsRemaining/self.theNumberOfJobs)
630 +
631 +        if (self.selectNumberOfJobs):
632 +            common.logger.message("May not create the exact number_of_jobs requested.")
633 +
634 +        if ( self.ncjobs == 'all' ) :
635 +            totalNumberOfJobs = 999999999
636 +        else :
637 +            totalNumberOfJobs = self.ncjobs
638 +
639 +        blocks = blockSites.keys()
640 +        blockCount = 0
641 +        # Backup variable in case self.maxEvents counted events in a non-included block
642 +        numBlocksInDataset = len(blocks)
643 +
644 +        jobCount = 0
645 +        list_of_lists = []
646 +
647 +        #AF
648 +        #AF do not reset input files and event count on block boundary
649 +        #AF
650 +        parString=""
651 +        filesEventCount = 0
652 +        #AF
653 +
654 +        # list tracking which jobs are in which jobs belong to which block
655 +        jobsOfBlock = {}
656 +        while ( (eventsRemaining > 0) and (blockCount < numBlocksInDataset) and (jobCount < totalNumberOfJobs)):
657 +            block = blocks[blockCount]
658 +            blockCount += 1
659 +            if block not in jobsOfBlock.keys() :
660 +                jobsOfBlock[block] = []
661 +
662 +            if self.eventsbyblock.has_key(block) :
663 +                numEventsInBlock = self.eventsbyblock[block]
664 +                common.logger.debug(5,'Events in Block File '+str(numEventsInBlock))
665 +                files = self.filesbyblock[block]
666 +                numFilesInBlock = len(files)
667 +                if (numFilesInBlock <= 0):
668 +                    continue
669 +                fileCount = 0
670 +                #AF
671 +                #AF do not reset input files and event count of block boundary
672 +                #AF
673 +                ## ---- New block => New job ---- #
674 +                #parString = ""
675 +                # counter for number of events in files currently worked on
676 +                #filesEventCount = 0
677 +                #AF
678 +                # flag if next while loop should touch new file
679 +                newFile = 1
680 +                # job event counter
681 +                jobSkipEventCount = 0
682 +
683 +                # ---- Iterate over the files in the block until we've met the requested ---- #
684 +                # ---- total # of events or we've gone over all the files in this block  ---- #
685 +                pString=''
686 +                while ( (eventsRemaining > 0) and (fileCount < numFilesInBlock) and (jobCount < totalNumberOfJobs) ):
687 +                    file = files[fileCount]
688 +                    if self.useParent:
689 +                        parent = self.parentFiles[file]
690 +                        for f in parent :
691 +                            pString += '\\\"' + f + '\\\"\,'
692 +                        common.logger.debug(6, "File "+str(file)+" has the following parents: "+str(parent))
693 +                        common.logger.write("File "+str(file)+" has the following parents: "+str(parent))
694 +                    if newFile :
695 +                        try:
696 +                            numEventsInFile = self.eventsbyfile[file]
697 +                            common.logger.debug(6, "File "+str(file)+" has "+str(numEventsInFile)+" events")
698 +                            # increase filesEventCount
699 +                            filesEventCount += numEventsInFile
700 +                            # Add file to current job
701 +                            parString += '\\\"' + file + '\\\"\,'
702 +                            newFile = 0
703 +                        except KeyError:
704 +                            common.logger.message("File "+str(file)+" has unknown number of events: skipping")
705 +                    eventsPerJobRequested = min(eventsPerJobRequested, eventsRemaining)
706 +                    #common.logger.message("AF filesEventCount %s - jobSkipEventCount %s "%(filesEventCount,jobSkipEventCount))
707 +                    # if less events in file remain than eventsPerJobRequested
708 +                    if ( filesEventCount - jobSkipEventCount < eventsPerJobRequested):
709 +                      #AF
710 +                      #AF skip fileboundary part
711 +                      #AF
712 +                            # go to next file
713 +                            newFile = 1
714 +                            fileCount += 1
715 +                    # if events in file equal to eventsPerJobRequested
716 +                    elif ( filesEventCount - jobSkipEventCount == eventsPerJobRequested ) :
717 +                        # close job and touch new file
718 +                        fullString = parString[:-2]
719 +                        if self.useParent:
720 +                            fullParentString = pString[:-2]
721 +                            list_of_lists.append([fullString,fullParentString,str(eventsPerJobRequested),str(jobSkipEventCount)])
722 +                        else:
723 +                            list_of_lists.append([fullString,str(eventsPerJobRequested),str(jobSkipEventCount)])
724 +                        common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(eventsPerJobRequested)+" events.")
725 +                        self.jobDestination.append(blockSites[block])
726 +                        common.logger.debug(5,"Job "+str(jobCount+1)+" Destination: "+str(self.jobDestination[jobCount]))
727 +                        jobsOfBlock[block].append(jobCount+1)
728 +                        # reset counter
729 +                        jobCount = jobCount + 1
730 +                        totalEventCount = totalEventCount + eventsPerJobRequested
731 +                        eventsRemaining = eventsRemaining - eventsPerJobRequested
732 +                        jobSkipEventCount = 0
733 +                        # reset file
734 +                        pString = ""
735 +                        parString = ""
736 +                        filesEventCount = 0
737 +                        newFile = 1
738 +                        fileCount += 1
739 +
740 +                    # if more events in file remain than eventsPerJobRequested
741 +                    else :
742 +                        # close job but don't touch new file
743 +                        fullString = parString[:-2]
744 +                        if self.useParent:
745 +                            fullParentString = pString[:-2]
746 +                            list_of_lists.append([fullString,fullParentString,str(eventsPerJobRequested),str(jobSkipEventCount)])
747 +                        else:
748 +                            list_of_lists.append([fullString,str(eventsPerJobRequested),str(jobSkipEventCount)])
749 +                        common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(eventsPerJobRequested)+" events.")
750 +                        self.jobDestination.append(blockSites[block])
751 +                        common.logger.debug(5,"Job "+str(jobCount+1)+" Destination: "+str(self.jobDestination[jobCount]))
752 +                        jobsOfBlock[block].append(jobCount+1)
753 +                        # increase counter
754 +                        jobCount = jobCount + 1
755 +                        totalEventCount = totalEventCount + eventsPerJobRequested
756 +                        eventsRemaining = eventsRemaining - eventsPerJobRequested
757 +                        # calculate skip events for last file
758 +                        # use filesEventCount (contains several files), jobSkipEventCount and eventsPerJobRequest
759 +                        jobSkipEventCount = eventsPerJobRequested - (filesEventCount - jobSkipEventCount - self.eventsbyfile[file])
760 +                        # remove all but the last file
761 +                        filesEventCount = self.eventsbyfile[file]
762 +                        if self.useParent:
763 +                            for f in parent : pString += '\\\"' + f + '\\\"\,'
764 +                        parString = '\\\"' + file + '\\\"\,'
765 +                    pass # END if
766 +                pass # END while (iterate over files in the block)
767 +        pass # END while (iterate over blocks in the dataset)
768 +        self.ncjobs = self.total_number_of_jobs = jobCount
769 +        if (eventsRemaining > 0 and jobCount < totalNumberOfJobs ):
770 +            common.logger.message("eventsRemaining "+str(eventsRemaining))
771 +            common.logger.message("jobCount "+str(jobCount))
772 +            common.logger.message(" totalNumberOfJobs "+str(totalNumberOfJobs))
773 +            common.logger.message("Could not run on all requested events because some blocks not hosted at allowed sites.")
774 +        common.logger.message(str(jobCount)+" job(s) can run on "+str(totalEventCount)+" events.\n")
775 +
776 +        # screen output
777 +        screenOutput = "List of jobs and available destination sites:\n\n"
778 +
779 +        #AF
780 +        #AF   skip check on  block with no sites
781 +        #AF
782 +        self.list_of_args = list_of_lists
783 +
784 +        return
785 +
786 +
787 +
788      def jobSplittingNoInput(self):
789          """
790          Perform job splitting based on number of event per job
# Line 602 | Line 833 | class Cmssw(JobType):
833              if (self.firstRun):
834                  ## pythia first run
835                  args.append(str(self.firstRun)+str(i))
836 <            if (self.sourceSeed):
837 <                args.append(str(self.sourceSeed)+str(i))
838 <                if (self.sourceSeedVtx):
839 <                    ## + vtx random seed
840 <                    args.append(str(self.sourceSeedVtx)+str(i))
841 <                if (self.sourceSeedG4):
611 <                    ## + G4 random seed
612 <                    args.append(str(self.sourceSeedG4)+str(i))
613 <                if (self.sourceSeedMix):
614 <                    ## + Mix random seed
615 <                    args.append(str(self.sourceSeedMix)+str(i))
616 <                pass
617 <            pass
836 >            if (self.generator in self.managedGenerators):
837 >                if (self.generator == 'comphep' and i == 0):
838 >                    # COMPHEP is brain-dead and wants event #'s like 1,100,200,300
839 >                    args.append('1')
840 >                else:
841 >                    args.append(str(i*self.eventsPerJob))
842              self.list_of_args.append(args)
619        pass
620
843          return
844  
845  
846 <    def jobSplittingForScript(self):#CarlosDaniele
846 >    def jobSplittingForScript(self):
847          """
848          Perform job splitting based on number of job
849          """
# Line 637 | Line 859 | class Cmssw(JobType):
859          # argument is seed number.$i
860          self.list_of_args = []
861          for i in range(self.total_number_of_jobs):
640            ## Since there is no input, any site is good
641           # self.jobDestination.append(["Any"])
862              self.jobDestination.append([""])
643            ## no random seed
863              self.list_of_args.append([str(i)])
864          return
865  
866 <    def split(self, jobParams):
866 >    def split(self, jobParams,firstJobID):
867  
649        common.jobDB.load()
650        #### Fabio
868          njobs = self.total_number_of_jobs
869          arglist = self.list_of_args
870 +        if njobs==0:
871 +            raise CrabException("Ask to split "+str(njobs)+" jobs: aborting")
872 +
873          # create the empty structure
874          for i in range(njobs):
875              jobParams.append("")
876  
877 <        for job in range(njobs):
878 <            jobParams[job] = arglist[job]
879 <            # print str(arglist[job])
880 <            # print jobParams[job]
881 <            common.jobDB.setArguments(job, jobParams[job])
882 <            common.logger.debug(5,"Job "+str(job)+" Destination: "+str(self.jobDestination[job]))
883 <            common.jobDB.setDestination(job, self.jobDestination[job])
877 >        listID=[]
878 >        listField=[]
879 >        for id in range(njobs):
880 >            job = id + int(firstJobID)
881 >            jobParams[id] = arglist[id]
882 >            listID.append(job+1)
883 >            job_ToSave ={}
884 >            concString = ' '
885 >            argu=''
886 >            if len(jobParams[id]):
887 >                argu +=   concString.join(jobParams[id] )
888 >            job_ToSave['arguments']= str(job+1)+' '+argu
889 >            job_ToSave['dlsDestination']= self.jobDestination[id]
890 >            listField.append(job_ToSave)
891 >            msg="Job "+str(job)+" Arguments:   "+str(job+1)+" "+argu+"\n"  \
892 >            +"                     Destination: "+str(self.jobDestination[id])
893 >            common.logger.debug(5,msg)
894 >        common._db.updateJob_(listID,listField)
895 >        self.argsList = (len(jobParams[0])+1)
896  
665        common.jobDB.save()
897          return
898  
668    def getJobTypeArguments(self, nj, sched):
669        result = ''
670        for i in common.jobDB.arguments(nj):
671            result=result+str(i)+" "
672        return result
673
899      def numberOfJobs(self):
675        # Fabio
900          return self.total_number_of_jobs
901  
902      def getTarBall(self, exe):
903          """
904          Return the TarBall with lib and exe
905          """
906 <
683 <        # if it exist, just return it
684 <        #
685 <        # Marco. Let's start to use relative path for Boss XML files
686 <        #
687 <        self.tgzNameWithPath = common.work_space.pathForTgz()+'share/'+self.tgz_name
906 >        self.tgzNameWithPath = common.work_space.pathForTgz()+self.tgz_name
907          if os.path.exists(self.tgzNameWithPath):
908              return self.tgzNameWithPath
909  
# Line 697 | Line 916 | class Cmssw(JobType):
916  
917          # First of all declare the user Scram area
918          swArea = self.scram.getSWArea_()
700        #print "swArea = ", swArea
701        # swVersion = self.scram.getSWVersion()
702        # print "swVersion = ", swVersion
919          swReleaseTop = self.scram.getReleaseTop_()
704        #print "swReleaseTop = ", swReleaseTop
920  
921          ## check if working area is release top
922          if swReleaseTop == '' or swArea == swReleaseTop:
923 +            common.logger.debug(3,"swArea = "+swArea+" swReleaseTop ="+swReleaseTop)
924              return
925  
926          import tarfile
# Line 733 | Line 949 | class Cmssw(JobType):
949                      pass
950  
951              ## Now get the libraries: only those in local working area
952 +            tar.dereference=True
953              libDir = 'lib'
954              lib = swArea+'/' +libDir
955              common.logger.debug(5,"lib "+lib+" to be tarred")
# Line 744 | Line 961 | class Cmssw(JobType):
961              module = swArea + '/' + moduleDir
962              if os.path.isdir(module):
963                  tar.add(module,moduleDir)
964 +            tar.dereference=False
965  
966              ## Now check if any data dir(s) is present
967 <            swAreaLen=len(swArea)
968 <            for root, dirs, files in os.walk(swArea):
969 <                if "data" in dirs:
970 <                    common.logger.debug(5,"data "+root+"/data"+" to be tarred")
971 <                    tar.add(root+"/data",root[swAreaLen:]+"/data")
972 <
973 <            ### Removed ProdAgent Api dependencies ###
974 <            ### Add ProdAgent dir to tar
975 <            #paDir = 'ProdAgentApi'
976 <            #pa = os.environ['CRABDIR'] + '/' + 'ProdAgentApi'
977 <            #if os.path.isdir(pa):
978 <            #    tar.add(pa,paDir)
967 >            self.dataExist = False
968 >            todo_list = [(i, i) for i in  os.listdir(swArea+"/src")]
969 >            while len(todo_list):
970 >                entry, name = todo_list.pop()
971 >                if name.startswith('crab_0_') or  name.startswith('.') or name == 'CVS':
972 >                    continue
973 >                if os.path.isdir(swArea+"/src/"+entry):
974 >                    entryPath = entry + '/'
975 >                    todo_list += [(entryPath + i, i) for i in  os.listdir(swArea+"/src/"+entry)]
976 >                    if name == 'data':
977 >                        self.dataExist=True
978 >                        common.logger.debug(5,"data "+entry+" to be tarred")
979 >                        tar.add(swArea+"/src/"+entry,"src/"+entry)
980 >                    pass
981 >                pass
982 >
983 >            ### CMSSW ParameterSet
984 >            if not self.pset is None:
985 >                cfg_file = common.work_space.jobDir()+self.configFilename()
986 >                tar.add(cfg_file,self.configFilename())
987 >
988  
989              ## Add ProdCommon dir to tar
990 <            prodcommonDir = 'ProdCommon'
991 <            prodcommonPath = os.environ['CRABDIR'] + '/' + 'ProdCommon'
992 <            if os.path.isdir(prodcommonPath):
993 <                tar.add(prodcommonPath,prodcommonDir)
990 >            prodcommonDir = './'
991 >            prodcommonPath = os.environ['CRABDIR'] + '/' + 'external/'
992 >            neededStuff = ['ProdCommon/__init__.py','ProdCommon/FwkJobRep', 'ProdCommon/CMSConfigTools', \
993 >                           'ProdCommon/Core', 'ProdCommon/MCPayloads', 'IMProv', 'ProdCommon/Storage']
994 >            for file in neededStuff:
995 >                tar.add(prodcommonPath+file,prodcommonDir+file)
996 >
997 >            ##### ML stuff
998 >            ML_file_list=['report.py', 'DashboardAPI.py', 'Logger.py', 'ProcInfo.py', 'apmon.py']
999 >            path=os.environ['CRABDIR'] + '/python/'
1000 >            for file in ML_file_list:
1001 >                tar.add(path+file,file)
1002 >
1003 >            ##### Utils
1004 >            Utils_file_list=['parseCrabFjr.py','writeCfg.py', 'fillCrabFjr.py','cmscp.py']
1005 >            for file in Utils_file_list:
1006 >                tar.add(path+file,file)
1007 >
1008 >            ##### AdditionalFiles
1009 >            tar.dereference=True
1010 >            for file in self.additional_inbox_files:
1011 >                tar.add(file,string.split(file,'/')[-1])
1012 >            tar.dereference=False
1013 >            common.logger.debug(5,"Files in "+self.tgzNameWithPath+" : "+str(tar.getnames()))
1014  
768            common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
1015              tar.close()
1016 <        except :
1017 <            raise CrabException('Could not create tar-ball')
1016 >        except IOError, exc:
1017 >            common.logger.write(str(exc))
1018 >            raise CrabException('Could not create tar-ball '+self.tgzNameWithPath)
1019 >        except tarfile.TarError, exc:
1020 >            common.logger.write(str(exc))
1021 >            raise CrabException('Could not create tar-ball '+self.tgzNameWithPath)
1022  
1023          ## check for tarball size
1024          tarballinfo = os.stat(self.tgzNameWithPath)
1025          if ( tarballinfo.st_size > self.MaxTarBallSize*1024*1024 ) :
1026 <            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.')
1026 >            msg  = 'Input sandbox size of ' + str(float(tarballinfo.st_size)/1024.0/1024.0) + ' MB is larger than the allowed ' + str(self.MaxTarBallSize) \
1027 >               +'MB input sandbox limit \n'
1028 >            msg += '      and not supported by the direct GRID submission system.\n'
1029 >            msg += '      Please use the CRAB server mode by setting server_name=<NAME> in section [CRAB] of your crab.cfg.\n'
1030 >            msg += '      For further infos please see https://twiki.cern.ch/twiki/bin/view/CMS/CrabServer#CRABSERVER_for_Users'
1031 >            raise CrabException(msg)
1032  
1033          ## create tar-ball with ML stuff
779        self.MLtgzfile =  common.work_space.pathForTgz()+'share/MLfiles.tgz'
780        try:
781            tar = tarfile.open(self.MLtgzfile, "w:gz")
782            path=os.environ['CRABDIR'] + '/python/'
783            for file in ['report.py', 'DashboardAPI.py', 'Logger.py', 'ProcInfo.py', 'apmon.py', 'parseCrabFjr.py']:
784                tar.add(path+file,file)
785            common.logger.debug(5,"Files added to "+self.MLtgzfile+" : "+str(tar.getnames()))
786            tar.close()
787        except :
788            raise CrabException('Could not create ML files tar-ball')
789
790        return
1034  
1035 <    def additionalInputFileTgz(self):
793 <        """
794 <        Put all additional files into a tar ball and return its name
795 <        """
796 <        import tarfile
797 <        tarName=  common.work_space.pathForTgz()+'share/'+self.additional_tgz_name
798 <        tar = tarfile.open(tarName, "w:gz")
799 <        for file in self.additional_inbox_files:
800 <            tar.add(file,string.split(file,'/')[-1])
801 <        common.logger.debug(5,"Files added to "+self.additional_tgz_name+" : "+str(tar.getnames()))
802 <        tar.close()
803 <        return tarName
804 <
805 <    def wsSetupEnvironment(self, nj):
1035 >    def wsSetupEnvironment(self, nj=0):
1036          """
1037          Returns part of a job script which prepares
1038          the execution environment for the job 'nj'.
1039          """
1040 +        if (self.CMSSW_major >= 2 and self.CMSSW_minor >= 1) or (self.CMSSW_major >= 3):
1041 +            psetName = 'pset.py'
1042 +        else:
1043 +            psetName = 'pset.cfg'
1044          # Prepare JobType-independent part
1045 <        txt = ''
1045 >        txt = '\n#Written by cms_cmssw::wsSetupEnvironment\n'
1046          txt += 'echo ">>> setup environment"\n'
1047          txt += 'if [ $middleware == LCG ]; then \n'
1048          txt += self.wsSetupCMSLCGEnvironment_()
1049          txt += 'elif [ $middleware == OSG ]; then\n'
1050          txt += '    WORKING_DIR=`/bin/mktemp  -d $OSG_WN_TMP/cms_XXXXXXXXXXXX`\n'
1051          txt += '    if [ ! $? == 0 ] ;then\n'
1052 <        txt += '        echo "SET_CMS_ENV 10016 ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n'
1053 <        txt += '        echo "JOB_EXIT_STATUS = 10016"\n'
1054 <        txt += '        echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
821 <        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
822 <        txt += '        exit 1\n'
1052 >        txt += '        echo "ERROR ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n'
1053 >        txt += '        job_exit_code=10016\n'
1054 >        txt += '        func_exit\n'
1055          txt += '    fi\n'
1056          txt += '    echo ">>> Created working directory: $WORKING_DIR"\n'
1057          txt += '\n'
# Line 827 | Line 1059 | class Cmssw(JobType):
1059          txt += '    cd $WORKING_DIR\n'
1060          txt += '    echo ">>> current directory (WORKING_DIR): $WORKING_DIR"\n'
1061          txt += self.wsSetupCMSOSGEnvironment_()
830        #txt += '    echo "### Set SCRAM ARCH to ' + self.executable_arch + ' ###"\n'
831        #txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
1062          txt += 'fi\n'
1063  
1064          # Prepare JobType-specific part
# Line 839 | Line 1069 | class Cmssw(JobType):
1069          txt += scram+' project CMSSW '+self.version+'\n'
1070          txt += 'status=$?\n'
1071          txt += 'if [ $status != 0 ] ; then\n'
1072 <        txt += '    echo "SET_EXE_ENV 10034 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n'
1073 <        txt += '    echo "JOB_EXIT_STATUS = 10034"\n'
1074 <        txt += '    echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n'
845 <        txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
846 <        txt += '    if [ $middleware == OSG ]; then \n'
847 <        txt += '        cd $RUNTIME_AREA\n'
848 <        txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
849 <        txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
850 <        txt += '        /bin/rm -rf $WORKING_DIR\n'
851 <        txt += '        if [ -d $WORKING_DIR ] ;then\n'
852 <        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'
853 <        txt += '            echo "JOB_EXIT_STATUS = 10018"\n'
854 <        txt += '            echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n'
855 <        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
856 <        txt += '        fi\n'
857 <        txt += '    fi \n'
858 <        txt += '    exit 1 \n'
1072 >        txt += '    echo "ERROR ==> CMSSW '+self.version+' not found on `hostname`" \n'
1073 >        txt += '    job_exit_code=10034\n'
1074 >        txt += '    func_exit\n'
1075          txt += 'fi \n'
1076          txt += 'cd '+self.version+'\n'
861        ########## FEDE FOR DBS2 ######################
1077          txt += 'SOFTWARE_DIR=`pwd`\n'
1078          txt += 'echo ">>> current directory (SOFTWARE_DIR): $SOFTWARE_DIR" \n'
864        ###############################################
865        ### needed grep for bug in scramv1 ###
1079          txt += 'eval `'+scram+' runtime -sh | grep -v SCRAMRT_LSB_JOBNAME`\n'
1080 +        txt += 'if [ $? != 0 ] ; then\n'
1081 +        txt += '    echo "ERROR ==> Problem with the command: "\n'
1082 +        txt += '    echo "eval \`'+scram+' runtime -sh | grep -v SCRAMRT_LSB_JOBNAME \` at `hostname`"\n'
1083 +        txt += '    job_exit_code=10034\n'
1084 +        txt += '    func_exit\n'
1085 +        txt += 'fi \n'
1086          # Handle the arguments:
1087          txt += "\n"
1088          txt += "## number of arguments (first argument always jobnumber)\n"
1089          txt += "\n"
1090 <        txt += "if [ $nargs -lt "+str(len(self.argsList[nj].split()))+" ]\n"
1090 >        txt += "if [ $nargs -lt "+str(self.argsList)+" ]\n"
1091          txt += "then\n"
1092 <        txt += "    echo 'SET_EXE_ENV 1 ==> ERROR Too few arguments' +$nargs+ \n"
1093 <        txt += '    echo "JOB_EXIT_STATUS = 50113"\n'
1094 <        txt += '    echo "JobExitCode=50113" | tee -a $RUNTIME_AREA/$repo\n'
876 <        txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
877 <        txt += '    if [ $middleware == OSG ]; then \n'
878 <        txt += '        cd $RUNTIME_AREA\n'
879 <        txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
880 <        txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
881 <        txt += '        /bin/rm -rf $WORKING_DIR\n'
882 <        txt += '        if [ -d $WORKING_DIR ] ;then\n'
883 <        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'
884 <        txt += '            echo "JOB_EXIT_STATUS = 50114"\n'
885 <        txt += '            echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n'
886 <        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
887 <        txt += '        fi\n'
888 <        txt += '    fi \n'
889 <        txt += "    exit 1\n"
1092 >        txt += "    echo 'ERROR ==> Too few arguments' +$nargs+ \n"
1093 >        txt += '    job_exit_code=50113\n'
1094 >        txt += "    func_exit\n"
1095          txt += "fi\n"
1096          txt += "\n"
1097  
1098          # Prepare job-specific part
1099          job = common.job_list[nj]
895        ### FEDE FOR DBS OUTPUT PUBLICATION
1100          if (self.datasetPath):
1101 +            self.primaryDataset = self.datasetPath.split("/")[1]
1102 +            DataTier = self.datasetPath.split("/")[2]
1103              txt += '\n'
1104              txt += 'DatasetPath='+self.datasetPath+'\n'
1105  
1106 <            datasetpath_split = self.datasetPath.split("/")
1107 <
902 <            txt += 'PrimaryDataset='+datasetpath_split[1]+'\n'
903 <            txt += 'DataTier='+datasetpath_split[2]+'\n'
1106 >            txt += 'PrimaryDataset='+self.primaryDataset +'\n'
1107 >            txt += 'DataTier='+DataTier+'\n'
1108              txt += 'ApplicationFamily=cmsRun\n'
1109  
1110          else:
1111 +            self.primaryDataset = 'null'
1112              txt += 'DatasetPath=MCDataTier\n'
1113              txt += 'PrimaryDataset=null\n'
1114              txt += 'DataTier=null\n'
1115              txt += 'ApplicationFamily=MCDataTier\n'
1116 <        if self.pset != None: #CarlosDaniele
1116 >        if self.pset != None:
1117              pset = os.path.basename(job.configFilename())
1118              txt += '\n'
1119              txt += 'cp  $RUNTIME_AREA/'+pset+' .\n'
1120              if (self.datasetPath): # standard job
1121 <                txt += 'InputFiles=${args[1]}\n'
1122 <                txt += 'MaxEvents=${args[2]}\n'
1123 <                txt += 'SkipEvents=${args[3]}\n'
1121 >                txt += 'InputFiles=${args[1]}; export InputFiles\n'
1122 >                if (self.useParent):
1123 >                    txt += 'ParentFiles=${args[2]}; export ParentFiles\n'
1124 >                    txt += 'MaxEvents=${args[3]}; export MaxEvents\n'
1125 >                    txt += 'SkipEvents=${args[4]}; export SkipEvents\n'
1126 >                else:
1127 >                    txt += 'MaxEvents=${args[2]}; export MaxEvents\n'
1128 >                    txt += 'SkipEvents=${args[3]}; export SkipEvents\n'
1129                  txt += 'echo "Inputfiles:<$InputFiles>"\n'
1130 <                txt += 'sed "s#\'INPUTFILE\'#$InputFiles#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
1130 >                if (self.useParent): txt += 'echo "ParentFiles:<$ParentFiles>"\n'
1131                  txt += 'echo "MaxEvents:<$MaxEvents>"\n'
922                txt += 'sed "s#int32 input = 0#int32 input = $MaxEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
1132                  txt += 'echo "SkipEvents:<$SkipEvents>"\n'
924                txt += 'sed "s#uint32 skipEvents = 0#uint32 skipEvents = $SkipEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
1133              else:  # pythia like job
1134 <                seedIndex=1
1134 >                argNum = 1
1135 >                txt += 'PreserveSeeds='  + ','.join(self.preserveSeeds)  + '; export PreserveSeeds\n'
1136 >                txt += 'IncrementSeeds=' + ','.join(self.incrementSeeds) + '; export IncrementSeeds\n'
1137 >                txt += 'echo "PreserveSeeds: <$PreserveSeeds>"\n'
1138 >                txt += 'echo "IncrementSeeds:<$IncrementSeeds>"\n'
1139                  if (self.firstRun):
1140 <                    txt += 'FirstRun=${args['+str(seedIndex)+']}\n'
1140 >                    txt += 'export FirstRun=${args[%s]}\n' % argNum
1141                      txt += 'echo "FirstRun: <$FirstRun>"\n'
1142 <                    txt += 'sed "s#uint32 firstRun = 0#uint32 firstRun = $FirstRun#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
1143 <                    seedIndex=seedIndex+1
1142 >                    argNum += 1
1143 >                if (self.generator == 'madgraph'):
1144 >                    txt += 'export FirstEvent=${args[%s]}\n' % argNum
1145 >                    txt += 'echo "FirstEvent:<$FirstEvent>"\n'
1146 >                    argNum += 1
1147 >                elif (self.generator == 'comphep'):
1148 >                    txt += 'export CompHEPFirstEvent=${args[%s]}\n' % argNum
1149 >                    txt += 'echo "CompHEPFirstEvent:<$CompHEPFirstEvent>"\n'
1150 >                    argNum += 1
1151  
1152 <                if (self.sourceSeed):
934 <                    txt += 'Seed=${args['+str(seedIndex)+']}\n'
935 <                    txt += 'sed "s#uint32 sourceSeed = 0#uint32 sourceSeed = $Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
936 <                    seedIndex=seedIndex+1
937 <                    ## the following seeds are not always present
938 <                    if (self.sourceSeedVtx):
939 <                        txt += 'VtxSeed=${args['+str(seedIndex)+']}\n'
940 <                        txt += 'echo "VtxSeed: <$VtxSeed>"\n'
941 <                        txt += 'sed "s#uint32 VtxSmeared = 0#uint32 VtxSmeared = $VtxSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
942 <                        seedIndex += 1
943 <                    if (self.sourceSeedG4):
944 <                        txt += 'G4Seed=${args['+str(seedIndex)+']}\n'
945 <                        txt += 'echo "G4Seed: <$G4Seed>"\n'
946 <                        txt += 'sed "s#uint32 g4SimHits = 0#uint32 g4SimHits = $G4Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
947 <                        seedIndex += 1
948 <                    if (self.sourceSeedMix):
949 <                        txt += 'mixSeed=${args['+str(seedIndex)+']}\n'
950 <                        txt += 'echo "MixSeed: <$mixSeed>"\n'
951 <                        txt += 'sed "s#uint32 mix = 0#uint32 mix = $mixSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
952 <                        seedIndex += 1
953 <                    pass
954 <                pass
955 <            txt += 'mv -f '+pset+' pset.cfg\n'
1152 >            txt += 'mv -f ' + pset + ' ' + psetName + '\n'
1153  
957        if len(self.additional_inbox_files) > 0:
958            txt += 'if [ -e $RUNTIME_AREA/'+self.additional_tgz_name+' ] ; then\n'
959            txt += '  tar xzvf $RUNTIME_AREA/'+self.additional_tgz_name+'\n'
960            txt += 'fi\n'
961            pass
1154  
1155 <        if self.pset != None: #CarlosDaniele
1156 <            txt += '\n'
965 <            txt += 'echo "***** cat pset.cfg *********"\n'
966 <            txt += 'cat pset.cfg\n'
967 <            txt += 'echo "****** end pset.cfg ********"\n'
1155 >        if self.pset != None:
1156 >            # FUTURE: Can simply for 2_1_x and higher
1157              txt += '\n'
1158 <            ### FEDE FOR DBS OUTPUT PUBLICATION
1159 <            txt += 'PSETHASH=`EdmConfigHash < pset.cfg` \n'
1158 >            if self.debug_wrapper==True:
1159 >                txt += 'echo "***** cat ' + psetName + ' *********"\n'
1160 >                txt += 'cat ' + psetName + '\n'
1161 >                txt += 'echo "****** end ' + psetName + ' ********"\n'
1162 >                txt += '\n'
1163 >            if (self.CMSSW_major >= 2 and self.CMSSW_minor >= 1) or (self.CMSSW_major >= 3):
1164 >                txt += 'PSETHASH=`edmConfigHash ' + psetName + '` \n'
1165 >            else:
1166 >                txt += 'PSETHASH=`edmConfigHash < ' + psetName + '` \n'
1167              txt += 'echo "PSETHASH = $PSETHASH" \n'
972            ##############
1168              txt += '\n'
1169          return txt
1170  
1171 <    def wsBuildExe(self, nj=0):
1171 >    def wsUntarSoftware(self, nj=0):
1172          """
1173          Put in the script the commands to build an executable
1174          or a library.
1175          """
1176  
1177 <        txt = ""
1177 >        txt = '\n#Written by cms_cmssw::wsUntarSoftware\n'
1178  
1179          if os.path.isfile(self.tgzNameWithPath):
1180              txt += 'echo ">>> tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+' :" \n'
1181 <            txt += 'tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n'
1181 >            txt += 'tar xzf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n'
1182 >            if  self.debug_wrapper:
1183 >                txt += 'tar tzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n'
1184 >                txt += 'ls -Al \n'
1185              txt += 'untar_status=$? \n'
1186              txt += 'if [ $untar_status -ne 0 ]; then \n'
1187 <            txt += '   echo "SET_EXE 1 ==> ERROR Untarring .tgz file failed"\n'
1188 <            txt += '   echo "JOB_EXIT_STATUS = $untar_status" \n'
1189 <            txt += '   echo "JobExitCode=$untar_status" | tee -a $RUNTIME_AREA/$repo\n'
992 <            txt += '   if [ $middleware == OSG ]; then \n'
993 <            txt += '       cd $RUNTIME_AREA\n'
994 <            txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
995 <            txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
996 <            txt += '       /bin/rm -rf $WORKING_DIR\n'
997 <            txt += '       if [ -d $WORKING_DIR ] ;then\n'
998 <            txt += '           echo "SET_EXE 50999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Untarring .tgz file failed"\n'
999 <            txt += '           echo "JOB_EXIT_STATUS = 50999"\n'
1000 <            txt += '           echo "JobExitCode=50999" | tee -a $RUNTIME_AREA/$repo\n'
1001 <            txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1002 <            txt += '       fi\n'
1003 <            txt += '   fi \n'
1004 <            txt += '   \n'
1005 <            txt += '   exit 1 \n'
1187 >            txt += '   echo "ERROR ==> Untarring .tgz file failed"\n'
1188 >            txt += '   job_exit_code=$untar_status\n'
1189 >            txt += '   func_exit\n'
1190              txt += 'else \n'
1191              txt += '   echo "Successful untar" \n'
1192              txt += 'fi \n'
1193              txt += '\n'
1194 <            #### Removed ProdAgent API dependencies
1011 <            txt += 'echo ">>> Include ProdCommon in PYTHONPATH:"\n'
1194 >            txt += 'echo ">>> Include $RUNTIME_AREA in PYTHONPATH:"\n'
1195              txt += 'if [ -z "$PYTHONPATH" ]; then\n'
1196 <            #### FEDE FOR DBS OUTPUT PUBLICATION
1014 <            txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdCommon\n'
1196 >            txt += '   export PYTHONPATH=$RUNTIME_AREA/\n'
1197              txt += 'else\n'
1198 <            txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdCommon:${PYTHONPATH}\n'
1198 >            txt += '   export PYTHONPATH=$RUNTIME_AREA/:${PYTHONPATH}\n'
1199              txt += 'echo "PYTHONPATH=$PYTHONPATH"\n'
1018            ###################
1200              txt += 'fi\n'
1201              txt += '\n'
1202  
# Line 1023 | Line 1204 | class Cmssw(JobType):
1204  
1205          return txt
1206  
1207 <    def modifySteeringCards(self, nj):
1207 >    def wsBuildExe(self, nj=0):
1208          """
1209 <        modify the card provided by the user,
1210 <        writing a new card into share dir
1209 >        Put in the script the commands to build an executable
1210 >        or a library.
1211          """
1212  
1213 +        txt = '\n#Written by cms_cmssw::wsBuildExe\n'
1214 +        txt += 'echo ">>> moving CMSSW software directories in `pwd`" \n'
1215 +
1216 +        txt += 'rm -r lib/ module/ \n'
1217 +        txt += 'mv $RUNTIME_AREA/lib/ . \n'
1218 +        txt += 'mv $RUNTIME_AREA/module/ . \n'
1219 +        if self.dataExist == True:
1220 +            txt += 'rm -r src/ \n'
1221 +            txt += 'mv $RUNTIME_AREA/src/ . \n'
1222 +        if len(self.additional_inbox_files)>0:
1223 +            for file in self.additional_inbox_files:
1224 +                txt += 'mv $RUNTIME_AREA/'+os.path.basename(file)+' . \n'
1225 +        # txt += 'mv $RUNTIME_AREA/ProdCommon/ . \n'
1226 +        # txt += 'mv $RUNTIME_AREA/IMProv/ . \n'
1227 +
1228 +        txt += 'echo ">>> Include $RUNTIME_AREA in PYTHONPATH:"\n'
1229 +        txt += 'if [ -z "$PYTHONPATH" ]; then\n'
1230 +        txt += '   export PYTHONPATH=$RUNTIME_AREA/\n'
1231 +        txt += 'else\n'
1232 +        txt += '   export PYTHONPATH=$RUNTIME_AREA/:${PYTHONPATH}\n'
1233 +        txt += 'echo "PYTHONPATH=$PYTHONPATH"\n'
1234 +        txt += 'fi\n'
1235 +        txt += '\n'
1236 +
1237 +        return txt
1238 +
1239 +
1240      def executableName(self):
1241 <        if self.scriptExe: #CarlosDaniele
1241 >        if self.scriptExe:
1242              return "sh "
1243          else:
1244              return self.executable
1245  
1246      def executableArgs(self):
1247 +        # FUTURE: This function tests the CMSSW version. Can be simplified as we drop support for old versions
1248          if self.scriptExe:#CarlosDaniele
1249              return   self.scriptExe + " $NJob"
1250          else:
1251 <            # if >= CMSSW_1_5_X, add -j crab_fjr.xml
1252 <            version_array = self.scram.getSWVersion().split('_')
1253 <            major = 0
1254 <            minor = 0
1255 <            try:
1256 <                major = int(version_array[1])
1257 <                minor = int(version_array[2])
1258 <            except:
1050 <                msg = "Cannot parse CMSSW version string: " + "_".join(version_array) + " for major and minor release number!"
1051 <                raise CrabException(msg)
1052 <            if major >= 1 and minor >= 5 :
1053 <                return " -j " + self.fjrFileName + " -p pset.cfg"
1251 >            ex_args = ""
1252 >            # FUTURE: This tests the CMSSW version. Can remove code as versions deprecated
1253 >            # Framework job report
1254 >            if (self.CMSSW_major >= 1 and self.CMSSW_minor >= 5) or (self.CMSSW_major >= 2):
1255 >                ex_args += " -j $RUNTIME_AREA/crab_fjr_$NJob.xml"
1256 >            # Type of config file
1257 >            if self.CMSSW_major >= 2 :
1258 >                ex_args += " -p pset.py"
1259              else:
1260 <                return " -p pset.cfg"
1260 >                ex_args += " -p pset.cfg"
1261 >            return ex_args
1262  
1263      def inputSandbox(self, nj):
1264          """
1265          Returns a list of filenames to be put in JDL input sandbox.
1266          """
1267          inp_box = []
1062        # # dict added to delete duplicate from input sandbox file list
1063        # seen = {}
1064        ## code
1268          if os.path.isfile(self.tgzNameWithPath):
1269              inp_box.append(self.tgzNameWithPath)
1270 <        if os.path.isfile(self.MLtgzfile):
1068 <            inp_box.append(self.MLtgzfile)
1069 <        ## config
1070 <        if not self.pset is None:
1071 <            inp_box.append(common.work_space.pathForTgz() + 'job/' + self.configFilename())
1072 <        ## additional input files
1073 <        tgz = self.additionalInputFileTgz()
1074 <        inp_box.append(tgz)
1270 >        inp_box.append(common.work_space.jobDir() + self.scriptName)
1271          return inp_box
1272  
1273      def outputSandbox(self, nj):
# Line 1083 | Line 1279 | class Cmssw(JobType):
1279          ## User Declared output files
1280          for out in (self.output_file+self.output_file_sandbox):
1281              n_out = nj + 1
1282 <            out_box.append(self.numberFile_(out,str(n_out)))
1282 >            out_box.append(numberFile(out,str(n_out)))
1283          return out_box
1284  
1089    def prepareSteeringCards(self):
1090        """
1091        Make initial modifications of the user's steering card file.
1092        """
1093        return
1285  
1286      def wsRenameOutput(self, nj):
1287          """
1288          Returns part of a job script which renames the produced files.
1289          """
1290  
1291 <        txt = '\n'
1291 >        txt = '\n#Written by cms_cmssw::wsRenameOutput\n'
1292          txt += 'echo ">>> current directory (SOFTWARE_DIR): $SOFTWARE_DIR" \n'
1293          txt += 'echo ">>> current directory content:"\n'
1294 <        txt += 'ls \n'
1294 >        if self.debug_wrapper:
1295 >            txt += 'ls -Al\n'
1296          txt += '\n'
1297  
1106        txt += 'output_exit_status=0\n'
1107
1108        for fileWithSuffix in (self.output_file_sandbox):
1109            output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1110            txt += '\n'
1111            txt += '# check output file\n'
1112            txt += 'if [ -e ./'+fileWithSuffix+' ] ; then\n'
1113            txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1114            txt += '    ln -s $RUNTIME_AREA/'+output_file_num+' $RUNTIME_AREA/'+fileWithSuffix+'\n'
1115            txt += 'else\n'
1116            txt += '    exit_status=60302\n'
1117            txt += '    echo "ERROR: Output file '+fileWithSuffix+' not found"\n'
1118            if common.scheduler.name() == 'CONDOR_G':
1119                txt += '    if [ $middleware == OSG ]; then \n'
1120                txt += '        echo "prepare dummy output file"\n'
1121                txt += '        echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n'
1122                txt += '    fi \n'
1123            txt += 'fi\n'
1124
1298          for fileWithSuffix in (self.output_file):
1299 <            output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1299 >            output_file_num = numberFile(fileWithSuffix, '$NJob')
1300              txt += '\n'
1301              txt += '# check output file\n'
1302              txt += 'if [ -e ./'+fileWithSuffix+' ] ; then\n'
# Line 1134 | Line 1307 | class Cmssw(JobType):
1307                  txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1308                  txt += '    ln -s $RUNTIME_AREA/'+output_file_num+' $RUNTIME_AREA/'+fileWithSuffix+'\n'
1309              txt += 'else\n'
1310 <            txt += '    exit_status=60302\n'
1311 <            txt += '    echo "ERROR: Output file '+fileWithSuffix+' not found"\n'
1312 <            txt += '    echo "JOB_EXIT_STATUS = $exit_status"\n'
1140 <            txt += '    output_exit_status=$exit_status\n'
1141 <            if common.scheduler.name() == 'CONDOR_G':
1310 >            txt += '    job_exit_code=60302\n'
1311 >            txt += '    echo "WARNING: Output file '+fileWithSuffix+' not found"\n'
1312 >            if common.scheduler.name().upper() == 'CONDOR_G':
1313                  txt += '    if [ $middleware == OSG ]; then \n'
1314                  txt += '        echo "prepare dummy output file"\n'
1315                  txt += '        echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n'
# Line 1146 | Line 1317 | class Cmssw(JobType):
1317              txt += 'fi\n'
1318          file_list = []
1319          for fileWithSuffix in (self.output_file):
1320 <             file_list.append(self.numberFile_(fileWithSuffix, '$NJob'))
1320 >             file_list.append(numberFile('$SOFTWARE_DIR/'+fileWithSuffix, '$NJob'))
1321  
1322 <        txt += 'file_list="'+string.join(file_list,' ')+'"\n'
1322 >        txt += 'file_list="'+string.join(file_list,',')+'"\n'
1323          txt += '\n'
1324          txt += 'echo ">>> current directory (SOFTWARE_DIR): $SOFTWARE_DIR" \n'
1325          txt += 'echo ">>> current directory content:"\n'
1326 <        txt += 'ls \n'
1326 >        if self.debug_wrapper:
1327 >            txt += 'ls -Al\n'
1328          txt += '\n'
1329          txt += 'cd $RUNTIME_AREA\n'
1330          txt += 'echo ">>> current directory (RUNTIME_AREA):  $RUNTIME_AREA"\n'
1331          return txt
1332  
1161    def numberFile_(self, file, txt):
1162        """
1163        append _'txt' before last extension of a file
1164        """
1165        p = string.split(file,".")
1166        # take away last extension
1167        name = p[0]
1168        for x in p[1:-1]:
1169            name=name+"."+x
1170        # add "_txt"
1171        if len(p)>1:
1172            ext = p[len(p)-1]
1173            result = name + '_' + txt + "." + ext
1174        else:
1175            result = name + '_' + txt
1176
1177        return result
1178
1333      def getRequirements(self, nj=[]):
1334          """
1335          return job requirements to add to jdl files
# Line 1185 | Line 1339 | class Cmssw(JobType):
1339              req='Member("VO-cms-' + \
1340                   self.version + \
1341                   '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
1342 <        ## SL add requirement for OS version only if SL4
1189 <        #reSL4 = re.compile( r'slc4' )
1190 <        if self.executable_arch: # and reSL4.search(self.executable_arch):
1342 >        if self.executable_arch:
1343              req+=' && Member("VO-cms-' + \
1344                   self.executable_arch + \
1345                   '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
1346  
1347          req = req + ' && (other.GlueHostNetworkAdapterOutboundIP)'
1348 +        if ( common.scheduler.name() == "glitecoll" ) or ( common.scheduler.name() == "glite"):
1349 +            req += ' && other.GlueCEStateStatus == "Production" '
1350  
1351          return req
1352  
1353      def configFilename(self):
1354          """ return the config filename """
1355 <        return self.name()+'.cfg'
1355 >        # FUTURE: Can remove cfg mode for CMSSW >= 2_1_x
1356 >        if (self.CMSSW_major >= 2 and self.CMSSW_minor >= 1) or (self.CMSSW_major >= 3):
1357 >          return self.name()+'.py'
1358 >        else:
1359 >          return self.name()+'.cfg'
1360  
1361      def wsSetupCMSOSGEnvironment_(self):
1362          """
1363          Returns part of a job script which is prepares
1364          the execution environment and which is common for all CMS jobs.
1365          """
1366 <        txt = '    echo ">>> setup CMS OSG environment:"\n'
1366 >        txt = '\n#Written by cms_cmssw::wsSetupCMSOSGEnvironment_\n'
1367 >        txt += '    echo ">>> setup CMS OSG environment:"\n'
1368          txt += '    echo "set SCRAM ARCH to ' + self.executable_arch + '"\n'
1369          txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
1370          txt += '    echo "SCRAM_ARCH = $SCRAM_ARCH"\n'
# Line 1213 | Line 1372 | class Cmssw(JobType):
1372          txt += '      # Use $OSG_APP/cmssoft/cms/cmsset_default.sh to setup cms software\n'
1373          txt += '        source $OSG_APP/cmssoft/cms/cmsset_default.sh '+self.version+'\n'
1374          txt += '    else\n'
1375 <        txt += '        echo "SET_CMS_ENV 10020 ==> ERROR $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1376 <        txt += '        echo "JOB_EXIT_STATUS = 10020"\n'
1377 <        txt += '        echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1219 <        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1220 <        txt += '\n'
1221 <        txt += '        cd $RUNTIME_AREA\n'
1222 <        txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
1223 <        txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
1224 <        txt += '        /bin/rm -rf $WORKING_DIR\n'
1225 <        txt += '        if [ -d $WORKING_DIR ] ;then\n'
1226 <        txt += '            echo "SET_CMS_ENV 10017 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1227 <        txt += '            echo "JOB_EXIT_STATUS = 10017"\n'
1228 <        txt += '            echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n'
1229 <        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1230 <        txt += '        fi\n'
1231 <        txt += '\n'
1232 <        txt += '        exit 1\n'
1375 >        txt += '        echo "ERROR ==> $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1376 >        txt += '        job_exit_code=10020\n'
1377 >        txt += '        func_exit\n'
1378          txt += '    fi\n'
1379          txt += '\n'
1380 <        txt += '    echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1380 >        txt += '    echo "==> setup cms environment ok"\n'
1381          txt += '    echo "SCRAM_ARCH = $SCRAM_ARCH"\n'
1382  
1383          return txt
1384  
1240    ### OLI_DANIELE
1385      def wsSetupCMSLCGEnvironment_(self):
1386          """
1387          Returns part of a job script which is prepares
1388          the execution environment and which is common for all CMS jobs.
1389          """
1390 <        txt = '    echo ">>> setup CMS LCG environment:"\n'
1390 >        txt = '\n#Written by cms_cmssw::wsSetupCMSLCGEnvironment_\n'
1391 >        txt += '    echo ">>> setup CMS LCG environment:"\n'
1392          txt += '    echo "set SCRAM ARCH and BUILD_ARCH to ' + self.executable_arch + ' ###"\n'
1393          txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
1394          txt += '    export BUILD_ARCH='+self.executable_arch+'\n'
1395          txt += '    if [ ! $VO_CMS_SW_DIR ] ;then\n'
1396 <        txt += '        echo "SET_CMS_ENV 10031 ==> ERROR CMS software dir not found on WN `hostname`"\n'
1397 <        txt += '        echo "JOB_EXIT_STATUS = 10031" \n'
1398 <        txt += '        echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n'
1254 <        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1255 <        txt += '        exit 1\n'
1396 >        txt += '        echo "ERROR ==> CMS software dir not found on WN `hostname`"\n'
1397 >        txt += '        job_exit_code=10031\n'
1398 >        txt += '        func_exit\n'
1399          txt += '    else\n'
1400          txt += '        echo "Sourcing environment... "\n'
1401          txt += '        if [ ! -s $VO_CMS_SW_DIR/cmsset_default.sh ] ;then\n'
1402 <        txt += '            echo "SET_CMS_ENV 10020 ==> ERROR cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
1403 <        txt += '            echo "JOB_EXIT_STATUS = 10020"\n'
1404 <        txt += '            echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1262 <        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1263 <        txt += '            exit 1\n'
1402 >        txt += '            echo "ERROR ==> cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
1403 >        txt += '            job_exit_code=10020\n'
1404 >        txt += '            func_exit\n'
1405          txt += '        fi\n'
1406          txt += '        echo "sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1407          txt += '        source $VO_CMS_SW_DIR/cmsset_default.sh\n'
1408          txt += '        result=$?\n'
1409          txt += '        if [ $result -ne 0 ]; then\n'
1410 <        txt += '            echo "SET_CMS_ENV 10032 ==> ERROR problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1411 <        txt += '            echo "JOB_EXIT_STATUS = 10032"\n'
1412 <        txt += '            echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n'
1272 <        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1273 <        txt += '            exit 1\n'
1410 >        txt += '            echo "ERROR ==> problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1411 >        txt += '            job_exit_code=10032\n'
1412 >        txt += '            func_exit\n'
1413          txt += '        fi\n'
1414          txt += '    fi\n'
1415          txt += '    \n'
1416 <        txt += '    echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1416 >        txt += '    echo "==> setup cms environment ok"\n'
1417          return txt
1418  
1419 <    ### FEDE FOR DBS OUTPUT PUBLICATION
1281 <    def modifyReport(self, nj):
1419 >    def wsModifyReport(self, nj):
1420          """
1421          insert the part of the script that modifies the FrameworkJob Report
1422          """
1423 <
1424 <        txt = ''
1287 <        try:
1288 <            publish_data = int(self.cfg_params['USER.publish_data'])
1289 <        except KeyError:
1290 <            publish_data = 0
1423 >        txt = '\n#Written by cms_cmssw::wsModifyReport\n'
1424 >        publish_data = int(self.cfg_params.get('USER.publish_data',0))
1425          if (publish_data == 1):
1292            txt += 'echo ">>> Modify Job Report:" \n'
1293            ################ FEDE FOR DBS2 #############################################
1294            #txt += 'chmod a+x $SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n'
1295            txt += 'chmod a+x $SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py\n'
1296            #############################################################################
1297
1298            txt += 'if [ -z "$SE" ]; then\n'
1299            txt += '    SE="" \n'
1300            txt += 'fi \n'
1301            txt += 'if [ -z "$SE_PATH" ]; then\n'
1302            txt += '    SE_PATH="" \n'
1303            txt += 'fi \n'
1304            txt += 'echo "SE = $SE"\n'
1305            txt += 'echo "SE_PATH = $SE_PATH"\n'
1426  
1427              processedDataset = self.cfg_params['USER.publish_data_name']
1428 <            txt += 'ProcessedDataset='+processedDataset+'\n'
1429 <            #### LFN=/store/user/<user>/processedDataset_PSETHASH
1430 <            txt += 'if [ "$SE_PATH" == "" ]; then\n'
1431 <            #### FEDE: added slash in LFN ##############
1428 >
1429 >            txt += 'if [ $StageOutExitStatus -eq 0 ]; then\n'
1430 >            txt += '    FOR_LFN=$LFNBaseName\n'
1431 >            txt += 'else\n'
1432              txt += '    FOR_LFN=/copy_problems/ \n'
1433 <            txt += 'else \n'
1434 <            txt += '    tmp=`echo $SE_PATH | awk -F \'store\' \'{print$2}\'` \n'
1435 <            #####  FEDE TO BE CHANGED, BECAUSE STORE IS HARDCODED!!!! ########
1436 <            txt += '    FOR_LFN=/store$tmp \n'
1437 <            txt += 'fi \n'
1433 >            txt += '    SE=""\n'
1434 >            txt += '    SE_PATH=""\n'
1435 >            txt += 'fi\n'
1436 >
1437 >            txt += 'echo ">>> Modify Job Report:" \n'
1438 >            txt += 'chmod a+x $RUNTIME_AREA/ProdCommon/FwkJobRep/ModifyJobReport.py\n'
1439 >            txt += 'ProcessedDataset='+processedDataset+'\n'
1440 >            #txt += 'ProcessedDataset=$procDataset \n'
1441              txt += 'echo "ProcessedDataset = $ProcessedDataset"\n'
1442 +            txt += 'echo "SE = $SE"\n'
1443 +            txt += 'echo "SE_PATH = $SE_PATH"\n'
1444              txt += 'echo "FOR_LFN = $FOR_LFN" \n'
1445              txt += 'echo "CMSSW_VERSION = $CMSSW_VERSION"\n\n'
1446 <            txt += 'echo "$SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n'
1447 <            txt += '$SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH\n'
1448 <
1446 >            args = '$RUNTIME_AREA/crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier ' \
1447 >                   '$USER-$ProcessedDataset-$PSETHASH $ApplicationFamily '+ \
1448 >                    '  $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH'
1449 >            txt += 'echo "$RUNTIME_AREA/ProdCommon/FwkJobRep/ModifyJobReport.py '+str(args)+'"\n'
1450 >            txt += '$RUNTIME_AREA/ProdCommon/FwkJobRep/ModifyJobReport.py '+str(args)+'\n'
1451              txt += 'modifyReport_result=$?\n'
1325            txt += 'echo modifyReport_result = $modifyReport_result\n'
1452              txt += 'if [ $modifyReport_result -ne 0 ]; then\n'
1453 <            txt += '    exit_status=1\n'
1454 <            txt += '    echo "ERROR: Problem with ModifyJobReport"\n'
1453 >            txt += '    modifyReport_result=70500\n'
1454 >            txt += '    job_exit_code=$modifyReport_result\n'
1455 >            txt += '    echo "ModifyReportResult=$modifyReport_result" | tee -a $RUNTIME_AREA/$repo\n'
1456 >            txt += '    echo "WARNING: Problem with ModifyJobReport"\n'
1457              txt += 'else\n'
1458 <            txt += '    mv NewFrameworkJobReport.xml crab_fjr_$NJob.xml\n'
1458 >            txt += '    mv NewFrameworkJobReport.xml $RUNTIME_AREA/crab_fjr_$NJob.xml\n'
1459              txt += 'fi\n'
1332        else:
1333            txt += 'echo "no data publication required"\n'
1460          return txt
1461  
1462 <    def cleanEnv(self):
1463 <        txt = ''
1464 <        txt += 'if [ $middleware == OSG ]; then\n'
1465 <        txt += '    cd $RUNTIME_AREA\n'
1466 <        txt += '    echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
1467 <        txt += '    echo ">>> Remove working directory: $WORKING_DIR"\n'
1468 <        txt += '    /bin/rm -rf $WORKING_DIR\n'
1469 <        txt += '    if [ -d $WORKING_DIR ] ;then\n'
1470 <        txt += '        echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
1471 <        txt += '        echo "JOB_EXIT_STATUS = 60999"\n'
1472 <        txt += '        echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
1473 <        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1462 >    def wsParseFJR(self):
1463 >        """
1464 >        Parse the FrameworkJobReport to obtain useful infos
1465 >        """
1466 >        txt = '\n#Written by cms_cmssw::wsParseFJR\n'
1467 >        txt += 'echo ">>> Parse FrameworkJobReport crab_fjr.xml"\n'
1468 >        txt += 'if [ -s $RUNTIME_AREA/crab_fjr_$NJob.xml ]; then\n'
1469 >        txt += '    if [ -s $RUNTIME_AREA/parseCrabFjr.py ]; then\n'
1470 >        txt += '        cmd_out=`python $RUNTIME_AREA/parseCrabFjr.py --input $RUNTIME_AREA/crab_fjr_$NJob.xml --dashboard $MonitorID,$MonitorJobID '+self.debugWrap+'`\n'
1471 >        if self.debug_wrapper :
1472 >            txt += '        echo "Result of parsing the FrameworkJobReport crab_fjr.xml: $cmd_out"\n'
1473 >        txt += '        executable_exit_status=`python $RUNTIME_AREA/parseCrabFjr.py --input $RUNTIME_AREA/crab_fjr_$NJob.xml --exitcode`\n'
1474 >        txt += '        if [ $executable_exit_status -eq 50115 ];then\n'
1475 >        txt += '            echo ">>> crab_fjr.xml contents: "\n'
1476 >        txt += '            cat $RUNTIME_AREA/crab_fjr_$NJob.xml\n'
1477 >        txt += '            echo "Wrong FrameworkJobReport --> does not contain useful info. ExitStatus: $executable_exit_status"\n'
1478 >        txt += '        elif [ $executable_exit_status -eq -999 ];then\n'
1479 >        txt += '            echo "ExitStatus from FrameworkJobReport not available. not available. Using exit code of executable from command line."\n'
1480 >        txt += '        else\n'
1481 >        txt += '            echo "Extracted ExitStatus from FrameworkJobReport parsing output: $executable_exit_status"\n'
1482 >        txt += '        fi\n'
1483 >        txt += '    else\n'
1484 >        txt += '        echo "CRAB python script to parse CRAB FrameworkJobReport crab_fjr.xml is not available, using exit code of executable from command line."\n'
1485 >        txt += '    fi\n'
1486 >          #### Patch to check input data reading for CMSSW16x Hopefully we-ll remove it asap
1487 >        txt += '    if [ $executable_exit_status -eq 0 ];then\n'
1488 >        txt += '      echo ">>> Executable succeded  $executable_exit_status"\n'
1489 >        if (self.datasetPath and not (self.dataset_pu or self.useParent)) :
1490 >          # VERIFY PROCESSED DATA
1491 >            txt += '      echo ">>> Verify list of processed files:"\n'
1492 >            txt += '      echo $InputFiles |tr -d \'\\\\\' |tr \',\' \'\\n\'|tr -d \'"\' > input-files.txt\n'
1493 >            txt += '      python $RUNTIME_AREA/parseCrabFjr.py --input $RUNTIME_AREA/crab_fjr_$NJob.xml --lfn > processed-files.txt\n'
1494 >            txt += '      cat input-files.txt  | sort | uniq > tmp.txt\n'
1495 >            txt += '      mv tmp.txt input-files.txt\n'
1496 >            txt += '      echo "cat input-files.txt"\n'
1497 >            txt += '      echo "----------------------"\n'
1498 >            txt += '      cat input-files.txt\n'
1499 >            txt += '      cat processed-files.txt | sort | uniq > tmp.txt\n'
1500 >            txt += '      mv tmp.txt processed-files.txt\n'
1501 >            txt += '      echo "----------------------"\n'
1502 >            txt += '      echo "cat processed-files.txt"\n'
1503 >            txt += '      echo "----------------------"\n'
1504 >            txt += '      cat processed-files.txt\n'
1505 >            txt += '      echo "----------------------"\n'
1506 >            txt += '      diff -q input-files.txt processed-files.txt\n'
1507 >            txt += '      fileverify_status=$?\n'
1508 >            txt += '      if [ $fileverify_status -ne 0 ]; then\n'
1509 >            txt += '         executable_exit_status=30001\n'
1510 >            txt += '         echo "ERROR ==> not all input files processed"\n'
1511 >            txt += '         echo "      ==> list of processed files from crab_fjr.xml differs from list in pset.cfg"\n'
1512 >            txt += '         echo "      ==> diff input-files.txt processed-files.txt"\n'
1513 >            txt += '      fi\n'
1514 >        txt += '    elif [ $executable_exit_status -ne 0 ] || [ $executable_exit_status -ne 50015 ] || [ $executable_exit_status -ne 50017 ];then\n'
1515 >        txt += '      echo ">>> Executable failed  $executable_exit_status"\n'
1516 >        txt += '      echo "ExeExitCode=$executable_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
1517 >        txt += '      echo "EXECUTABLE_EXIT_STATUS = $executable_exit_status"\n'
1518 >        txt += '      job_exit_code=$executable_exit_status\n'
1519 >        txt += '      func_exit\n'
1520          txt += '    fi\n'
1521 +        txt += '\n'
1522 +        txt += 'else\n'
1523 +        txt += '    echo "CRAB FrameworkJobReport crab_fjr.xml is not available, using exit code of executable from command line."\n'
1524          txt += 'fi\n'
1525          txt += '\n'
1526 +        txt += 'echo "ExeExitCode=$executable_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
1527 +        txt += 'echo "EXECUTABLE_EXIT_STATUS = $executable_exit_status"\n'
1528 +        txt += 'job_exit_code=$executable_exit_status\n'
1529 +
1530          return txt
1531  
1532      def setParam_(self, param, value):
# Line 1365 | Line 1544 | class Cmssw(JobType):
1544              nd[e]=0
1545          return nd.keys()
1546  
1547 <
1369 <    def checkOut(self, limit):
1547 >    def outList(self,list=False):
1548          """
1549          check the dimension of the output files
1550          """
1551 <        txt = 'echo ">>> Starting output sandbox limit check :"\n'
1552 <        allOutFiles = ""
1551 >        txt = ''
1552 >        txt += 'echo ">>> list of expected files on output sandbox"\n'
1553          listOutFiles = []
1554 <        txt += 'stdoutFile=`ls *stdout` \n'
1555 <        txt += 'stderrFile=`ls *stderr` \n'
1554 >        stdout = 'CMSSW_$NJob.stdout'
1555 >        stderr = 'CMSSW_$NJob.stderr'
1556          if (self.return_data == 1):
1557 <            for fileOut in (self.output_file+self.output_file_sandbox):
1558 <                allOutFiles = allOutFiles + " " + self.numberFile_(fileOut, '$NJob') + " $stdoutFile $stderrFile"
1559 <        else:            
1560 <            for fileOut in (self.output_file_sandbox):
1561 <                txt += 'echo " '+fileOut+'";\n'
1562 <                allOutFiles = allOutFiles + " " + self.numberFile_(fileOut, '$NJob') + " $stdoutFile $stderrFile"
1563 <        txt += 'echo "OUTPUT files: '+str(allOutFiles)+'";\n'
1564 <        txt += 'ls -gGhrta;\n'
1565 <        txt += 'sum=0;\n'
1566 <        txt += 'for file in '+str(allOutFiles)+' ; do\n'
1567 <        txt += '    if [ -e $file ]; then\n'
1568 <        txt += '        tt=`ls -gGrta $file | awk \'{ print $3 }\'`\n'
1569 <        txt += '        sum=`expr $sum + $tt`\n'
1392 <        txt += '    else\n'
1393 <        txt += '        echo "WARNING: output file $file not found!"\n'
1394 <        txt += '    fi\n'
1395 <        txt += 'done\n'
1396 <        txt += 'echo "Total Output dimension: $sum";\n'
1397 <        txt += 'limit='+str(limit)+';\n'
1398 <        txt += 'echo "OUTPUT FILES LIMIT SET TO: $limit";\n'
1399 <        txt += 'if [ $limit -lt $sum ]; then\n'
1400 <        txt += '    echo "WARNING: output files have to big size - something will be lost;"\n'
1401 <        txt += '    echo "         checking the output file sizes..."\n'
1402 <        txt += '    tot=0;\n'
1403 <        txt += '    for filefile in '+str(allOutFiles)+' ; do\n'
1404 <        txt += '        dimFile=`ls -gGrta $filefile | awk \'{ print $3 }\';`\n'
1405 <        txt += '        tot=`expr $tot + $tt`;\n'
1406 <        txt += '        if [ $limit -lt $dimFile ]; then\n'
1407 <        txt += '            echo "deleting file: $filefile";\n'
1408 <        txt += '            rm -f $filefile\n'
1409 <        txt += '        elif [ $limit -lt $tot ]; then\n'
1410 <        txt += '            echo "deleting file: $filefile";\n'
1411 <        txt += '            rm -f $filefile\n'
1412 <        txt += '        else\n'
1413 <        txt += '            echo "saving file: $filefile"\n'
1414 <        txt += '        fi\n'
1415 <        txt += '    done\n'
1416 <
1417 <        txt += '    ls -agGhrt;\n'
1418 <        txt += '    echo "WARNING: output files are too big in dimension: can not put in the output_sandbox.";\n'
1419 <        txt += '    echo "JOB_EXIT_STATUS = 70000";\n'
1420 <        txt += '    exit_status=70000;\n'
1421 <        txt += 'else'
1422 <        txt += '    echo "Total Output dimension $sum is fine.";\n'
1423 <        txt += 'fi\n'
1424 <        txt += 'echo "Ending output sandbox limit check"\n'
1557 >            for file in (self.output_file+self.output_file_sandbox):
1558 >                listOutFiles.append(numberFile(file, '$NJob'))
1559 >            listOutFiles.append(stdout)
1560 >            listOutFiles.append(stderr)
1561 >        else:
1562 >            for file in (self.output_file_sandbox):
1563 >                listOutFiles.append(numberFile(file, '$NJob'))
1564 >            listOutFiles.append(stdout)
1565 >            listOutFiles.append(stderr)
1566 >        txt += 'echo "output files: '+string.join(listOutFiles,' ')+'"\n'
1567 >        txt += 'filesToCheck="'+string.join(listOutFiles,' ')+'"\n'
1568 >        txt += 'export filesToCheck\n'
1569 >        if list : return self.output_file
1570          return txt

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines