修复编程单下发ftp路径
This commit is contained in:
@@ -32,11 +32,11 @@ class FtpController():
|
|||||||
for directory in directories:
|
for directory in directories:
|
||||||
if directory:
|
if directory:
|
||||||
# 检查目录是否存在
|
# 检查目录是否存在
|
||||||
if directory in ['NC']:
|
if (directory in ['NC']) or (directory not in ['home', 'ftp', 'ftp_root', 'NC']):
|
||||||
self.ftp.cwd(directory)
|
self.ftp.cwd(directory)
|
||||||
if directory not in ['home', 'ftp', 'ftp_root', 'NC']:
|
if directory not in ['home', 'ftp', 'ftp_root', 'NC']:
|
||||||
# 切换到新的目录
|
# 切换到新的目录
|
||||||
self.ftp.cwd(current_dir)
|
self.ftp.cwd(directory)
|
||||||
return os.path.basename(path)
|
return os.path.basename(path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error checking file: {e}")
|
logging.error(f"Error checking file: {e}")
|
||||||
@@ -60,14 +60,13 @@ class FtpController():
|
|||||||
try:
|
try:
|
||||||
logging.info('FTP目录:%s' % target_dir)
|
logging.info('FTP目录:%s' % target_dir)
|
||||||
logging.info("进入FTP目录 ")
|
logging.info("进入FTP目录 ")
|
||||||
# self.ftp.cwd(target_dir) # 切换工作路径
|
|
||||||
# logging.info('FTP目录:%s' % target_dir)
|
|
||||||
remotenames = self.ftp.nlst()
|
remotenames = self.ftp.nlst()
|
||||||
logging.info('FTP目录文件:%s' % remotenames)
|
logging.info('FTP目录文件:%s' % remotenames)
|
||||||
for file in remotenames:
|
for file in remotenames:
|
||||||
server = os.path.join(serverdir, file)
|
server = os.path.join(serverdir, file)
|
||||||
if file.find(".pdf") != -1:
|
if file.find(".pdf") != -1:
|
||||||
self.download_file(server, file)
|
self.download_file(server, file)
|
||||||
|
return True
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user