summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugin_loader/browser.py16
-rw-r--r--plugin_loader/injector.py6
-rw-r--r--plugin_loader/loader.py27
-rw-r--r--plugin_loader/main.py2
4 files changed, 25 insertions, 26 deletions
diff --git a/plugin_loader/browser.py b/plugin_loader/browser.py
index a81551ef..7fc8773b 100644
--- a/plugin_loader/browser.py
+++ b/plugin_loader/browser.py
@@ -40,15 +40,15 @@ class PluginBrowser:
async def _install(self, artifact, version, hash):
name = artifact.split("/")[-1]
rmtree(path.join(self.plugin_path, name), ignore_errors=True)
- self.log.info("Installing {} (Version: {})".format(artifact, version))
+ self.log.info(f"Installing {artifact} (Version: {version})")
async with ClientSession() as client:
- url = "https://github.com/{}/archive/refs/tags/{}.zip".format(artifact, version)
- self.log.debug("Fetching {}".format(url))
+ url = f"https://github.com/{artifact}/archive/refs/tags/{version}.zip"
+ self.log.debug(f"Fetching {url}")
res = await client.get(url)
if res.status == 200:
self.log.debug("Got 200. Reading...")
data = await res.read()
- self.log.debug("Read {} bytes".format(len(data)))
+ self.log.debug(f"Read {len(data)} bytes")
res_zip = BytesIO(data)
with ProcessPoolExecutor() as executor:
self.log.debug("Unzipping...")
@@ -60,11 +60,11 @@ class PluginBrowser:
hash
)
if ret:
- self.log.info("Installed {} (Version: {})".format(artifact, version))
+ self.log.info(f"Installed {artifact} (Version: {version})")
else:
- self.log.fatal("SHA-256 Mismatch!!!! {} (Version: {})".format(artifact, version))
+ self.log.fatal(f"SHA-256 Mismatch!!!! {artifact} (Version: {version})")
else:
- self.log.fatal("Could not fetch from github. {}".format(await res.text()))
+ self.log.fatal(f"Could not fetch from github. {await res.text()}")
async def redirect_to_store(self, request):
return web.Response(status=302, headers={"Location": self.store_url})
@@ -79,7 +79,7 @@ class PluginBrowser:
self.install_requests[request_id] = PluginInstallContext(artifact, version, hash)
tab = await get_tab("QuickAccess")
await tab.open_websocket()
- await tab.evaluate_js("addPluginInstallPrompt('{}', '{}', '{}')".format(artifact, version, request_id))
+ await tab.evaluate_js(f"addPluginInstallPrompt('{artifact}', '{version}', '{request_id}')")
async def confirm_plugin_install(self, request_id):
request = self.install_requests.pop(request_id)
diff --git a/plugin_loader/injector.py b/plugin_loader/injector.py
index edb09527..bf970780 100644
--- a/plugin_loader/injector.py
+++ b/plugin_loader/injector.py
@@ -58,7 +58,7 @@ async def get_tabs():
while True:
try:
- res = await web.get("{}/json".format(BASE_ADDRESS))
+ res = await web.get(f"{BASE_ADDRESS}/json")
break
except:
logger.info("Steam isn't available yet. Wait for a moment...")
@@ -68,13 +68,13 @@ async def get_tabs():
res = await res.json()
return [Tab(i) for i in res]
else:
- raise Exception("/json did not return 200. {}".format(await res.text()))
+ raise Exception(f"/json did not return 200. {await res.text()}")
async def get_tab(tab_name):
tabs = await get_tabs()
tab = next((i for i in tabs if i.title == tab_name), None)
if not tab:
- raise ValueError("Tab {} not found".format(tab_name))
+ raise ValueError(f"Tab {tab_name} not found")
return tab
async def inject_to_tab(tab_name, js, run_async=False):
diff --git a/plugin_loader/loader.py b/plugin_loader/loader.py
index cf5ca381..20a05096 100644
--- a/plugin_loader/loader.py
+++ b/plugin_loader/loader.py
@@ -84,11 +84,10 @@ class Loader:
module.Plugin._plugin_directory = plugin_directory
if not hasattr(module.Plugin, "name"):
- raise KeyError("Plugin {} has not defined a name".format(file))
+ raise KeyError(f"Plugin {file} has not defined a name")
if module.Plugin.name in self.plugins:
if hasattr(module.Plugin, "hot_reload") and not module.Plugin.hot_reload and refresh:
- self.logger.info("Plugin {} is already loaded and has requested to not be re-loaded"
- .format(module.Plugin.name))
+ self.logger.info(f"Plugin {module.Plugin.name} is already loaded and has requested to not be re-loaded")
return
else:
if hasattr(self.plugins[module.Plugin.name], "task"):
@@ -98,9 +97,9 @@ class Loader:
if hasattr(module.Plugin, "__main"):
setattr(self.plugins[module.Plugin.name], "task",
self.loop.create_task(self.plugins[module.Plugin.name].__main()))
- self.logger.info("Loaded {}".format(module.Plugin.name))
+ self.logger.info(f"Loaded {module.Plugin.name}")
except Exception as e:
- self.logger.error("Could not load {}. {}".format(file, e))
+ self.logger.error(f"Could not load {file}. {e}")
finally:
if refresh:
self.loop.create_task(self.refresh_iframe())
@@ -136,12 +135,12 @@ class Loader:
with open(path.join(self.plugin_path, plugin._plugin_directory, plugin.main_view_html), 'r') as template:
template_data = template.read()
# setup the main script, plugin, and pull in the template
- ret = """
+ ret = f"""
<script src="/static/library.js"></script>
- <script>const plugin_name = '{}' </script>
- <base href="http://127.0.0.1:1337/plugins/plugin_resource/{}/">
- {}
- """.format(plugin.name, plugin.name, template_data)
+ <script>const plugin_name = '{plugin.name}' </script>
+ <base href="http://127.0.0.1:1337/plugins/plugin_resource/{plugin.name}/">
+ {template_data}
+ """
return web.Response(text=ret, content_type="text/html")
async def handle_sub_route(self, request):
@@ -169,18 +168,18 @@ class Loader:
inner_content = template_data
# setup the default template
- ret = """
+ ret = f"""
<html style="height: fit-content;">
<head>
<link rel="stylesheet" href="/static/styles.css">
<script src="/static/library.js"></script>
- <script>const plugin_name = '{name}';</script>
+ <script>const plugin_name = '{plugin.name}';</script>
</head>
<body style="height: fit-content; display: block;">
- {content}
+ {inner_content}
</body>
<html>
- """.format(name=plugin.name, content=inner_content)
+ """
return web.Response(text=ret, content_type="text/html")
@template('plugin_view.html')
diff --git a/plugin_loader/main.py b/plugin_loader/main.py
index 1d622098..37a4ad1d 100644
--- a/plugin_loader/main.py
+++ b/plugin_loader/main.py
@@ -53,7 +53,7 @@ class PluginManager:
"id": 1,
"method": "Runtime.evaluate",
"params": {
- "expression": "resolveMethodCall({}, {})".format(call_id, dumps(response)),
+ "expression": f"resolveMethodCall({call_id}, {dumps(response)})",
"userGesture": True
}
}, receive=False)