Commit 6e06aefe authored by 邱阿朋's avatar 邱阿朋

refactor(build): 优化构建脚本并调整下载路径设置

- 移除 build 目录和 spec 文件的删除操作
- 修改 gui.py 和 main.py 中的下载路径设置,不再创建 downloads 目录
- 在 payment.py 和 return_goods.py 中添加文件保存完成的日志记录
- 优化 rabbitmq.py 中的连接初始化和关闭逻辑
- 修改 spa.py 中的文件保存日志记录位置
parent 982a5ce6
...@@ -16,7 +16,7 @@ class RabbitMQClient: ...@@ -16,7 +16,7 @@ class RabbitMQClient:
self.username = username self.username = username
self.password = password self.password = password
self.connection = None self.conn = None
self.channel = None self.channel = None
self.exchange = None self.exchange = None
...@@ -27,10 +27,10 @@ class RabbitMQClient: ...@@ -27,10 +27,10 @@ class RabbitMQClient:
"""初始化连接和通道""" """初始化连接和通道"""
try: try:
credentials = pika.PlainCredentials(self.username, self.password) credentials = pika.PlainCredentials(self.username, self.password)
self.connection = pika.BlockingConnection(pika.ConnectionParameters( self.conn = pika.BlockingConnection(pika.ConnectionParameters(
host=self.host, port=self.port, credentials=credentials host=self.host, port=self.port, credentials=credentials
)) ))
self.channel = self.connection.channel() self.channel = self.conn.channel()
print(f"Initialized connection to RabbitMQ at {self.host}.") print(f"Initialized connection to RabbitMQ at {self.host}.")
except Exception as e: except Exception as e:
print(f"Error initializing RabbitMQ connection: {e}") print(f"Error initializing RabbitMQ connection: {e}")
...@@ -111,6 +111,6 @@ class RabbitMQClient: ...@@ -111,6 +111,6 @@ class RabbitMQClient:
def close(self): def close(self):
"""关闭连接""" """关闭连接"""
if self.connection and not self.connection.is_closed: if self.conn and not self.conn.is_closed:
self.connection.close() self.conn.close()
print("Connection closed.") print("Connection closed.")
...@@ -391,6 +391,8 @@ class Payment(AutoInterface): ...@@ -391,6 +391,8 @@ class Payment(AutoInterface):
price_pay_summary = pd.concat(all_price_pay_data, ignore_index=True) price_pay_summary = pd.concat(all_price_pay_data, ignore_index=True)
excel.save_xls(price_pay_summary, new_file_name, "Price导出明细") excel.save_xls(price_pay_summary, new_file_name, "Price导出明细")
self.logger.info(f"文件 {new_file_name} 保存完成,路径:{os.path.abspath(new_file_name)}")
def push_data_queue(self): def push_data_queue(self):
rabbit.connection() rabbit.connection()
rabbit.connect(queue='refund_robot', routing_key='refund_robot', exchange='reports') rabbit.connect(queue='refund_robot', routing_key='refund_robot', exchange='reports')
......
...@@ -14,7 +14,7 @@ from app.vc.interface import AutoInterface ...@@ -14,7 +14,7 @@ from app.vc.interface import AutoInterface
class ReturnGoods(AutoInterface): class ReturnGoods(AutoInterface):
def __init__(self,logger: Logger, page: Page, country: str,shop_code: str): def __init__(self, logger: Logger, page: Page, country: str, shop_code: str):
self.logger = logger self.logger = logger
self.page = page self.page = page
self.country = country self.country = country
...@@ -76,7 +76,7 @@ class ReturnGoods(AutoInterface): ...@@ -76,7 +76,7 @@ class ReturnGoods(AutoInterface):
}) })
for _, item_row in item_data_result.iterrows(): for _, item_row in item_data_result.iterrows():
relation = relations_dict.get(item_row.get('ASIN')) relation = relations_dict.get(item_row.get('ASIN'), {})
erp_sku = relation.get('erp_sku', "") erp_sku = relation.get('erp_sku', "")
data_dict = data.to_dict() data_dict = data.to_dict()
data_dict.update({ data_dict.update({
...@@ -98,6 +98,8 @@ class ReturnGoods(AutoInterface): ...@@ -98,6 +98,8 @@ class ReturnGoods(AutoInterface):
excel.save_xls(new_list_data, self.result_file_name) excel.save_xls(new_list_data, self.result_file_name)
self.logger.info(f"文件 {self.result_file_name} 保存完成,路径:{os.path.abspath(self.result_file_name)}")
def push_data_queue(self): def push_data_queue(self):
rabbit.connection() rabbit.connection()
rabbit.connect(queue='return_robot', routing_key='return_robot', exchange='reports') rabbit.connect(queue='return_robot', routing_key='return_robot', exchange='reports')
...@@ -123,4 +125,4 @@ class ReturnGoods(AutoInterface): ...@@ -123,4 +125,4 @@ class ReturnGoods(AutoInterface):
# 推送数据 # 推送数据
rabbit.send_message(push_data) rabbit.send_message(push_data)
rabbit.close() rabbit.close()
\ No newline at end of file
...@@ -196,8 +196,6 @@ class Spa(AutoInterface): ...@@ -196,8 +196,6 @@ class Spa(AutoInterface):
# for sheet_name, data in large_sheet_data.items(): # for sheet_name, data in large_sheet_data.items():
# executor.submit(write_sheet, writer, data, sheet_name) # executor.submit(write_sheet, writer, data, sheet_name)
self.logger.info(f"文件 {new_file_name} 保存完成,路径:{os.path.abspath(new_file_name)}")
def push_data_queue(self): def push_data_queue(self):
rabbit.connection() rabbit.connection()
rabbit.connect(queue='spa_robot', routing_key='spa_robot', exchange='reports') rabbit.connect(queue='spa_robot', routing_key='spa_robot', exchange='reports')
...@@ -281,3 +279,5 @@ class Spa(AutoInterface): ...@@ -281,3 +279,5 @@ class Spa(AutoInterface):
# 保存数据到 Excel 文件 # 保存数据到 Excel 文件
self.__save_excel(sheet_data, large_sheet_data, self.result_file_name) self.__save_excel(sheet_data, large_sheet_data, self.result_file_name)
self.logger.info(f"文件 {self.result_file_name} 保存完成,路径:{os.path.abspath(self.result_file_name)}")
...@@ -2,5 +2,4 @@ pip.exe install -i https://mirrors.cloud.tencent.com/pypi/simple -r requirements ...@@ -2,5 +2,4 @@ pip.exe install -i https://mirrors.cloud.tencent.com/pypi/simple -r requirements
pyinstaller -F -n amazon_cmd.exe main.py pyinstaller -F -n amazon_cmd.exe main.py
pyinstaller -F -n amazon_gui.exe --noconsole gui.py pyinstaller -F -n amazon_gui.exe --noconsole gui.py
pyinstaller -F -n easy_gui.exe --noconsole easy.py pyinstaller -F -n easy_gui.exe --noconsole easy.py
rd /s /q build
del *.spec del *.spec
\ No newline at end of file
...@@ -213,8 +213,7 @@ class VCManagerGUI(ttk.Window): ...@@ -213,8 +213,7 @@ class VCManagerGUI(ttk.Window):
self.page = ChromiumPage() self.page = ChromiumPage()
self.page.set.load_mode.normal() self.page.set.load_mode.normal()
self.page.set.when_download_file_exists('overwrite') self.page.set.when_download_file_exists('overwrite')
download_path = os.path.join(os.getcwd(), "downloads") download_path = os.path.join(os.getcwd())
file.make_dir(download_path)
self.page.set.download_path(download_path) self.page.set.download_path(download_path)
self.log(f"下载目录设置为:{download_path}") self.log(f"下载目录设置为:{download_path}")
......
...@@ -18,8 +18,6 @@ if __name__ == '__main__': ...@@ -18,8 +18,6 @@ if __name__ == '__main__':
page.set.when_download_file_exists('overwrite') page.set.when_download_file_exists('overwrite')
# 下载目录 # 下载目录
download_path = os.getcwd() download_path = os.getcwd()
# 检查下载目录是否存在,如果不存在则创建
file.make_dir(download_path)
# 设置下载路径,确保在打开浏览器前设置 # 设置下载路径,确保在打开浏览器前设置
page.set.download_path(download_path) page.set.download_path(download_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 to comment