Commit 84ef6a18 authored by 宋朋's avatar 宋朋

update

parent 47a5a1b2
...@@ -52,89 +52,89 @@ class MyFTP: ...@@ -52,89 +52,89 @@ class MyFTP:
self.deal_error("FTP 连接或登录失败 ,错误信息为:%s" % err) self.deal_error("FTP 连接或登录失败 ,错误信息为:%s" % err)
pass pass
# def is_same_size(self, local_file, remote_file): def is_same_size(self, local_file, remote_file):
# """判断远程文件和本地文件大小是否一致 """判断远程文件和本地文件大小是否一致
# 参数: 参数:
# local_file: 本地文件 local_file: 本地文件
# remote_file: 远程文件 remote_file: 远程文件
# """ """
# try: try:
# remote_file_size = self.ftp.size(remote_file) remote_file_size = self.ftp.size(remote_file)
# except Exception as err: except Exception as err:
#
# remote_file_size = -1 remote_file_size = -1
#
# try: try:
# local_file_size = os.path.getsize(local_file) local_file_size = os.path.getsize(local_file)
# except Exception as err: except Exception as err:
# local_file_size = -1 local_file_size = -1
#
# self.debug_print('local_file_size:%d , remote_file_size:%d' % (local_file_size, remote_file_size)) self.debug_print('local_file_size:%d , remote_file_size:%d' % (local_file_size, remote_file_size))
# if remote_file_size == local_file_size: if remote_file_size == local_file_size:
# return 1 return 1
# else: else:
# return 0 return 0
# def download_file(self, local_file, remote_file): def download_file(self, local_file, remote_file):
# """从ftp下载文件 """从ftp下载文件
# 参数: 参数:
# local_file: 本地文件 local_file: 本地文件
# remote_file: 远程文件 remote_file: 远程文件
# """ """
# self.debug_print("download_file()---> local_path = %s ,remote_path = %s" % (local_file, remote_file)) self.debug_print("download_file()---> local_path = %s ,remote_path = %s" % (local_file, remote_file))
#
# if self.is_same_size(local_file, remote_file): if self.is_same_size(local_file, remote_file):
# self.debug_print('%s 文件大小相同,无需下载' % local_file) self.debug_print('%s 文件大小相同,无需下载' % local_file)
# return return
# else: else:
# try: try:
# self.debug_print('>>>>>>>>>>>>下载文件 %s ... ...' % local_file) self.debug_print('>>>>>>>>>>>>下载文件 %s ... ...' % local_file)
# buf_size = 1024 buf_size = 1024
# file_handler = open(local_file, 'wb') file_handler = open(local_file, 'wb')
# self.ftp.retrbinary('RETR %s' % remote_file, file_handler.write, buf_size) self.ftp.retrbinary('RETR %s' % remote_file, file_handler.write, buf_size)
# file_handler.close() file_handler.close()
# except Exception as err: except Exception as err:
# self.debug_print('下载文件出错,出现异常:%s ' % err) self.debug_print('下载文件出错,出现异常:%s ' % err)
# return return
# def download_file_tree(self, local_path, remote_path): def download_file_tree(self, local_path, remote_path):
# """从远程目录下载多个文件到本地目录 """从远程目录下载多个文件到本地目录
# 参数: 参数:
# local_path: 本地路径 local_path: 本地路径
# remote_path: 远程路径 remote_path: 远程路径
# """ """
# print("download_file_tree()---> local_path = %s ,remote_path = %s" % (local_path, remote_path)) print("download_file_tree()---> local_path = %s ,remote_path = %s" % (local_path, remote_path))
# try: try:
# self.ftp.cwd(remote_path) self.ftp.cwd(remote_path)
# except Exception as err: except Exception as err:
# self.debug_print('远程目录%s不存在,继续...' % remote_path + " ,具体错误描述为:%s" % err) self.debug_print('远程目录%s不存在,继续...' % remote_path + " ,具体错误描述为:%s" % err)
# return return
#
# if not os.path.isdir(local_path): if not os.path.isdir(local_path):
# self.debug_print('本地目录%s不存在,先创建本地目录' % local_path) self.debug_print('本地目录%s不存在,先创建本地目录' % local_path)
# os.makedirs(local_path) os.makedirs(local_path)
#
# self.debug_print('切换至目录: %s' % self.ftp.pwd()) self.debug_print('切换至目录: %s' % self.ftp.pwd())
#
# self.file_list = [] self.file_list = []
# # 方法回调 # 方法回调
# self.ftp.dir(self.get_file_list) self.ftp.dir(self.get_file_list)
#
# remote_names = self.file_list remote_names = self.file_list
# self.debug_print('远程目录 列表: %s' % remote_names) self.debug_print('远程目录 列表: %s' % remote_names)
# for item in remote_names: for item in remote_names:
# file_type = item[0] file_type = item[0]
# file_name = item[1] file_name = item[1]
# local = os.path.join(local_path, file_name) local = os.path.join(local_path, file_name)
# if file_type == 'd': if file_type == 'd':
# print("download_file_tree()---> 下载目录: %s" % file_name) print("download_file_tree()---> 下载目录: %s" % file_name)
# self.download_file_tree(local, file_name) self.download_file_tree(local, file_name)
# elif file_type == '-': elif file_type == '-':
# print("download_file()---> 下载文件: %s" % file_name) print("download_file()---> 下载文件: %s" % file_name)
# self.download_file(local, file_name) self.download_file(local, file_name)
# self.ftp.cwd("..") self.ftp.cwd("..")
# self.debug_print('返回上层目录 %s' % self.ftp.pwd()) self.debug_print('返回上层目录 %s' % self.ftp.pwd())
# return True return True
def upload_file(self, local_file, remote_file): def upload_file(self, local_file, remote_file):
"""从本地上传文件到ftp """从本地上传文件到ftp
......
...@@ -8,7 +8,7 @@ import pandas as pd ...@@ -8,7 +8,7 @@ import pandas as pd
import numpy as np import numpy as np
import re import re
from wanjia_tuomin.micko import modifyStatus, constants, DbUtils from wanjia_tuomin.data_process import modifyStatus, constants, DbUtils
import time import time
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment