CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 = HTMLNAME+'.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 More...
 
string TREEDIR = BASEDIR+'/'
 
list treelist = []
 

Function Documentation

def dbtoweb.myparser (   input,
  parstag 
)

Definition at line 41 of file dbtoweb.py.

References split.

Referenced by single().

41 
42 def myparser(input,parstag):
43  out='-1'
44 
45  if input.find(parstag)!=-1:
46  first=input.split(parstag)
47  second=first[1].split()
48 # print second
49  if (len(second)>=1):
50  out=second[0]
51 
52  return out
53 
54 
def myparser
Definition: dbtoweb.py:41
double split
Definition: MVATrainer.cc:139
def dbtoweb.single (   currgtag)

Definition at line 55 of file dbtoweb.py.

References myparser(), and split.

55 
56 def single(currgtag):
57 
58  root=''
59  node=''
60  globparent=''
61  leafnode=[]
62  parent=[]
63  tag=[]
64  pfn=[]
65  object=[]
66  record=[]
67  connstring=[]
68  account=[]
69 
70  htmltag=open(currgtag+'.html','w')
71  htmltag.write('<html>\n')
72  htmltag.write('<body>\n')
73  htmltag.write('<h3> Tag List for Global Tag: '+currgtag+' </h3>\n')
74  htmltag.write('<h4> The first time you access a tag below you have to login (HN credentials)<br>')
75  htmltag.write('Then you can come back here and access all tags </h4>\n')
76 
77 
78  htmltag.write('<table border="1">\n')
79  htmltag.write('<tr>\n')
80  htmltag.write('<th>Tag</th>\n')
81  htmltag.write('<th>Source</th>\n')
82  htmltag.write('</tr>\n')
83 
84 
85  TMPTAG=commands.getoutput('mktemp')
86  os.system('cmscond_tagtree_list -c '+CONNSTRINGGLOBTAG+' -T '+currgtag+' > '+TMPTAG)
87 # os.system('cat '+TMPTAG)
88  nlines=0
89  tmp=open(TMPTAG,'r')
90  while tmp:
91  line=tmp.readline()
92  if len(line)==0:
93  break
94  nlines=nlines+1
95  line=string.strip(line)
96  if line.find('leafnode')==-1:
97  out=myparser(line,'root:')
98  if out!='-1':
99  root=out
100  out=myparser(line,'node:')
101  if out!='-1':
102  node=out
103  out=myparser(line,'parent:')
104  if out!='-1':
105  globparent=out
106  else:
107  leafnode.append(myparser(line,'leafnode:'))
108  parent.append(myparser(line,'parent:'))
109  tag.append(myparser(line,'tag:'))
110  pfn.append(myparser(line,'pfn:'))
111 
112  # print nlines,line
113 
114  tmp.close()
115  print 'Read '+str(nlines)+' lines...'
116  print 'Read ',len(leafnode),' leafnodes'
117  print 'Read ',len(parent),' parent'
118  print 'Read ',len(tag),' tag'
119  print 'Read ',len(pfn),' pfn'
120 
121  if len(leafnode)!=len(parent) or len(leafnode)!=len(tag) or len(leafnode)!=len(pfn):
122  print "# of leafnodes different from parent/tag/pfn"
123  sys.exit()
124 
125  #output
126  #print root,node,globparent
127  #`create dictionary
128  tagdict={}
129  for i in range(0,len(leafnode)):
130  tagdict[i]=pfn[i]
131 
132  sortindex=sorted(tagdict.items(), key=itemgetter(1))
133 
134  # print tagdict
135  # for i in range(0,len(leafnode)):
136  # print sortindex[i][0]
137 
138  print 'Scanning tags:'
139  for i in range(0,len(leafnode)):
140  index=sortindex[i][0]
141  #lm
142  # command='cmscond_list_iov -c '+pfn[i].replace('frontier:','frontier://cmsfrontier:8000')+' -t '+tag[i]
143  #
144  # for ntime in range(0,MAXRETRIES):
145  # fullout=commands.getoutput(command)
146  # if fullout.count(tag[i])>=1:
147  # # success
148  # break
149  # print "Try: ",ntime, ".....",tag[i]
150  # time.sleep(0.5)
151  # if fullout.count(tag[i])<1:
152  # print "Unable to get information on tag:",tag[i]," after ", MAXRETRIES, "retries"
153  # print "Giving up here..."
154  # sys.exit(1)
155 
156  # adding tag to tag list page with link to condweb page
157  # first define needed parameters
158  TEMP=pfn[index].split('/')
159  ACCOUNT=TEMP[len(TEMP)-1]
160  TEMP=ACCOUNT.split('_')
161  DET=TEMP[len(TEMP)-1]
162  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='
163 # print 'href= '+HREFSTRING
164 
165 
166  htmltag.write('<tr>\n')
167 # htmltag.write('<td><a href="'+tag[i]+'">'+tag[i]+'</a></td>\n')
168  htmltag.write('<td><a href="'+HREFSTRING+'">'+tag[index]+'</a></td>\n')
169  htmltag.write('<td>'+pfn[index]+'</td>\n')
170  htmltag.write('</tr>\n')
171  # open output file
172  #lm
173  #taginfo=open(tag[i],'w')
174  #taginfo.write(pfn[i]+'\n')
175  #taginfo.write('========================================================\n')
176  #taginfo.write(fullout)
177  #taginfo.close()
178 #
179 # print '%-50s - %-30s' % (pfn[i],tag[i])
180  os.system('rm -f '+TMPTAG)
181  htmltag.write('</table>\n')
182  htmltag.write('<h3> This list was created on: '+time.ctime()+'</h3>\n')
183  htmltag.write('</body>\n</html>\n')
184  htmltag.close()
185  return 'done'
186 
# main start here
def myparser
Definition: dbtoweb.py:41
def single
Definition: dbtoweb.py:55
double split
Definition: MVATrainer.cc:139

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 = HTMLNAME+'.tmp'

Definition at line 206 of file dbtoweb.py.

tuple dbtoweb.line = tmplist.readline()

Definition at line 234 of file dbtoweb.py.

int dbtoweb.MAXRETRIES = 10

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.

int dbtoweb.TOBECREATED = 0

initialization first change to root dir

Definition at line 190 of file dbtoweb.py.

string dbtoweb.TREEDIR = BASEDIR+'/'

Definition at line 260 of file dbtoweb.py.

list dbtoweb.treelist = []

Definition at line 225 of file dbtoweb.py.