修复 log 文件不会自动创建

This commit is contained in:
Jalin
2019-01-16 13:17:06 +08:00
parent 682613ca31
commit 0524f5fc27
3 changed files with 6 additions and 1 deletions

View File

@@ -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):

View File

@@ -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]

View File

@@ -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 = '从免费打码获取结果失败'