Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
- Fixed KeyError in execute_in_tab
- Changed the plugin process dispatch method, this *should* fix that annoying server hang issue.
  • Loading branch information
marios8543 committed Apr 29, 2022
1 parent fe1f647 commit 7d74e98
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
10 changes: 5 additions & 5 deletions plugin_loader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def filter(self, record):
basicConfig(level=CONFIG["log_level"], format="[%(module)s][%(levelname)s]: %(message)s")
for handler in root.handlers:
if not CONFIG["log_base_events"]:
print("adding filter")
handler.addFilter(NoBaseEvents())

from aiohttp.web import Application, run_app, static
Expand All @@ -35,6 +34,7 @@ def filter(self, record):
from browser import PluginBrowser

logger = getLogger("Main")
from traceback import print_exc

async def chown_plugin_dir(_):
Popen(["chown", "-R", "deck:deck", CONFIG["plugin_path"]])
Expand Down Expand Up @@ -64,11 +64,11 @@ def exception_handler(self, loop, context):

async def loader_reinjector(self):
finished_reinjection = False

logger.info("Plugin loader isn't present in Steam anymore, reinjecting...")
while True:
await sleep(1)
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()
finished_reinjection = True
elif finished_reinjection:
Expand All @@ -89,8 +89,8 @@ async def resolve_method_call(self, tab, call_id, response):
try:
r = dumps(response)
except Exception as e:
logger.error(e)
response["result"] = str(response)
logger.error(response["result"])
response["result"] = str(response["result"])
r = response
await tab._send_devtools_cmd({
"id": 1,
Expand Down
5 changes: 1 addition & 4 deletions plugin_loader/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ async def _open_socket_if_not_exists(self):
def start(self):
if self.passive:
return self
get_event_loop().run_in_executor(
ProcessPoolExecutor(),
self._init
)
ProcessPoolExecutor().submit(self._init, self)
return self

def stop(self):
Expand Down
3 changes: 1 addition & 2 deletions plugin_loader/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ async def ping(self, **kwargs):
async def execute_in_tab(self, tab, run_async, code):
try:
result = await inject_to_tab(tab, code, run_async)

if "exceptionDetails" in result["result"]:
return {
"success": False,
Expand All @@ -41,7 +40,7 @@ async def execute_in_tab(self, tab, run_async, code):

return {
"success": True,
"result" : result["result"]["result"]["value"]
"result" : result["result"]["result"].get("value")
}
except Exception as e:
return {
Expand Down

0 comments on commit 7d74e98

Please sign in to comment.