1 import os,commands,re,urllib2
3 def __init__(self,statusfilename='tagstatus.txt'):
4 self.
lumiurl=
'http://cms-service-lumi.web.cern.ch/cms-service-lumi/'+statusfilename
7 openurl=urllib2.build_opener()
8 tagfile=openurl.open(self.
lumiurl)
9 tagfileStr=tagfile.read()
10 for tag
in tagfileStr.lstrip(
'\n').
strip(
'\n').
split(
'\n'):
12 taglist.append([fields[0],fields[1],fields[2]])
15 currentdir=os.getcwd()
16 os.chdir(os.path.join(cmsswWorkingBase,
'src',
'RecoLuminosity',
'LumiDB',
'scripts'))
17 cvscmmd=
'cvs status '+scriptname
18 (cmmdstatus,result)=commands.getstatusoutput(cvscmmd+
'| grep "Sticky Tag:"')
20 cleanresult=result.lstrip().
strip()
21 cleanresult=re.sub(
r'\s+|\t+',
' ',cleanresult)
22 allfields=cleanresult.split(
' ')
23 workingversion =
"n/a" 24 for line
in filter(
lambda line:
"Sticky Tag" in line, result.split(
'\n')):
25 workingversion = line.split()[2]
26 if workingversion==
'(none)':
29 print 'checking current version......' 30 print ' project base : '+cmsswWorkingBase
31 print ' script : '+scriptname
32 print ' version : '+workingversion
36 if workingtag==
'(none)':
38 print 'checking update for HEAD' 41 w=workingtag.lstrip(
'V').
split(
'-')
47 for [tagstr,ismajor,desc]
in newtags:
48 digits=[
int(r)
for r
in tagstr.lstrip(
'V').
split(
'-')]
49 if digits[0]==w[0]
and digits[1]==w[1]
and digits[2]==w[2]:
59 updatetags.append([tagstr,ismajor,desc])
61 print 'checking update for '+workingtag
65 for [tag,ismajor,description]
in updatetags:
67 print ' major update, tag ',tag+
' , '+description
69 print ' minor update, tag ',tag+
' , '+description
72 if __name__==
'__main__':
73 scriptname=
'lumiCalc2.py' 74 cmsswWorkingBase=os.environ[
'CMSSW_BASE']
76 workingversion=c.runningVersion(cmsswWorkingBase,scriptname)
78 c.checkforupdate(workingversion)
def checkforupdate(self, workingtag, isverbose=True)
def runningVersion(self, cmsswWorkingBase, scriptname, isverbose=True)
def __init__(self, statusfilename='tagstatus.txt')