CMS 3D CMS Logo

Functions | Variables

dbtoweb Namespace Reference

Functions

def myparser
def single

Variables

tuple ACCOUNT = CONFIG.get('Common','Account')
string AUTHPATH = ''
tuple BASEDIR = os.getcwd()
tuple CONFIG = ConfigParser.ConfigParser()
string CONFIGFILE = 'dbtoweb.cfg'
tuple CONNSTRINGGLOBTAG = CONFIG.get('Common','Conn_string_gtag')
list file = treelist[tree]
tuple GLOBTAG = CONFIG.get('Common','Globtag')
tuple HTMLNAME = CONFIG.get('Common','HTMLName')
tuple htmlroot = open(HTMLTMP,'w')
string HTMLTMP = '.tmp'
tuple line = tmplist.readline()
int MAXRETRIES = 10
int ntrees = 0
tuple out = myparser(line,'tree:')
tuple ROOTDIR = CONFIG.get('Common','Rootdir')
tuple tmplist = open(TMPTAGLIST,'r')
tuple TMPTAGLIST = commands.getoutput('mktemp')
int TOBECREATED = 0
 initialization first change to root dir
string TREEDIR = '/'
list treelist = []

Function Documentation

def dbtoweb::myparser (   input,
  parstag 
)

Definition at line 41 of file dbtoweb.py.

00042                            :
00043     out='-1'
00044 
00045     if input.find(parstag)!=-1:
00046         first=input.split(parstag)
00047         second=first[1].split()
00048 #        print second
00049         if (len(second)>=1):
00050             out=second[0]
00051             
00052     return out
00053 
00054 

def dbtoweb::single (   currgtag)

Definition at line 55 of file dbtoweb.py.

Referenced by CombinationGenerator< T >::separateOneElement().

00056                     :
00057 
00058     root=''
00059     node=''
00060     globparent=''
00061     leafnode=[]
00062     parent=[]
00063     tag=[]
00064     pfn=[]
00065     object=[]
00066     record=[]
00067     connstring=[]
00068     account=[]
00069     
00070     htmltag=open(currgtag+'.html','w')
00071     htmltag.write('<html>\n')
00072     htmltag.write('<body>\n')
00073     htmltag.write('<h3> Tag List for Global Tag: '+currgtag+' </h3>\n')
00074     htmltag.write('<h4> The first time you access a tag below you have to login (HN credentials)<br>')
00075     htmltag.write('Then you can come back here and access all tags </h4>\n')
00076  
00077 
00078     htmltag.write('<table border="1">\n')
00079     htmltag.write('<tr>\n')
00080     htmltag.write('<th>Tag</th>\n')
00081     htmltag.write('<th>Source</th>\n')
00082     htmltag.write('</tr>\n')
00083 
00084 
00085     TMPTAG=commands.getoutput('mktemp')
00086     os.system('cmscond_tagtree_list -c '+CONNSTRINGGLOBTAG+' -T '+currgtag+' > '+TMPTAG)
00087 #    os.system('cat '+TMPTAG)
00088     nlines=0
00089     tmp=open(TMPTAG,'r')
00090     while tmp:
00091         line=tmp.readline()
00092         if len(line)==0:
00093             break
00094         nlines=nlines+1
00095         line=string.strip(line)
00096         if line.find('leafnode')==-1:
00097             out=myparser(line,'root:')
00098             if out!='-1':
00099                 root=out
00100             out=myparser(line,'node:')
00101             if out!='-1':
00102                 node=out
00103             out=myparser(line,'parent:')
00104             if out!='-1':
00105                 globparent=out
00106         else:
00107             leafnode.append(myparser(line,'leafnode:'))
00108             parent.append(myparser(line,'parent:'))
00109             tag.append(myparser(line,'tag:'))
00110             pfn.append(myparser(line,'pfn:'))
00111     
00112     #    print nlines,line
00113     
00114     tmp.close()
00115     print 'Read '+str(nlines)+' lines...'
00116     print 'Read ',len(leafnode),' leafnodes'
00117     print 'Read ',len(parent),' parent'
00118     print 'Read ',len(tag),' tag'
00119     print 'Read ',len(pfn),' pfn'
00120     
00121     if len(leafnode)!=len(parent) or len(leafnode)!=len(tag) or len(leafnode)!=len(pfn):
00122         print "# of leafnodes different from parent/tag/pfn"
00123         sys.exit()
00124     
00125     #output
00126     #print root,node,globparent
00127     #`create dictionary
00128     tagdict={}
00129     for i in range(0,len(leafnode)):
00130         tagdict[i]=pfn[i]
00131 
00132     sortindex=sorted(tagdict.items(), key=itemgetter(1))
00133 
00134     #    print tagdict
00135     #    for i in range(0,len(leafnode)):
00136     #    print sortindex[i][0]
00137 
00138     print 'Scanning tags:'
00139     for i in range(0,len(leafnode)):
00140         index=sortindex[i][0]
00141        #lm
00142         #     command='cmscond_list_iov -c '+pfn[i].replace('frontier:','frontier://cmsfrontier:8000')+' -t '+tag[i]
00143         #
00144         #     for ntime in range(0,MAXRETRIES):
00145         #         fullout=commands.getoutput(command)
00146         #         if fullout.count(tag[i])>=1:
00147         #             # success
00148         #             break
00149         #         print "Try: ",ntime, ".....",tag[i]
00150         #         time.sleep(0.5)
00151         #     if fullout.count(tag[i])<1:
00152         #         print "Unable to get information on tag:",tag[i]," after ", MAXRETRIES, "retries"
00153         #         print "Giving up here..."
00154         #         sys.exit(1)
00155     
00156         # adding tag to tag list page with link to condweb page
00157         # first define needed parameters
00158         TEMP=pfn[index].split('/')
00159         ACCOUNT=TEMP[len(TEMP)-1]
00160         TEMP=ACCOUNT.split('_')
00161         DET=TEMP[len(TEMP)-1]
00162         HREFSTRING='https://cmsweb.cern.ch/conddb/IOVManagement/get_iovs?det='+DET+'&service=cms_orcoff_prod&schema='+ACCOUNT+'&viacache=CHECKED&sel_tag='+tag[index]+'&tags=Display+IOV+for+selected+tags&destTag=&firstSince=&lastTill='
00163 #        print 'href= '+HREFSTRING
00164 
00165 
00166         htmltag.write('<tr>\n')
00167 #        htmltag.write('<td><a href="'+tag[i]+'">'+tag[i]+'</a></td>\n')
00168         htmltag.write('<td><a href="'+HREFSTRING+'">'+tag[index]+'</a></td>\n')
00169         htmltag.write('<td>'+pfn[index]+'</td>\n')
00170         htmltag.write('</tr>\n')
00171         # open output file
00172         #lm
00173         #taginfo=open(tag[i],'w')
00174         #taginfo.write(pfn[i]+'\n')
00175         #taginfo.write('========================================================\n')
00176         #taginfo.write(fullout)
00177         #taginfo.close()
00178 #    
00179 #        print '%-50s - %-30s' % (pfn[i],tag[i])
00180     os.system('rm -f '+TMPTAG)
00181     htmltag.write('</table>\n')
00182     htmltag.write('<h3> This list was created on: '+time.ctime()+'</h3>\n')
00183     htmltag.write('</body>\n</html>\n')
00184     htmltag.close()
00185     return 'done'
00186 
# main start here

Variable Documentation

tuple dbtoweb::ACCOUNT = CONFIG.get('Common','Account')

Definition at line 16 of file dbtoweb.py.

tuple dbtoweb::AUTHPATH = ''

Definition at line 22 of file dbtoweb.py.

tuple dbtoweb::BASEDIR = os.getcwd()

Definition at line 196 of file dbtoweb.py.

tuple dbtoweb::CONFIG = ConfigParser.ConfigParser()

Definition at line 8 of file dbtoweb.py.

string dbtoweb::CONFIGFILE = 'dbtoweb.cfg'

Definition at line 7 of file dbtoweb.py.

tuple dbtoweb::CONNSTRINGGLOBTAG = CONFIG.get('Common','Conn_string_gtag')

Definition at line 17 of file dbtoweb.py.

list dbtoweb::file = treelist[tree]

Definition at line 253 of file dbtoweb.py.

tuple dbtoweb::GLOBTAG = CONFIG.get('Common','Globtag')

Definition at line 18 of file dbtoweb.py.

tuple dbtoweb::HTMLNAME = CONFIG.get('Common','HTMLName')

Definition at line 20 of file dbtoweb.py.

tuple dbtoweb::htmlroot = open(HTMLTMP,'w')

Definition at line 208 of file dbtoweb.py.

string dbtoweb::HTMLTMP = '.tmp'

Definition at line 206 of file dbtoweb.py.

tuple dbtoweb::line = tmplist.readline()

Definition at line 234 of file dbtoweb.py.

Definition at line 5 of file dbtoweb.py.

int dbtoweb::ntrees = 0

Definition at line 231 of file dbtoweb.py.

tuple dbtoweb::out = myparser(line,'tree:')

Definition at line 239 of file dbtoweb.py.

tuple dbtoweb::ROOTDIR = CONFIG.get('Common','Rootdir')

Definition at line 19 of file dbtoweb.py.

tuple dbtoweb::tmplist = open(TMPTAGLIST,'r')

Definition at line 232 of file dbtoweb.py.

tuple dbtoweb::TMPTAGLIST = commands.getoutput('mktemp')

Definition at line 229 of file dbtoweb.py.

initialization first change to root dir

Definition at line 190 of file dbtoweb.py.

string dbtoweb::TREEDIR = '/'

Definition at line 260 of file dbtoweb.py.

list dbtoweb::treelist = []

Definition at line 225 of file dbtoweb.py.