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 exe(self): if(self._ftpdir is None or self._wkpath is None):return oftp=None back=False try: oftp=ftpw.FTPPool.pop(self._imptype) ##wlog.getLogger().debug("do ftp:"+self._ftpdir) oftp.cwd(self._ftpdir) self.ftpDowns(oftp, self._ftpdir, self._wkpath, BaseAction.getWFileName, BaseAction.getWFFileName) return except: wlog.doTraceBack() back=True raise errs.RbFtpErr("error work for ftp") finally: ftpw.FTPPool.back(oftp, self._imptype, back) oftp=None