Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
def main():
    linux.doPrint("start main")
    onLogger()
    onStart()
    onBackendStart()
    #pool=rbdatabase.PojoBuilder._InnerPool()
    #rbcfg.WEB["app"].runbasic()
    runWebber()
    linux.doPrint("started main")
    return
Ejemplo n.º 4
0
    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
Ejemplo n.º 5
0
 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
Ejemplo n.º 6
0
    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
Ejemplo n.º 7
0
 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 
Ejemplo n.º 8
0
    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
Ejemplo n.º 9
0
 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
Ejemplo n.º 10
0
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       
        
Ejemplo n.º 11
0
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
Ejemplo n.º 12
0
 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()
Ejemplo n.º 13
0
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)
Ejemplo n.º 14
0
    def realUpg():
        linux.doPrint("begin upg work")
        upgwork.upgWorkMain()
        linux.doPrint("upg worked  restart remotebox...")

        linux.remoteBoxRework(
        )  #linux.remoteBoxUpgRework() remoteBoxRework()  linux.doReboot()
        return
Ejemplo n.º 15
0
    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()
Ejemplo n.º 16
0
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)
Ejemplo n.º 17
0
 def doBuildDSCfgByDB(fdb):
     import rbruntime.Linux as linux
     linux.doBuildDSCfgByDB(fdb)
     
     return
Ejemplo n.º 18
0
 def doCopyLocalCfg(fdb):
     import rbruntime.Linux as linux
     linux.copyLocalIP(getCommCfg())
     
     return
Ejemplo n.º 19
0
def inLinux():
    import rbruntime.Linux as linux
    return linux.inLinux()
Ejemplo n.º 20
0
 def rebootLinux():
     Linux.doReboot()
     return
Ejemplo n.º 21
0
 def startBox():
     linux.remoteBoxUpgRework()  #
     return
Ejemplo n.º 22
0
 def rebootLinux():
     Linux.doReboot()
     return
Ejemplo n.º 23
0
    def doBuildDSCfgByDB(fdb):
        import rbruntime.Linux as linux
        linux.doBuildDSCfgByDB(fdb)

        return
Ejemplo n.º 24
0
def inLinux():
    import rbruntime.Linux as linux
    return linux.inLinux()
Ejemplo n.º 25
0
def emptyRuner():
    Linux.doPrint("emptyRuner")
    return
Ejemplo n.º 26
0
def main():
    linux.doPrint("start upg main")
    onLogger()
    onStart()
    onBackendStart()
    return
Ejemplo n.º 27
0
    def doCopyLocalCfg(fdb):
        import rbruntime.Linux as linux
        linux.copyLocalIP(getCommCfg())

        return
Ejemplo n.º 28
0
     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" 
 
Ejemplo n.º 29
0
 def inLinux():
     return Linux.inLinux()
Ejemplo n.º 30
0
def inLinux():
    return linux.inLinux()
Ejemplo n.º 31
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"
Ejemplo n.º 32
0
def emptyRuner():
    Linux.doPrint( "emptyRuner")
    return