CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Static Public Attributes
logger.logger Class Reference

Public Member Functions

def __init__ (self, dirLocalOrTgzDirOnCastor)
 
def addFile (self, file)
 
def dump (self)
 
def gitdiff (self, log)
 
def isDirLocal (self, file)
 
def isTgzDirOnEOS (self, file)
 
def logCMSSW (self)
 
def logJobs (self, n)
 
def showtags (self, log)
 
def stageIn (self)
 
def stageOut (self, castorDir)
 

Public Attributes

 dirLocal
 
 tgzDirOnCastor
 

Static Public Attributes

 isTgzDirOnCastor
 

Detailed Description

COLIN: do something cleaner with tagPackage

Definition at line 7 of file logger.py.

Constructor & Destructor Documentation

def logger.logger.__init__ (   self,
  dirLocalOrTgzDirOnCastor 
)

Definition at line 9 of file logger.py.

9  def __init__(self, dirLocalOrTgzDirOnCastor):
10 
11  self.dirLocal = None
12  self.tgzDirOnCastor = None
13  dirLocalOrTgzDirOnCastor = dirLocalOrTgzDirOnCastor.rstrip('/')
14 
15  if self.isDirLocal( dirLocalOrTgzDirOnCastor ):
16  self.dirLocal = dirLocalOrTgzDirOnCastor
17  elif self.isTgzDirOnCastor( dirLocalOrTgzDirOnCastor ):
18  self.tgzDirOnCastor = dirLocalOrTgzDirOnCastor
19  else:
20  raise ValueError( dirLocalOrTgzDirOnCastor + ' is neither a tgz directory on castor (provide a LFN!) nor a local directory')
21 
22 
isTgzDirOnCastor
Definition: logger.py:44
def isDirLocal(self, file)
Definition: logger.py:23
def __init__(self, dirLocalOrTgzDirOnCastor)
Definition: logger.py:9

Member Function Documentation

def logger.logger.addFile (   self,
  file 
)

Definition at line 50 of file logger.py.

References logger.logger.dirLocal.

Referenced by logger.logger.logCMSSW(), and logger.logger.logJobs().

50  def addFile(self, file):
51  # if self.dirLocal == None:
52  # self.stageIn()
53  # os.system( 'cp %s %s' % (file, self.dirLocal) )
54  # self.stageOut( self.tgzDirOnCastor )
55  if self.dirLocal != None:
56  os.system( 'cp %s %s' % (file, self.dirLocal) )
57 
def addFile(self, file)
Definition: logger.py:50
def logger.logger.dump (   self)

Definition at line 46 of file logger.py.

References logger.logger.dirLocal, edm.print(), and logger.logger.tgzDirOnCastor.

46  def dump(self):
47  print('local dir :', self.dirLocal)
48  print('castor archive :',self.tgzDirOnCastor)
49 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def dump(self)
Definition: logger.py:46
def logger.logger.gitdiff (   self,
  log 
)

Definition at line 74 of file logger.py.

References edm.print().

Referenced by logger.logger.logCMSSW().

74  def gitdiff(self, log):
75  oldPwd = os.getcwd()
76  os.chdir( os.getenv('CMSSW_BASE') + '/src/' )
77  diffCmd = 'git diff -p --stat --color=never > %s/%s 2> /dev/null' % (oldPwd, log)
78  print(diffCmd)
79  os.system( diffCmd )
80  os.chdir( oldPwd )
81 
def gitdiff(self, log)
Definition: logger.py:74
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def logger.logger.isDirLocal (   self,
  file 
)

Definition at line 23 of file logger.py.

23  def isDirLocal(self, file ):
24  if os.path.isdir( file ):
25  return True
26  else:
27  return False
28 
def isDirLocal(self, file)
Definition: logger.py:23
def logger.logger.isTgzDirOnEOS (   self,
  file 
)
Checks if file is a .tgz file in an eos dir

Definition at line 29 of file logger.py.

29  def isTgzDirOnEOS(self, file ):
30  '''Checks if file is a .tgz file in an eos dir'''
31  if not castortools.isCastorDir( file ):
32  file = castortools.castorToLFN(file)
33 
34  if castortools.isLFN( file ):
35  tgzPattern = re.compile('.*\.tgz$')
36  m = tgzPattern.match( file )
37  if m:
38  return True
39  else:
40  return False
41  else:
42  return False
43 
def isTgzDirOnEOS(self, file)
Definition: logger.py:29
def logger.logger.logCMSSW (   self)

Definition at line 58 of file logger.py.

