| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

DybDbi::__init__ Namespace Reference


Classes

class  NullHandler
class  Level

Functions

def DbiCascader__getitem__
 wrap DbiTableRow subclasses and associated templated classes
def DbiCascader__repr__
def DbiCascader__check
def DbiConnection__repr__
def DbiStatement__del__
def DbiCtx__repr__
def DbiCtx__call__
def DybDbi__comment
def LOG
def MYSQLDUMP
def POST

Variables

tuple h = NullHandler()
tuple log = logging.getLogger("DybDbi")
tuple _getattr = lambdan:(n,getattr(gbl,n,None) or getattr(gbl,"DayaBay::%s" % n) )
tuple clss = map(_getattr,__all__)
 gDbi = gbl.gDbi
 instances
tuple dtrs = inspect.getmembers(genDbi,lambda o:inspect.isclass(o) and o.__name__[0] == 'G')
tuple GNAMES = map( lambda _:_[0] , dtrs )
tuple attfn
 skips must be defined before wrapping generates the repr and adds properties special handling of some attributes used in the generated repr
tuple detector_reps
 Detector subclass attributes with known representations, needed as do not follow Get/Set convention .

Function Documentation

def DybDbi::__init__::DbiCascader__getitem__ (   self,
  i 
)

wrap DbiTableRow subclasses and associated templated classes

Definition at line 136 of file __init__.py.

00136                                     :
00137     l = self.GetNumDb()
00138     if -1 < i < l:
00139         return self.GetConnection(i)
00140     raise IndexError("out of range for index %d" % i )  
00141 DbiCascader.__getitem__ = DbiCascader__getitem__
00142 DbiCascader.__len__ = DbiCascader.GetNumDb
00143 
def DbiCascader__repr__(self):

def DybDbi::__init__::DbiCascader__repr__ (   self  ) 

Definition at line 144 of file __init__.py.

00144                              :
00145     smry = "DbiCascader numdb %s authorisingdbno %s (1st with GLOBALSEQNO) " % ( self.GetNumDb(), self.GetAuthorisingDbNo() ) 
00146     return "\n".join([smry] + [ "%-10s %s " % ( self.GetStatusAsString(i), repr(con)) for i,con in enumerate(self) ])
00147 DbiCascader.__repr__ = DbiCascader__repr__
00148             
def DbiCascader__check(self):

def DybDbi::__init__::DbiCascader__check (   self  ) 

Definition at line 149 of file __init__.py.

00149                             :
00150     for i,con in enumerate(self):
00151         n = con.numconnectedstatements
00152         assert n == 0 , ( n, i, con )
00153 DbiCascader.check = DbiCascader__check
00154 
def DbiConnection__repr__(self):

def DybDbi::__init__::DbiConnection__repr__ (   self  ) 

Definition at line 155 of file __init__.py.

00155                                :
00156     return  " %-20s #%d %-10s %-10s %s " % ( self.GetDbName(), self.GetNumConnectedStatements(), ("not-tmp","tmp")[self.IsTemporary()] , ("open","closed")[self.IsClosed()] , self.GetUrl() ) 
00157 DbiConnection.__repr__ = DbiConnection__repr__
00158 
def DbiStatement__del__(self):

def DybDbi::__init__::DbiStatement__del__ (   self  ) 

Definition at line 159 of file __init__.py.

00159                              :
00160     print "DbiStatement__del__ committing hari-kari "
00161     self.IsA().Destructor(self)  ## hari-kari   http://wlav.web.cern.ch/wlav/pyroot/memory.html
00162 DbiStatement.__del__ = DbiStatement__del__
00163 
00164 
def DbiCtx__repr__(self):

def DybDbi::__init__::DbiCtx__repr__ (   self  ) 

Special handling of the DbiCtx repr so that only properties 
that have been set (as recorded in the "mask" property ) are shown  

Definition at line 165 of file __init__.py.

00165                         :
00166     """
00167     Special handling of the DbiCtx repr so that only properties 
00168     that have been set (as recorded in the "mask" property ) are shown  
00169     """
00170     getters = Wrap(DbiCtx).getters 
00171     prps = [ (g,getattr(self,'Get%s'%g)()) for g in getters if getattr( Ctx,'k%s'%g , 0) & self.mask > 0 or getattr( Ctx,'k%s'%g , 0) == 0 ] 
00172     return pprint.pformat( dict( prps ) ,indent=4)
00173 DbiCtx.__repr__ = DbiCtx__repr__
00174 
def DbiCtx__call__( self, *args , **kwa ):

def DybDbi::__init__::DbiCtx__call__ (   self,
  args,
  kwa 
)

Shorthand context attribute setting in kwa style

Definition at line 175 of file __init__.py.

00175                                          :
00176     """
00177     Shorthand context attribute setting in kwa style
00178     """
00179     for arg in args:
00180         self.Update(arg)
00181     for k,v in kwa.items():
00182         setattr( self, k, v )
00183     return self
00184 DbiCtx.__call__ = DbiCtx__call__
00185 
00186 
def DybDbi__comment( self, *args , **kwa ):

def DybDbi::__init__::DybDbi__comment (   self,
  args,
  kwa 
)

Cheap trick to scribble on the mysql command list ... in order to see the order of things::

     gDbi.comment("hello","world")

Definition at line 187 of file __init__.py.

00187                                           :
00188     """ 
00189     Cheap trick to scribble on the mysql command list ... in order to see the order of things::
00190 
00191          gDbi.comment("hello","world")
00192 
00193     """
00194     dbno = kwa.pop('dbno', 0)
00195     comment = "\n".join(map(lambda l:"# %s"%l, args))
00196     log.info( comment )
00197     self.cascader[dbno].CreatePreparedStatement( comment )
00198     pass
00199 DybDbi.comment = DybDbi__comment
00200 
00201 
00202 
00203 
00204 
00205 
## Detector subclass attributes with known representations, needed as do not follow Get/Set convention ... 

def DybDbi::__init__::LOG (   level = "INFO"  ) 

By wrapping a test function with this decorator,
the logging level is changed to the chosen level 
while the test is running.

Definition at line 259 of file __init__.py.

00259                      :
00260     """
00261     By wrapping a test function with this decorator,
00262     the logging level is changed to the chosen level 
00263     while the test is running.
00264     """
00265     level = Level.From(level)
00266     def _decorate(func):
00267         def _wrapper(*args, **kargs):
00268             gDbi.comment("entering %s " % func.__name__ , "")
00269             ol = gDbi.GetOutputLevel()
00270             gDbi.SetOutputLevel(level)
00271             func(*args, **kargs)
00272             gDbi.SetOutputLevel(ol)
00273             gDbi.comment("exiting %s " % func.__name__ , "")
00274         _wrapper = make_decorator(func)(_wrapper)
00275         return _wrapper
00276     return _decorate
00277 
def MYSQLDUMP(level="INFO", opt=" --extended-insert=0 --skip-comments " , cfdir=None, reference=False ):

def DybDbi::__init__::MYSQLDUMP (   level = "INFO",
  opt = " --extended-insert=0 --skip-comments ",
  cfdir = None,
  reference = False 
)

By wrapping a test function with this decorator,
the database is mysqldumped after the test has run 
   
The output dumps are saved in a directory created at path  
based on the names of test module and function

Definition at line 278 of file __init__.py.

00278                                                                                                        :
00279     """
00280     By wrapping a test function with this decorator,
00281     the database is mysqldumped after the test has run 
00282    
00283     The output dumps are saved in a directory created at path  
00284     based on the names of test module and function
00285     """
00286     level = Level.From(level)
00287     def _decorate(func):
00288         def _wrapper(*args, **kargs):
00289             print "MYSQLDUMP for func %s  " % ( func.__name__ )
00290             ol = gDbi.GetOutputLevel()
00291             gDbi.SetOutputLevel(level)
00292             func(*args, **kargs)
00293             gDbi.SetOutputLevel(ol)
00294             dir = os.path.join( os.getcwd(), "tests", func.__module__ , func.__name__ ) 
00295             DBCas.Dump( dir=dir, opt=opt , cfdir=cfdir, reference=reference )
00296         _wrapper = make_decorator(func)(_wrapper)
00297         return _wrapper
00298     return _decorate
00299 
00300 
def POST(level="WARNING"):

def DybDbi::__init__::POST (   level = "WARNING"  ) 

By wrapping a test function with this decorator, some 
post test checks are performed on the cascade

Distributing usage of this throughout the a collection of 
nosetests is useful when searching for which test is messing something up.  

Definition at line 301 of file __init__.py.

00301                          :
00302     """
00303     By wrapping a test function with this decorator, some 
00304     post test checks are performed on the cascade
00305 
00306     Distributing usage of this throughout the a collection of 
00307     nosetests is useful when searching for which test is messing something up.  
00308     """ 
00309     level = Level.From(level)
00310     def _decorate(func):
00311         def _wrapper(*args, **kargs):
00312             print "POST for func %s  " % ( func.__name__ )
00313             ol = gDbi.outputlevel
00314             gDbi.outputlevel = level
00315             func(*args, **kargs)
00316             gDbi.cascader.check()
00317             gDbi.outputlevel = ol
00318         _wrapper = make_decorator(func)(_wrapper)
00319         return _wrapper
00320     return _decorate
00321 
00322 
00323 
00324 
__all__ += "LOG MYSQLDUMP POST".split()


Variable Documentation

tuple DybDbi::__init__::h = NullHandler() [static]

Definition at line 58 of file __init__.py.

tuple DybDbi::__init__::log = logging.getLogger("DybDbi") [static]

Definition at line 59 of file __init__.py.

tuple DybDbi::__init__::_getattr = lambdan:(n,getattr(gbl,n,None) or getattr(gbl,"DayaBay::%s" % n) ) [static]

Definition at line 84 of file __init__.py.

tuple DybDbi::__init__::clss = map(_getattr,__all__) [static]

Definition at line 85 of file __init__.py.

DybDbi::__init__::gDbi = gbl.gDbi [static]

instances

Definition at line 90 of file __init__.py.

tuple DybDbi::__init__::dtrs = inspect.getmembers(genDbi,lambda o:inspect.isclass(o) and o.__name__[0] == 'G') [static]

Definition at line 95 of file __init__.py.

tuple DybDbi::__init__::GNAMES = map( lambda _:_[0] , dtrs ) [static]

Definition at line 97 of file __init__.py.

tuple DybDbi::__init__::attfn [static]

Initial value:

dict(
     UpdateMask=lambda obj:("UpdateMask",Ctx.StringFromMask( obj.GetUpdateMask() )),
           Mask=lambda obj:("Mask", Ctx.StringFromMask( obj.GetMask() )),
        SimMask=lambda obj:("SimMask",SimFlag.StringFromMask( obj.GetSimMask() )),
       SiteMask=lambda obj:("SiteMask",Site.StringFromMask( obj.GetSiteMask() )),
  )
skips must be defined before wrapping generates the repr and adds properties special handling of some attributes used in the generated repr

Definition at line 107 of file __init__.py.

tuple DybDbi::__init__::detector_reps [static]

Initial value:

dict( 
   detName=lambda x:x.detName(),
   site=lambda x:Site.AsString(x.site()) , 
   detectorId=lambda x:DetectorId.AsString(x.detectorId()),  
   sensorId=lambda x:x.sensorId(),
   ring=lambda x:x.ring(),
   column=lambda x:x.column(),
   wallNumber=lambda x:x.wallNumber(),
   wallSpot=lambda x:x.wallSpot(),
   panelRow=lambda x:x.panelRow(),
   layer=lambda x:x.layer(),
   strip=lambda x:x.strip(),
)
Detector subclass attributes with known representations, needed as do not follow Get/Set convention .

..

Definition at line 207 of file __init__.py.

| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:17:17 2011 for DybDbi by doxygen 1.4.7