Commit 0e4f556d by larosa

add exception handle

parent b4df46bb
Showing with 12 additions and 11 deletions
......@@ -216,19 +216,20 @@ if __name__ == '__main__':
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_3, extract_dir)
"""handle the file and then post to rabbitmq"""
rs_hk_supplier_id = get_supplier_id(supplier_name='Rs', conf=conf_environment)
rs_cn_supplier_id = get_supplier_id(supplier_name='RS-CN', conf=conf_environment)
if rs_cn_supplier_id == -1 or rs_hk_supplier_id == -1:
sys.exit("can't query the correct supplier id.")
handle_hk_csv(extract_dir + handle_file_name_1, conf_environment, rs_hk_supplier_id)
handle_cn_csv(extract_dir + handle_file_name_3, conf_environment, rs_cn_supplier_id)
try:
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_3, extract_dir)
"""handle the file and then post to rabbitmq"""
rs_hk_supplier_id = get_supplier_id(supplier_name='Rs', conf=conf_environment)
rs_cn_supplier_id = get_supplier_id(supplier_name='RS-CN', conf=conf_environment)
if rs_cn_supplier_id == -1 or rs_hk_supplier_id == -1:
sys.exit("can't query the correct supplier id.")
handle_hk_csv(extract_dir + handle_file_name_1, conf_environment, rs_hk_supplier_id)
handle_cn_csv(extract_dir + handle_file_name_3, conf_environment, rs_cn_supplier_id)
except Exception as e:
print(e)
"""remove the temp file, close the connection"""
remove(extract_dir + handle_file_name_1)
remove(extract_dir + handle_file_name_3)
......
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