References logger.logger.addFile(), logger.logger.gitdiff(), and logger.logger.showtags().

58  def logCMSSW(self):
59  showtagsLog = 'logger_showtags.txt'
60  diffLog = 'logger_diff.txt'
61  # os.system('showtags > ' + showtagsLog)
62  self.showtags(showtagsLog)
63  self.gitdiff(diffLog)
64  self.addFile(showtagsLog)
65  self.addFile(diffLog)
66 
def gitdiff(self, log)
Definition: logger.py:74
def showtags(self, log)
Definition: logger.py:82
def addFile(self, file)
Definition: logger.py:50
def logCMSSW(self)
Definition: logger.py:58
def logger.logger.logJobs (   self,
  n 
)

Definition at line 67 of file logger.py.

References logger.logger.addFile(), and FrontierConditions_GlobalTag_cff.file.

67  def logJobs(self, n):
68  nJobs = 'logger_jobs.txt'
69  out = file(nJobs,'w')
70  out.write('NJobs: %i\n' % n)
71  out.close()
72  self.addFile(nJobs)
73 
def logJobs(self, n)
Definition: logger.py:67
def addFile(self, file)
Definition: logger.py:50
def logger.logger.showtags (   self,
  log 
)

Definition at line 82 of file logger.py.

Referenced by logger.logger.logCMSSW().

82  def showtags(self, log):
83  oldPwd = os.getcwd()
84  os.chdir( os.getenv('CMSSW_BASE') + '/src/' )
85  cmd = 'echo "Test Release based on: $CMSSW_VERSION" > %s/%s 2> /dev/null' % (oldPwd, log)
86  os.system( cmd )
87  cmd = 'echo "Base Release in: $CMSSW_RELEASE_BASE" >> %s/%s 2> /dev/null' % (oldPwd, log)
88  os.system( cmd )
89  cmd = 'echo "Your Test release in: $CMSSW_BASE" >> %s/%s 2> /dev/null' % (oldPwd, log)
90  os.system( cmd )
91  cmd = 'git status --porcelain -b | head -n 1 >> %s/%s 2> /dev/null' % (oldPwd, log)
92  os.system( cmd )
93  cmd = 'git log -n 100 --format="%%T %%ai %%s %%d" >> %s/%s 2> /dev/null' % (oldPwd, log)
94  os.system( cmd )
95  os.chdir( oldPwd )
96 
def showtags(self, log)
Definition: logger.py:82
def logger.logger.stageIn (   self)

Definition at line 97 of file logger.py.

References logger.logger.dirLocal, edm.print(), and logger.logger.tgzDirOnCastor.

97  def stageIn(self):
98  if self.tgzDirOnCastor != None:
99  # castortools.xrdcp( '.', [self.tgzDirOnCastor] )
100  cmsStage = 'cmsStage -f ' + self.tgzDirOnCastor + ' .'
101  print(cmsStage)
102  os.system( cmsStage )
103  tgzDir = os.path.basename( self.tgzDirOnCastor )
104  print(tgzDir)
105  os.system('tar -zxvf ' + tgzDir)
106  os.system('rm ' + tgzDir )
107  (root, ext) = os.path.splitext(tgzDir)
108  self.dirLocal = root
109  else:
110  print('cannot stage in, the log had not been staged out')
111 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def stageIn(self)
Definition: logger.py:97
def logger.logger.stageOut (   self,
  castorDir 
)

Definition at line 112 of file logger.py.

References logger.logger.dirLocal, edm.print(), and logger.logger.tgzDirOnCastor.

112  def stageOut(self, castorDir):
113 
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 .')
117  return False
118 
119  if self.dirLocal != None:
120  tgzDir = self.dirLocal + '.tgz'
121  tgzCmd = 'tar -zcvf ' + tgzDir + ' ' + self.dirLocal
122  print(tgzCmd)
123  os.system( tgzCmd)
124  cmsStage = 'cmsStage -f %s %s' % (tgzDir, castorDir )
125  print(cmsStage)
126  os.system( cmsStage )
127  os.system('rm ' + tgzDir )
128  self.tgzDirOnCastor = castorDir + '/' + tgzDir
129  else:
130  print('cannot stage out, the log is not staged in')
131 
132 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def stageOut(self, castorDir)
Definition: logger.py:112

Member Data Documentation

logger.logger.dirLocal
logger.logger.isTgzDirOnCastor
static

Definition at line 44 of file logger.py.

logger.logger.tgzDirOnCastor

Definition at line 12 of file logger.py.

Referenced by logger.logger.dump(), logger.logger.stageIn(), and logger.logger.stageOut().