From cbe19ea6066a600cbd0b5110db5d43f8252d14a8 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期四, 13 六月 2024 11:23:53 +0800 Subject: [PATCH] L撤成交进度相关改进 --- log_module/log_export.py | 34 ++++++++++++++++++---------------- 1 files changed, 18 insertions(+), 16 deletions(-) diff --git a/log_module/log_export.py b/log_module/log_export.py index 08e7b6d..2696945 100644 --- a/log_module/log_export.py +++ b/log_module/log_export.py @@ -123,22 +123,24 @@ if not date: date = datetime.datetime.now().strftime("%Y-%m-%d") pos_list = [] - with open("{}/logs/gp/l2/l2_process.{}.log".format(constant.get_path_prefix(), date), mode='r', - encoding="utf-8") as f: - while True: - line = f.readline() - if not line: - break - if line.find("code:{}".format(code)) < 0: - continue - time_ = __get_log_time(line) - line = line[line.find("澶勭悊鏁版嵁鑼冨洿") + len("澶勭悊鏁版嵁鑼冨洿") + 1:line.find("澶勭悊鏃堕棿")].strip() - if len(pos_list) == 0 or pos_list[-1][1] < int(line.split("-")[0]): - if int("093000") <= int(time_.replace(":", "")) <= int("150000"): - try: - pos_list.append((int(line.split("-")[0]), int(line.split("-")[1]))) - except Exception as e: - logging.exception(e) + path_ = "{}/logs/gp/l2/l2_process.{}.log".format(constant.get_path_prefix(), date) + if os.path.exists(path_): + with open(path_, mode='r', + encoding="utf-8") as f: + while True: + line = f.readline() + if not line: + break + if line.find("code:{}".format(code)) < 0: + continue + time_ = __get_log_time(line) + line = line[line.find("澶勭悊鏁版嵁鑼冨洿") + len("澶勭悊鏁版嵁鑼冨洿") + 1:line.find("澶勭悊鏃堕棿")].strip() + if len(pos_list) == 0 or pos_list[-1][1] < int(line.split("-")[0]): + if int("093000") <= int(time_.replace(":", "")) <= int("150000"): + try: + pos_list.append((int(line.split("-")[0]), int(line.split("-")[1]))) + except Exception as e: + logging.exception(e) return pos_list -- Gitblit v1.8.0