1.ftp文件路径修改为:/NC/以下

This commit is contained in:
jinling.yang
2024-04-16 16:22:26 +08:00
parent cc7a72d6f4
commit d777970a9b
10 changed files with 103 additions and 33 deletions

View File

@@ -27,8 +27,16 @@ class FtpController():
os.makedirs(serverdir)
try:
logging.info("进入FTP目录 ")
self.ftp.cwd(target_dir) # 切换工作路径
logging.info('FTP目录:%s' % target_dir)
logging.info('目录:%s' % target_dir)
target_dir1 = target_dir.split('/')
logging.info('目录1:%s' % target_dir1[1])
self.ftp.cwd(target_dir1[1]) # 切换工作路径
logging.info('目录2:%s' % target_dir1[2])
self.ftp.cwd(target_dir1[2]) # 切换工作路径
logging.info('目录3:%s' % target_dir1[3])
self.ftp.cwd(target_dir1[3]) # 切换工作路径
logging.info('目录4:%s' % target_dir1[4])
self.ftp.cwd(target_dir1[4]) # 切换工作路径
remotenames = self.ftp.nlst()
logging.info('FTP目录文件:%s' % remotenames)
for file in remotenames:
@@ -38,6 +46,9 @@ class FtpController():
return 1
except Exception:
return 0
finally:
self.ftp.quit()
logging.info("ftp已关闭")
# 下载目录下的检测文件
def download_reportfile_tree(self, target_dir, serverdir, reportpath):
@@ -51,6 +62,8 @@ class FtpController():
self.ftp.cwd(target_dir1[1]) # 切换工作路径
logging.info('目录2:%s' % target_dir1[2])
self.ftp.cwd(target_dir1[2]) # 切换工作路径
logging.info('目录2:%s' % target_dir1[3])
self.ftp.cwd(target_dir1[3]) # 切换工作路径
remotenames = self.ftp.nlst()
logging.info('FTP目录检测报告文件:%s' % remotenames)
for filename in remotenames: