/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Public Attributes | Properties
DybPython::dbaux::Aux Class Reference

List of all members.

Public Member Functions

def __init__
def fresh_db
def sslog
def ls_
def svnup_
def rcmpcat_
def rloadcat_
def __call__

Public Attributes

 args
 slog
 db

Properties

 cachesvnlog = property(lambda self:"/tmp/dbaux-slog-%s-%s.xml" % (os.getlogin(), self.args.revs ))
 info = property(lambda self:Info(self.args.workingcopy), doc="parse/wrap output of `svn info --xml` ... caution rerun on each access" )
 stat = property(lambda self:Status(self.args.workingcopy), doc="parse/wrap output of `svn status --xml` ... caution rerun on each access" )

Detailed Description

Definition at line 272 of file dbaux.py.


Constructor & Destructor Documentation

def DybPython::dbaux::Aux::__init__ (   self,
  args 
)

Definition at line 274 of file dbaux.py.

00275                              :
00276         log.info( "Aux %r" % args )
00277         self.args = args
00278         
00279         opts = {'limit':args.limit } 
00280         if args.cachesvnlog:
00281             opts['xmlcache'] = self.cachesvnlog
00282 
00283         if args.action == "rloadcat" and args.dbconf == 'offline_db':
00284             log.warn( "checking options for definitive rloadcat into offline_db"  )
00285             #if not args.ffcommit: 
00286             #    log.fatal( "definitive rloadcat requires the  -f/--ffcommit option ")
00287             #    sys.exit(1)
00288         else:
00289             pass
00290 
00291         slog = SVNLog( args.baseurl, args.revs, opts )
00292         self.slog = slog 
00293         log.info( "completed the slog " )
00294         pass 
00295         self.fresh_db()
00296         info = self.info 
00297         log.info("%r ... revision %s " % ( info, info.revision) ) 


Member Function Documentation

def DybPython::dbaux::Aux::fresh_db (   self)
Pull up a new DB instance

Definition at line 302 of file dbaux.py.

00303                       :
00304         """
00305         Pull up a new DB instance
00306         """
00307         self.db = db_( self.args )

def DybPython::dbaux::Aux::sslog (   self)

Definition at line 308 of file dbaux.py.

00309                    :
00310         for e in self.slog:
00311             if self.args.author and e.author != self.args.author:
00312                 continue 
00313             yield e 

def DybPython::dbaux::Aux::ls_ (   self)
Lists the revisions, author, time, commit message

Definition at line 314 of file dbaux.py.

00315                  :
00316         """
00317         Lists the revisions, author, time, commit message
00318         """
00319         for i,e in enumerate(self.sslog()):
00320             log.info( "%-3s %6s %10s %20s %s " % (i,e.revision,e.author,e.t,e.msg) )   

def DybPython::dbaux::Aux::svnup_ (   self,
  rev,
  reset = False,
  force = False 
)
:param rev: revision number to bring working copy directory to 
:param reset:  remove the directory first, wiping away uncommitted changes/conflicts 


Aug 22, 2012 moved to checkout and revert rather than priot just update
as this was  failing with ``--reset`` due to lack of the working copy directory,
resulting in ``svn up`` skipping and subsequent assertions.  The idea is to step 
thru pristine revisions, one by one::

    svn co -r 5292 http://dayabay.ihep.ac.cn/svn/dybaux/catalog/tmp_offline_db ~/dybaux/catalog/tmp_offline_db
    svn revert ~/dybaux/catalog/tmp_offline_db

Definition at line 321 of file dbaux.py.

00322                                                      :
00323         """
00324         :param rev: revision number to bring working copy directory to 
00325         :param reset:  remove the directory first, wiping away uncommitted changes/conflicts 
00326 
00327 
00328         Aug 22, 2012 moved to checkout and revert rather than priot just update
00329         as this was  failing with ``--reset`` due to lack of the working copy directory,
00330         resulting in ``svn up`` skipping and subsequent assertions.  The idea is to step 
00331         thru pristine revisions, one by one::
00332 
00333             svn co -r 5292 http://dayabay.ihep.ac.cn/svn/dybaux/catalog/tmp_offline_db ~/dybaux/catalog/tmp_offline_db
00334             svn revert ~/dybaux/catalog/tmp_offline_db
00335 
00336         """ 
00337         info = self.info
00338         if info.revision == rev and not force:
00339             log.info(repr(info))
00340             log.info("svnup_ skip update as working copy is already at revision %(rev)s" % locals() )  
00341             return None
00342 
00343         wc = pathx(self.args.workingcopy)
00344         url = "%s/catalog/tmp_offline_db" % self.args.baseurl
00345         if reset:
00346             basename = os.path.basename(wc)
00347             assert os.path.isdir(wc) and len(wc) > 10, "bad wc %s " % wc 
00348             assert basename == 'tmp_offline_db'  
00349             log.info("removing working copy dir %s " % wc )
00350             shutil.rmtree(wc)
00351         else:
00352             stat = self.stat
00353             if len(stat) > 0:
00354                 log.fatal("svnup_ into unclean working copy %r " % stat )
00355                 log.fatal("\n".join([repr(e) for e in stat])) 
00356                 log.fatal("consider using --reset option to blow away the working copy before update")
00357                 sys.exit(1)
00358 
00359         svnco = "svn co -r %(rev)s %(url)s %(wc)s " % locals() 
00360         svnrv = "svn revert %(wc)s " % locals() 
00361         for svnxx in (svnco,svnrv):
00362             log.info(svnxx) 
00363             ret = os.popen(svnxx).read()
00364             log.info(ret)
 
def DybPython::dbaux::Aux::rcmpcat_ (   self)
Loops over revisions:

#. `svn up -r` the working copy  
#. runs **rcmpcat**  comparing the ascii catalog with DB
 

Definition at line 365 of file dbaux.py.

00366                       :
00367         """
00368         Loops over revisions:
00369         
00370         #. `svn up -r` the working copy  
00371         #. runs **rcmpcat**  comparing the ascii catalog with DB
00372  
00373         """
00374         stat = self.stat    
00375         if len(stat) > 0:
00376             log.warn("unclean working copy %r " % stat )
00377             log.warn("\n".join([repr(e) for e in stat])) 
00378 
00379         cat = self.args.workingcopy
00380         log.info("rcmpcat_ %r" % cat )
00381         for i,e in enumerate(self.sslog()):
00382             log.info("commit %-3s %6s %10s %20s %s " % (i,e.revision,e.author,e.t,e.msg) )   
00383             self.svnup_(e.revision, reset=self.args.reset )
00384             rcc = self.db.rcmpcat_(cat)   ## compare  
00385             log.info("rcmpcat %r" % rcc )

def DybPython::dbaux::Aux::rloadcat_ (   self)
Loops over revisions
 
#. `svn up -r` the working copy  
#. runs **rcmpcat** to verify there are some updates to be loaded
#. invokes **rloadcat** loading ascii catalog into DB
#. runs **rcmpcat** agsin to verify load is complete 


NB no confirmation is requested, thus before doing this perform an 
**rcmpcat** to verify expected updates

Rerunning an **rloadcat** ::

    ./dbaux.py rloadcat 4913   ## 1st time OK
    ./dbaux.py rloadcat 4913   ## 2nd time was giving conflicts ... now fails with unclean error
    ./dbaux.py --reset rloadcat 4913   ## blow away conflicts by deletion of working copy before "svn up"

How to fix ?

#.  When testing "svn revert" the changed validity tables throwing away
    the fastforward times ?  via parsing "svn status"  

Definition at line 386 of file dbaux.py.

00387                        :
00388         """
00389         Loops over revisions
00390  
00391         #. `svn up -r` the working copy  
00392         #. runs **rcmpcat** to verify there are some updates to be loaded
00393         #. invokes **rloadcat** loading ascii catalog into DB
00394         #. runs **rcmpcat** agsin to verify load is complete 
00395 
00396 
00397         NB no confirmation is requested, thus before doing this perform an 
00398         **rcmpcat** to verify expected updates
00399 
00400         Rerunning an **rloadcat** ::
00401 
00402             ./dbaux.py rloadcat 4913   ## 1st time OK
00403             ./dbaux.py rloadcat 4913   ## 2nd time was giving conflicts ... now fails with unclean error
00404             ./dbaux.py --reset rloadcat 4913   ## blow away conflicts by deletion of working copy before "svn up"
00405 
00406         How to fix ?
00407 
00408         #.  When testing "svn revert" the changed validity tables throwing away
00409             the fastforward times ?  via parsing "svn status"  
00410 
00411         """
00412         cat = self.args.workingcopy
00413         sslog = [e for e in self.sslog()]
00414         log.info("rloadcat_ %r over %s revisions " % (cat, len(sslog)) )
00415         for i,e in enumerate(sslog):
00416             log.info( "commit %-3s %6s %10s %20s %s " % (i,e.revision,e.author,e.t,e.msg) )   
00417             self.svnup_(e.revision, reset=self.args.reset )
00418             rlc = self.db.rloadcat_(cat)                       ## compares and loads 
00419             if len(rlc) == 0:
00420                 log.info("rloadcat_ didnt see any updates for revision %s " % e.revision )
00421                 continue
00422 
00423             log.info("rloadcat %r" % rlc )
00424             self.fresh_db()
00425             rcc = self.db.rcmpcat_(cat)  
00426             log.info("after rloadcat rcmpcat %r" % rcc )
00427 
00428             assert len(rcc) == 0 , "should be no table/seqno differences after rloadcat " 
00429             if i + 1 < len(sslog):
00430                 sleep = self.args.sleep
00431                 log.info("sleeping for %s seconds" % sleep )
00432                 time.sleep(sleep)  
00433 

def DybPython::dbaux::Aux::__call__ (   self)

Definition at line 434 of file dbaux.py.

00435                       :
00436         cmd = self.args.action + "_"
00437         if hasattr( self , cmd ):
00438             getattr( self, cmd )() 
00439         else:
00440             log.warn("no method %s " % cmd ) 
00441 


Member Data Documentation

Definition at line 274 of file dbaux.py.

Definition at line 274 of file dbaux.py.

Definition at line 304 of file dbaux.py.


Property Documentation

DybPython::dbaux::Aux::cachesvnlog = property(lambda self:"/tmp/dbaux-slog-%s-%s.xml" % (os.getlogin(), self.args.revs )) [static]

Definition at line 298 of file dbaux.py.

DybPython::dbaux::Aux::info = property(lambda self:Info(self.args.workingcopy), doc="parse/wrap output of `svn info --xml` ... caution rerun on each access" ) [static]

Definition at line 299 of file dbaux.py.

DybPython::dbaux::Aux::stat = property(lambda self:Status(self.args.workingcopy), doc="parse/wrap output of `svn status --xml` ... caution rerun on each access" ) [static]

Definition at line 300 of file dbaux.py.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:55:40 for DybPython by doxygen 1.7.4