test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 6 of file logger.py.

Constructor & Destructor Documentation

def logger.logger.__init__ (   self,
  dirLocalOrTgzDirOnCastor 
)

Definition at line 8 of file logger.py.

8 
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 
def __init__
Definition: logger.py:8
isTgzDirOnCastor
Definition: logger.py:43
def isDirLocal
Definition: logger.py:22

Member Function Documentation

def logger.logger.addFile (   self,
  file 
)

Definition at line 49 of file logger.py.

References logger.logger.dirLocal.

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

49 
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) )
def addFile
Definition: logger.py:49
def logger.logger.dump (   self)

Definition at line 45 of file logger.py.

References logger.logger.dirLocal, and logger.logger.tgzDirOnCastor.

45 
46  def dump(self):
47  print 'local dir :', self.dirLocal
48  print 'castor archive :',self.tgzDirOnCastor
def dump
Definition: logger.py:45
def logger.logger.gitdiff (   self,
  log 
)

Definition at line 73 of file logger.py.

Referenced by logger.logger.logCMSSW().

73 
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 )
def gitdiff
Definition: logger.py:73
def logger.logger.isDirLocal (   self,
  file 
)

Definition at line 22 of file logger.py.

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

Definition at line 28 of file logger.py.

28 
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
def isTgzDirOnEOS
Definition: logger.py:28
def logger.logger.logCMSSW (   self)

Definition at line 57 of file logger.py.

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

57 
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)
def gitdiff
Definition: logger.py:73
def logCMSSW
Definition: logger.py:57
def showtags
Definition: logger.py:81
def addFile
Definition: logger.py:49
def logger.logger.logJobs (   self,
  n 
)

Definition at line 66 of file logger.py.

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

66 
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)
def logJobs
Definition: logger.py:66
def addFile
Definition: logger.py:49
def logger.logger.showtags (   self,
  log 
)

Definition at line 81 of file logger.py.

Referenced by logger.logger.logCMSSW().

81 
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 )
def showtags
Definition: logger.py:81
def logger.logger.stageIn (   self)

Definition at line 96 of file logger.py.

References logger.logger.dirLocal, and logger.logger.tgzDirOnCastor.

96 
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'
def stageIn
Definition: logger.py:96
def logger.logger.stageOut (   self,
  castorDir 
)

Definition at line 111 of file logger.py.

References logger.logger.dirLocal, 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 
def stageOut
Definition: logger.py:111

Member Data Documentation

logger.logger.dirLocal

Definition at line 10 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 43 of file logger.py.

logger.logger.tgzDirOnCastor

Definition at line 11 of file logger.py.

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