mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-06-17 08:47:49 +00:00
Custom error handler and some misc fixes
This commit is contained in:
@@ -16,6 +16,7 @@ from .enums import UserType
|
||||
from logging import getLogger
|
||||
from packaging.version import Version
|
||||
|
||||
SSHD_UNIT = "sshd.service"
|
||||
REMOTE_DEBUGGER_UNIT = "steam-web-debug-portforward.service"
|
||||
|
||||
# global vars
|
||||
|
||||
@@ -160,7 +160,7 @@ class Loader:
|
||||
self.plugins[plugin.name] = plugin.start()
|
||||
self.logger.info(f"Loaded {plugin.name}")
|
||||
if not batch:
|
||||
self.loop.create_task(self.dispatch_plugin(plugin.name, plugin.version))
|
||||
self.loop.create_task(self.dispatch_plugin(plugin.name, plugin.version, plugin.load_type))
|
||||
except Exception as e:
|
||||
self.logger.error(f"Could not load {file}. {e}")
|
||||
print_exc()
|
||||
|
||||
@@ -158,6 +158,7 @@ async def service_start(service_name : str) -> bool:
|
||||
|
||||
async def restart_webhelper() -> bool:
|
||||
logger.info("Restarting steamwebhelper")
|
||||
# TODO move to pkill
|
||||
res = run(["killall", "-s", "SIGTERM", "steamwebhelper"], stdout=DEVNULL, stderr=DEVNULL)
|
||||
return res.returncode == 0
|
||||
|
||||
|
||||
@@ -99,8 +99,10 @@ class PluginWrapper:
|
||||
return self
|
||||
|
||||
def stop(self, uninstall: bool = False):
|
||||
self._listener_task.cancel()
|
||||
if hasattr(self, "_listener_task"):
|
||||
self._listener_task.cancel()
|
||||
async def _(self: PluginWrapper):
|
||||
await self._socket.write_single_line(dumps({ "stop": True, "uninstall": uninstall }, ensure_ascii=False))
|
||||
await self._socket.close_socket_connection()
|
||||
if hasattr(self, "_socket"):
|
||||
await self._socket.write_single_line(dumps({ "stop": True, "uninstall": uninstall }, ensure_ascii=False))
|
||||
await self._socket.close_socket_connection()
|
||||
create_task(_(self))
|
||||
@@ -142,7 +142,10 @@ class SandboxedPlugin:
|
||||
try:
|
||||
self.log.info("Attempting to uninstall with plugin " + self.name + "'s \"_uninstall\" function.\n")
|
||||
if hasattr(self.Plugin, "_uninstall"):
|
||||
await self.Plugin._uninstall(self.Plugin)
|
||||
if self.api_version > 0:
|
||||
await self.Plugin._uninstall()
|
||||
else:
|
||||
await self.Plugin._uninstall(self.Plugin)
|
||||
self.log.info("Uninstalled " + self.name + "\n")
|
||||
else:
|
||||
self.log.info("Could not find \"_uninstall\" in " + self.name + "'s main.py" + "\n")
|
||||
|
||||
@@ -6,7 +6,7 @@ from os import getcwd, path, remove
|
||||
from typing import TYPE_CHECKING, List, TypedDict
|
||||
if TYPE_CHECKING:
|
||||
from .main import PluginManager
|
||||
from .localplatform.localplatform import chmod, service_restart, ON_LINUX, ON_WINDOWS, get_keep_systemd_service, get_selinux
|
||||
from .localplatform.localplatform import chmod, service_restart, service_stop, ON_LINUX, ON_WINDOWS, get_keep_systemd_service, get_selinux
|
||||
import shutil
|
||||
from typing import List, TYPE_CHECKING, TypedDict
|
||||
import zipfile
|
||||
@@ -53,6 +53,7 @@ class Updater:
|
||||
context.ws.add_route("updater/get_version_info", self.get_version_info);
|
||||
context.ws.add_route("updater/check_for_updates", self.check_for_updates);
|
||||
context.ws.add_route("updater/do_restart", self.do_restart);
|
||||
context.ws.add_route("updater/do_shutdown", self.do_shutdown);
|
||||
context.ws.add_route("updater/do_update", self.do_update);
|
||||
context.ws.add_route("updater/get_testing_versions", self.get_testing_versions);
|
||||
context.ws.add_route("updater/download_testing_version", self.download_testing_version);
|
||||
@@ -184,8 +185,8 @@ class Updater:
|
||||
|
||||
logger.info("Updated loader installation.")
|
||||
await self.context.ws.emit("updater/finish_download")
|
||||
await self.do_restart()
|
||||
await tab.close_websocket()
|
||||
await self.do_restart()
|
||||
|
||||
async def do_update(self):
|
||||
logger.debug("Starting update.")
|
||||
@@ -242,6 +243,9 @@ class Updater:
|
||||
async def do_restart(self):
|
||||
await service_restart("plugin_loader")
|
||||
|
||||
async def do_shutdown(self):
|
||||
await service_stop("plugin_loader")
|
||||
|
||||
async def get_testing_versions(self) -> List[TestingVersion]:
|
||||
result: List[TestingVersion] = []
|
||||
async with ClientSession() as web:
|
||||
|
||||
@@ -79,6 +79,8 @@ class Utilities:
|
||||
context.ws.add_route("utilities/remove_css_from_tab", self.remove_css_from_tab)
|
||||
context.ws.add_route("utilities/allow_remote_debugging", self.allow_remote_debugging)
|
||||
context.ws.add_route("utilities/disallow_remote_debugging", self.disallow_remote_debugging)
|
||||
context.ws.add_route("utilities/start_ssh", self.allow_remote_debugging)
|
||||
context.ws.add_route("utilities/stop_ssh", self.allow_remote_debugging)
|
||||
context.ws.add_route("utilities/filepicker_ls", self.filepicker_ls)
|
||||
context.ws.add_route("utilities/disable_rdt", self.disable_rdt)
|
||||
context.ws.add_route("utilities/enable_rdt", self.enable_rdt)
|
||||
@@ -284,6 +286,14 @@ class Utilities:
|
||||
await service_stop(helpers.REMOTE_DEBUGGER_UNIT)
|
||||
return True
|
||||
|
||||
async def start_ssh(self):
|
||||
await service_start(helpers.SSHD_UNIT)
|
||||
return True
|
||||
|
||||
async def stop_ssh(self):
|
||||
await service_stop(helpers.SSHD_UNIT)
|
||||
return True
|
||||
|
||||
async def filepicker_ls(self,
|
||||
path: str | None = None,
|
||||
include_files: bool = True,
|
||||
|
||||
Reference in New Issue
Block a user