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

Constructor & Destructor Documentation

def logger.logger.__init__ (   self,
  dirLocalOrTgzDirOnCastor 
)

Definition at line 8 of file logger.py.

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

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  def addFile(self, file):
50  # if self.dirLocal == None:
51  # self.stageIn()
52  # os.system( 'cp %s %s' % (file, self.dirLocal) )
53  # self.stageOut( self.tgzDirOnCastor )
54  if self.dirLocal != None:
55  os.system( 'cp %s %s' % (file, self.dirLocal) )
56 
def addFile(self, file)
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  def dump(self):
46  print 'local dir :', self.dirLocal
47  print 'castor archive :',self.tgzDirOnCastor
48 
def dump(self)
Definition: logger.py:45
def logger.logger.gitdiff (   self,
  log 
)

Definition at line 73 of file logger.py.

Referenced by logger.logger.logCMSSW().

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

Definition at line 22 of file logger.py.

22  def isDirLocal(self, file ):
23  if os.path.isdir( file ):
24  return True
25  else:
26  return False
27 
def isDirLocal(self, file)
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  def isTgzDirOnEOS(self, file ):
29  '''Checks if file is a .tgz file in an eos dir'''
30  if not castortools.isCastorDir( file ):
31  file = castortools.castorToLFN(file)
32 
33  if castortools.isLFN( file ):
34  tgzPattern = re.compile('.*\.tgz$')
35  m = tgzPattern.match( file )
36  if m:
37  return True
38  else:
39  return False
40  else:
41  return False
42 
def isTgzDirOnEOS(self, file)
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  def logCMSSW(self):
58  showtagsLog = 'logger_showtags.txt'
59  diffLog = 'logger_diff.txt'
60  # os.system('showtags > ' + showtagsLog)
61  self.showtags(showtagsLog)
62  self.gitdiff(diffLog)
63  self.addFile(showtagsLog)
64  self.addFile(diffLog)
65 
def gitdiff(self, log)
Definition: logger.py:73
def showtags(self, log)
Definition: logger.py:81
def addFile(self, file)
Definition: logger.py:49
def logCMSSW(self)
Definition: logger.py:57
def logger.logger.logJobs (   self,
  n 
)

Definition at line 66 of file logger.py.

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

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

Definition at line 81 of file logger.py.

Referenced by logger.logger.logCMSSW().

81  def showtags(self, log):
82  oldPwd = os.getcwd()
83  os.chdir( os.getenv('CMSSW_BASE') + '/src/' )
84  cmd = 'echo "Test Release based on: $CMSSW_VERSION" > %s/%s 2> /dev/null' % (oldPwd, log)
85  os.system( cmd )
86  cmd = 'echo "Base Release in: $CMSSW_RELEASE_BASE" >> %s/%s 2> /dev/null' % (oldPwd, log)
87  os.system( cmd )
88  cmd = 'echo "Your Test release in: $CMSSW_BASE" >> %s/%s 2> /dev/null' % (oldPwd, log)
89  os.system( cmd )
90  cmd = 'git status --porcelain -b | head -n 1 >> %s/%s 2> /dev/null' % (oldPwd, log)
91  os.system( cmd )
92  cmd = 'git log -n 100 --format="%%T %%ai %%s %%d" >> %s/%s 2> /dev/null' % (oldPwd, log)
93  os.system( cmd )
94  os.chdir( oldPwd )
95 
def showtags(self, log)
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  def stageIn(self):
97  if self.tgzDirOnCastor != None:
98  # castortools.xrdcp( '.', [self.tgzDirOnCastor] )
99  cmsStage = 'cmsStage -f ' + self.tgzDirOnCastor + ' .'
100  print cmsStage
101  os.system( cmsStage )
102  tgzDir = os.path.basename( self.tgzDirOnCastor )
103  print tgzDir
104  os.system('tar -zxvf ' + tgzDir)
105  os.system('rm ' + tgzDir )
106  (root, ext) = os.path.splitext(tgzDir)
107  self.dirLocal = root
108  else:
109  print 'cannot stage in, the log had not been staged out'
110 
def stageIn(self)
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.

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

Member Data Documentation

logger.logger.dirLocal
logger.logger.isTgzDirOnCastor
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().