summaryrefslogtreecommitdiff
path: root/ATRI/plugins/console/data_source.py
diff options
context:
space:
mode:
Diffstat (limited to 'ATRI/plugins/console/data_source.py')
-rw-r--r--ATRI/plugins/console/data_source.py55
1 files changed, 0 insertions, 55 deletions
diff --git a/ATRI/plugins/console/data_source.py b/ATRI/plugins/console/data_source.py
deleted file mode 100644
index 990b1c9..0000000
--- a/ATRI/plugins/console/data_source.py
+++ /dev/null
@@ -1,55 +0,0 @@
-import os
-import json
-from pathlib import Path
-from datetime import datetime
-
-from ATRI.service import Service
-
-
-CONSOLE_DIR = Path(".") / "data" / "database" / "console"
-os.makedirs(CONSOLE_DIR, exist_ok=True)
-
-
-is_connect = False
-
-
-class Console(Service):
- def __init__(self):
- Service.__init__(self, "控制台")
-
- @staticmethod
- def record_data(data: dict) -> None:
- now_time = datetime.now().strftime("%Y-%m-%d")
- file_name = f"{now_time}-runtime.json"
- path = CONSOLE_DIR / file_name
- if not path.is_file():
- with open(path, "w", encoding="utf-8") as w:
- w.write(json.dumps(list()))
- temp_data = list()
-
- temp_data: list = json.loads(path.read_bytes())
- temp_data.append(data)
- with open(path, "w", encoding="utf-8") as w:
- w.write(json.dumps(temp_data, indent=4))
-
- @staticmethod
- def load_data() -> list:
- now_time = datetime.now().strftime("%Y-%m-%d")
- file_name = f"{now_time}-runtime.json"
- path = CONSOLE_DIR / file_name
- if not path.is_file():
- with open(path, "w", encoding="utf-8") as w:
- w.write(json.dumps(list()))
- return list()
-
- data: list = json.loads(path.read_bytes())
- return data
-
- @staticmethod
- def store_connect_stat(i: bool):
- global is_connect
- is_connect = i
-
- @staticmethod
- def is_connect() -> bool:
- return is_connect