summaryrefslogtreecommitdiff
path: root/backend/utilities.py
diff options
context:
space:
mode:
authorAAGaming <aa@mail.catvibers.me>2022-11-15 16:44:24 -0500
committerGitHub <noreply@github.com>2022-11-15 13:44:24 -0800
commit50764600c83b2bdec599a9fd8e27b3c10a2afd96 (patch)
treef802b7c438723846971162d0c845caa237e0cb7d /backend/utilities.py
parentaec70631393ba307f1ca493a4d96f244e1439555 (diff)
downloaddecky-loader-50764600c83b2bdec599a9fd8e27b3c10a2afd96.tar.gz
decky-loader-50764600c83b2bdec599a9fd8e27b3c10a2afd96.zip
Refactoring in preparation for WebSockets (#254)v2.4.1-pre2
* Fix injector race conditions * add some more tasks * hide useless rollup warnings * goodbye to clientsession errors * completely fix desktop mode switch race condition * fix typos and TS warning in plugin error handler * fix chown error * start debugger if needed and not already started * fix get_steam_resource for the like 2 legacy plugins still using it lol * add ClientOSError to get_tabs error handling
Diffstat (limited to 'backend/utilities.py')
-rw-r--r--backend/utilities.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/backend/utilities.py b/backend/utilities.py
index 61e6b523..10651d2f 100644
--- a/backend/utilities.py
+++ b/backend/utilities.py
@@ -80,12 +80,12 @@ class Utilities:
async def http_request(self, method="", url="", **kwargs):
async with ClientSession() as web:
- async with web.request(method, url, ssl=helpers.get_ssl_context(), **kwargs) as res:
- return {
- "status": res.status,
- "headers": dict(res.headers),
- "body": await res.text()
- }
+ res = await web.request(method, url, ssl=helpers.get_ssl_context(), **kwargs)
+ return {
+ "status": res.status,
+ "headers": dict(res.headers),
+ "body": await res.text()
+ }
async def ping(self, **kwargs):
return "pong"
@@ -241,17 +241,17 @@ class Utilities:
if ip != None:
self.logger.info("Connecting to React DevTools at " + ip)
async with ClientSession() as web:
- async with web.request("GET", "http://" + ip + ":8097", ssl=helpers.get_ssl_context()) as res:
- if res.status != 200:
- self.logger.error("Failed to connect to React DevTools at " + ip)
- return False
- self.start_rdt_proxy(ip, 8097)
- script = "if(!window.deckyHasConnectedRDT){window.deckyHasConnectedRDT=true;\n" + await res.text() + "\n}"
- self.logger.info("Connected to React DevTools, loading script")
- tab = await get_gamepadui_tab()
- # RDT needs to load before React itself to work.
- result = await tab.reload_and_evaluate(script)
- self.logger.info(result)
+ res = await web.request("GET", "http://" + ip + ":8097", ssl=helpers.get_ssl_context())
+ if res.status != 200:
+ self.logger.error("Failed to connect to React DevTools at " + ip)
+ return False
+ self.start_rdt_proxy(ip, 8097)
+ script = "if(!window.deckyHasConnectedRDT){window.deckyHasConnectedRDT=true;\n" + await res.text() + "\n}"
+ self.logger.info("Connected to React DevTools, loading script")
+ tab = await get_gamepadui_tab()
+ # RDT needs to load before React itself to work.
+ result = await tab.reload_and_evaluate(script)
+ self.logger.info(result)
except Exception:
self.logger.error("Failed to connect to React DevTools")