summaryrefslogtreecommitdiff
path: root/backend/helpers.py
diff options
context:
space:
mode:
authorPhilipp Richter <richterphilipp.pops@gmail.com>2023-02-19 22:42:55 +0000
committerGitHub <noreply@github.com>2023-02-19 14:42:55 -0800
commitf1e679c3fb26bf2a3264ef63b4b207412417521e (patch)
tree57874cf585a31d2a0be69fa9dd439162891f954f /backend/helpers.py
parente1b138bcbdcb899e43166a9ece5173d0fc0cab0a (diff)
downloaddecky-loader-f1e679c3fb26bf2a3264ef63b4b207412417521e.tar.gz
decky-loader-f1e679c3fb26bf2a3264ef63b4b207412417521e.zip
Expose a 'decky_plugin' module to decky plugins (#353)
* Expose a 'decky_plugin' module to decky plugins * expose decky user home path * support 'py_modules' python modules in plugins * allow for a '_migration' method in plugins to have an explicit file moving step * Expose the plugin python module as .pyi stub interface * Expose system and user python paths to plugins
Diffstat (limited to 'backend/helpers.py')
-rw-r--r--backend/helpers.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/backend/helpers.py b/backend/helpers.py
index 7cab512b..35681f68 100644
--- a/backend/helpers.py
+++ b/backend/helpers.py
@@ -115,8 +115,18 @@ def mkdir_as_user(path):
# Fetches the version of loader
def get_loader_version() -> str:
- with open(os.path.join(os.path.dirname(sys.argv[0]), ".loader.version"), "r", encoding="utf-8") as version_file:
- return version_file.readline().replace("\n", "")
+ try:
+ with open(os.path.join(os.path.dirname(sys.argv[0]), ".loader.version"), "r", encoding="utf-8") as version_file:
+ return version_file.readline().replace("\n", "")
+ except:
+ return ""
+
+# returns the appropriate system python paths
+def get_system_pythonpaths() -> list[str]:
+ # run as normal normal user to also include user python paths
+ proc = subprocess.run(["python3", "-c", "import sys; print(':'.join(x for x in sys.path if x))"],
+ user=get_user_id(), env={}, capture_output=True)
+ return proc.stdout.decode().strip().split(":")
# Download Remote Binaries to local Plugin
async def download_remote_binary_to_path(url, binHash, path) -> bool: