From b7d7ca04e12690b5e65259c8806e5e895cdc16aa Mon Sep 17 00:00:00 2001 From: botato <63275405+botatooo@users.noreply.github.com> Date: Sat, 27 Aug 2022 00:01:23 -0400 Subject: Refractor plugin backend (#111) * refractor uninstall plugin backend * refractor plugin installation method * Change formatting in browser.py * Manually format main.py * Manually format utilities.py * remove inconsistency * remove unnecessary linebreaks * lol what * last minute pythoning * Fix async missing * lint * more refractor * await forgotten * fix: menu not disappearing after first click * lint * bug: fix double click on uninstall * depricate request installs * basic patch notes viewer, lazy-load settings and store, build frontend as esmodule, add lazy-loaded react-markdown, backend changes to accomodate ESModule frontend * refractor uninstall plugin backend * Change formatting in browser.py * Manually format main.py * Manually format utilities.py * remove unnecessary linebreaks * lol what * last minute pythoning * Fix async missing * rebase onto main * fix error, fix React crash if patch notes are opened before remote version info is loaded Co-authored-by: TrainDoctor Co-authored-by: AAGaming --- backend/main.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'backend/main.py') diff --git a/backend/main.py b/backend/main.py index dfbf1829..1f365fe5 100644 --- a/backend/main.py +++ b/backend/main.py @@ -36,10 +36,15 @@ CONFIG = { "server_host": getenv("SERVER_HOST", "127.0.0.1"), "server_port": int(getenv("SERVER_PORT", "1337")), "live_reload": getenv("LIVE_RELOAD", "1") == "1", - "log_level": {"CRITICAL": 50, "ERROR": 40, "WARNING":30, "INFO": 20, "DEBUG": 10}[getenv("LOG_LEVEL", "INFO")] + "log_level": {"CRITICAL": 50, "ERROR": 40, "WARNING": 30, "INFO": 20, "DEBUG": 10}[ + getenv("LOG_LEVEL", "INFO") + ], } -basicConfig(level=CONFIG["log_level"], format="[%(module)s][%(levelname)s]: %(message)s") +basicConfig( + level=CONFIG["log_level"], + format="[%(module)s][%(levelname)s]: %(message)s" +) logger = getLogger("Main") @@ -55,11 +60,14 @@ class PluginManager: self.web_app = Application() self.web_app.middlewares.append(csrf_middleware) self.cors = aiohttp_cors.setup(self.web_app, defaults={ - "https://steamloopback.host": aiohttp_cors.ResourceOptions(expose_headers="*", - allow_headers="*", allow_credentials=True) + "https://steamloopback.host": aiohttp_cors.ResourceOptions( + expose_headers="*", + allow_headers="*", + allow_credentials=True + ) }) self.plugin_loader = Loader(self.web_app, CONFIG["plugin_path"], self.loop, CONFIG["live_reload"]) - self.plugin_browser = PluginBrowser(CONFIG["plugin_path"], self.web_app, self.plugin_loader.plugins) + self.plugin_browser = PluginBrowser(CONFIG["plugin_path"], self.plugin_loader.plugins) self.settings = SettingsManager("loader", path.join(HOMEBREW_PATH, "settings")) self.utilities = Utilities(self) self.updater = Updater(self) @@ -75,7 +83,7 @@ class PluginManager: self.web_app.add_routes([get("/auth/token", self.get_auth_token)]) for route in list(self.web_app.router.routes()): - self.cors.add(route) + self.cors.add(route) self.web_app.add_routes([static("/static", path.join(path.dirname(__file__), 'static'))]) self.web_app.add_routes([static("/legacy", path.join(path.dirname(__file__), 'legacy'))]) @@ -99,7 +107,7 @@ class PluginManager: async def load_plugins(self): await self.wait_for_server() self.plugin_loader.import_plugins() - #await inject_to_tab("SP", "window.syncDeckyPlugins();") + # await inject_to_tab("SP", "window.syncDeckyPlugins();") async def loader_reinjector(self): await sleep(2) -- cgit v1.2.3