CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Public Attributes | Static Public Attributes
logger.logger Class Reference

Public Member Functions

def __init__
 
def addFile
 
def dump
 
def gitdiff
 
def isDirLocal
 
def isTgzDirOnEOS
 
def logCMSSW
 
def logJobs
 
def showtags
 
def stageIn
 
def stageOut
 

Public Attributes

 dirLocal
 
 tgzDirOnCastor
 

Static Public Attributes

 isTgzDirOnCastor = isTgzDirOnEOS
 

Detailed Description

COLIN: do something cleaner with tagPackage

Definition at line 8 of file logger.py.

Constructor & Destructor Documentation

def logger.logger.__init__ (   self,
  dirLocalOrTgzDirOnCastor 
)

Definition at line 10 of file logger.py.

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

Member Function Documentation

def logger.logger.addFile (   self,
  file 
)

Definition at line 51 of file logger.py.

References logger.logger.dirLocal.

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

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

Definition at line 47 of file logger.py.

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

47 
48  def dump(self):
49  print('local dir :', self.dirLocal)
50  print('castor archive :',self.tgzDirOnCastor)
def dump
Definition: logger.py:47
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def logger.logger.gitdiff (   self,
  log 
)

Definition at line 75 of file logger.py.

References print().

Referenced by logger.logger.logCMSSW().

75 
76  def gitdiff(self, log):
77  oldPwd = os.getcwd()
78  os.chdir( os.getenv('CMSSW_BASE') + '/src/' )
79  diffCmd = 'git diff -p --stat --color=never > %s/%s 2> /dev/null' % (oldPwd, log)
80  print(diffCmd)
81  os.system( diffCmd )
82  os.chdir( oldPwd )
def gitdiff
Definition: logger.py:75
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def logger.logger.isDirLocal (   self,
  file 
)

Definition at line 24 of file logger.py.

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

Definition at line 30 of file logger.py.

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

Definition at line 59 of file logger.py.

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

59 
60  def logCMSSW(self):
61  showtagsLog = 'logger_showtags.txt'
62  diffLog = 'logger_diff.txt'
63  # os.system('showtags > ' + showtagsLog)
64  self.showtags(showtagsLog)
65  self.gitdiff(diffLog)
66  self.addFile(showtagsLog)
67  self.addFile(diffLog)
def gitdiff
Definition: logger.py:75
def logCMSSW
Definition: logger.py:59
def showtags
Definition: logger.py:83
def addFile
Definition: logger.py:51
def logger.logger.logJobs (   self,
  n 
)

Definition at line 68 of file logger.py.

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

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

Definition at line 83 of file logger.py.

Referenced by logger.logger.logCMSSW().

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

Definition at line 98 of file logger.py.

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

98 
99  def stageIn(self):
100  if self.tgzDirOnCastor != None:
101  # castortools.xrdcp( '.', [self.tgzDirOnCastor] )
102  cmsStage = 'cmsStage -f ' + self.tgzDirOnCastor + ' .'
103  print(cmsStage)
104  os.system( cmsStage )
105  tgzDir = os.path.basename( self.tgzDirOnCastor )
106  print(tgzDir)
107  os.system('tar -zxvf ' + tgzDir)
108  os.system('rm ' + tgzDir )
109  (root, ext) = os.path.splitext(tgzDir)
110  self.dirLocal = root
111  else:
112  print('cannot stage in, the log had not been staged out')
def stageIn
Definition: logger.py:98
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def logger.logger.stageOut (   self,
  castorDir 
)

Definition at line 113 of file logger.py.

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

114  def stageOut(self, castorDir):
115 
116  castorDir = castortools.eosToLFN( castorDir )
117  if not castortools.isLFN( castorDir ):
118  print('cannot stage out, you need to provide an LFN as a destination directory, beginning with /store .')
119  return False
120 
121  if self.dirLocal != None:
122  tgzDir = self.dirLocal + '.tgz'
123  tgzCmd = 'tar -zcvf ' + tgzDir + ' ' + self.dirLocal
124  print(tgzCmd)
125  os.system( tgzCmd)
126  cmsStage = 'cmsStage -f %s %s' % (tgzDir, castorDir )
127  print(cmsStage)
128  os.system( cmsStage )
129  os.system('rm ' + tgzDir )
130  self.tgzDirOnCastor = castorDir + '/' + tgzDir
131  else:
132  print('cannot stage out, the log is not staged in')
133 
def stageOut
Definition: logger.py:113
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

Member Data Documentation

logger.logger.dirLocal

Definition at line 12 of file logger.py.

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

logger.logger.isTgzDirOnCastor = isTgzDirOnEOS
static

Definition at line 45 of file logger.py.

logger.logger.tgzDirOnCastor

Definition at line 13 of file logger.py.

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