def _open(self): if ((self.conn is None) or (self._isClose == True)): linux.doPrint("self._connstring:" + self._connstring) self.conn = pyodbc.connect(self._connstring) self._isClose = False return self.conn
def _open(self): if((self.conn is None) or (self._isClose==True) ): linux.doPrint( "self._connstring:"+self._connstring) self.conn=pyodbc.connect(self._connstring) self._isClose=False return self.conn
def main(): linux.doPrint("start main") onLogger() onStart() onBackendStart() #pool=rbdatabase.PojoBuilder._InnerPool() #rbcfg.WEB["app"].runbasic() runWebber() linux.doPrint("started main") return
def _delAPath(self, AIMP): pss = AIMP["PATH"] if (pss is None): return pth = rbruntime.dirfile.joinPath(self._bpath, pss) linux.doPrint("pth=%s \n ptn=%s " % (pth, self._patten)) rbruntime.dirfile.chkCreateDir(pth) self._delFile(pth) return
def _delAPath(self,AIMP): pss=AIMP["PATH"] if(pss is None): return pth=rbruntime.dirfile.joinPath(self._bpath, pss) linux.doPrint("pth=%s \n ptn=%s "% (pth,self._patten)) rbruntime.dirfile.chkCreateDir(pth) self._delFile(pth) return
def start(self, stoped=False): if (self._timer is None): return wlog.getLogger().debug("Daemon tostart" + str(self)) linux.doPrint("Daemon tostart" + str(self)) if self._started is False: self._started = True self._timer.start() wlog.getLogger().debug("Daemon started" + str(self)) linux.doPrint("Daemon started" + str(self)) self._stoped = stoped return
def start(self,stoped=False): if(self._timer is None):return wlog.getLogger().debug("Daemon tostart"+str(self)) linux.doPrint( "Daemon tostart"+str(self)) if self._started is False: self._started=True self._timer.start() wlog.getLogger().debug("Daemon started"+str(self)) linux.doPrint( "Daemon started"+str(self)) self._stoped=stoped return
def _before(self): if (self._posted is True): self._posted = False ok = self._canWork() #todo stop if (ok == False): return ok self._now = datetime.datetime.now() if (self._last is None): return ok dd1 = self._now - self._last slp = self._dtdelta.seconds - dd1.seconds if (slp > 0): linux.doPrint("Map Sleep:", slp) time.sleep(slp) return ok
def _before(self): if(self._posted is True):self._posted=False ok=self._canWork() #todo stop if(ok==False): return ok self._now=datetime.datetime.now() if(self._last is None): return ok dd1=self._now-self._last slp=self._dtdelta.seconds-dd1.seconds if(slp>0): linux.doPrint( "Map Sleep:",slp) time.sleep(slp) return ok
def doSleepReduce(num,dprt=False): if(type(num)==type(1) ): ddelay=getDelay() ws=10 if(type(ddelay['reduceSleep']['base'])==type(ws) and ddelay['reduceSleep']['base']>0): ws=ddelay['reduceSleep']['base'] try: if((num % ws)==0): doSleep(ddelay['reduceSleep']['sleep']) if(True==dprt): import rbruntime.Linux as linux linux.doPrint( 'doSleepReduce:',num,ddelay['reduceSleep']['sleep']) except: wlog.doTraceBack() return
def doSleepReduce(num, dprt=False): if (type(num) == type(1)): ddelay = getDelay() ws = 10 if (type(ddelay['reduceSleep']['base']) == type(ws) and ddelay['reduceSleep']['base'] > 0): ws = ddelay['reduceSleep']['base'] try: if ((num % ws) == 0): doSleep(ddelay['reduceSleep']['sleep']) if (True == dprt): import rbruntime.Linux as linux linux.doPrint('doSleepReduce:', num, ddelay['reduceSleep']['sleep']) except: wlog.doTraceBack() return
def _run(self): _BasePooledDaemon._run(self) cfgcmd.setSts(**{self._imptype:"RUNNING"}) if(self.dbw is None): self.dbw =pjbuilder.DBPool.pop(rbcfg.IMPLEMENTS[self._imptype]["POOL"]) linux.doPrint( self._imptype+".dbw:"+str(self.dbw)) wlog.getLogger().debug( self._imptype+".dbw:"+str(self.dbw)) for r in self.runners: # r.exe(self.dbw) try: r.exe(self.dbw) except errs.RbDBErr,dbe: cfgcmd.setSts(**{self._imptype:"ERRDB"}) pjbuilder.DBPool.back(self.dbw,rbcfg.IMPLEMENTS[self._imptype]["POOL"],True) self.dbw=None wlog.doTraceBack() return except Exception,err: wlog.doTraceBack()
def _getConnString(** args): vls={} try: vls=args.copy() finally: pass if(not vls.has_key(drivern) or vls[drivern] is None): vls[drivern]= defaultDrv ks=connperpn["win"] if(linux.inLinux()):ks=connperpn["linux"] return rbruntime.StringUtils.join2AStr(ks, vls, conneqsplit, connpsplit)#(connperpn, vls, conneqsplit, connpsplit)
def realUpg(): linux.doPrint("begin upg work") upgwork.upgWorkMain() linux.doPrint("upg worked restart remotebox...") linux.remoteBoxRework( ) #linux.remoteBoxUpgRework() remoteBoxRework() linux.doReboot() return
def _run(self): _BasePooledDaemon._run(self) cfgcmd.setSts(**{self._imptype: "RUNNING"}) if (self.dbw is None): self.dbw = pjbuilder.DBPool.pop( rbcfg.IMPLEMENTS[self._imptype]["POOL"]) linux.doPrint(self._imptype + ".dbw:" + str(self.dbw)) wlog.getLogger().debug(self._imptype + ".dbw:" + str(self.dbw)) for r in self.runners: # r.exe(self.dbw) try: r.exe(self.dbw) except errs.RbDBErr, dbe: cfgcmd.setSts(**{self._imptype: "ERRDB"}) pjbuilder.DBPool.back(self.dbw, rbcfg.IMPLEMENTS[self._imptype]["POOL"], True) self.dbw = None wlog.doTraceBack() return except Exception, err: wlog.doTraceBack()
def _getConnString(**args): vls = {} try: vls = args.copy() finally: pass if (not vls.has_key(drivern) or vls[drivern] is None): vls[drivern] = defaultDrv ks = connperpn["win"] if (linux.inLinux()): ks = connperpn["linux"] return rbruntime.StringUtils.join2AStr( ks, vls, conneqsplit, connpsplit) #(connperpn, vls, conneqsplit, connpsplit)
def doBuildDSCfgByDB(fdb): import rbruntime.Linux as linux linux.doBuildDSCfgByDB(fdb) return
def doCopyLocalCfg(fdb): import rbruntime.Linux as linux linux.copyLocalIP(getCommCfg()) return
def inLinux(): import rbruntime.Linux as linux return linux.inLinux()
def rebootLinux(): Linux.doReboot() return
def startBox(): linux.remoteBoxUpgRework() # return
def rebootLinux(): Linux.doReboot() return
def doBuildDSCfgByDB(fdb): import rbruntime.Linux as linux linux.doBuildDSCfgByDB(fdb) return
def inLinux(): import rbruntime.Linux as linux return linux.inLinux()
def emptyRuner(): Linux.doPrint("emptyRuner") return
def main(): linux.doPrint("start upg main") onLogger() onStart() onBackendStart() return
def doCopyLocalCfg(fdb): import rbruntime.Linux as linux linux.copyLocalIP(getCommCfg()) return
dtimes=0 while dtimes<ddelay['socket']['times']: dtimes+=1 cmodem.doSleep(ddelay['socket']['recv']) # reduce cpu usage and syn socket try: data=sock.recv(1024) except Exception,x: wlog.getLogger().error("ignor sock.recv:"+str(dtimes)) wlog.doTraceBack() continue if(data) : break if(data is not None and len(data)>0) : linux.doPrint( data) if(data[0]=='1'): rok="OK" wlog.getLogger().debug("send data success:" + data) else: rok="ERR_RECV" wlog.getLogger().error("ERR_RECV listener error:"+data) else: rok=onFAILRECV() except Exception,x: wlog.getLogger().error("FAIL_SEND remote listener error:") #wlog.doTraceBack() wlog.doTraceBack() #return "FAIL_SEND" rok="FAIL_SEND"
def inLinux(): return Linux.inLinux()
def inLinux(): return linux.inLinux()
while dtimes < ddelay['socket']['times']: dtimes += 1 cmodem.doSleep( ddelay['socket']['recv']) # reduce cpu usage and syn socket try: data = sock.recv(1024) except Exception, x: wlog.getLogger().error("ignor sock.recv:" + str(dtimes)) wlog.doTraceBack() continue if (data): break if (data is not None and len(data) > 0): linux.doPrint(data) if (data[0] == '1'): rok = "OK" wlog.getLogger().debug("send data success:" + data) else: rok = "ERR_RECV" wlog.getLogger().error("ERR_RECV listener error:" + data) else: rok = onFAILRECV() except Exception, x: wlog.getLogger().error("FAIL_SEND remote listener error:") #wlog.doTraceBack() wlog.doTraceBack() #return "FAIL_SEND" rok = "FAIL_SEND"
def emptyRuner(): Linux.doPrint( "emptyRuner") return