From 0524f5fc27c50b24052e87f9058cbceef36ed69c Mon Sep 17 00:00:00 2001 From: Jalin Date: Wed, 16 Jan 2019 13:17:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20log=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8D=E4=BC=9A=E8=87=AA=E5=8A=A8=E5=88=9B=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- py12306/app.py | 1 + py12306/helpers/func.py | 4 ++++ py12306/log/common_log.py | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/py12306/app.py b/py12306/app.py index e0f720c..d5fd25b 100644 --- a/py12306/app.py +++ b/py12306/app.py @@ -97,6 +97,7 @@ class App: def check_data_dir_exists(): os.makedirs(Config().QUERY_DATA_DIR, exist_ok=True) os.makedirs(Config().USER_DATA_DIR, exist_ok=True) + touch_file(Config().OUT_PUT_LOG_TO_FILE_PATH) @classmethod def test_send_notifications(cls): diff --git a/py12306/helpers/func.py b/py12306/helpers/func.py index 0c8b648..b6f7196 100644 --- a/py12306/helpers/func.py +++ b/py12306/helpers/func.py @@ -105,6 +105,10 @@ def get_file_total_line_num(file, encoding='utf-8'): return len(f.readlines()) +def touch_file(path): + with open(path, 'a'): pass + + def pick_file_lines(file, lines): return [x for i, x in enumerate(file) if i in lines] diff --git a/py12306/log/common_log.py b/py12306/log/common_log.py index 9b6f3ce..6e65962 100644 --- a/py12306/log/common_log.py +++ b/py12306/log/common_log.py @@ -43,7 +43,7 @@ class CommonLog(BaseLog): MESSAGE_SEND_PUSH_BEAR_SUCCESS = '发送成功,请检查微信' MESSAGE_SEND_PUSH_BEAR_FAIL = 'PushBear发送失败,请检查KEY' - MESSAGE_OUTPUT_TO_FILE_IS_UN_ENABLE = '请先打开配置:输出到文件' + MESSAGE_OUTPUT_TO_FILE_IS_UN_ENABLE = '请先打开配置项中的:OUT_PUT_LOG_TO_FILE_ENABLED ( 输出到文件 )' MESSAGE_GET_RESPONSE_FROM_FREE_AUTO_CODE = '从免费打码获取结果失败'