This repository has been archived on 2024-10-14. You can view files and clone it, but cannot push or open issues or pull requests.
AutoZoom/functions.py

46 lines
1.5 KiB
Python
Raw Permalink Normal View History

# -*- coding: utf-8 -*-
import pip
import json
import os
import importlib
from pathlib import Path
from colors import *
path = Path(__file__).resolve().parent
sounds_folder = str(Path(str(path)+"/sounds/")) + os.sep
files_folder = str(Path(str(path)+"/files/")) + os.sep
def getConfig(some_var):
global files_folder
if os.path.exists(files_folder):
if not os.path.exists(files_folder+'config.json'):
temp_config_list = {}
temp_config_list["debug"] = False
temp_config_list["shutdown_timeout"] = 30
temp_config_list["shutdown_enabled"] = True
temp_config_list["start"] = "shift+f7"
temp_config_list["stop"] = "shift+f8"
temp_config_list["telegram_enabled"] = False
temp_config_list["use_colors"] = True
temp_config_list["run_fullscreen"] = False
temp_config_list["use_rpc"] = True
temp_config_list["sounds"] = True
temp_config_list["end_mode"] = "shutdown"
saveJson(files_folder+'config.json', temp_config_list)
else:
try:
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
config_list = json.load(json_file)
return config_list[some_var]
except:
return "Error"
else:
os.mkdir(files_folder)
def saveJson(filename, value):
with open(filename, 'w', encoding="utf-8") as f:
json.dump(value, f, indent=4, ensure_ascii=False)