Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Public Attributes | Private Member Functions | List of all members
sim_check_batch.DataBase Class Reference
Inheritance diagram for sim_check_batch.DataBase:
Collaboration diagram for sim_check_batch.DataBase:

Public Member Functions

def __init__ (self, fname)
 
def openConnection (self)
 
def insert (self, tname='t_run', hargs=[], args=[])
 
def dummyHostInfo (self)
 
def addRun (self)
 
def addFile (self, fl)
 
def addFunction (self, fn)
 
def addFunctions (self, parser)
 
def addCountAndLinks (self, rid, parser=None)
 

Public Attributes

 fname
 
 cnx
 
 cur
 
 rid
 
 parser
 

Private Member Functions

def _execute (self, cmd, args=())
 
def _dumpTable (self, t)
 

Detailed Description

Definition at line 26 of file sim_check_batch.py.

Constructor & Destructor Documentation

◆ __init__()

def sim_check_batch.DataBase.__init__ (   self,
  fname 
)

Definition at line 27 of file sim_check_batch.py.

27  def __init__(self,fname):
28  self.fname=fname
29  self.cnx=None
30  self.cur=None
31 

Member Function Documentation

◆ _dumpTable()

def sim_check_batch.DataBase._dumpTable (   self,
  t 
)
private

Definition at line 41 of file sim_check_batch.py.

41  def _dumpTable(self,t):
42  #t = (symbol,)
43  #cur.execute('select * from stocks where symbol=?', t)
44  self._execute('select * from %s'%t)
45  header= [ s[0] for s in self.cur.description ]
46  format= ' '.join([ '%25s' for s in self.cur.description])
47  print format%tuple(header)
48  for res in self.cur.fetchall():
49  print format%res
50 
51 

◆ _execute()

def sim_check_batch.DataBase._execute (   self,
  cmd,
  args = () 
)
private

Definition at line 37 of file sim_check_batch.py.

37  def _execute(self,cmd,args=()):
38  print 'SQL:',cmd,args
39  self.cur.execute(cmd,args)
40 

◆ addCountAndLinks()

def sim_check_batch.DataBase.addCountAndLinks (   self,
  rid,
  parser = None 
)

Definition at line 141 of file sim_check_batch.py.

141  def addCountAndLinks(self,rid,parser=None):
142  if parser!=None:
143  self.parser=parser
144 
145  success=True
146  for fn in parser.functions.values():
147  if fn.dbid is None:
148  print 'ERROR fn=',fn.fn,'not in db yet'
149  self.addFunction(fn)
150 
151  hargs=['rid','fid','selfcounts','totalcounts']
152  args=[rid,fn.dbid,fn.selfcost,fn.totalcost]
153  # add counts to db
154  try:
155  self.insert('t_counts',hargs,args)
156  except IntegrityError as detail:
157  print 'IntegrityError',detail
158  success=False
159  print 'fn=',fn
160  continue
161 
162  # add sub call links to db
163  for i,counts in fn.calls.iteritems():
164  if i!=0:
165  cfn=self.parser.functions[i]
166  if cfn.dbid is None:
167  print 'ERROR cfn=',cfn.fn,'not in db yet'
168  self.addFunction(cfn)
169  hargs=['rid','fid','cfunid','counts']
170  args=[rid,fn.dbid,cfn.dbid,counts]
171  try:
172  self.insert('t_links',hargs,args)
173  except IntegrityError as detail:
174  print 'IntegrityError',detail
175  success=False
176  print 'fn=',fn
177  print 'cfn=',cfn
178 
179  if success:
180  self.cnx.commit()
181  else:
182  print 'some ERROR occured rolling back'
183  self.cnx.rollback()
184 
185 

◆ addFile()

def sim_check_batch.DataBase.addFile (   self,
  fl 
)

Definition at line 97 of file sim_check_batch.py.

97  def addFile(self,fl):
98  "add file entry to db and return id"
99  # check if already registered
100  if fl.dbid is not None:
101  return fl.dbid
102 
103  # check if database
104  cmd='select id from t_files where fl_name=?'
105  self._execute(cmd,(fl.fl,))
106  res=self.cur.fetchone()
107  if res is None:
108  print 'WARNING',fl.fl,'not found'
109  # adding it
110  id=self.insert('t_files',['fl_name'],[fl.fl])
111  else:
112  # receive existing entry
113  id=res[0]
114  fl.dbid=id
115  return id
116 

◆ addFunction()

def sim_check_batch.DataBase.addFunction (   self,
  fn 
)

Definition at line 117 of file sim_check_batch.py.

