Bug fixes

- Fixed KeyError in execute_in_tab
- Changed the plugin process dispatch method, this *should* fix that annoying server hang issue.
This commit is contained in:
marios
2022-04-29 12:52:24 +03:00
parent fe1f6473e9
commit 7d74e98f4f
3 changed files with 7 additions and 11 deletions
+5 -5
View File
@@ -18,7 +18,6 @@ class NoBaseEvents(Filter):
basicConfig(level=CONFIG["log_level"], format="[%(module)s][%(levelname)s]: %(message)s") basicConfig(level=CONFIG["log_level"], format="[%(module)s][%(levelname)s]: %(message)s")
for handler in root.handlers: for handler in root.handlers:
if not CONFIG["log_base_events"]: if not CONFIG["log_base_events"]:
print("adding filter")
handler.addFilter(NoBaseEvents()) handler.addFilter(NoBaseEvents())
from aiohttp.web import Application, run_app, static from aiohttp.web import Application, run_app, static
@@ -35,6 +34,7 @@ from utilities import Utilities
from browser import PluginBrowser from browser import PluginBrowser
logger = getLogger("Main") logger = getLogger("Main")
from traceback import print_exc
async def chown_plugin_dir(_): async def chown_plugin_dir(_):
Popen(["chown", "-R", "deck:deck", CONFIG["plugin_path"]]) Popen(["chown", "-R", "deck:deck", CONFIG["plugin_path"]])
@@ -64,11 +64,11 @@ class PluginManager:
async def loader_reinjector(self): async def loader_reinjector(self):
finished_reinjection = False finished_reinjection = False
logger.info("Plugin loader isn't present in Steam anymore, reinjecting...")
while True: while True:
await sleep(1) await sleep(1)
if not await tab_has_element("QuickAccess", "plugin_iframe"): if not await tab_has_element("QuickAccess", "plugin_iframe"):
logger.info("Plugin loader isn't present in Steam anymore, reinjecting...") logger.debug("Plugin loader isn't present in Steam anymore, reinjecting...")
await self.inject_javascript() await self.inject_javascript()
finished_reinjection = True finished_reinjection = True
elif finished_reinjection: elif finished_reinjection:
@@ -89,8 +89,8 @@ class PluginManager:
try: try:
r = dumps(response) r = dumps(response)
except Exception as e: except Exception as e:
logger.error(e) logger.error(response["result"])
response["result"] = str(response) response["result"] = str(response["result"])
r = response r = response
await tab._send_devtools_cmd({ await tab._send_devtools_cmd({
"id": 1, "id": 1,
+1 -4
View File
@@ -73,10 +73,7 @@ class PluginWrapper:
def start(self): def start(self):
if self.passive: if self.passive:
return self return self
get_event_loop().run_in_executor( ProcessPoolExecutor().submit(self._init, self)
ProcessPoolExecutor(),
self._init
)
return self return self
def stop(self): def stop(self):
+1 -2
View File
@@ -32,7 +32,6 @@ class Utilities:
async def execute_in_tab(self, tab, run_async, code): async def execute_in_tab(self, tab, run_async, code):
try: try:
result = await inject_to_tab(tab, code, run_async) result = await inject_to_tab(tab, code, run_async)
if "exceptionDetails" in result["result"]: if "exceptionDetails" in result["result"]:
return { return {
"success": False, "success": False,
@@ -41,7 +40,7 @@ class Utilities:
return { return {
"success": True, "success": True,
"result" : result["result"]["result"]["value"] "result" : result["result"]["result"].get("value")
} }
except Exception as e: except Exception as e:
return { return {