summaryrefslogtreecommitdiff
path: root/plugin_loader/utilities.py
diff options
context:
space:
mode:
authortza <marios8543@gmail.com>2022-04-07 22:38:26 +0300
committertza <marios8543@gmail.com>2022-04-07 22:38:26 +0300
commitc65427e693daf3ee96cfd707e74efcb8d9d985f2 (patch)
treea61d643ea63517dbac2c2035c88802e631843b85 /plugin_loader/utilities.py
parent0f14f2707bf0c50d6fbbfda3da66394953ae4128 (diff)
downloaddecky-loader-c65427e693daf3ee96cfd707e74efcb8d9d985f2.tar.gz
decky-loader-c65427e693daf3ee96cfd707e74efcb8d9d985f2.zip
initial browser/installer commit, injector get_tab and stateful utils
- Integrated plugin downloader/installer. It accepts POST requests at /browser/install_plugin, containing an artifact (basically an author/repo string like you'd find on github), and a release version, then fetches the zip file from the repo releases and unzips it inside the plugin dir, after asking for user confirmation (pop-up message in the plugin menu). - Injector get_tab method. Basically get_tabs with the usual search for a specific tab. Decided to implement this because it was needed again and again, and we kept pasting the same list search one-liner. - Utilities now have access to the main PluginManager class
Diffstat (limited to 'plugin_loader/utilities.py')
-rw-r--r--plugin_loader/utilities.py33
1 files changed, 20 insertions, 13 deletions
diff --git a/plugin_loader/utilities.py b/plugin_loader/utilities.py
index 4e9a1ac0..a4abf5bc 100644
--- a/plugin_loader/utilities.py
+++ b/plugin_loader/utilities.py
@@ -1,18 +1,25 @@
from aiohttp import ClientSession
-async def http_request(method="", url="", **kwargs):
- async with ClientSession() as web:
- res = await web.request(method, url, **kwargs)
- return {
- "status": res.status,
- "headers": dict(res.headers),
- "body": await res.text()
+class Utilities:
+ def __init__(self, context) -> None:
+ self.context = context
+ self.util_methods = {
+ "ping": self.ping,
+ "http_request": self.http_request,
+ "confirm_plugin_install": self.confirm_plugin_install
}
-async def ping(**kwargs):
- return "pong"
+ async def confirm_plugin_install(self, request_id):
+ return await self.context.plugin_browser.confirm_plugin_install(request_id)
-util_methods = {
- "ping": ping,
- "http_request": http_request
-} \ No newline at end of file
+ async def http_request(self, method="", url="", **kwargs):
+ async with ClientSession() as web:
+ res = await web.request(method, url, **kwargs)
+ return {
+ "status": res.status,
+ "headers": dict(res.headers),
+ "body": await res.text()
+ }
+
+ async def ping(self, **kwargs):
+ return "pong" \ No newline at end of file