def backupCurVol(): vol=cfgvol.upgmsg['curRunVol'] src=rbcfg.apppath ptar=dfile.joinPath(cfgvol.upg['workpath']['pworkex'], vol) dfile.copyDirToDir(src, ptar, umode.bckdirmode, umode.bckfilemode) bcktar=dfile.joinPath(cfgvol.upg['workpath']['pback'], vol+umode.filefix["backup"]) dfile.tarADir(bcktar, ptar, "RemoteBox") # dfile.tarADir(bcktar, ptar, vol) dfile.delete_file_folder(ptar) return
def onPath(curpath): if(curpath is None ):curpath= os.getcwd() rbcfg.apppath=dfile.joinPath(curpath, rbcfg.apppath) rbcfg.basepath=dfile.joinPath(curpath, rbcfg.basepath) rbcfg.webroot=dfile.joinPath(rbcfg.basepath,rbcfg.webroot) rbcfg.cfgpath=dfile.joinPath(rbcfg.basepath,rbcfg.cfgpath) #after 0.8.7 cfgvol.onWorkPath(curpath) return
def onPath(curpath): if (curpath is None): curpath = os.getcwd() rbcfg.apppath = dfile.joinPath(curpath, rbcfg.apppath) rbcfg.basepath = dfile.joinPath(curpath, rbcfg.basepath) rbcfg.webroot = dfile.joinPath(rbcfg.basepath, rbcfg.webroot) rbcfg.cfgpath = dfile.joinPath(rbcfg.basepath, rbcfg.cfgpath) #after 0.8.7 cfgvol.onWorkPath(curpath) return
def backupCurVol(): vol = cfgvol.upgmsg['curRunVol'] src = rbcfg.apppath ptar = dfile.joinPath(cfgvol.upg['workpath']['pworkex'], vol) dfile.copyDirToDir(src, ptar, umode.bckdirmode, umode.bckfilemode) bcktar = dfile.joinPath(cfgvol.upg['workpath']['pback'], vol + umode.filefix["backup"]) dfile.tarADir(bcktar, ptar, "RemoteBox") # dfile.tarADir(bcktar, ptar, vol) dfile.delete_file_folder(ptar) return
def _mkNames(self): self._ffn= getWFFileName(self._filen) self._fpfn=dfile.joinPath(self._path, self._ffn) self._rfn= getRFileName(self._filen) self._rpfn= dfile.joinPath(self._path, self._rfn) self._dfn= getRDFileName(self._filen) self._dpfn=dfile.joinPath(self._path, self._dfn) self._zip= getZipFileName(self._filen) self._pzip=dfile.joinPath(self._path, self._zip) return
def _mkNames(self): self._ffn = getWFFileName(self._filen) self._fpfn = dfile.joinPath(self._path, self._ffn) self._rfn = getRFileName(self._filen) self._rpfn = dfile.joinPath(self._path, self._rfn) self._dfn = getRDFileName(self._filen) self._dpfn = dfile.joinPath(self._path, self._dfn) self._zip = getZipFileName(self._filen) self._pzip = dfile.joinPath(self._path, self._zip) return
def ftpDowns(self,oftp,ftpdir,wkpath,funW,funF): if(oftp is None or funW is None or funF is None):return bn=dirf.joinPath(wkpath, ftpdir) ftpfs=[] try: ftpfs=oftp.nlst() except: wlog.doTraceBack() raise errs.RbFtpErr("error get ftp files") for ftpf in ftpfs: if(ftpw.ignorFile(ftpf) or ftpw.existFile(ftpf,wkpath)):continue localW=funW(bn) localF=funF(bn) try: ##wlog.getLogger().debug("from ftp:"+ftpf) ftpw.downFile(oftp,ftpf,localW) ##wlog.getLogger().debug("ftp ok:"+localW) except: wlog.doTraceBack() continue try: ftpw.delFile(oftp,ftpf) except: wlog.doTraceBack() continue dirf.fileRename(localW, localF) return
def ftpDowns(oftp,ftpdir,wkpath,funW,funF): if(oftp is None or funW is None or funF is None):return bn=dirfile.joinPath(wkpath, ftpdir) for ftpf in oftp.nlst(): if(ignorFile(ftpf) or existFile(ftpf,wkpath)):continue localW=funW(bn) localF=funF(bn) try: downFile(oftp,ftpf,localW) except: wlog.doTraceBack() continue try: delFile(oftp,ftpf) except: wlog.doTraceBack() continue dirfile.fileRename(localW, localF) return
def onStart(): wrkCtrl.onPath(curpath) rbcfg.RUNMSG["COMM"] = "STOP" rbcfg.WEB["tpls"] = webroot rbcfg.WEB["tplsA"] = dfile.joinPath(webroot, "WEB-INF") wlog.getLogger().debug(webroot) cfgdb.onCfg() #cfgdb.freshConfByDB() app = webRun() session = tweb.session.Session(app, tweb.session.DiskStore('sessions'), initializer={'count': 0}) import rbsite.CmdRender as CmdRender refs4tpl = { 'context': session, "vtypeof": type, "cmdsRender": CmdRender.cmdsRender1 } render = tweb.template.render(rbcfg.WEB["tpls"], globals=refs4tpl) renderA = tweb.template.render(rbcfg.WEB["tplsA"], globals=refs4tpl) rbcfg.WEB["render"] = render rbcfg.WEB["renderA"] = renderA rbcfg.WEB["app"] = app rbsite.RBSite.regPageCtx4Tpls() return
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 getTarFile(): vol = cfgvol.getCurDown() if (vol is None): return None return dfile.joinPath(cfgvol.upg['workpath']['pctar'], vol + umode.filefix["down"]) # todo chk tardir,
def __init__(self, basepath, imptype=None, detaSec=datetime.timedelta(seconds=30), delaySec=0): self._basepath = basepath self._imptype = imptype self._wkpth = basepath if (not (imptype is None)): if (imptype in rbcfg.IMPLEMENTS): refp = rbcfg.IMPLEMENTS[imptype]["PATH"] self._wkpth = dfile.joinPath(self._wkpth, refp) self._can = True self._started = False self._stoped = False self._posted = False self._last = None # datetime.datetime.now() self._now = None self._dtdelta = detaSec self._timer = None if (type(basepath) == type('')): self._timer = threading.Timer(delaySec, self._exe) return
def getCurs(): ret=[] base=cfgvol.upg['workpath']['pctar'] cfgvol.upgmsg['downloads'].sort() for r in cfgvol.upgmsg['downloads']: ret.append(dfile.joinPath(base, r+umode.filefix["down"])) return ret
def getCurs(): ret = [] base = cfgvol.upg['workpath']['pctar'] cfgvol.upgmsg['downloads'].sort() for r in cfgvol.upgmsg['downloads']: ret.append(dfile.joinPath(base, r + umode.filefix["down"])) return ret
def fullCurTarDirFile(): base=cfgvol.upg['workpath']['pworkex'] vol=cfgvol.getLastOKVol() if(vol is None): return [None,None] dir=dfile.joinPath(base, vol) file=dir+umode.filefix["cdown"] return [dir,file]
def fullCurTarDirFile(): base = cfgvol.upg['workpath']['pworkex'] vol = cfgvol.getLastOKVol() if (vol is None): return [None, None] dir = dfile.joinPath(base, vol) file = dir + umode.filefix["cdown"] return [dir, file]
def buildLogFile(ldir, logFN): if (type(logFN) == type(ldir)): lf = dfile.joinPath(ldir, logFN) fileh = open(lf, 'a') fileh.close() return lf return None
def afterCommCfgCtx(*arg, **karg): ctx = karg['ctx'] pg = arg[0] ctx["action"] = dfile.joinPath('/A/', pg) if ("pri" in ctx): pg = ctx["tpl"] return pg, [ctx], {}
def afterCommCfgCtx(* arg,** karg): ctx=karg['ctx'] pg=arg[0] ctx["action"]=dfile.joinPath('/A/', pg) if("pri" in ctx): pg=ctx["tpl"] return pg,[ctx],{}
def onWorkPath(bpath): #rbcfg.cfgpath=dfile.joinPath(rbcfg.basepath,rbcfg.cfgpath) def isSPath(pp): return type(pp) == type('') and pp.startswith('upg/') for pp in upg['workpath']: if (isSPath(upg['workpath'][pp])): upg['workpath'][pp] = dfile.joinPath(bpath, upg['workpath'][pp]) dfile.chkCreateDir(upg['workpath'][pp]) return
def getExCurs(): ret=[] base=cfgvol.upg['workpath']['ptestex'] cfgvol.upgmsg['downloads'].sort() for r in cfgvol.upgmsg['downloads']: exdir=dfile.joinPath(base, r) if(os.path.exists(exdir)): ret.append(exdir) return ret
def getExCurs(): ret = [] base = cfgvol.upg['workpath']['ptestex'] cfgvol.upgmsg['downloads'].sort() for r in cfgvol.upgmsg['downloads']: exdir = dfile.joinPath(base, r) if (os.path.exists(exdir)): ret.append(exdir) return ret
def onStart(): wrkCtrl.onPath(curpath) rbcfg.RUNMSG["COMM"] = "STOP" rbcfg.WEB["tpls"] = webroot rbcfg.WEB["tplsA"] = dfile.joinPath(webroot, "WEB-INF") cfgdb.onCfg() return
def exe(self): wkpath=dirf.joinPath(self._bpath, conff.IMPLEMENTS[self._implType]["PATH"]) dirf.delFile(wkpath, "*"+BaseAction.fileSuffs[4]) self._exe4Path(wkpath, "*"+BaseAction.fileSuffs[2]) self._exe4Path(wkpath, "*"+BaseAction.fileSuffs[1]) ''' for v in glob.glob1(wkpath,"*"+BaseAction.fileSuffs[2]): self._doexe(wkpath,v) if flc=1 for v in glob.glob1(wkpath,"*"+BaseAction.fileSuffs[1]): self._doexe(wkpath,v) ''' return
def __init__(self,basepath,imptype=None,detaSec=datetime.timedelta(seconds=30),delaySec=0): self._basepath=basepath self._imptype=imptype self._wkpth=basepath if(not (imptype is None) ): if(imptype in rbcfg.IMPLEMENTS): refp=rbcfg.IMPLEMENTS[imptype]["PATH"] self._wkpth=dfile.joinPath(self._wkpth, refp) self._can=True self._started=False self._stoped=False self._posted=False self._last=None # datetime.datetime.now() self._now=None self._dtdelta=detaSec self._timer=None if(type(basepath)==type('')): self._timer=threading.Timer(delaySec,self._exe) return
def _initObjs(self): a=None if("file" in self._wkarg): a=self._wkarg["file"] if(a is None): self._wkarg["file"]=self._tbn if("delWhere" not in self._wkarg): self._wkarg["delWhere"] =None if(self._imp is None) : self._imp=self._wkarg["ctrlc"] self._wkpath=dirf.joinPath(self._basepath, conff.IMPLEMENTS[self._imp]["PATH"]) fs=self.getCtrlDef() #rbdatabase.Pojos.ctrlDef[self._wkarg["ctrlc"]] # fs=rbdatabase.Pojos.ctrlDef[self._imp] self._ctrl=fs["ctrl"](self._dbw,self._tbn,self._wkarg["dtfield"]) #todo self._pjCaptrue=fs["pjcap"](self._tbn,PAGESIZE=conff.db["PAGESIZE"],** self._wkarg) #todo fs["pjcap"](self._tbn,** self._wkarg) self._lstParse=fs["lstp"](self._wkarg["file"],self._wkarg["fieldsdef"])#todo self._wFile=fs["wfile"]()#todo return
def getUserDBF(): return dfile.joinPath(chkcfgPath(conff.cfgpath), dbuser)
def getCommCfg(): return dfile.joinPath(chkcfgPath(conff.cfgpath), conff.commcfg)
def getCfgDBF(): return dfile.joinPath(chkcfgPath(conff.cfgpath), dbf)
def getRbBckModPath(basep,mod="RemoteBox"): return dfile.joinPath(basep, mod)
def getPathInCtx(): #'PATH_INFO' environ = weba.ctx.environ path = dfile.joinPath(rbcfg.WEB["tpls"], environ['PATH_INFO']) return path
def getPathInCtx():#'PATH_INFO' environ= weba.ctx.environ path= dfile.joinPath(rbcfg.WEB["tpls"], environ['PATH_INFO'] ) return path
def getRbBckModPath(basep, mod="RemoteBox"): return dfile.joinPath(basep, mod)
def getVolDBF(): return dfile.joinPath(cfgdb.chkcfgPath(conff.cfgpath), cfgvolu)