Accept Merge Request #1098: (feature/修复编程单下发ftp路径 -> develop)

Merge Request: 修复编程单下发ftp路径

Created By: @杨金灵
Reviewed By: @马广威
Approved By: @马广威 
Accepted By: @杨金灵
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1098?initial=true
This commit is contained in:
杨金灵
2024-06-26 11:24:40 +08:00
committed by Coding
2 changed files with 10 additions and 11 deletions

View File

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