From 80e3c8d9a7e10ec19df38a8dc8423293135b94e5 Mon Sep 17 00:00:00 2001 From: yoshiko2 Date: Fri, 10 Dec 2021 13:24:53 +0800 Subject: [PATCH] Add read ```config.ini``` error output message --- config.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index d06b392..2f41c4c 100644 --- a/config.py +++ b/config.py @@ -2,6 +2,7 @@ import os import re import sys import configparser +import time from pathlib import Path @@ -47,10 +48,18 @@ class Config: if self.conf.read(ini_path, encoding="utf-8-sig"): if G_conf_override[0] is None: G_conf_override[0] = self - except: + except UnicodeDecodeError: if self.conf.read(ini_path, encoding="utf-8"): if G_conf_override[0] is None: G_conf_override[0] = self + except Exception as e: + print("ERROR: Config file can not read!") + print("读取配置文件出错!") + print('=================================') + print(e) + print("======= Auto exit in 60s ======== ") + time.sleep(60) + os._exit(-1) else: print("ERROR: Config file not found!") print("Please put config file into one of the following path:")