合并工单优化

This commit is contained in:
gqh
2023-01-11 11:13:52 +08:00
parent 01cf30b03f
commit eb162cb416
17 changed files with 350 additions and 386 deletions

View File

@@ -15,31 +15,26 @@ class FtpController():
ftp = FTP()
def __init__(self, host, port, username, password):
def __init__(self, host="192.168.50.202", port=21, username="ftpuser", password="123456"):
try:
self.ftp.connect(host, port)
self.ftp.login(username, password)
logging.info("ftp连接成功")
logging.info("连接成功: ")
except:
logging.info("ftp连接失败")
return False
logging.info("连接失败: ")
# 下载目录下的文件
def download_file_tree(self, target_dir, serverdir):
if not os.path.exists(serverdir):
os.makedirs(serverdir)
try:
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(".") != -1:
self.download_file(server, file)
except:
return False
else:
return
# 下载指定目录下的指定文件
def download_file(self, serverfile, remotefile):