From 50764600c83b2bdec599a9fd8e27b3c10a2afd96 Mon Sep 17 00:00:00 2001 From: AAGaming Date: Tue, 15 Nov 2022 16:44:24 -0500 Subject: Refactoring in preparation for WebSockets (#254) * 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 --- backend/utilities.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'backend/utilities.py') 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") -- cgit v1.2.3