117  def addFunction(self,fn):
118  if self.parser.filelist.has_key(fn.fl_id):
119  fl=self.parser.filelist[fn.fl_id]
120  fid=self.addFile(fl)
121  else:
122  fid=0
123  cmd='select id from t_functions where fn_name=? and fid=? and issue=?'
124  self._execute(cmd,(fn.fn,fid,fn.issue))
125  res=self.cur.fetchone()
126  if res is None:
127  # adding it
128  hargs=['fn_name','fid','issue','lib']
129  args=[fn.fn,fid,fn.issue,fn.lib]
130  id = self.insert('t_functions',hargs,args)
131  else:
132  id = res[0]
133  fn.dbid=id
134 

◆ addFunctions()

def sim_check_batch.DataBase.addFunctions (   self,
  parser 
)

Definition at line 135 of file sim_check_batch.py.

135  def addFunctions(self,parser):
136  self.parser=parser
137  for fn in parser.functions.values():
138  self.addFunction(fn)
139  self.cnx.commit()
140 

◆ addRun()

def sim_check_batch.DataBase.addRun (   self)

Definition at line 74 of file sim_check_batch.py.

74  def addRun(self):
75 
76  #AtlasArea=/afs/cern.ch/atlas/software/builds/nightlies/devval/AtlasProduction/rel_2
77  atlasArea=os.getenv('AtlasArea')
78  dummy,branch,proj,rel=atlasArea.rsplit('/',3)
79 
80  #LS_SUBCWD=/afs/cern.ch/atlas/project/RTT/prod/Results/rtt/rel_2/devval/build/x86_64-slc5-gcc43-opt/offline/SimCoreTests/AtlasG4_muons
81  subcwd=os.getenv('LS_SUBCWD')
82  dummy1,cmt,dummy2,package,job=subcwd.rsplit('/',4)
83 
84  rdate,rtime=dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S').split()
85 
86  hostInfo=getHost()
87  hostInfo=dict(zip(*hostInfo))
88 
89  machine=hostInfo['HOST_NAME']
90  KSI2K_fac=float(hostInfo['cpuf'])
91  hargs=['branch', 'rel', 'cmt', 'rdate', 'rtime', 'machine', 'KSI2K_fac', 'package', 'job']
92  args=[locals()[x] for x in hargs]
93  id=self.insert('t_run',hargs,args)
94  self.cnx.commit()
95  return id
96 

◆ dummyHostInfo()

def sim_check_batch.DataBase.dummyHostInfo (   self)

Definition at line 62 of file sim_check_batch.py.

62  def dummyHostInfo(self):
63  hostInfo={'HOST_NAME': 'lxplus443',
64  'RESOURCES': '(intel plus quadcore wan)',
65  'cpuf': '1.9',
66  'maxmem': '48161M',
67  'maxswp': '51207M',
68  'model': 'vi_10_24',
69  'ncpus': '8',
70  'server': 'Yes',
71  'type': 'SLC5_64'}
72  return hostInfo
73 

◆ insert()

def sim_check_batch.DataBase.insert (   self,
  tname = 't_run',
  hargs = [],
  args = [] 
)

Definition at line 52 of file sim_check_batch.py.

52  def insert(self,tname='t_run',hargs=[],args=[]):
53  "create prepared statement and execute"
54  keys=','.join(hargs)
55  vals=','.join(('?',)*len(args))
56  cmd="insert into %s (%s) values (%s)"%(tname,keys,vals)
57  print cmd,args
58  self.cur.execute(cmd,args)
59  self.rid=self.cur.lastrowid
60  return self.rid
61 

◆ openConnection()

def sim_check_batch.DataBase.openConnection (   self)

Definition at line 32 of file sim_check_batch.py.

32  def openConnection(self):
33  import sqlite3
34  self.cnx = sqlite3.connect(self.fname)
35  self.cur = self.cnx.cursor()
36 

Member Data Documentation

◆ cnx

sim_check_batch.DataBase.cnx

Definition at line 29 of file sim_check_batch.py.

◆ cur

sim_check_batch.DataBase.cur

Definition at line 30 of file sim_check_batch.py.

◆ fname

sim_check_batch.DataBase.fname

Definition at line 28 of file sim_check_batch.py.

◆ parser

sim_check_batch.DataBase.parser

Definition at line 136 of file sim_check_batch.py.

◆ rid

sim_check_batch.DataBase.rid

Definition at line 59 of file sim_check_batch.py.


The documentation for this class was generated from the following file:
LArG4FSStartPointFilterLegacy.execute
execute
Definition: LArG4FSStartPointFilterLegacy.py:20
sim_check_batch.getHost
def getHost(hostname=None)
Definition: sim_check_batch.py:14
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
query_example.cursor
cursor
Definition: query_example.py:21
calibdata.commit
bool commit
Definition: calibdata.py:832
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65