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 8 of file logger.py.

Constructor & Destructor Documentation

◆ __init__()

def logger.logger.__init__ (   self,
  dirLocalOrTgzDirOnCastor 
)

Definition at line 10 of file logger.py.

10  def __init__(self, dirLocalOrTgzDirOnCastor):
11 
12  self.dirLocal = None
13  self.tgzDirOnCastor = None
14  dirLocalOrTgzDirOnCastor = dirLocalOrTgzDirOnCastor.rstrip('/')
15 
16  if self.isDirLocal( dirLocalOrTgzDirOnCastor ):
17  self.dirLocal = dirLocalOrTgzDirOnCastor
18  elif self.isTgzDirOnCastor( dirLocalOrTgzDirOnCastor ):
19  self.tgzDirOnCastor = dirLocalOrTgzDirOnCastor
20  else:
21  raise ValueError( dirLocalOrTgzDirOnCastor + ' is neither a tgz directory on castor (provide a LFN!) nor a local directory')
22 
23 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

Member Function Documentation

◆ addFile()

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  def addFile(self, file):
52  # if self.dirLocal == None:
53  # self.stageIn()
54  # os.system( 'cp %s %s' % (file, self.dirLocal) )
55  # self.stageOut( self.tgzDirOnCastor )
56  if self.dirLocal != None:
57  os.system( 'cp %s %s' % (file, self.dirLocal) )
58 
int addFile(MEStore &micromes, int fd)
Definition: fastHadd.cc:352

◆ dump()

def logger.logger.dump (   self)

Definition at line 47 of file logger.py.

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

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

◆ gitdiff()

def logger.logger.gitdiff (   self,
  log 
)

Definition at line 75 of file logger.py.

References print().

Referenced by logger.logger.logCMSSW().

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

◆ isDirLocal()

def logger.logger.isDirLocal (   self,
  file 
)

Definition at line 24 of file logger.py.

24  def isDirLocal(self, file ):
25  if os.path.isdir( file ):
26  return True
27  else:
28  return False
29 

◆ isTgzDirOnEOS()

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  def isTgzDirOnEOS(self, file ):
31  '''Checks if file is a .tgz file in an eos dir'''
32  if not castortools.isCastorDir( file ):
33  file = castortools.castorToLFN(file)
34 
35  if castortools.isLFN( file ):
36  tgzPattern = re.compile('.*\\.tgz$')
37  m = tgzPattern.match( file )
38  if m:
39  return True
40  else:
41  return False
42  else:
43  return False
44 

◆ logCMSSW()

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  def logCMSSW(self):
60  showtagsLog = 'logger_showtags.txt'
61  diffLog = 'logger_diff.txt'
62  # os.system('showtags > ' + showtagsLog)
63  self.showtags(showtagsLog)
64  self.gitdiff(diffLog)
65  self.addFile(showtagsLog)
66  self.addFile(diffLog)
67 

◆ logJobs()

def logger.logger.logJobs (   self,
  n 
)

Definition at line 68 of file logger.py.

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

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

◆ showtags()

def logger.logger.showtags (   self,
  log 
)

Definition at line 83 of file logger.py.

Referenced by logger.logger.logCMSSW().

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

◆ stageIn()

def logger.logger.stageIn (   self)

Definition at line 98 of file logger.py.

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

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

◆ stageOut()

def logger.logger.stageOut (   self,
  castorDir 
)

Definition at line 113 of file logger.py.

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

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

Member Data Documentation

◆ dirLocal

logger.logger.dirLocal

◆ isTgzDirOnCastor

logger.logger.isTgzDirOnCastor
static

Definition at line 45 of file logger.py.

◆ tgzDirOnCastor

logger.logger.tgzDirOnCastor

Definition at line 13 of file logger.py.

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