ATLAS Offline Software
sim_rttUpdate.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
4 
5 """
6 check/update references
7 
8 for SimCoreTest
9 
10 update script:
11  - check file exists before doing something (dcube)
12  - restrict to used branches
13 
14 fix DCube for devval
15 
16 add sqlite
17  t_logs ( rel, cmt, branch, rundate, update date&time , comment, jobsalias_id )
18 --
19  t_branches (branch,ref,project) [ 17.X.0-VAL , 17.X.0 ]
20  t_alias (alias, branch) [ 'devval', '17.X.0-VAL']
21  t_tests (testname,pathpiece,project) ['SimCoreTests','Simulation/Tests','simulation']
22  t_jobs (testname, job, file, type) ['SimCoreTests','AtlasG4_muons'
23  t_joblsit (alias, job) -- except 'all' ['dcube','AtlasG4_%']
24  t_user (admins) ['jchapman','aschaeli','z']
25 """
26 
27 from exceptions import Exception
28 
29 class SimRttDBError(Exception):
30  pass
31 
32 class SimRttUpdateError(Exception):
33  pass
34 
35 
36 try:
37  import sqlite3
38 except:
39  print 'ERROR:'
40  print 'please use Python 2.5 or above:'
41  print '> source ~aschaeli/public/setup_python26.sh'
42  print ' '
43  raise SimRttUpdateError()
44 
45 
47  def __init__(self,fname):
48  self.fname=fname
49  self.cnx=None
50  self.cur=None
51 
52 
53  def openConnection(self):
54  self.cnx = sqlite3.connect(self.fname)
55  self.cur = self.cnx.cursor()
56 
57  def _execute(self,cmd,args=()):
58  print 'SQL:',cmd,args
59  self.cur.execute(cmd,args)
60 
61  def _createTable(self,tname,*args):
62  #print 'creating table',tname
63  vals=','.join(('%s text ',)*len(args))
64  cmd=('create table %s ('+vals+')')% ( (tname,)+args )
65  self._execute(cmd)
66 
67  def _fillTable(self,tname,*args):
68  #print 'updating table',tname
69  vals=','.join(('?',)*len(args))
70  cmd="insert into %s values (%s)"%(tname,vals)
71  self._execute(cmd,args)
72 
73  #insert into t_branches values ('17.2.X-VAL','17.2.X','simulation');
74  #Error: column branch is not unique
75 
76  def _hasKey(self,tname,column,value):
77  cmd='select count(*) from %s where %s=?'%(tname,column)
78  self._execute(cmd,(value,))
79  res=sel.cur.fetchone()
80  print res
81  print res[0]>0
82  return res[0]
83 
84  def _updateTable(self,tname,keys,*args):
85  cmd='select * from %s limit 1'%tname
86  self._execute(cmd)
87  header= [ s[0] for s in self.cur.description ]
88  res=self.cur.fetchall()
89 
90  values=[ k+'=?' for k in header if k not in keys ]
91  key_values=tuple([ a for k,a in zip(header,args) if k in keys])
92  set_values=tuple([ a for k,a in zip(header,args) if k not in keys])
93  vals=','.join(values)
94  cmd="update %s set %s where %s=?"%(tname,vals,keys[0])
95  for k in keys[1:]:
96  cmd+=' and %s=?'%k
97  self._execute(cmd, set_values+key_values)
98  self.cnx.commit()
99 
100  def _dropTable(self,tname):
101  cmd='drop table %s'%tname
102  try:
103  self._execute(cmd)
104  except:
105  print 'SQL Error:',cmd
106 
107  def create(self):
108  for t in ['t_logs','t_branches','t_alias','t_tests','t_jobs','t_joblist','t_user']:
109  self._dropTable(t)
110  self._createTable('t_logs','branch','rel','cmt','res_date','up_date')
111  #self._createTable('t_branches','branch','ref','project')
112  #'alter table t_branches rename to t_branches_old;'
113  self._execute('create table t_branches (branch text, ref text, project text, primary key (branch,project) ) ;')
114  #'insert into t_branches select * from t_branches_old;'
115  self._createTable('t_alias','alias','value')
116  self._createTable('t_tests','testname','pathpiece','project')
117  self._createTable('t_jobs','testname','job','file','type')
118  self._createTable('t_joblist','jalias','job')
119  self._createTable('t_user','login','rights')
120  self.cnx.commit()
121 
122  def initialFill(self):
123  # dev, devval ??!!
124  sim='simulation'
125  for br in ['17.X.0-VAL','17.X.0']:
126  self._fillTable('t_branches', br, '17.X.0',sim)
127  for br in ['17.1.X-VAL','17.1.X','17.1.X.Y-VAL','17.1.X.Y','17.2.X-VAL','17.2.X']:
128  self._fillTable('t_branches', br, '17.1.X',sim)
129  for br in ['16.6.X.Y-VAL','16.6.X.Y','16.6.X-VAL','16.6.X']:
130  self._fillTable('t_branches', br, '16.6.X',sim)
131 
132 
133  self.djobs={ 'AtlasG4_electrons' : ['truth.root'],
134  'AtlasG4_muons' : ['truth.root'],
135  'WriteCalHitsTest' : ['truth.root'],
136  'AtlasG4_pions' : ['truth.root'] }
137 
138  self.jobs={'AtlasGeom19Sim' : ['test.HITS.pool.root'],
139  'CavernBg_EVNT2TR' : ['cavbg.EVNT.pool.root'],
140  'CavernBg_TR2HITS' : ['cavbg.HITS.pool.root'],
141  'CosmicSim' : ['testCosmics.HITS.pool.root','testCosmics.TR.pool.root'],
142  'CosmicSimTR' : ['testCosmics.HITS.pool.root'],
143  'HeavyIonSim': ['test.HITS.pool.root'],
144  'TTbarSim' : ['test.HITS.pool.root'],
145  'FtfpBertTest': ['test.HITS.pool.root'],
146  'LucidSimTest': ['testLucid.HITS.pool.root'],
147  'NeutronCutTest': ['test.HITS.pool.root'],
148  'QgsBicTest': ['test.HITS.pool.root'],
149  'QgspBertChipsTest': ['test.HITS.pool.root'],
150  'SimCheckDBRel': ['test.HITS.pool.root'],
151  'ALFASimTest' : ['testALFA.HITS.pool.root'],
152  'ZDCSimTest' : ['testZDC.HITS.pool.root']}
153 
154  self.jobs0={'FrozenShowerFCalOnly': ['test.HITS.pool.root']}
155  self.jobs1={'FrozenShowerTest1': ['test.HITS.pool.root'],
156  'FrozenShowerTest2': ['test.HITS.pool.root']}
157  self.alias={} #{'FrozenShowerFCalOnly':'FrozenShowerTest1'}
158 
159  tn='SimCoreTests'
160  self._fillTable('t_tests',tn,'Simulation/Tests','simulation')
161  tn1='G4AtlasTests'
162  self._fillTable('t_tests',tn1,'Simulation/G4Atlas','simulation')
163  for dj,files in self.djobs.iteritems():
164  self._fillTable('t_joblist','dcube_jobs',dj)
165  for fn in files:
166  self._fillTable('t_jobs',tn,dj,fn,'dcube')
167  self._fillTable('t_jobs',tn1,dj,fn,'dcube')
168 
169  for j,files in self.jobs.iteritems():
170  self._fillTable('t_joblist','diffpool_jobs',j)
171  for fn in files:
172  self._fillTable('t_jobs',tn,j,fn,'diffpool')
173  self._fillTable('t_jobs',tn1,j,fn,'diffpool')
174 
175  for j,files in self.jobs0.iteritems():
176  self._fillTable('t_joblist','diffpool_jobs',j)
177  for fn in files:
178  self._fillTable('t_jobs',tn,j,fn,'diffpool')
179 
180  for j,files in self.jobs1.iteritems():
181  self._fillTable('t_joblist','diffpool_jobs',j)
182  for fn in files:
183  self._fillTable('t_jobs',tn1,j,fn,'diffpool')
184 
185  tn2='SimExoticsTests'
186  self._fillTable('t_tests',tn2,'Simulation/Tests','simulation')
187 
188  tn3='SimPerformanceTests'
189  self._fillTable('t_tests',tn3,'Simulation/Tests','simulation')
190 
191 
192  self.users=['aschaeli', 'jchapman', 'fmgaray']
193  for u in self.users:
194  self._fillTable('t_user',u,'a')
195 
196  self.cnx.commit()
197 
198  def _dumpTable(self,t):
199  #t = (symbol,)
200  #cur.execute('select * from stocks where symbol=?', t)
201  self._execute('select * from %s'%t)
202  header= [ s[0] for s in self.cur.description ]
203  format= ' '.join([ '%25s' for s in self.cur.description])
204  print format%tuple(header)
205  for res in self.cur.fetchall():
206  print format%res
207 
208  def getUsers(self,right='a'):
209  cmd='select login from t_user where rights=?'
210  self._execute(cmd,(right,))
211  return [res[0] for res in self.cur.fetchall()]
212 
213  def findPackage(self,package):
214  cmd='select pathpiece,project from t_tests where testname=?'
215  self._execute(cmd,(package,))
216  return self.cur.fetchone()
217 
218  def findReference(self,branch,project):
219  cmd='select ref from t_branches where branch=? and project=?'
220  if branch=='devval' :
221  branch='18.X.0-VAL'
222  if branch=='dev':
223  branch='18.X.0'
224  self._execute(cmd,(branch,project))
225  res=self.cur.fetchone()
226  if res is None:
227  print 'ERROR',branch,project,'not found in t_branches'
228  raise SimRttDBError
229 
230  #print res
231  return res[0]
232 
233  def findJobs(self,testname,jobtype):
234  cmd='select job,file from t_jobs where testname=? and type=?'
235  self._execute(cmd,(testname,jobtype))
236  res=self.cur.fetchall()
237  jobs={}
238  for r in res:
239  key=r[0]
240  fname=r[1]
241  if jobs.has_key(key):
242  jobs[key].append(fname)
243  else:
244  jobs[key]=[fname]
245 
246  return jobs
247 
248 
249  def dump(self):
250  for t in ['t_user','t_branches','t_tests','t_jobs','t_alias','t_joblist']:
251  self._dumpTable(t)
252 
253 
254  def addUser(self,username='aschaeli',right='a'):
255  self._fillTable('t_user',username,right)
256  self.cnx.commit()
257 
258  def addBranch(self,branch='17.X.0-VAL',refid='17.X.0'):
259  self._fillTable('t_branches',branch,refid)
260  self.cnx.commit()
261 
262  def addTest(self,testname='SimCoreTests',path='Simulation/Tests'):
263  self._fillTable('t_tests',testname,path)
264  self.cnx.commit()
265 
266  def addJob(self,testname='SimCoreTests',jobname='AtlasG4_muons',
267  files=['truth.root'],typeid='dcube'):
268  for fn in files:
269  self._fillTable('t_jobs',testname,jobname,fn,typeid)
270  self.cnx.commit()
271 
272  def defineJobAlias(self,alias='dcube_jobs',
273  joblist=['AtlasG4_muons','AtlasG4_electrons','AtlasG4_pions']):
274  for job in joblist:
275  self._fillTable('t_joblist',alias,job)
276  self.cnx.commit()
277 
278 
279 
280  # We can also close the cursor if we are done with it
281  #cur.close()
282 
283 
284 
285 import os
286 import datetime as dt
287 from argparse import ArgumentParser
288 import pwd
289 
290 
291 class MyArgumentParser(ArgumentParser):
292  def __init__(self,admin=True,user='aschaeli'):
293  usage= "updates reference files for the Core Simulation Runtime Tests"
294 
295  epilog="""
296  Example:
297  %prog -n --branch=devval --rel=rel_3 --package=G4AtlasTests
298  """
299 
300  """
301  update --branch --rel --cmt --jobs --today --rttpath (--suffix)
302 
303  dumpDB
304  dumpUser [--right]
305  dumpTests [--project]
306  dumpBranches [--project]
307  addUser --user --right
308  addBranch --branch --ref --project
309  addTest --package --testpath --project
310  addJobs --package --jobs --jobfiles --testtype
311  defAlias --jobalias --jobs
312  """
313 
314  ArgumentParser.__init__(self,description=usage,epilog=epilog)
315 
316  self.add_argument('-n', '--dryrun', action='store_const',
317  const=True, dest='dryrun', default=False,
318  help='dry run - do nothing')
319  group = self.add_mutually_exclusive_group(required=not admin)
320  group.add_argument('--branch', action='store', dest='branch', default='devval',
321  help='release to use')
322 
323  group.add_argument('--logs', '-l', action='store_true', dest='logs',
324  help='print logs but do nothing')
325 
326 
327  self.add_argument('--package', action='store', dest='package', default='G4AtlasTests',
328  help='package containing the tests (default G4AtlasTests)')
329 
330  self.add_argument('--rel', action='store', dest='rel', default='rel_X',
331  help='rel identifier (default todays rel_X)')
332 
333  self.add_argument('--cmt', action='store', dest='cmt', default='x86_64-slc5-gcc43-opt',
334  help='cmt identifier (default:x86_64-slc5-gcc43-opt)')
335 
336  self.add_argument('--jobs', action='store', dest='jobs', default='',
337  help='job names, e.g. CosmicSim,WriteCalHitsTest')
338 
339  self.add_argument('--today', action='store', dest='today', default='AUTO',
340  help='store results in specified subdir ')
341 
342  self.add_argument('--rttpath', action='store', dest='rttpath', default='default',
343  help='use path for looking for root files')
344 
345  self.add_argument('--suffix', action='store', dest='sbranch', default='',
346  help='file suffix to distingish ref files for different releases')
347 
348  # admin arguments
349  # TODO: only add if admin
350  if admin:
351  group1=self.add_argument_group('admin arguments', 'commands for changing the configuration')
352 
353  group1.add_argument('--dumpDB', action='store_true', dest='dumpDB',
354  help='print all database entries')
355 
356  group1.add_argument('--dumpUsers',action='store_true', dest='dumpUsers',
357  help='print all users authorised to use admin commands')
358 
359  group1.add_argument('--dumpTests',action='store_true', dest='dumpTests',
360  help='print all Tests')
361 
362  group1.add_argument('--dumpBranches',action='store_true', dest='dumpBranches',
363  help='print all Branches')
364 
365  group1.add_argument('--addBranch', action='store_true', dest='addBranch',
366  help='add new branch to configuration file')
367 
368  group1.add_argument('--refpath', action='store', dest='ref', default='17.X.0',
369  help='assign refpath to given branch')
370 
371  group1.add_argument('--project', action='store', dest='project', default='simulation',
372  help='assign project e.g. digitization (default: simulation)')
373 
374  group1.add_argument('--addTest', action='store_true', dest='addTest',
375  help='add new test to configuraiton file')
376 
377  group1.add_argument('--testpath', action='store', dest='testpath',
378  default='Simulation/Tests',
379  help='assign path to given test')
380 
381  group1.add_argument('--addJobs', action='store_true', dest='addJobs',
382  help='add new job(s) to a given test')
383 
384  group1.add_argument('--jobfiles', action='store', dest='jobfiles',
385  default='test.HITS.pool.root',
386  help='comma separated list of files to be updated')
387 
388  group1.add_argument('--testtype', action='store', dest='testtype',
389  default='diffpool',
390  help='currently only dcube or diffpool supported')
391 
392  group1.add_argument('--jobalias', action='store', dest='jobalias', default='',
393  help='assign alias to joblist (e.g. cavernbg_tests)')
394 
395 
396 
398  return pwd.getpwuid( os.getuid() )[ 0 ]
399 
400 class RttUpdate :
401  def __init__(self,opt,db):
402  self.db = db
403  self.opt = opt
404 
405  # release
406  if opt.rel=='rel_X':
407  opt.rel='rel_%d'% (dt.date.today().isoweekday() % 7)
408 
409  # RTT result directory
410  if opt.rttpath == 'default':
411  opt.rttpath='/afs/cern.ch/atlas/project/RTT/prod/Results/rtt/'+opt.rel+'/'+opt.branch+'/build/'+opt.cmt+'/offline/'+opt.package
412  print 'using default rttpath =',opt.rttpath
413 
414  # EOS result directory, etc.
415  opt.rttcastor='/eos/atlas/atlascerngroupdisk/proj-sit/rtt/prod/rtt/'+opt.rel+'/'+opt.branch+'/'+opt.cmt+'/offline/'+opt.package
416  opt.eoscmd='/afs/cern.ch/project/eos/installation/0.1.0-22d/bin/eos.select'
417  opt.eosprefix='root://eosatlas.cern.ch/'
418 
419  """
420  xrdcp root://eosatlas.cern.ch//eos/atlas/atlascerngroupdisk/proj-sit/rtt/prod/rtt/rel_2/17.1.X.Y/i686-slc5-gcc43-opt/offline/DigitizationTests/mc11_ttbar_LVL1_on/mc11_ttbar.RDO.pool.root root://eosatlas.cern.ch//eos/atlas/atlascerngroupdisk/proj-sit/digitization/RTT/ReferenceFiles/MC12/MC11_ttbar_LVL1_ON.RDO.pool.root
421 """
422 
423  opt.testpath,opt.project=db.findPackage(opt.package)
424  opt.ref=db.findReference(opt.branch,opt.project)
425 
426 
427  opt.refpath='/eos/atlas/atlascerngroupdisk/proj-sit/'+opt.project+'/validation/RTT/referenceFiles/'
428  opt.dcubepath='/afs/cern.ch/atlas/project/RTT/DCubeReference/offline/'+opt.testpath+'/'+opt.package+'/'
429  if opt.ref!='':
430  opt.refpath+=opt.ref+'/'
431  opt.dcubepath+=opt.ref+'/'
432 
433  #db._dumpTable('t_jobs')
434  self.djobs=db.findJobs(opt.package,jobtype='dcube')
435  #print 'djobs=',self.djobs
436 
437  self.jobs=db.findJobs(opt.package,jobtype='diffpool')
438  #print 'jobs=',self.jobs
439 
440  if opt.jobs!='':
441  print "selected jobs"
442  print opt.jobs
443  joblist=opt.jobs.split(',')
444  print joblist
445 
446  self.jobs = dict ( [ (k,self.jobs[k]) for k in joblist if self.jobs.has_key(k) ])
447  print self.jobs
448  self.djobs = dict ( [ (k,self.djobs[k]) for k in joblist if self.djobs.has_key(k) ])
449  print self.djobs
450  # python 2.7 could use
451  # self.djobs = { k:self.djobs[k] for k in joblist if self.djobs.has_key(k) }
452 
453  # obsolete for devval
454  #self.alias={'AtlasGeom19Sim':'SingleParticleSim'}
455  self.alias={} #{'FrozenShowerFCalOnly':'FrozenShowerTest1'}
456 
457  if self.opt.today=='AUTO':
458  self.opt.today=dt.date.today().strftime("%y%m%d")
459  #self.opt.today=self.today
460  self.opt.user=get_username()
461  #self.opt.today='120207-fix' #*AS* fix !!
462  self.logfile='/afs/cern.ch/atlas/groups/Simulation/rtt/rttUpdate.log'
463 
464  self.writeLogFile()
465 
466  def ls(self):
467  os.system('ls '+self.opt.rttpath)
468 
469  def printOptions(self):
470 
471  print '*** options: ***'
472  for i in dir(self.opt):
473  if i=='ensure_value' or i=='read_file' or i=='read_module':
474  continue
475  if i.startswith('_'):
476  continue
477  print '%12s:'%i,getattr(self.opt,i)
478 
479  def writeLogFile(self):
480  f=file(self.logfile,'a')
481  for i in ['today','dryrun','user','branch','rel','cmt', 'package','jobs','comment']:
482  val ='None'
483  if hasattr(self.opt,i):
484  val = str(getattr(self.opt,i))
485  if val=='':
486  val='None'
487  if val.count(' ')>0:
488  val='"'+val+'"'
489  #print i,'=',val
490  f.write( val )
491  f.write(' ')
492  f.write('\n')
493 
494  def printLogFile(self):
495  f=file(self.logfile)
496  for l in f:
497  print l,
498 
499  def updateDcubeXML(self,tname,path):
500  print "updating dcube xml file"
501  print tname
502  print path
503 
504  dxml=path+"dcube-"+tname+".xml"
505  dxmln=dxml+".new"
506  print dxml
507 
508  dfile=file(dxml)
509  dnew=file(dxmln,"w")
510  for l in dfile:
511  if l.count("Results from")>0:
512  print l,
513 
514  newl= "Results from "
515  newl+= dt.date.today().strftime("%d %B %Y")
516  newl+= ", "+self.opt.rel+" "
517  newl+= self.opt.branch+" "
518  newl+= self.opt.cmt
519  self.opt.comment=newl
520  newl+= " for "+tname
521  print newl
522  l=newl+"\n"
523  dnew.write(l)
524  dnew.close()
525  dfile.close()
526 
527  cmd="mv "+dxmln+" "+dxml
528  print cmd
529  if not self.opt.dryrun:
530  print "..."
531  os.system(cmd)
532 
533 
534 
535  def updateDcube(self):
536  if len(self.djobs)>0:
537  cmd='mkdir '+self.opt.dcubepath+self.opt.today
538  print cmd
539  if not self.opt.dryrun:
540  os.system(cmd)
541 
542  # dcube
543  for j,files in self.djobs.items():
544  epath=self.opt.rttpath+'/'+j
545  print '########################################'
546  if len(files)==0:
547  print 'WARNING, no files given, looking for root files '
548  os.system('ls -l '+epath+'/*.root')
549 
550  for f in files:
551  src=epath+'/'+f
552  if not os.path.exists(src):
553  print src,'does not exist'
554  break
555  sj = j
556  parts=j.split('_')
557  dst=self.opt.dcubepath+sj+'.'+f
558  s=os.system('ls '+dst)
559  if (s==0) :
560  print 'destination exists'
561  cmd='rm '+dst
562  print cmd
563  if not self.opt.dryrun:
564  os.system(cmd)
565 
566  cmd='cp -v '+src+' '+self.opt.dcubepath+self.opt.today+'/'+sj+'.'+f
567  print cmd
568  if not self.opt.dryrun:
569  os.system(cmd)
570  cmd='ln -s '+self.opt.today+'/'+sj+'.'+f+' '+dst
571  print cmd
572  if not self.opt.dryrun:
573  os.system(cmd)
574 
575  self.updateDcubeXML(j,self.opt.dcubepath)
576 
577 
578  # break
579  def updateRefs(self):
580  if len(self.jobs)>0:
581 
582  # diffPoolFileRunner
583  cmd=self.opt.eoscmd+' mkdir '+self.opt.refpath+self.opt.today
584  print cmd
585  if not self.opt.dryrun:
586  os.system(cmd)
587 
588  for j,files in self.jobs.items():
589  epath=self.opt.rttpath+'/'+j
590  print '########################################'
591  #print epath,':'
592  #print files
593 
594  if len(files)==0:
595  print 'WARNING, no files given, looking for root files '
596  os.system('ls -l '+epath+'/*.root')
597 
598  for f in files:
599  #print '#'
600  s=os.system('ls -l '+epath+'/'+f)
601  #print '#',s
602  if s!=0:
603  epath=self.opt.rttcastor+'/'+j
604  #print epath,':'
605  #s=os.system('nsls -l '+epath+'/'+f) ### Castor
606  s=os.system(self.opt.eoscmd+' ls '+epath+'/'+f)
608  if s==0:
609  epath= self.opt.eosprefix+epath
610 
611  if s==0:
612  #
613  src=epath+'/'+f
614  sj = j
615  parts=j.split('_')
616  if len(parts)>1 and parts[1] in ['EVNT2TR','TR2HITS']:
617  sj=parts[0]
618  if self.alias.has_key(sj):
619  print 'changed', sj
620  sj=self.alias[sj]
621  print 'to', sj
622 
623  #print parts
624  pref,suff=f.split('.',1)
625  dst=self.opt.refpath+sj+self.opt.sbranch+'.'+suff
626  #s=os.system('nsls -l '+dst) ### Castor
627  s=os.system(self.opt.eoscmd+' ls '+dst)
629  if (s==0) :
630  print 'destination exists'
631  # cmd='nsrename '+dst+' '+dst+'.1'
632  # cmd="nsrm "+dst ### Castor
633  cmd=self.opt.eoscmd+" rm "+dst
634  print cmd
635  if not self.opt.dryrun:
636  os.system(cmd)
637  cmd='xrdcp '+src+' '+self.opt.eosprefix+dst
638  print cmd
639  if not self.opt.dryrun:
640  os.system(cmd)
641  dst=self.opt.refpath+self.opt.today+'/'+sj+self.opt.sbranch+'.'+suff
642  cmd='xrdcp '+src+' '+self.opt.eosprefix+dst
643  print cmd
644  if not self.opt.dryrun:
645  os.system(cmd)
646  else:
647  print 'source not found!'
648 
649 
650 if __name__=='__main__':
651 
652  # load configuration
653  db=SimRttDataBase('/afs/cern.ch/atlas/groups/Simulation/rtt/rttUpdate.sqlite')
654  db.openConnection()
655  #db.create()
656  #db.initialFill()
657  #db.dump()
658 
659  # check user rights
660  users=db.getUsers()
661  #print 'users=', users;
663  #print 'user=', user
664  admin=False
665  if user in users:
666  #db.addJob(jobname='AtlasG4_minbias',files=['truth.root'],typeid='dcube')
667 
668  admin=True
669  print 'user',user,'authorised for admin commands'
670 
671  # parse commandline options
672  optP=MyArgumentParser(admin=admin,user=user)
673  args = optP.parse_args()
674  adminCommand=False
675 
676  if args.addBranch:
677  print 'addBranch'
678  branch=args.branch
679  if args.branch=='devval' :
680  branch='17.X.0-VAL'
681  if args.sbranch=='dev':
682  branch='17.X.0'
683  print 'branch=',branch
684  print 'refpath=',args.ref
685  print 'proj=',args.project
686  try:
687  db._fillTable('t_branches',branch,args.ref,args.project)
688  db.cnx.commit()
689  except sqlite3.IntegrityError:
690  print "key exists, try updating"
691  db._updateTable('t_branches',['branch','project'],branch,args.ref,args.project)
692  adminCommand=True
693 
694  if args.dumpDB:
695  db.dump()
696  adminCommand=True
697  if args.dumpUsers:
698  db._dumpTable('t_user')
699  adminCommand=True
700  if args.dumpTests:
701  db._dumpTable('t_tests')
702  adminCommand=True
703  if args.dumpBranches:
704  db._dumpTable('t_branches')
705  adminCommand=True
706 
707  if not adminCommand:
708  rttUpdate=RttUpdate(args,db)
709  #rttUpdate.ls()
710  rttUpdate.printOptions()
711  if args.logs:
712  rttUpdate.printLogFile()
713  else:
714  rttUpdate.updateDcube()
715  rttUpdate.updateRefs()
716  rttUpdate.writeLogFile()
717 
718 
sim_rttUpdate.SimRttDataBase._dumpTable
def _dumpTable(self, t)
Definition: sim_rttUpdate.py:198
sim_rttUpdate.get_username
def get_username()
Definition: sim_rttUpdate.py:397
python.Bindings.iteritems
iteritems
Definition: Control/AthenaPython/python/Bindings.py:812
sim_rttUpdate.RttUpdate.logfile
logfile
Definition: sim_rttUpdate.py:462
sim_rttUpdate.SimRttDataBase._fillTable
def _fillTable(self, tname, *args)
Definition: sim_rttUpdate.py:67
sim_rttUpdate.SimRttDataBase._execute
def _execute(self, cmd, args=())
Definition: sim_rttUpdate.py:57
sim_rttUpdate.SimRttDataBase.jobs0
jobs0
Definition: sim_rttUpdate.py:154
sim_rttUpdate.SimRttDataBase._dropTable
def _dropTable(self, tname)
Definition: sim_rttUpdate.py:100
sim_rttUpdate.SimRttDataBase.addBranch
def addBranch(self, branch='17.X.0-VAL', refid='17.X.0')
Definition: sim_rttUpdate.py:258
sim_rttUpdate.SimRttDataBase.findPackage
def findPackage(self, package)
Definition: sim_rttUpdate.py:213
sim_rttUpdate.RttUpdate.printLogFile
def printLogFile(self)
Definition: sim_rttUpdate.py:494
sim_rttUpdate.RttUpdate.printOptions
def printOptions(self)
Definition: sim_rttUpdate.py:469
sim_rttUpdate.SimRttDataBase.djobs
djobs
Definition: sim_rttUpdate.py:133
sim_rttUpdate.SimRttDataBase.defineJobAlias
def defineJobAlias(self, alias='dcube_jobs', joblist=['AtlasG4_muons', 'AtlasG4_electrons', 'AtlasG4_pions'])
Definition: sim_rttUpdate.py:272
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
sim_rttUpdate.SimRttDataBase.__init__
def __init__(self, fname)
Definition: sim_rttUpdate.py:47
sim_rttUpdate.SimRttDataBase.users
users
Definition: sim_rttUpdate.py:192
sim_rttUpdate.SimRttDataBase.cur
cur
Definition: sim_rttUpdate.py:50
sim_rttUpdate.SimRttDataBase.addTest
def addTest(self, testname='SimCoreTests', path='Simulation/Tests')
Definition: sim_rttUpdate.py:262
sim_rttUpdate.RttUpdate.updateDcubeXML
def updateDcubeXML(self, tname, path)
Definition: sim_rttUpdate.py:499
sim_rttUpdate.RttUpdate.ls
def ls(self)
Definition: sim_rttUpdate.py:466
sim_rttUpdate.SimRttDataBase._createTable
def _createTable(self, tname, *args)
Definition: sim_rttUpdate.py:61
LArG4FSStartPointFilterLegacy.execute
execute
Definition: LArG4FSStartPointFilterLegacy.py:20
sim_rttUpdate.SimRttDBError
Definition: sim_rttUpdate.py:29
sim_rttUpdate.RttUpdate.alias
alias
Definition: sim_rttUpdate.py:455
sim_rttUpdate.RttUpdate.__init__
def __init__(self, opt, db)
Definition: sim_rttUpdate.py:401
sim_rttUpdate.MyArgumentParser.__init__
def __init__(self, admin=True, user='aschaeli')
Definition: sim_rttUpdate.py:292
sim_rttUpdate.RttUpdate.updateRefs
def updateRefs(self)
Definition: sim_rttUpdate.py:579
sim_rttUpdate.SimRttDataBase.dump
def dump(self)
Definition: sim_rttUpdate.py:249
file
TFile * file
Definition: tile_monitor.h:29
sim_rttUpdate.RttUpdate
Definition: sim_rttUpdate.py:400
sim_rttUpdate.RttUpdate.updateDcube
def updateDcube(self)
Definition: sim_rttUpdate.py:535
sim_rttUpdate.SimRttDataBase.create
def create(self)
Definition: sim_rttUpdate.py:107
sim_rttUpdate.RttUpdate.writeLogFile
def writeLogFile(self)
Definition: sim_rttUpdate.py:479
sim_rttUpdate.RttUpdate.jobs
jobs
Definition: sim_rttUpdate.py:437
sim_rttUpdate.RttUpdate.db
db
Definition: sim_rttUpdate.py:402
sim_rttUpdate.SimRttDataBase.alias
alias
Definition: sim_rttUpdate.py:157
sim_rttUpdate.SimRttDataBase
Definition: sim_rttUpdate.py:46
sim_rttUpdate.SimRttDataBase.addUser
def addUser(self, username='aschaeli', right='a')
Definition: sim_rttUpdate.py:254
beamspotman.dir
string dir
Definition: beamspotman.py:623
sim_rttUpdate.RttUpdate.opt
opt
Definition: sim_rttUpdate.py:403
sim_rttUpdate.SimRttDataBase.openConnection
def openConnection(self)
Definition: sim_rttUpdate.py:53
sim_rttUpdate.MyArgumentParser
Definition: sim_rttUpdate.py:291
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
sim_rttUpdate.SimRttDataBase.jobs1
jobs1
Definition: sim_rttUpdate.py:155
sim_rttUpdate.RttUpdate.djobs
djobs
Definition: sim_rttUpdate.py:434
sim_rttUpdate.SimRttDataBase.fname
fname
Definition: sim_rttUpdate.py:48
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:79
sim_rttUpdate.SimRttDataBase._updateTable
def _updateTable(self, tname, keys, *args)
Definition: sim_rttUpdate.py:84
query_example.cursor
cursor
Definition: query_example.py:21
sim_rttUpdate.SimRttDataBase._hasKey
def _hasKey(self, tname, column, value)
Definition: sim_rttUpdate.py:76
sim_rttUpdate.SimRttDataBase.cnx
cnx
Definition: sim_rttUpdate.py:49
sim_rttUpdate.SimRttDataBase.findReference
def findReference(self, branch, project)
Definition: sim_rttUpdate.py:218
sim_rttUpdate.SimRttDataBase.findJobs
def findJobs(self, testname, jobtype)
Definition: sim_rttUpdate.py:233
str
Definition: BTagTrackIpAccessor.cxx:11
calibdata.commit
bool commit
Definition: calibdata.py:832
sim_rttUpdate.SimRttDataBase.addJob
def addJob(self, testname='SimCoreTests', jobname='AtlasG4_muons', files=['truth.root'], typeid='dcube')
Definition: sim_rttUpdate.py:266
sim_rttUpdate.SimRttDataBase.jobs
jobs
Definition: sim_rttUpdate.py:138
sim_rttUpdate.SimRttDataBase.initialFill
def initialFill(self)
Definition: sim_rttUpdate.py:122
sim_rttUpdate.SimRttDataBase.getUsers
def getUsers(self, right='a')
Definition: sim_rttUpdate.py:208
sim_rttUpdate.SimRttUpdateError
Definition: sim_rttUpdate.py:32