def chkLogger(): def buildLogFile(ldir, logFN): if (type(logFN) == type(ldir)): lf = dfile.joinPath(ldir, logFN) fileh = open(lf, 'a') fileh.close() return lf return None if (wlog.LOGFILE is None): ldir = dfile.joinPath(basepath, wlog.LOG_PATH) dfile.chkCreateDir(ldir) ''' wlog.LOGFILE=dfile.joinPath(ldir,wlog.LOG_FILENAME) fileh=open(wlog.LOGFILE,'a') fileh.close() ''' wlog.LOGFILE = buildLogFile(ldir, wlog.LOG_FILENAME) for extag in wlog.EXLOGTAGS: logfn = buildLogFile(ldir, wlog.defaultEXLogName(extag)) if (logfn is None): continue wlog.initEXLogDef(extag, logfn) wlog.getExLogger(extag) return
def freshRealP(* key): pojonames["REALP"]=[] for k in set(key) & set(pojonames.keys()): pojonames["REALP"].extend(pojonames[k]) wlog.getExLogger(rbdatabase.logTag).debug(str(pojonames["REALP"])) return
def _curexe(curs, *arg): try: curs.execute(*arg) except: emsg = "error_curexe()" + str(arg) wlog.getExLogger(rbdatabase.logTag).debug(emsg) wlog.doExTraceBack(rbdatabase.logTag) raise errs.RbDBErr(emsg)
def _curexe(curs,* arg): try: curs.execute(* arg) except: emsg="error_curexe()"+str(arg) wlog.getExLogger(rbdatabase.logTag).debug(emsg) wlog.doExTraceBack(rbdatabase.logTag) raise errs.RbDBErr(emsg)
def _post(self): self._pjCaptrue.delPojos(self._dbw,self._ctrl) self._ctrl.reset() self._dbw=None #todo 0901 lmsg= self._imp+"_post()"+self._tbn+"" wlog.getLogger().debug(lmsg) wlog.getExLogger(rbdatabase.logTag).debug(lmsg) return
def _setTbn(self): self._head=rbCfg.getCtrlHead() #1.0.0.1 wlog.getExLogger(rbdatabase.logTag).debug("setTbn_head:"+self._head+"_tbn:"+self.tbn) if(self.tbn.startswith(self._head)):return if(self.tbn.startswith(self._head)):return # fore self.tbn=self._head+self.tbn return
def _setTbn(self): self._head = rbCfg.getCtrlHead() #1.0.0.1 wlog.getExLogger(rbdatabase.logTag).debug("setTbn_head:" + self._head + "_tbn:" + self.tbn) if (self.tbn.startswith(self._head)): return if (self.tbn.startswith(self._head)): return # fore self.tbn = self._head + self.tbn return
def parseAnswerStr(datastr): if (type(datastr) == type('') and len(datastr) == 21): ret = [datastr[0], datastr[1:11], datastr[12:]] try: int(ret[1]) int(ret[2]) return ret except: wlog.getExLogger(cfgvol.upg['logtag']).debug(datastr) raise errs.RbRemoteErr("ERR_RECV") raise errs.RbRemoteErr("ERR_RECV")
def getPojos(self):# return None or return [], hasNext=False if(self.pgNo<0): return None,hasNext lc=len(self.rcds) be=self._pgsize if lc>0: wlog.getExLogger(rbdatabase.logTag).debug(self.tbn+":getPojos() lc="+str(len(self.rcds))+":be="+str(be)) if(lc<=self._pgsize): be=lc else: hasNext=True try:# get cur page return self.rcds[:be],hasNext finally: # del cur page at once del self.rcds[:be]
def getPojos(self): # return None or return [], hasNext = False if (self.pgNo < 0): return None, hasNext lc = len(self.rcds) be = self._pgsize if lc > 0: wlog.getExLogger( rbdatabase.logTag).debug(self.tbn + ":getPojos() lc=" + str(len(self.rcds)) + ":be=" + str(be)) if (lc <= self._pgsize): be = lc else: hasNext = True try: # get cur page return self.rcds[:be], hasNext finally: # del cur page at once del self.rcds[:be]
def exe(self,dbw=None): #todo 0901 if(dbw is not None): self._dbw=dbw nowT=datetime.datetime.now() ##wlog.getLogger().debug(self._imp+":exe()"+str(nowT)) self._pjCaptrue.begin(self._dbw,self._ctrl) lmsg= self._imp+"_pjCaptrue.begun:"+str(nowT) wlog.getLogger().debug(lmsg) wlog.getExLogger(rbdatabase.logTag).debug(lmsg) hasNext=True while hasNext==True: pjs,hasNext=self._pjCaptrue.getPojos() if(pjs is None or len(pjs)<1): break self._doPWF(pjs) pjs=[] cmodem.doSleep(1) # reduce cpu usage self._post() return
def begin(self,dbw,dbctrl): self.delsub=None self.wheresub,self.dt1,self.dt2=dbctrl.begin(dbw); wlog.getExLogger(rbdatabase.logTag).debug(str((dbctrl,dbctrl.rcd2))) # 1.0.0 if(self.wheresub is None): dbctrl.oked() return ssql=self.createQuerySQL() wlog.getExLogger(rbdatabase.logTag).debug(str((dbctrl,ssql,self.dt1,self.dt2))) self.rcds=dbw.fetchRs("ALL",ssql,(self.dt1,self.dt2)) if len(self.rcds)>0: wlog.getExLogger(rbdatabase.logTag).debug(self.tbn+":begun() fetch:"+str(len(self.rcds))) if(not(self.rcds is None)): self.pgNo=0 #return ''' lc=len(self.rcds) if(lc==0): self.pgCount=0 else: self.pgCount=len(self.rcds)/self._pgsize +1 # self.pgNo=0 ''' self.delsub,self.dt1,self.dt2=dbctrl.okDone(self._pojodef["delWhere"]) return
def begin(self, dbw, dbctrl): self.delsub = None self.wheresub, self.dt1, self.dt2 = dbctrl.begin(dbw) wlog.getExLogger(rbdatabase.logTag).debug(str( (dbctrl, dbctrl.rcd2))) # 1.0.0 if (self.wheresub is None): dbctrl.oked() return ssql = self.createQuerySQL() wlog.getExLogger(rbdatabase.logTag).debug( str((dbctrl, ssql, self.dt1, self.dt2))) self.rcds = dbw.fetchRs("ALL", ssql, (self.dt1, self.dt2)) if len(self.rcds) > 0: wlog.getExLogger( rbdatabase.logTag).debug(self.tbn + ":begun() fetch:" + str(len(self.rcds))) if (not (self.rcds is None)): self.pgNo = 0 #return ''' lc=len(self.rcds) if(lc==0): self.pgCount=0 else: self.pgCount=len(self.rcds)/self._pgsize +1 # self.pgNo=0 ''' self.delsub, self.dt1, self.dt2 = dbctrl.okDone( self._pojodef["delWhere"]) return