2 import os,string,sys,commands,time,ConfigParser
6 CONFIGFILE=
'dbtoconf.cfg'
7 CONFIG = ConfigParser.ConfigParser()
8 print 'Reading configuration file from ',CONFIGFILE
9 CONFIG.read(CONFIGFILE)
15 ACCOUNT=CONFIG.get(
'Common',
'Account')
16 CONNSTRINGGLOBTAG=CONFIG.get(
'Common',
'Conn_string_gtag')
17 GLOBTAG=CONFIG.get(
'Common',
'Globtag')
18 CONFFILE=CONFIG.get(
'Common',
'Confoutput')
21 AUTHPATH=CONFIG.get(
'Common',
'AuthPath')
23 print "WARNING: No authpath fount in config file"
27 CONNREP=CONFIG.get(
'Common',
'Conn_rep')
29 print "WARNING: No CONN_REP fount in config file"
33 TAGREP=CONFIG.get(
'Common',
'Tag_rep')
35 print "WARNING: No TAG_REP fount in config file"
38 print "Configuration:"
39 print "================================"
40 print "Account:",ACCOUNT
41 print "CONNSTRING:",CONNSTRINGGLOBTAG
42 print "GLOBALTAG:",GLOBTAG
43 print "CONF OUTPUT:",CONFFILE
44 print "Auth. Path:",AUTHPATH
45 print "Conn. replacement:",CONNREP
46 print "TAG replacement:",TAGREP
47 print "================================"
54 if input.find(parstag)!=-1:
55 first=input.split(parstag)
56 second=first[1].
split()
83 os.system(
'rm -f '+TMPTAG)
84 tagtree_cmd =
'cmscond_tagtree_list -c '+CONNSTRINGGLOBTAG+
' -T '+GLOBTAG
86 tagtree_cmd +=
' -P ' + AUTHPATH
88 os.system(tagtree_cmd +
' > '+TMPTAG)
97 line=string.strip(line)
98 if line.find(
'leafnode')==-1:
109 leafnode.append(
myparser(line,
'leafnode:'))
110 parent.append(
myparser(line,
'parent:'))
113 record.append(
myparser(line,
'record:'))
114 label.append(
myparser(line,
'label:'))
115 object.append(
myparser(line,
'object:'))
116 connstring.append(
myparser(line,
'pfn:').
split(
'/CMS_COND')[0])
117 account.append(
'CMS_COND'+
myparser(line,
'pfn:').
split(
'/CMS_COND')[1])
121 print 'Read '+str(nlines)+
' lines...'
122 print 'Read ',len(leafnode),
' leafnodes'
123 print 'Read ',len(parent),
' parent'
124 print 'Read ',len(tag),
' tag'
125 print 'Read ',len(pfn),
' pfn'
127 if len(leafnode)!=len(parent)
or len(leafnode)!=len(tag)
or len(leafnode)!=len(pfn):
128 print "# of leafnodes different from parent/tag/pfn"
185 conf=open(CONFFILE,
'w')
186 conf.write(
'[COMMON]\n')
187 conf.write(
'connect=sqlite_file:' + GLOBTAG +
'.db\n')
188 conf.write(
'#connect=oracle://cms_orcoff_int2r/'+ACCOUNT+
'\n')
189 conf.write(
'#connect=oracle://cms_orcon_prod/'+ACCOUNT+
'\n')
191 conf.write(
'[TAGINVENTORY]\n')
192 conf.write(
'tagdata=\n')
193 for iline
in range(0,len(leafnode)):
195 if label[iline] ==
'None':
196 outline=
' '+tag[iline]+
'{pfn='+connstring[iline]+
'/'+account[iline]+
',objectname='+object[iline]+
',recordname='+record[iline]+
'}'
198 outline=
' '+tag[iline]+
'{pfn='+connstring[iline]+
'/'+account[iline]+
',objectname='+object[iline]+
',recordname='+record[iline]+
',labelname='+label[iline]+
'}'
200 if iline != len(leafnode)-1:
207 conf.write(
'[TAGTREE '+GLOBTAG+
']\n')
209 conf.write(
'[TAGTREE '+TAGREP+
']\n')
211 conf.write(
'root='+root+
'\n')
212 conf.write(
'nodedata='+node+
'{parent='+globparent+
'}\n')
213 conf.write(
'leafdata=\n')
214 for ileaf
in range(0,len(leafnode)):
215 outline=
' '+leafnode[ileaf]+
'{parent='+parent[ileaf]+
',tagname='+tag[ileaf]+
',pfn='+connstring[ileaf]+
'/'+account[ileaf]+
'}'
216 if ileaf!=len(leafnode)-1:
223 print CONFFILE+
' ready. Plase have a look'