Commit f7fd1d21 by 岳巧源

handle the file

parent c1b5117f
Showing with 60 additions and 8 deletions
......@@ -4,12 +4,9 @@ parse the various supplier data.
In order to avoid coupling with other projects, this project is separated
# Install
dev
# Run
$ python XXX.py [local|dev|prod]
$ pip3 install -r requirements_dev.txt
xxx.py means different supplier
prod
$ pip3 install -r reuirements_prod.txt
import json
def load_config() -> dict:
def load_config_map() -> dict:
with open('config.json', 'r', encoding='UTF-8') as f:
return json.load(f)
import os.path
import sys
import config
from utils import ftp
from utils import file_handle
remote_file_name_1 = "/rs_components_HK-cn_chiplink.csv.zip"
remote_file_name_2 = "/rs_components_HK-en_chiplink.csv.zip"
remote_file_name_3 = "/rs_components_cn_chiplink.csv.zip"
local_file_name_1 = "rs_components_HK-cn_chiplink.csv.zip"
local_file_name_2 = "rs_components_HK-en_chiplink.csv.zip"
local_file_name_3 = "rs_components_cn_chiplink.csv.zip"
conf = config.load_config_map()
def handle_csv():
pass
if __name__ == '__main__':
conf = config.load_config()
environment = sys.argv[1]
if environment not in {"local", "dev", "prod"}:
sys.exit("param error!")
conf_environment = conf[environment]
ftp_client = ftp.FTPUtil(host=conf_environment["ftp"]["host"],
port=conf_environment["ftp"]["port"],
passive=True,
username=conf_environment["ftp"]["username"],
password=conf_environment["ftp"]["password"]
)
"""download the zip file"""
# ftp_client.download(remote_file_name_1, conf_environment["tmp_file_path"] + local_file_name_1)
# ftp_client.download(remote_file_name_2, conf_environment["tmp_file_path"] + local_file_name_2)
# ftp_client.download(remote_file_name_3, conf_environment["tmp_file_path"] + local_file_name_3)
extract_dir = conf_environment["tmp_file_path"] + "extract/"
if not os.path.exists(extract_dir):
os.makedirs(extract_dir)
"""unzip the zip file"""
# file_handle.unzip(conf_environment["tmp_file_path"] + local_file_name_1, extract_dir)
# file_handle.unzip(conf_environment["tmp_file_path"] + local_file_name_2, extract_dir)
# file_handle.unzip(conf_environment["tmp_file_path"] + local_file_name_3, extract_dir)
"""handle the file and then post to rabbitmq"""
"""remove the temp file, close the connection"""
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