From d6f336d84b8b00161a688d4b39b82165a3ebe1f3 Mon Sep 17 00:00:00 2001 From: suchmememanyskill <38142618+suchmememanyskill@users.noreply.github.com> Date: Tue, 25 Apr 2023 05:12:42 +0200 Subject: Feat/configurable paths (#404) --- backend/localplatform.py | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'backend/localplatform.py') diff --git a/backend/localplatform.py b/backend/localplatform.py index c1453227..a788d59f 100644 --- a/backend/localplatform.py +++ b/backend/localplatform.py @@ -1,4 +1,4 @@ -import platform +import platform, os ON_WINDOWS = platform.system() == "Windows" ON_LINUX = not ON_WINDOWS @@ -8,4 +8,33 @@ if ON_WINDOWS: import localplatformwin as localplatform else: from localplatformlinux import * - import localplatformlinux as localplatform \ No newline at end of file + import localplatformlinux as localplatform + +def get_privileged_path() -> str: + '''Get path accessible by elevated user. Holds plugins, decky loader and decky loader configs''' + return localplatform.get_privileged_path() + +def get_unprivileged_path() -> str: + '''Get path accessible by non-elevated user. Holds plugin configuration, plugin data and plugin logs. Externally referred to as the 'Homebrew' directory''' + return localplatform.get_unprivileged_path() + +def get_unprivileged_user() -> str: + '''Get user that should own files made in unprivileged path''' + return localplatform.get_unprivileged_user() + +def get_chown_plugin_path() -> bool: + return os.getenv("CHOWN_PLUGIN_PATH", "1") == "1" + +def get_server_host() -> str: + return os.getenv("SERVER_HOST", "127.0.0.1") + +def get_server_port() -> int: + return int(os.getenv("SERVER_PORT", "1337")) + +def get_live_reload() -> bool: + os.getenv("LIVE_RELOAD", "1") == "1" + +def get_log_level() -> int: + return {"CRITICAL": 50, "ERROR": 40, "WARNING": 30, "INFO": 20, "DEBUG": 10}[ + os.getenv("LOG_LEVEL", "INFO") + ] \ No newline at end of file -- cgit v1.2.3