1 from optparse
import OptionParser
2 import sys,os, re, subprocess, datetime
4 import eostools
as castortools
7 '''COLIN: do something cleaner with tagPackage''' 8 def __init__(self, dirLocalOrTgzDirOnCastor):
12 dirLocalOrTgzDirOnCastor = dirLocalOrTgzDirOnCastor.rstrip(
'/')
14 if self.
isDirLocal( dirLocalOrTgzDirOnCastor ):
15 self.
dirLocal = dirLocalOrTgzDirOnCastor
19 raise ValueError( dirLocalOrTgzDirOnCastor +
' is neither a tgz directory on castor (provide a LFN!) nor a local directory')
23 if os.path.isdir( file ):
29 '''Checks if file is a .tgz file in an eos dir''' 30 if not castortools.isCastorDir( file ):
31 file = castortools.castorToLFN(file)
33 if castortools.isLFN( file ):
34 tgzPattern = re.compile(
'.*\.tgz$')
35 m = tgzPattern.match( file )
43 isTgzDirOnCastor = isTgzDirOnEOS
55 os.system(
'cp %s %s' % (file, self.
dirLocal) )
58 showtagsLog =
'logger_showtags.txt' 59 diffLog =
'logger_diff.txt' 67 nJobs =
'logger_jobs.txt' 69 out.write(
'NJobs: %i\n' % n)
75 os.chdir( os.getenv(
'CMSSW_BASE') +
'/src/' )
76 diffCmd =
'git diff -p --stat --color=never > %s/%s 2> /dev/null' % (oldPwd, log)
83 os.chdir( os.getenv(
'CMSSW_BASE') +
'/src/' )
84 cmd =
'echo "Test Release based on: $CMSSW_VERSION" > %s/%s 2> /dev/null' % (oldPwd, log)
86 cmd =
'echo "Base Release in: $CMSSW_RELEASE_BASE" >> %s/%s 2> /dev/null' % (oldPwd, log)
88 cmd =
'echo "Your Test release in: $CMSSW_BASE" >> %s/%s 2> /dev/null' % (oldPwd, log)
90 cmd =
'git status --porcelain -b | head -n 1 >> %s/%s 2> /dev/null' % (oldPwd, log)
92 cmd =
'git log -n 100 --format="%%T %%ai %%s %%d" >> %s/%s 2> /dev/null' % (oldPwd, log)
101 os.system( cmsStage )
104 os.system(
'tar -zxvf ' + tgzDir)
105 os.system(
'rm ' + tgzDir )
106 (root, ext) = os.path.splitext(tgzDir)
109 print 'cannot stage in, the log had not been staged out' 113 castorDir = castortools.eosToLFN( castorDir )
114 if not castortools.isLFN( castorDir ):
115 print 'cannot stage out, you need to provide an LFN as a destination directory, beginning with /store .' 120 tgzCmd =
'tar -zcvf ' + tgzDir +
' ' + self.
dirLocal 123 cmsStage =
'cmsStage -f %s %s' % (tgzDir, castorDir )
125 os.system( cmsStage )
126 os.system(
'rm ' + tgzDir )
129 print 'cannot stage out, the log is not staged in'
def isDirLocal(self, file)
def stageOut(self, castorDir)
def isTgzDirOnEOS(self, file)
def __init__(self, dirLocalOrTgzDirOnCastor)