CMS 3D CMS Logo

Public Member Functions | Public Attributes

checkforupdate::checkforupdate Class Reference

List of all members.

Public Member Functions

def __init__
def checkforupdate
def fetchTagsHTTP
def runningVersion

Public Attributes

 lumiurl

Detailed Description

Definition at line 2 of file checkforupdate.py.


Constructor & Destructor Documentation

def checkforupdate::checkforupdate::__init__ (   self,
  statusfilename = 'tagstatus.txt' 
)

Definition at line 3 of file checkforupdate.py.

00004                                                      :
        self.lumiurl='http://cms-service-lumi.web.cern.ch/cms-service-lumi/'+statusfilename
def checkforupdate::checkforupdate::checkforupdate (   self,
  workingtag,
  isverbose = True 
)

Definition at line 34 of file checkforupdate.py.

00035                                                       :
00036         newtags=self.fetchTagsHTTP()
00037         if workingtag=='(none)':#means HEAD
00038             if isverbose:
00039                 print 'checking update for HEAD'
00040                 print '  no update'
00041             return []
00042         w=workingtag.lstrip('V').split('-')
00043         if len(w)!=3:
00044             #print workingtag+' is not a release tag, can not compare'
00045             return []
00046         w=[int(r) for r in w]
00047         updatetags=[]
00048         for [tagstr,ismajor,desc] in newtags:
00049             digits=[int(r) for r in tagstr.lstrip('V').split('-')]
00050             if digits[0]==w[0] and  digits[1]==w[1] and digits[2]==w[2]:
00051                 continue
00052             if digits[0]<w[0]: 
00053                 continue            
00054             elif digits[0]==w[0]:
00055                 if digits[1]<w[1]:
00056                     continue
00057                 elif digits[1]==w[1]:
00058                     if digits[2]<=w[2]:
00059                         continue
00060             updatetags.append([tagstr,ismajor,desc])
00061         if isverbose:
00062             print 'checking update for '+workingtag
00063             if not updatetags:
00064                 print '  no update'
00065                 return []
00066             for [tag,ismajor,description] in updatetags:
00067                 if ismajor=='1':
00068                     print '  major update, tag ',tag+' , '+description
00069                 else:
00070                     print '  minor update, tag ',tag+' , '+description
00071         return updatetags
        

Member Function Documentation

def checkforupdate::checkforupdate::fetchTagsHTTP (   self)

Definition at line 5 of file checkforupdate.py.

00006                            :
00007         taglist=[]
00008         openurl=urllib2.build_opener()
00009         tagfile=openurl.open(self.lumiurl)
00010         tagfileStr=tagfile.read()
00011         for tag in tagfileStr.lstrip('\n').strip('\n').split('\n'):
00012             fields=tag.split(',')
00013             taglist.append([fields[0],fields[1],fields[2]])
        return taglist
def checkforupdate::checkforupdate::runningVersion (   self,
  cmsswWorkingBase,
  scriptname,
  isverbose = True 
)

Definition at line 14 of file checkforupdate.py.

00015                                                                        :
00016         currentdir=os.getcwd()
00017         os.chdir(os.path.join(cmsswWorkingBase,'src','RecoLuminosity','LumiDB','scripts'))
00018         cvscmmd='cvs status '+scriptname
00019         (cmmdstatus,result)=commands.getstatusoutput(cvscmmd+'| grep "Sticky Tag:"')
00020         os.chdir(currentdir)
00021         cleanresult=result.lstrip().strip()
00022         cleanresult=re.sub(r'\s+|\t+',' ',cleanresult)
00023         allfields=cleanresult.split(' ')
00024         workingversion = "n/a"
00025         for line in filter(lambda line: "Sticky Tag" in line, result.split('\n')):
00026             workingversion = line.split()[2]
00027         if workingversion=='(none)':
00028             workingversion='HEAD'
00029         if isverbose:
00030             print 'checking current version......'
00031             print '  project base : '+cmsswWorkingBase
00032             print '  script : '+scriptname
00033             print '  version : '+workingversion
        return workingversion

Member Data Documentation

Definition at line 3 of file checkforupdate.py.