Skip to content

Commit

Permalink
Custom error handler and some misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AAGaming00 committed May 25, 2024
1 parent 96cc72f commit a84a13c
Show file tree
Hide file tree
Showing 28 changed files with 1,108 additions and 1,094 deletions.
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"deploy"
],
"detail": "Check for local runs, create a plugins folder",
"command": "ssh ${config:deckuser}@${config:deckip} -p ${config:deckport} ${config:deckkey} 'python -m ensurepip && python -m pip install --user --upgrade poetry && cd ${config:deckdir}/homebrew/dev/pluginloader/backend && python -m poetry install'",
"command": "ssh ${config:deckuser}@${config:deckip} -p ${config:deckport} ${config:deckkey} 'python -m ensurepip --root / && python -m pip install --user --break-system-packages --upgrade poetry && cd ${config:deckdir}/homebrew/dev/pluginloader/backend && python -m poetry install'",
"problemMatcher": []
},
{
Expand Down
1 change: 1 addition & 0 deletions backend/decky_loader/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from logging import getLogger
from packaging.version import Version

SSHD_UNIT = "sshd.service"
REMOTE_DEBUGGER_UNIT = "steam-web-debug-portforward.service"

# global vars
Expand Down
2 changes: 1 addition & 1 deletion backend/decky_loader/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ async def plugin_emitted_event(event: str, args: Any):
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()
Expand Down
1 change: 1 addition & 0 deletions backend/decky_loader/localplatform/localplatformlinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 5 additions & 3 deletions backend/decky_loader/plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ def start(self):
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))
5 changes: 4 additions & 1 deletion backend/decky_loader/plugin/sandboxed_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ async def _uninstall(self):
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")
Expand Down
8 changes: 6 additions & 2 deletions backend/decky_loader/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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
Expand Down Expand Up @@ -53,6 +53,7 @@ def __init__(self, context: PluginManager) -> None:
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);
Expand Down Expand Up @@ -184,8 +185,8 @@ async def download_decky_binary(self, download_url: str, version: str, is_zip: b

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.")
Expand Down Expand Up @@ -242,6 +243,9 @@ async def do_update(self):
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:
Expand Down
10 changes: 10 additions & 0 deletions backend/decky_loader/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def __init__(self, context: PluginManager) -> None:
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)
Expand Down Expand Up @@ -284,6 +286,14 @@ async def disallow_remote_debugging(self):
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,
Expand Down
31 changes: 16 additions & 15 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,31 @@
"format": "prettier -c src -w"
},
"devDependencies": {
"@decky/api": "^1.0.3",
"@rollup/plugin-commonjs": "^21.1.0",
"@rollup/plugin-image": "^3.0.2",
"@rollup/plugin-image": "^3.0.3",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-replace": "^4.0.0",
"@rollup/plugin-typescript": "^8.5.0",
"@types/react": "16.14.0",
"@types/react-file-icon": "^1.0.1",
"@types/react": "18.2.0",
"@types/react-file-icon": "^1.0.4",
"@types/react-router": "5.1.18",
"@types/webpack": "^5.28.1",
"@types/webpack": "^5.28.5",
"husky": "^8.0.3",
"i18next-parser": "^8.0.0",
"i18next-parser": "^8.13.0",
"import-sort-style-module": "^6.0.0",
"inquirer": "^8.2.5",
"inquirer": "^8.2.6",
"prettier": "^3.2.5",
"prettier-plugin-import-sort": "^0.0.7",
"react": "16.14.0",
"react-dom": "16.14.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"rollup": "^2.79.1",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-external-globals": "^0.6.1",
"rollup-plugin-polyfill-node": "^0.10.2",
"rollup-plugin-visualizer": "^5.9.2",
"tslib": "^2.5.3",
"rollup-plugin-visualizer": "^5.12.0",
"tslib": "^2.6.2",
"typescript": "^4.9.5"
},
"importSort": {
Expand All @@ -44,12 +45,12 @@
},
"dependencies": {
"decky-frontend-lib": "3.25.0",
"filesize": "^10.0.7",
"i18next": "^23.2.1",
"i18next-http-backend": "^2.2.1",
"react-file-icon": "^1.3.0",
"filesize": "^10.1.2",
"i18next": "^23.11.5",
"i18next-http-backend": "^2.5.2",
"react-file-icon": "^1.4.0",
"react-i18next": "^12.3.1",
"react-icons": "^4.9.0",
"react-icons": "^4.12.0",
"react-markdown": "^8.0.7",
"remark-gfm": "^3.0.1"
}
Expand Down
Loading

0 comments on commit a84a13c

Please sign in to comment.