2 import os,string,sys,commands,time,ConfigParser,operator
4 from operator
import itemgetter
7 CONFIGFILE=
'dbtoweb.cfg'
8 CONFIG = ConfigParser.ConfigParser()
9 print 'Reading configuration file from ',CONFIGFILE
10 CONFIG.read(CONFIGFILE)
16 ACCOUNT=CONFIG.get(
'Common',
'Account')
17 CONNSTRINGGLOBTAG=CONFIG.get(
'Common',
'Conn_string_gtag')
18 GLOBTAG=CONFIG.get(
'Common',
'Globtag')
19 ROOTDIR=CONFIG.get(
'Common',
'Rootdir')
20 HTMLNAME=CONFIG.get(
'Common',
'HTMLName')
24 AUTHPATH=CONFIG.get(
'Common',
'AuthPath')
26 print "WARNING: No authpath fount in config file"
30 print "Configuration:"
31 print "================================"
32 print "Account:",ACCOUNT
33 print "CONNSTRING:",CONNSTRINGGLOBTAG
34 print "Auth. Path:",AUTHPATH
35 print "GLOBALTAG:",GLOBTAG
36 print "Root dir:",ROOTDIR
38 print "================================"
44 if input.find(parstag)!=-1:
45 first=input.split(parstag)
46 second=first[1].
split()
69 htmltag=open(currgtag+
'.html',
'w')
70 htmltag.write(
'<html>\n')
71 htmltag.write(
'<body>\n')
72 htmltag.write(
'<h3> Tag List for Global Tag: '+currgtag+
' </h3>\n')
73 htmltag.write(
'<h4> The first time you access a tag below you have to login (HN credentials)<br>')
74 htmltag.write(
'Then you can come back here and access all tags </h4>\n')
77 htmltag.write(
'<table border="1">\n')
78 htmltag.write(
'<tr>\n')
79 htmltag.write(
'<th>Tag</th>\n')
80 htmltag.write(
'<th>Source</th>\n')
81 htmltag.write(
'</tr>\n')
84 TMPTAG=commands.getoutput(
'mktemp')
85 os.system(
'cmscond_tagtree_list -c '+CONNSTRINGGLOBTAG+
' -T '+currgtag+
' > '+TMPTAG)
94 line=string.strip(line)
95 if line.find(
'leafnode')==-1:
106 leafnode.append(
myparser(line,
'leafnode:'))
107 parent.append(
myparser(line,
'parent:'))
114 print 'Read '+str(nlines)+
' lines...'
115 print 'Read ',len(leafnode),
' leafnodes'
116 print 'Read ',len(parent),
' parent'
117 print 'Read ',len(tag),
' tag'
118 print 'Read ',len(pfn),
' pfn'
120 if len(leafnode)!=len(parent)
or len(leafnode)!=len(tag)
or len(leafnode)!=len(pfn):
121 print "# of leafnodes different from parent/tag/pfn"
128 for i
in range(0,len(leafnode)):
131 sortindex=sorted(tagdict.items(), key=itemgetter(1))
137 print 'Scanning tags:'
138 for i
in range(0,len(leafnode)):
139 index=sortindex[i][0]
157 TEMP=pfn[index].
split(
'/')
158 ACCOUNT=TEMP[len(TEMP)-1]
159 TEMP=ACCOUNT.split(
'_')
160 DET=TEMP[len(TEMP)-1]
161 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='
165 htmltag.write(
'<tr>\n')
167 htmltag.write(
'<td><a href="'+HREFSTRING+
'">'+tag[index]+
'</a></td>\n')
168 htmltag.write(
'<td>'+pfn[index]+
'</td>\n')
169 htmltag.write(
'</tr>\n')
179 os.system(
'rm -f '+TMPTAG)
180 htmltag.write(
'</table>\n')
181 htmltag.write(
'<h3> This list was created on: '+time.ctime()+
'</h3>\n')
182 htmltag.write(
'</body>\n</html>\n')
192 if not os.path.exists(ROOTDIR):
197 print 'ROOTDIR created, current dir= '+BASEDIR
201 print 'ROOTDIR exists already, current dir= '+BASEDIR
203 print "ERROR: it is impossible to chdir in",ROOTDIR
206 HTMLTMP=HTMLNAME+
'.tmp'
208 htmlroot=open(HTMLTMP,
'w')
210 os.system(
'head -n -4 '+HTMLNAME+
' > '+HTMLTMP)
211 htmlroot=open(HTMLTMP,
'a')
215 htmlroot.write(
'<html>\n')
216 htmlroot.write(
'<body>\n')
217 htmlroot.write(
'<h3>Global Tag List:</h3>\n')
218 htmlroot.write(
'<table border="1">\n')
219 htmlroot.write(
'<tr>\n')
220 htmlroot.write(
'<th>Global Tag</th>\n')
221 htmlroot.write(
'<th>Source</th>\n')
222 htmlroot.write(
'</tr>\n')
229 TMPTAGLIST=commands.getoutput(
'mktemp')
230 os.system(
'cmscond_tagtree_list -c '+CONNSTRINGGLOBTAG+
' > '+TMPTAGLIST)
232 tmplist=open(TMPTAGLIST,
'r')
234 line=tmplist.readline()
237 line=string.strip(line)
238 if line.find(
'tree:')!=1:
244 os.system(
'rm -f '+TMPTAGLIST)
246 treelist.append(GLOBTAG)
249 for tree
in range(0,len(treelist)):
250 print str(tree)+
': Tree= '+treelist[tree]
252 htmlroot.write(
'<tr>\n')
253 file=treelist[tree]+
'/'+treelist[tree]+
'.html'
254 htmlroot.write(
'<td><a href="'+file+
'">'+treelist[tree]+
'</a></td>\n')
255 htmlroot.write(
'<td>'+ACCOUNT+
'</td>\n')
256 htmlroot.write(
'</tr>\n')
260 TREEDIR=BASEDIR+
'/'+treelist[tree]
261 if not os.path.exists(TREEDIR):
264 print 'TREEDIR created, current dir is '+os.getcwd()
269 htmlroot.write(
'</table>\n')
270 htmlroot.write(
'<h3> This list was created on: '+time.ctime()+
'</h3>\n')
271 htmlroot.write(
'</body>\n</html>\n')
273 print 'A new root html has been created: '
274 print BASEDIR+
'/'+HTMLTMP
275 print 'Please check and replace (in case)'