1 from __future__
import print_function
2 from optparse
import OptionParser
3 import sys,os, re, subprocess, datetime
5 import eostools
as castortools
8 '''COLIN: do something cleaner with tagPackage''' 9 def __init__(self, dirLocalOrTgzDirOnCastor):
13 dirLocalOrTgzDirOnCastor = dirLocalOrTgzDirOnCastor.rstrip(
'/')
15 if self.
isDirLocal( dirLocalOrTgzDirOnCastor ):
16 self.
dirLocal = dirLocalOrTgzDirOnCastor
20 raise ValueError( dirLocalOrTgzDirOnCastor +
' is neither a tgz directory on castor (provide a LFN!) nor a local directory')
24 if os.path.isdir( file ):
30 '''Checks if file is a .tgz file in an eos dir''' 31 if not castortools.isCastorDir( file ):
32 file = castortools.castorToLFN(file)
34 if castortools.isLFN( file ):
35 tgzPattern = re.compile(
'.*\.tgz$')
36 m = tgzPattern.match( file )
44 isTgzDirOnCastor = isTgzDirOnEOS
56 os.system(
'cp %s %s' % (file, self.
dirLocal) )
59 showtagsLog =
'logger_showtags.txt' 60 diffLog =
'logger_diff.txt' 68 nJobs =
'logger_jobs.txt' 70 out.write(
'NJobs: %i\n' % n)
76 os.chdir( os.getenv(
'CMSSW_BASE') +
'/src/' )
77 diffCmd =
'git diff -p --stat --color=never > %s/%s 2> /dev/null' % (oldPwd, log)
84 os.chdir( os.getenv(
'CMSSW_BASE') +
'/src/' )
85 cmd =
'echo "Test Release based on: $CMSSW_VERSION" > %s/%s 2> /dev/null' % (oldPwd, log)
87 cmd =
'echo "Base Release in: $CMSSW_RELEASE_BASE" >> %s/%s 2> /dev/null' % (oldPwd, log)
89 cmd =
'echo "Your Test release in: $CMSSW_BASE" >> %s/%s 2> /dev/null' % (oldPwd, log)
91 cmd =
'git status --porcelain -b | head -n 1 >> %s/%s 2> /dev/null' % (oldPwd, log)
93 cmd =
'git log -n 100 --format="%%T %%ai %%s %%d" >> %s/%s 2> /dev/null' % (oldPwd, log)
102 os.system( cmsStage )
105 os.system(
'tar -zxvf ' + tgzDir)
106 os.system(
'rm ' + tgzDir )
107 (root, ext) = os.path.splitext(tgzDir)
110 print(
'cannot stage in, the log had not been staged out')
114 castorDir = castortools.eosToLFN( castorDir )
115 if not castortools.isLFN( castorDir ):
116 print(
'cannot stage out, you need to provide an LFN as a destination directory, beginning with /store .')
121 tgzCmd =
'tar -zcvf ' + tgzDir +
' ' + self.
dirLocal 124 cmsStage =
'cmsStage -f %s %s' % (tgzDir, castorDir )
126 os.system( cmsStage )
127 os.system(
'rm ' + tgzDir )
130 print(
'cannot stage out, the log is not staged in')
S & print(S &os, JobReport::InputFile const &f)
def isDirLocal(self, file)
def stageOut(self, castorDir)
def isTgzDirOnEOS(self, file)
def __init__(self, dirLocalOrTgzDirOnCastor)