Commit 9867575e by 岳巧源

modify script

parent 63ec1cee
Showing with 4 additions and 1 deletions
...@@ -99,21 +99,24 @@ def resolve(file_name: str, supplier_id: int): ...@@ -99,21 +99,24 @@ def resolve(file_name: str, supplier_id: int):
table["ladder_price"].append(item_map) table["ladder_price"].append(item_map)
ans = json.dumps(table, ensure_ascii=False) ans = json.dumps(table, ensure_ascii=False)
producer.push(ans) producer.push(ans)
os.remove(file_name)
producer.close() producer.close()
def process(url: str, supplier_id: int): def process(url: str, supplier_id: int):
# http://erp.liexindev.net/sku/20240823/p6jMKaPtjMpNnZMK5vEX3KEQf7Gdvgvw3TCA7d6b.xls # http://erp.liexindev.net/sku/20240823/p6jMKaPtjMpNnZMK5vEX3KEQf7Gdvgvw3TCA7d6b.xls
abs_path = ""
try: try:
response = requests.get(url) response = requests.get(url)
if response.status_code == 200: if response.status_code == 200:
tmp_file = url.split(sep="/")[-1] tmp_file = url.split(sep="/")[-1]
absolute_path = config.tmp_xls_file_dir + tmp_file absolute_path = config.tmp_xls_file_dir + tmp_file
abs_path = absolute_path
with open(absolute_path, "wb") as f: with open(absolute_path, "wb") as f:
f.write(response.content) f.write(response.content)
resolve(absolute_path, supplier_id) resolve(absolute_path, supplier_id)
except Exception as e: except Exception as e:
print(e) print(e)
finally:
os.remove(abs_path)
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