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.173 by fanzago, Tue Apr 8 09:32:51 2008 UTC

# Line 5 | Line 5 | from crab_util import *
5   from BlackWhiteListParser import BlackWhiteListParser
6   import common
7   import Scram
8 + from LFNBaseName import *
9  
10   import os, string, glob
11  
# Line 47 | Line 48 | class Cmssw(JobType):
48          # Try to block creation in case of arch/version mismatch
49          #
50  
51 <        a = string.split(self.version, "_")
51 > #        a = string.split(self.version, "_")
52 > #
53 > #        if int(a[1]) == 1 and (int(a[2]) < 5 and self.executable_arch.find('slc4') == 0):
54 > #            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)
55 > #            common.logger.message(msg)
56 > #        if int(a[1]) == 1 and (int(a[2]) >= 5 and self.executable_arch.find('slc3') == 0):
57 > #            msg = "Error: CMS does not support %s with %s architecture"%(self.version, self.executable_arch)
58 > #            raise CrabException(msg)
59 > #
60  
52        if int(a[1]) == 1 and (int(a[2]) < 5 and self.executable_arch.find('slc4') == 0):
53            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)
54            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)
57            raise CrabException(msg)
58
59        common.taskDB.setDict('codeVersion',self.version)
61          self.setParam_('application', self.version)
62  
63          ### collect Data cards
# Line 90 | Line 91 | class Cmssw(JobType):
91                  self.setParam_('dataset', self.datasetPath)
92                  self.setParam_('owner', self.datasetPath)
93  
94 <        self.setParam_('taskId', common.taskDB.dict('taskId'))
94 >        self.setParam_('taskId', common._db.queryTask('name')) ## new BL--DS
95  
96          self.dataTiers = []
97  
# Line 202 | Line 203 | class Cmssw(JobType):
203                   msg = 'Must specify  number_of_jobs.'
204                   raise CrabException(msg)
205  
206 <        ## source seed for pythia
206 >        ## New method of dealing with seeds
207 >        self.incrementSeeds = []
208 >        self.preserveSeeds = []
209 >        if cfg_params.has_key('CMSSW.preserve_seeds'):
210 >            tmpList = cfg_params['CMSSW.preserve_seeds'].split(',')
211 >            for tmp in tmpList:
212 >                tmp.strip()
213 >                self.preserveSeeds.append(tmp)
214 >        if cfg_params.has_key('CMSSW.increment_seeds'):
215 >            tmpList = cfg_params['CMSSW.increment_seeds'].split(',')
216 >            for tmp in tmpList:
217 >                tmp.strip()
218 >                self.incrementSeeds.append(tmp)
219 >
220 >        ## Old method of dealing with seeds
221 >        ## FUTURE: This is for old CMSSW and old CRAB. Can throw exceptions after a couple of CRAB releases and then
222 >        ## remove
223          self.sourceSeed = cfg_params.get('CMSSW.pythia_seed',None)
224 +        if self.sourceSeed:
225 +          print "pythia_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds."
226 +          self.incrementSeeds.append('sourceSeed')
227  
228          self.sourceSeedVtx = cfg_params.get('CMSSW.vtx_seed',None)
229 +        if self.sourceSeedVtx:
230 +          print "vtx_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds."
231 +          self.incrementSeeds.append('VtxSmeared')
232  
233          self.sourceSeedG4 = cfg_params.get('CMSSW.g4_seed',None)
234 +        if self.sourceSeedG4:
235 +          print "g4_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds."
236 +          self.incrementSeeds.append('g4SimHits')
237  
238          self.sourceSeedMix = cfg_params.get('CMSSW.mix_seed',None)
239 +        if self.sourceSeedMix:
240 +          print "mix_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds."
241 +          self.incrementSeeds.append('mix')
242  
243          self.firstRun = cfg_params.get('CMSSW.first_run',None)
244  
# Line 248 | Line 277 | class Cmssw(JobType):
277          # modify Pset
278          if self.pset != None: #CarlosDaniele
279              try:
280 <                if (self.datasetPath): # standard job
281 <                    # allow to processa a fraction of events in a file
253 <                    PsetEdit.inputModule("INPUTFILE")
254 <                    PsetEdit.maxEvent(0)
255 <                    PsetEdit.skipEvent(0)
256 <                else:  # pythia like job
257 <                    PsetEdit.maxEvent(self.eventsPerJob)
258 <                    if (self.firstRun):
259 <                        PsetEdit.pythiaFirstRun(0)  #First Run
260 <                    if (self.sourceSeed) :
261 <                        PsetEdit.pythiaSeed(0)
262 <                        if (self.sourceSeedVtx) :
263 <                            PsetEdit.vtxSeed(0)
264 <                        if (self.sourceSeedG4) :
265 <                            PsetEdit.g4Seed(0)
266 <                        if (self.sourceSeedMix) :
267 <                            PsetEdit.mixSeed(0)
268 <                # add FrameworkJobReport to parameter-set
280 >                # Add FrameworkJobReport to parameter-set, set max events.
281 >                # Reset later for data jobs by writeCFG which does all modifications
282                  PsetEdit.addCrabFJR(self.fjrFileName)
283 +                PsetEdit.maxEvent(self.eventsPerJob)
284                  PsetEdit.psetWriter(self.configFilename())
285              except:
286                  msg='Error while manipuliating ParameterSet: exiting...'
# Line 325 | Line 339 | class Cmssw(JobType):
339  
340          return sites
341  
342 <    def setArgsList(self, argsList):
343 <        self.argsList = argsList
342 >  # to Be Removed  DS -- BL
343 >  #  def setArgsList(self, argsList):
344 >  #      self.argsList = argsList
345  
346      def jobSplittingByBlocks(self, blockSites):
347          """
# Line 499 | Line 514 | class Cmssw(JobType):
514                          jobSkipEventCount = eventsPerJobRequested - (filesEventCount - jobSkipEventCount - self.eventsbyfile[file])
515                          # remove all but the last file
516                          filesEventCount = self.eventsbyfile[file]
517 <                        parString = ""
503 <                        parString += '\\\"' + file + '\\\"\,'
517 >                        parString = '\\\"' + file + '\\\"\,'
518                      pass # END if
519                  pass # END while (iterate over files in the block)
520          pass # END while (iterate over blocks in the dataset)
# Line 602 | Line 616 | class Cmssw(JobType):
616              if (self.firstRun):
617                  ## pythia first run
618                  args.append(str(self.firstRun)+str(i))
605            if (self.sourceSeed):
606                args.append(str(self.sourceSeed)+str(i))
607                if (self.sourceSeedVtx):
608                    ## + vtx random seed
609                    args.append(str(self.sourceSeedVtx)+str(i))
610                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
619              self.list_of_args.append(args)
619        pass
620  
621          return
622  
# Line 646 | Line 646 | class Cmssw(JobType):
646  
647      def split(self, jobParams):
648  
649        common.jobDB.load()
649          #### Fabio
650          njobs = self.total_number_of_jobs
651          arglist = self.list_of_args
# Line 654 | Line 653 | class Cmssw(JobType):
653          for i in range(njobs):
654              jobParams.append("")
655  
656 +        listID=[]
657 +        listField=[]
658          for job in range(njobs):
659              jobParams[job] = arglist[job]
660 <            # print str(arglist[job])
661 <            # print jobParams[job]
662 <            common.jobDB.setArguments(job, jobParams[job])
663 <            common.logger.debug(5,"Job "+str(job)+" Destination: "+str(self.jobDestination[job]))
664 <            common.jobDB.setDestination(job, self.jobDestination[job])
660 >            listID.append(job+1)
661 >            job_ToSave ={}
662 >            concString = ' '
663 >            argu=''
664 >            if len(jobParams[job]):
665 >                argu +=   concString.join(jobParams[job] )
666 >            job_ToSave['arguments']= str(job+1)+' '+argu## new BL--DS
667 >            job_ToSave['dlsDestination']= self.jobDestination[job]## new BL--DS
668 >            #common._db.updateJob_(job,job_ToSave)## new BL--DS
669 >            listField.append(job_ToSave)
670 >            msg="Job "+str(job)+" Arguments:   "+str(job+1)+" "+argu+"\n"  \
671 >            +"                     Destination: "+str(self.jobDestination[job])
672 >            common.logger.debug(5,msg)
673 >            #common.logger.debug(5,"Job "+str(job)+" Destination: "+str(self.jobDestination[job]))
674 >        common._db.updateJob_(listID,listField)## new BL--DS
675 >        ## Pay Attention Here....DS--BL
676 >        self.argsList = (len(jobParams[1])+1)
677  
665        common.jobDB.save()
678          return
679 <
680 <    def getJobTypeArguments(self, nj, sched):
681 <        result = ''
682 <        for i in common.jobDB.arguments(nj):
683 <            result=result+str(i)+" "
684 <        return result
679 > #
680 > #    def getJobTypeArguments(self, nj, sched):
681 > #        result = ''
682 > #        jobs=[]
683 > #        jobs.append(nj)
684 > #        for i in common._db.queryJob('arguments',jobs):##  BL--DS
685 > #            result=result+str(i)+" "
686 > #        return result
687  
688      def numberOfJobs(self):
689          # Fabio
# Line 705 | Line 719 | class Cmssw(JobType):
719  
720          ## check if working area is release top
721          if swReleaseTop == '' or swArea == swReleaseTop:
722 +            common.logger.debug(3,"swArea = "+swArea+" swReleaseTop ="+swReleaseTop)
723              return
724  
725          import tarfile
# Line 752 | Line 767 | class Cmssw(JobType):
767                      common.logger.debug(5,"data "+root+"/data"+" to be tarred")
768                      tar.add(root+"/data",root[swAreaLen:]+"/data")
769  
755            ### Removed ProdAgent Api dependencies ###
756            ### Add ProdAgent dir to tar
757            #paDir = 'ProdAgentApi'
758            #pa = os.environ['CRABDIR'] + '/' + 'ProdAgentApi'
759            #if os.path.isdir(pa):
760            #    tar.add(pa,paDir)
770  
771              ## Add ProdCommon dir to tar
772              prodcommonDir = 'ProdCommon'
# Line 780 | Line 789 | class Cmssw(JobType):
789          try:
790              tar = tarfile.open(self.MLtgzfile, "w:gz")
791              path=os.environ['CRABDIR'] + '/python/'
792 <            for file in ['report.py', 'DashboardAPI.py', 'Logger.py', 'ProcInfo.py', 'apmon.py', 'parseCrabFjr.py']:
792 >            for file in ['report.py', 'DashboardAPI.py', 'Logger.py', 'ProcInfo.py', 'apmon.py', 'parseCrabFjr.py','writeCfg.py', 'JobReportErrorCode.py']:
793                  tar.add(path+file,file)
794              common.logger.debug(5,"Files added to "+self.MLtgzfile+" : "+str(tar.getnames()))
795              tar.close()
# Line 802 | Line 811 | class Cmssw(JobType):
811          tar.close()
812          return tarName
813  
814 <    def wsSetupEnvironment(self, nj):
814 >    def wsSetupEnvironment(self, nj=0):
815          """
816          Returns part of a job script which prepares
817          the execution environment for the job 'nj'.
818          """
819          # Prepare JobType-independent part
820 <        txt = ''
820 >        txt = '\n#Written by cms_cmssw::wsSetupEnvironment\n'
821          txt += 'echo ">>> setup environment"\n'
822          txt += 'if [ $middleware == LCG ]; then \n'
823          txt += self.wsSetupCMSLCGEnvironment_()
824          txt += 'elif [ $middleware == OSG ]; then\n'
825          txt += '    WORKING_DIR=`/bin/mktemp  -d $OSG_WN_TMP/cms_XXXXXXXXXXXX`\n'
826          txt += '    if [ ! $? == 0 ] ;then\n'
827 <        txt += '        echo "SET_CMS_ENV 10016 ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n'
828 <        txt += '        echo "JOB_EXIT_STATUS = 10016"\n'
829 <        txt += '        echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
821 <        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
822 <        txt += '        exit 1\n'
827 >        txt += '        echo "ERROR ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n'
828 >        txt += '        job_exit_code=10016\n'
829 >        txt += '        func_exit\n'
830          txt += '    fi\n'
831          txt += '    echo ">>> Created working directory: $WORKING_DIR"\n'
832          txt += '\n'
# Line 839 | Line 846 | class Cmssw(JobType):
846          txt += scram+' project CMSSW '+self.version+'\n'
847          txt += 'status=$?\n'
848          txt += 'if [ $status != 0 ] ; then\n'
849 <        txt += '    echo "SET_EXE_ENV 10034 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n'
850 <        txt += '    echo "JOB_EXIT_STATUS = 10034"\n'
851 <        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'
849 >        txt += '    echo "ERROR ==> CMSSW '+self.version+' not found on `hostname`" \n'
850 >        txt += '    job_exit_code=10034\n'
851 >        txt += '    func_exit\n'
852          txt += 'fi \n'
853          txt += 'cd '+self.version+'\n'
854          ########## FEDE FOR DBS2 ######################
# Line 868 | Line 861 | class Cmssw(JobType):
861          txt += "\n"
862          txt += "## number of arguments (first argument always jobnumber)\n"
863          txt += "\n"
864 <        txt += "if [ $nargs -lt "+str(len(self.argsList[nj].split()))+" ]\n"
864 >        txt += "if [ $nargs -lt "+str(self.argsList)+" ]\n"
865          txt += "then\n"
866 <        txt += "    echo 'SET_EXE_ENV 1 ==> ERROR Too few arguments' +$nargs+ \n"
867 <        txt += '    echo "JOB_EXIT_STATUS = 50113"\n'
868 <        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"
866 >        txt += "    echo 'ERROR ==> Too few arguments' +$nargs+ \n"
867 >        txt += '    job_exit_code=50113\n'
868 >        txt += "    func_exit\n"
869          txt += "fi\n"
870          txt += "\n"
871  
# Line 908 | Line 887 | class Cmssw(JobType):
887              txt += 'PrimaryDataset=null\n'
888              txt += 'DataTier=null\n'
889              txt += 'ApplicationFamily=MCDataTier\n'
890 <        if self.pset != None: #CarlosDaniele
890 >        if self.pset != None:
891              pset = os.path.basename(job.configFilename())
892              txt += '\n'
893              txt += 'cp  $RUNTIME_AREA/'+pset+' .\n'
894              if (self.datasetPath): # standard job
895 <                txt += 'InputFiles=${args[1]}\n'
896 <                txt += 'MaxEvents=${args[2]}\n'
897 <                txt += 'SkipEvents=${args[3]}\n'
895 >                txt += 'InputFiles=${args[1]}; export InputFiles\n'
896 >                txt += 'MaxEvents=${args[2]}; export MaxEvents\n'
897 >                txt += 'SkipEvents=${args[3]}; export SkipEvents\n'
898                  txt += 'echo "Inputfiles:<$InputFiles>"\n'
920                txt += 'sed "s#\'INPUTFILE\'#$InputFiles#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
899                  txt += 'echo "MaxEvents:<$MaxEvents>"\n'
922                txt += 'sed "s#int32 input = 0#int32 input = $MaxEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
900                  txt += 'echo "SkipEvents:<$SkipEvents>"\n'
924                txt += 'sed "s#uint32 skipEvents = 0#uint32 skipEvents = $SkipEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
901              else:  # pythia like job
902 <                seedIndex=1
902 >                txt += 'PreserveSeeds='  + ','.join(self.preserveSeeds)  + '; export PreserveSeeds\n'
903 >                txt += 'IncrementSeeds=' + ','.join(self.incrementSeeds) + '; export IncrementSeeds\n'
904 >                txt += 'echo "PreserveSeeds: <$PreserveSeeds>"\n'
905 >                txt += 'echo "IncrementSeeds:<$IncrementSeeds>"\n'
906                  if (self.firstRun):
907 <                    txt += 'FirstRun=${args['+str(seedIndex)+']}\n'
907 >                    txt += 'FirstRun=${args[1]}; export FirstRun\n'
908                      txt += 'echo "FirstRun: <$FirstRun>"\n'
930                    txt += 'sed "s#uint32 firstRun = 0#uint32 firstRun = $FirstRun#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
931                    seedIndex=seedIndex+1
909  
933                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
910              txt += 'mv -f '+pset+' pset.cfg\n'
911  
912          if len(self.additional_inbox_files) > 0:
# Line 960 | Line 915 | class Cmssw(JobType):
915              txt += 'fi\n'
916              pass
917  
918 <        if self.pset != None: #CarlosDaniele
918 >        if self.pset != None:
919              txt += '\n'
920              txt += 'echo "***** cat pset.cfg *********"\n'
921              txt += 'cat pset.cfg\n'
922              txt += 'echo "****** end pset.cfg ********"\n'
923              txt += '\n'
969            ### FEDE FOR DBS OUTPUT PUBLICATION
924              txt += 'PSETHASH=`EdmConfigHash < pset.cfg` \n'
925              txt += 'echo "PSETHASH = $PSETHASH" \n'
972            ##############
926              txt += '\n'
927          return txt
928 <
976 <    def wsBuildExe(self, nj=0):
928 >    def wsUntarSoftware(self, nj=0):
929          """
930          Put in the script the commands to build an executable
931          or a library.
932          """
933  
934 <        txt = ""
934 >        txt = '\n#Written by cms_cmssw::wsUntarSoftware\n'
935  
936          if os.path.isfile(self.tgzNameWithPath):
937              txt += 'echo ">>> tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+' :" \n'
938              txt += 'tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n'
939              txt += 'untar_status=$? \n'
940              txt += 'if [ $untar_status -ne 0 ]; then \n'
941 <            txt += '   echo "SET_EXE 1 ==> ERROR Untarring .tgz file failed"\n'
942 <            txt += '   echo "JOB_EXIT_STATUS = $untar_status" \n'
943 <            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'
941 >            txt += '   echo "ERROR ==> Untarring .tgz file failed"\n'
942 >            txt += '   job_exit_code=$untar_status\n'
943 >            txt += '   func_exit\n'
944              txt += 'else \n'
945              txt += '   echo "Successful untar" \n'
946              txt += 'fi \n'
947              txt += '\n'
1010            #### Removed ProdAgent API dependencies
948              txt += 'echo ">>> Include ProdCommon in PYTHONPATH:"\n'
949              txt += 'if [ -z "$PYTHONPATH" ]; then\n'
950 <            #### FEDE FOR DBS OUTPUT PUBLICATION
1014 <            txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdCommon\n'
950 >            txt += '   export PYTHONPATH=$RUNTIME_AREA/ProdCommon\n'
951              txt += 'else\n'
952 <            txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdCommon:${PYTHONPATH}\n'
952 >            txt += '   export PYTHONPATH=$RUNTIME_AREA/ProdCommon:${PYTHONPATH}\n'
953              txt += 'echo "PYTHONPATH=$PYTHONPATH"\n'
1018            ###################
954              txt += 'fi\n'
955              txt += '\n'
956  
# Line 1023 | Line 958 | class Cmssw(JobType):
958  
959          return txt
960  
961 +    def wsBuildExe(self, nj=0):
962 +        """
963 +        Put in the script the commands to build an executable
964 +        or a library.
965 +        """
966 +
967 +        txt = '\n#Written by cms_cmssw::wsBuildExe\n'
968 +        txt += 'echo ">>> moving CMSSW software directories in `pwd`" \n'
969 +
970 + <<<<<<< cms_cmssw.py
971 +        txt += 'mv $RUNTIME_AREA/lib . \n'
972 +        txt += 'mv $RUNTIME_AREA/module . \n'
973 +        txt += 'mv $RUNTIME_AREA/ProdCommon . \n'
974 + =======
975 +        txt += 'rm -r lib/ module/ \n'
976 +        txt += 'mv $RUNTIME_AREA/lib/ . \n'
977 +        txt += 'mv $RUNTIME_AREA/module/ . \n'
978 +        txt += 'mv $RUNTIME_AREA/ProdCommon/ . \n'
979 +
980 +
981 +        #if os.path.isfile(self.tgzNameWithPath):
982 +        #    txt += 'echo ">>> tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+' :" \n'
983 +        #    txt += 'tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n'
984 +        #    txt += 'untar_status=$? \n'
985 +        #    txt += 'if [ $untar_status -ne 0 ]; then \n'
986 +        #    txt += '   echo "ERROR ==> Untarring .tgz file failed"\n'
987 +        #    txt += '   job_exit_code=$untar_status\n'
988 +        #    txt += '   func_exit\n'
989 +        #    txt += 'else \n'
990 +        #    txt += '   echo "Successful untar" \n'
991 +        #    txt += 'fi \n'
992 +        #    txt += '\n'
993 +        #    txt += 'echo ">>> Include ProdCommon in PYTHONPATH:"\n'
994 + >>>>>>> 1.170
995 +        txt += 'if [ -z "$PYTHONPATH" ]; then\n'
996 +        txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdCommon\n'
997 +        txt += 'else\n'
998 +        txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdCommon:${PYTHONPATH}\n'
999 +        txt += 'echo "PYTHONPATH=$PYTHONPATH"\n'
1000 +        txt += 'fi\n'
1001 +        txt += '\n'
1002 +
1003 +        return txt
1004 +
1005      def modifySteeringCards(self, nj):
1006          """
1007          modify the card provided by the user,
# Line 1036 | Line 1015 | class Cmssw(JobType):
1015              return self.executable
1016  
1017      def executableArgs(self):
1018 +        # FUTURE: This function tests the CMSSW version. Can be simplified as we drop support for old versions
1019          if self.scriptExe:#CarlosDaniele
1020              return   self.scriptExe + " $NJob"
1021          else:
1042            # if >= CMSSW_1_5_X, add -j crab_fjr.xml
1022              version_array = self.scram.getSWVersion().split('_')
1023              major = 0
1024              minor = 0
# Line 1049 | Line 1028 | class Cmssw(JobType):
1028              except:
1029                  msg = "Cannot parse CMSSW version string: " + "_".join(version_array) + " for major and minor release number!"
1030                  raise CrabException(msg)
1031 +
1032 +            ex_args = ""
1033 +            # FUTURE: This tests the CMSSW version. Can remove code as versions deprecated
1034 +            # Framework job report
1035              if major >= 1 and minor >= 5 :
1036 <                return " -j " + self.fjrFileName + " -p pset.cfg"
1036 >                ex_args += " -j $RUNTIME_AREA/crab_fjr_$NJob.xml"
1037 >            # Type of cfg file
1038 >            if major >= 2 :
1039 >                ex_args += " -p pset.py"
1040              else:
1041 <                return " -p pset.cfg"
1041 >                ex_args += " -p pset.cfg"
1042 >            return ex_args
1043  
1044      def inputSandbox(self, nj):
1045          """
# Line 1072 | Line 1059 | class Cmssw(JobType):
1059          ## additional input files
1060          tgz = self.additionalInputFileTgz()
1061          inp_box.append(tgz)
1062 +        ## executable
1063 +        wrapper = os.path.basename(str(common._db.queryTask('scriptName')))
1064 +        inp_box.append(common.work_space.pathForTgz() +'job/'+ wrapper)
1065          return inp_box
1066  
1067      def outputSandbox(self, nj):
# Line 1097 | Line 1087 | class Cmssw(JobType):
1087          Returns part of a job script which renames the produced files.
1088          """
1089  
1090 <        txt = '\n'
1090 >        txt = '\n#Written by cms_cmssw::wsRenameOutput\n'
1091          txt += 'echo ">>> current directory (SOFTWARE_DIR): $SOFTWARE_DIR" \n'
1092          txt += 'echo ">>> current directory content:"\n'
1093          txt += 'ls \n'
1094          txt += '\n'
1095  
1096 <        txt += 'output_exit_status=0\n'
1096 >        #txt += 'output_exit_status=0\n'
1097  
1098 <        for fileWithSuffix in (self.output_file_sandbox):
1099 <            output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1100 <            txt += '\n'
1101 <            txt += '# check output file\n'
1102 <            txt += 'if [ -e ./'+fileWithSuffix+' ] ; then\n'
1103 <            txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1104 <            txt += '    ln -s $RUNTIME_AREA/'+output_file_num+' $RUNTIME_AREA/'+fileWithSuffix+'\n'
1105 <            txt += 'else\n'
1106 <            txt += '    exit_status=60302\n'
1107 <            txt += '    echo "ERROR: Output file '+fileWithSuffix+' not found"\n'
1108 <            if common.scheduler.name() == 'CONDOR_G':
1109 <                txt += '    if [ $middleware == OSG ]; then \n'
1110 <                txt += '        echo "prepare dummy output file"\n'
1111 <                txt += '        echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n'
1112 <                txt += '    fi \n'
1113 <            txt += 'fi\n'
1098 >        ### FEDE #######
1099 >        #for fileWithSuffix in (self.output_file_sandbox):
1100 >        #    output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1101 >        #    txt += '\n'
1102 >        #    txt += '# check output file\n'
1103 >        #    txt += 'if [ -e ./'+fileWithSuffix+' ] ; then\n'
1104 >        #    txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1105 >        #    txt += '    ln -s $RUNTIME_AREA/'+output_file_num+' $RUNTIME_AREA/'+fileWithSuffix+'\n'
1106 >        #    txt += 'else\n'
1107 >        #    txt += '    echo "WARNING: Output file '+fileWithSuffix+' not found"\n'
1108 >        #    txt += '    job_exit_code=60302\n'
1109 >        #    if common.scheduler.name().upper() == 'CONDOR_G':
1110 >        #        txt += '    if [ $middleware == OSG ]; then \n'
1111 >        #        txt += '        echo "prepare dummy output file"\n'
1112 >        #        txt += '        echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n'
1113 >        #        txt += '    fi \n'
1114 >        #    txt += 'fi\n'
1115  
1116          for fileWithSuffix in (self.output_file):
1117              output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
# Line 1134 | Line 1125 | class Cmssw(JobType):
1125                  txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1126                  txt += '    ln -s $RUNTIME_AREA/'+output_file_num+' $RUNTIME_AREA/'+fileWithSuffix+'\n'
1127              txt += 'else\n'
1128 <            txt += '    exit_status=60302\n'
1129 <            txt += '    echo "ERROR: Output file '+fileWithSuffix+' not found"\n'
1130 <            txt += '    echo "JOB_EXIT_STATUS = $exit_status"\n'
1140 <            txt += '    output_exit_status=$exit_status\n'
1141 <            if common.scheduler.name() == 'CONDOR_G':
1128 >            txt += '    job_exit_code=60302\n'
1129 >            txt += '    echo "WARNING: Output file '+fileWithSuffix+' not found"\n'
1130 >            if common.scheduler.name().upper() == 'CONDOR_G':
1131                  txt += '    if [ $middleware == OSG ]; then \n'
1132                  txt += '        echo "prepare dummy output file"\n'
1133                  txt += '        echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n'
# Line 1193 | Line 1182 | class Cmssw(JobType):
1182                   '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
1183  
1184          req = req + ' && (other.GlueHostNetworkAdapterOutboundIP)'
1185 +        if common.scheduler.name() == "glitecoll":
1186 +            req += ' && other.GlueCEStateStatus == "Production" '
1187  
1188          return req
1189  
# Line 1205 | Line 1196 | class Cmssw(JobType):
1196          Returns part of a job script which is prepares
1197          the execution environment and which is common for all CMS jobs.
1198          """
1199 <        txt = '    echo ">>> setup CMS OSG environment:"\n'
1199 >        txt = '\n#Written by cms_cmssw::wsSetupCMSOSGEnvironment_\n'
1200 >        txt += '    echo ">>> setup CMS OSG environment:"\n'
1201          txt += '    echo "set SCRAM ARCH to ' + self.executable_arch + '"\n'
1202          txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
1203          txt += '    echo "SCRAM_ARCH = $SCRAM_ARCH"\n'
# Line 1213 | Line 1205 | class Cmssw(JobType):
1205          txt += '      # Use $OSG_APP/cmssoft/cms/cmsset_default.sh to setup cms software\n'
1206          txt += '        source $OSG_APP/cmssoft/cms/cmsset_default.sh '+self.version+'\n'
1207          txt += '    else\n'
1208 <        txt += '        echo "SET_CMS_ENV 10020 ==> ERROR $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1209 <        txt += '        echo "JOB_EXIT_STATUS = 10020"\n'
1210 <        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'
1208 >        txt += '        echo "ERROR ==> $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1209 >        txt += '        job_exit_code=10020\n'
1210 >        txt += '        func_exit\n'
1211          txt += '    fi\n'
1212          txt += '\n'
1213 <        txt += '    echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1213 >        txt += '    echo "==> setup cms environment ok"\n'
1214          txt += '    echo "SCRAM_ARCH = $SCRAM_ARCH"\n'
1215  
1216          return txt
# Line 1243 | Line 1221 | class Cmssw(JobType):
1221          Returns part of a job script which is prepares
1222          the execution environment and which is common for all CMS jobs.
1223          """
1224 <        txt = '    echo ">>> setup CMS LCG environment:"\n'
1224 >        txt = '\n#Written by cms_cmssw::wsSetupCMSLCGEnvironment_\n'
1225 >        txt += '    echo ">>> setup CMS LCG environment:"\n'
1226          txt += '    echo "set SCRAM ARCH and BUILD_ARCH to ' + self.executable_arch + ' ###"\n'
1227          txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
1228          txt += '    export BUILD_ARCH='+self.executable_arch+'\n'
1229          txt += '    if [ ! $VO_CMS_SW_DIR ] ;then\n'
1230 <        txt += '        echo "SET_CMS_ENV 10031 ==> ERROR CMS software dir not found on WN `hostname`"\n'
1231 <        txt += '        echo "JOB_EXIT_STATUS = 10031" \n'
1232 <        txt += '        echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n'
1254 <        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1255 <        txt += '        exit 1\n'
1230 >        txt += '        echo "ERROR ==> CMS software dir not found on WN `hostname`"\n'
1231 >        txt += '        job_exit_code=10031\n'
1232 >        txt += '        func_exit\n'
1233          txt += '    else\n'
1234          txt += '        echo "Sourcing environment... "\n'
1235          txt += '        if [ ! -s $VO_CMS_SW_DIR/cmsset_default.sh ] ;then\n'
1236 <        txt += '            echo "SET_CMS_ENV 10020 ==> ERROR cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
1237 <        txt += '            echo "JOB_EXIT_STATUS = 10020"\n'
1238 <        txt += '            echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1262 <        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1263 <        txt += '            exit 1\n'
1236 >        txt += '            echo "ERROR ==> cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
1237 >        txt += '            job_exit_code=10020\n'
1238 >        txt += '            func_exit\n'
1239          txt += '        fi\n'
1240          txt += '        echo "sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1241          txt += '        source $VO_CMS_SW_DIR/cmsset_default.sh\n'
1242          txt += '        result=$?\n'
1243          txt += '        if [ $result -ne 0 ]; then\n'
1244 <        txt += '            echo "SET_CMS_ENV 10032 ==> ERROR problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1245 <        txt += '            echo "JOB_EXIT_STATUS = 10032"\n'
1246 <        txt += '            echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n'
1272 <        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1273 <        txt += '            exit 1\n'
1244 >        txt += '            echo "ERROR ==> problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1245 >        txt += '            job_exit_code=10032\n'
1246 >        txt += '            func_exit\n'
1247          txt += '        fi\n'
1248          txt += '    fi\n'
1249          txt += '    \n'
1250 <        txt += '    echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1250 >        txt += '    echo "==> setup cms environment ok"\n'
1251          return txt
1252  
1253      ### FEDE FOR DBS OUTPUT PUBLICATION
# Line 1283 | Line 1256 | class Cmssw(JobType):
1256          insert the part of the script that modifies the FrameworkJob Report
1257          """
1258  
1259 <        txt = ''
1259 >        txt = '\n#Written by cms_cmssw::modifyReport\n'
1260          try:
1261              publish_data = int(self.cfg_params['USER.publish_data'])
1262          except KeyError:
1263              publish_data = 0
1264          if (publish_data == 1):
1265 <            txt += 'echo ">>> Modify Job Report:" \n'
1266 <            ################ FEDE FOR DBS2 #############################################
1267 <            #txt += 'chmod a+x $SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n'
1268 <            txt += 'chmod a+x $SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py\n'
1269 <            #############################################################################
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'
1265 >            txt += 'if [ $copy_exit_status -eq 0 ]; then\n'
1266 >            txt += '    echo ">>> Modify Job Report:" \n'
1267 >            txt += '    chmod a+x $SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py\n'
1268 >            txt += '    echo "SE = $SE"\n'
1269 >            txt += '    echo "SE_PATH = $SE_PATH"\n'
1270  
1271              processedDataset = self.cfg_params['USER.publish_data_name']
1272 <            txt += 'ProcessedDataset='+processedDataset+'\n'
1273 <            #### LFN=/store/user/<user>/processedDataset_PSETHASH
1274 <            txt += 'if [ "$SE_PATH" == "" ]; then\n'
1275 <            #### FEDE: added slash in LFN ##############
1276 <            txt += '    FOR_LFN=/copy_problems/ \n'
1277 <            txt += 'else \n'
1278 <            txt += '    tmp=`echo $SE_PATH | awk -F \'store\' \'{print$2}\'` \n'
1279 <            #####  FEDE TO BE CHANGED, BECAUSE STORE IS HARDCODED!!!! ########
1280 <            txt += '    FOR_LFN=/store$tmp \n'
1281 <            txt += 'fi \n'
1282 <            txt += 'echo "ProcessedDataset = $ProcessedDataset"\n'
1283 <            txt += 'echo "FOR_LFN = $FOR_LFN" \n'
1284 <            txt += 'echo "CMSSW_VERSION = $CMSSW_VERSION"\n\n'
1285 <            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'
1286 <            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'
1287 <
1288 <            txt += 'modifyReport_result=$?\n'
1325 <            txt += 'echo modifyReport_result = $modifyReport_result\n'
1326 <            txt += 'if [ $modifyReport_result -ne 0 ]; then\n'
1327 <            txt += '    exit_status=1\n'
1328 <            txt += '    echo "ERROR: Problem with ModifyJobReport"\n'
1329 <            txt += 'else\n'
1330 <            txt += '    mv NewFrameworkJobReport.xml crab_fjr_$NJob.xml\n'
1272 >            LFNBaseName = LFNBase(processedDataset)
1273 >            txt += '    ProcessedDataset='+processedDataset+'\n'
1274 >            txt += '    FOR_LFN=%s_${PSETHASH}/\n'%(LFNBaseName)
1275 >            txt += '    echo "ProcessedDataset = $ProcessedDataset"\n'
1276 >            txt += '    echo "FOR_LFN = $FOR_LFN" \n'
1277 >            txt += '    echo "CMSSW_VERSION = $CMSSW_VERSION"\n\n'
1278 >            txt += '    echo "$SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py $RUNTIME_AREA/crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n'
1279 >            txt += '    $SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py $RUNTIME_AREA/crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH\n'
1280 >            txt += '    modifyReport_result=$?\n'
1281 >            txt += '    if [ $modifyReport_result -ne 0 ]; then\n'
1282 >            txt += '        modifyReport_result=70500\n'
1283 >            txt += '        job_exit_code=$modifyReport_result\n'
1284 >            txt += '        echo "ModifyReportResult=$modifyReport_result" | tee -a $RUNTIME_AREA/$repo\n'
1285 >            txt += '        echo "WARNING: Problem with ModifyJobReport"\n'
1286 >            txt += '    else\n'
1287 >            txt += '        mv NewFrameworkJobReport.xml $RUNTIME_AREA/crab_fjr_$NJob.xml\n'
1288 >            txt += '    fi\n'
1289              txt += 'fi\n'
1332        else:
1333            txt += 'echo "no data publication required"\n'
1334        return txt
1335
1336    def cleanEnv(self):
1337        txt = ''
1338        txt += 'if [ $middleware == OSG ]; then\n'
1339        txt += '    cd $RUNTIME_AREA\n'
1340        txt += '    echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
1341        txt += '    echo ">>> Remove working directory: $WORKING_DIR"\n'
1342        txt += '    /bin/rm -rf $WORKING_DIR\n'
1343        txt += '    if [ -d $WORKING_DIR ] ;then\n'
1344        txt += '        echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
1345        txt += '        echo "JOB_EXIT_STATUS = 60999"\n'
1346        txt += '        echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
1347        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1348        txt += '    fi\n'
1349        txt += 'fi\n'
1350        txt += '\n'
1290          return txt
1291  
1292      def setParam_(self, param, value):
# Line 1365 | Line 1304 | class Cmssw(JobType):
1304              nd[e]=0
1305          return nd.keys()
1306  
1307 <
1369 <    def checkOut(self, limit):
1307 >    def outList(self):
1308          """
1309          check the dimension of the output files
1310          """
1311 <        txt = 'echo ">>> Starting output sandbox limit check :"\n'
1312 <        allOutFiles = ""
1311 >        txt = ''
1312 >        txt += 'echo ">>> list of expected files on output sandbox"\n'
1313          listOutFiles = []
1314 <        txt += 'stdoutFile=`ls *stdout` \n'
1315 <        txt += 'stderrFile=`ls *stderr` \n'
1314 >        stdout = 'CMSSW_$NJob.stdout'
1315 >        stderr = 'CMSSW_$NJob.stderr'
1316          if (self.return_data == 1):
1317 <            for fileOut in (self.output_file+self.output_file_sandbox):
1318 <                allOutFiles = allOutFiles + " " + self.numberFile_(fileOut, '$NJob') + " $stdoutFile $stderrFile"
1319 <        else:            
1320 <            for fileOut in (self.output_file_sandbox):
1321 <                txt += 'echo " '+fileOut+'";\n'
1322 <                allOutFiles = allOutFiles + " " + self.numberFile_(fileOut, '$NJob') + " $stdoutFile $stderrFile"
1323 <        txt += 'echo "OUTPUT files: '+str(allOutFiles)+'";\n'
1317 >            for file in (self.output_file+self.output_file_sandbox):
1318 >                listOutFiles.append(self.numberFile_(file, '$NJob'))
1319 >            listOutFiles.append(stdout)
1320 >            listOutFiles.append(stderr)
1321 >        else:
1322 >            for file in (self.output_file_sandbox):
1323 >                listOutFiles.append(self.numberFile_(file, '$NJob'))
1324 >            listOutFiles.append(stdout)
1325 >            listOutFiles.append(stderr)
1326 >        txt += 'echo "output files: '+string.join(listOutFiles,' ')+'"\n'
1327 >        txt += 'filesToCheck="'+string.join(listOutFiles,' ')+'"\n'
1328 > <<<<<<< cms_cmssw.py
1329          txt += 'ls -gGhrta;\n'
1330          txt += 'sum=0;\n'
1331 <        txt += 'for file in '+str(allOutFiles)+' ; do\n'
1331 >        txt += 'for file in $filesToCheck ; do\n'
1332          txt += '    if [ -e $file ]; then\n'
1333          txt += '        tt=`ls -gGrta $file | awk \'{ print $3 }\'`\n'
1334          txt += '        sum=`expr $sum + $tt`\n'
# Line 1395 | Line 1338 | class Cmssw(JobType):
1338          txt += 'done\n'
1339          txt += 'echo "Total Output dimension: $sum";\n'
1340          txt += 'limit='+str(limit)+';\n'
1341 <        txt += 'echo "OUTPUT FILES LIMIT SET TO: $limit";\n'
1341 >        txt += 'echo "WARNING: output files size limit is set to: $limit";\n'
1342          txt += 'if [ $limit -lt $sum ]; then\n'
1343          txt += '    echo "WARNING: output files have to big size - something will be lost;"\n'
1344          txt += '    echo "         checking the output file sizes..."\n'
1345          txt += '    tot=0;\n'
1346 <        txt += '    for filefile in '+str(allOutFiles)+' ; do\n'
1346 >        txt += '    for filefile in $filesToCheck ; do\n'
1347          txt += '        dimFile=`ls -gGrta $filefile | awk \'{ print $3 }\';`\n'
1348          txt += '        tot=`expr $tot + $tt`;\n'
1349          txt += '        if [ $limit -lt $dimFile ]; then\n'
# Line 1414 | Line 1357 | class Cmssw(JobType):
1357          txt += '        fi\n'
1358          txt += '    done\n'
1359  
1360 <        txt += '    ls -agGhrt;\n'
1361 <        txt += '    echo "WARNING: output files are too big in dimension: can not put in the output_sandbox.";\n'
1362 <        txt += '    echo "JOB_EXIT_STATUS = 70000";\n'
1363 <        txt += '    exit_status=70000;\n'
1364 <        txt += 'else'
1422 <        txt += '    echo "Total Output dimension $sum is fine.";\n'
1360 >        txt += '    ls -agGhrt\n'
1361 >        txt += '    echo "WARNING: output files are too big in dimension: can not put in the output_sandbox."\n'
1362 >        txt += '    job_exit_code=70000\n'
1363 >        txt += 'else\n'
1364 >        txt += '    echo "Total Output dimension $sum is fine."\n'
1365          txt += 'fi\n'
1366          txt += 'echo "Ending output sandbox limit check"\n'
1367          return txt
1368 + =======
1369 +        txt += 'export filesToCheck\n'
1370 + <<<<<<< cms_cmssw.py
1371 +        return txt
1372 + >>>>>>> 1.169
1373 + =======
1374 +        return txt
1375 + >>>>>>> 1.170

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines