Classes | |
class | CSVFormat |
class | DB |
Functions | |
def | main |
Variables | |
tuple | db = main() |
def DybPython::db::main | ( | ) |
Definition at line 727 of file db.py.
00727 : 00728 """ 00729 00730 """ 00731 #exclude="", #"DcsAdTemp,DcsAdTempVld,DcsPmtHv,DcsPmtHvVld,DaqRawDataFileInfo,DaqRawDataFileInfoVld,DaqRunConfig,DaqRunInfo,DaqRunInfoVld,DaqCalibRunInfo", 00732 tables = "CalibFeeSpec CalibPmtSpec FeeCableMap SimPmtSpec DaqRunInfo".split() 00733 from optparse import OptionParser 00734 op = OptionParser(usage=__doc__ + "\n" + DB.docs() ) 00735 op.add_option("-v", "--verbose", action="store_true" ) 00736 op.add_option("-a", "--all", action="store_true" , help="Do not apply table exclusions for the command. Default %default " ) 00737 op.add_option("-R", "--replace", action="store_true", help="Drop existing tables prior to loading tables from catalog into DB. Default %default " ) 00738 op.add_option("-T", "--tcreate", action="store_true", help="Create non-existing tables where needed. Default %default " ) 00739 op.add_option("-t", "--tselect", help="Comma delimited list of selected table names to be included in operations. Default %default " ) 00740 op.add_option("-p", "--prefix", help="Table name prefix (used for testing loadcat machinery). Default %default " ) 00741 op.add_option("-b", "--tmpbase", help="Path of existing temporary base directory. Default %default " ) 00742 op.add_option("-C", "--nocheck", action="store_false", help="Skip connection check at startup, for debugging usage only. Default %default " ) 00743 op.set_defaults(all=False, 00744 replace=False, 00745 verbose=False, 00746 tcreate=False, 00747 nocheck=False, 00748 prefix="Tmp", 00749 tselect=",".join( map(lambda _:"%s,%sVld" % (_,_) , tables) + ["LOCALSEQNO"] ), 00750 tmpbase="/tmp", 00751 ) 00752 00753 00754 (opts_ , args) = op.parse_args() 00755 opts = vars(opts_) 00756 00757 sect = len(args)>0 and args[0] or "offline_db" 00758 cmd = len(args)>1 and "%s_" % args[1] or "count_" 00759 00760 ## "load" is a special case as need to connect without database specified 00761 ## allowing dropping of any preexisting DB and creation of a new one 00762 nodb = cmd == 'load_' 00763 00764 db = DB(sect, verbose=opts['verbose'], opts=opts, nodb=nodb ) 00765 if not opts.get('nocheck'): 00766 print db.check_(**opts) 00767 00768 if opts['verbose'] and nodb == False: 00769 print "showtables : %s " % repr(db.showtables) 00770 print " tables : %s " % repr(db.tables) 00771 00772 if hasattr(db, cmd): 00773 getattr( db , cmd)( *args[2:], **opts ) 00774 else: 00775 raise Exception("cmd %s not implemented " % cmd) 00776 return db 00777 #db.close() 00778 if __name__=='__main__':
tuple DybPython::db::db = main() [static] |