diff options
author | Kyomotoi <[email protected]> | 2022-06-18 00:22:37 +0800 |
---|---|---|
committer | Kyomotoi <[email protected]> | 2022-06-18 00:22:37 +0800 |
commit | f6b5e9aec639fe279c5c5ab70f5c4e534ddc3b45 (patch) | |
tree | cd7fe7aaf0518c221dec474127f72233553a2780 /ATRI/plugins/console/driver | |
parent | 48ccaabf66828594051de919c9b52098debf95a3 (diff) | |
download | ATRI-f6b5e9aec639fe279c5c5ab70f5c4e534ddc3b45.tar.gz ATRI-f6b5e9aec639fe279c5c5ab70f5c4e534ddc3b45.tar.bz2 ATRI-f6b5e9aec639fe279c5c5ab70f5c4e534ddc3b45.zip |
💩 优化代码
Diffstat (limited to 'ATRI/plugins/console/driver')
-rw-r--r-- | ATRI/plugins/console/driver/api.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ATRI/plugins/console/driver/api.py b/ATRI/plugins/console/driver/api.py index d83f98b..452d063 100644 --- a/ATRI/plugins/console/driver/api.py +++ b/ATRI/plugins/console/driver/api.py @@ -6,7 +6,7 @@ from pathlib import Path from datetime import datetime from ATRI.service import ServiceTools, SERVICES_DIR -from ATRI.exceptions import GetStatusError, ReadFileError, WriteFileError +from ATRI.exceptions import GetStatusError from ..models import PlatformRuntimeInfo, BotRuntimeInfo, ServiceInfo @@ -33,7 +33,7 @@ def get_processing_data() -> tuple: datetime.utcfromtimestamp(now).replace(microsecond=0) - datetime.utcfromtimestamp(b).replace(microsecond=0) ) - except GetStatusError: + except Exception: raise GetStatusError("Getting runtime failed.") if p_cpu > 90: # type: ignore @@ -97,7 +97,7 @@ def control_service( ) -> tuple: try: serv_data = ServiceTools().load_service(serv_name) - except ReadFileError: + except Exception: return False, dict() if is_enab != 1: @@ -128,7 +128,7 @@ def control_service( try: ServiceTools().save_service(serv_data, serv_name) - except WriteFileError: + except Exception: return False, dict() return True, serv_data @@ -187,7 +187,7 @@ def edit_block_list(is_enab: bool, user_id: str, group_id: str) -> tuple: path = MANEGE_DIR / g_f with open(path, "w", encoding="utf-8") as w: w.write(json.dumps(g_d)) - except WriteFileError: + except Exception: return False, dict() return True, {"user": u_d, "group": g_d} |