Commit 479e5c0c by 岳巧源

init

parents
File mode changed
from utils.file_handle import unzip
if __name__ == '__main__':
unzip('rs_components_cn_chiplink.csv.zip', './')
\ No newline at end of file
File mode changed
import zipfile
def unzip(zip_path, save_path):
"""
unzip the file like *.zip
save_path means the directory where you want to save the unzip file.
"""
f = zipfile.ZipFile(zip_path)
print('start unzip the file...')
f.extractall(save_path)
print('the unzipping process is over...')
f.close()
import ftplib
class FTPUtil:
def __init__(
self,
*,
host="localhost",
port=21,
passive=True,
username="",
password=""):
ftp = ftplib.FTP()
ftp.connect(host, port)
ftp.login(username, password)
ftp.set_pasv(passive)
self.ftp = ftp
def get_connection(self):
return self.ftp
def download(self, remote_path, local_path):
"""
remote_path means the remote file name
and local_path is the local file name.
"""
with open(local_path, 'wb') as fp:
self.ftp.retrbinary('RETR ' + remote_path, fp.write)
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 sign in to comment