summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNik <werwolv98@gmail.com>2022-12-16 15:23:04 +0100
committerGitHub <noreply@github.com>2022-12-16 06:23:04 -0800
commit0474095a40ba6cb729064654d22efd88f91958d6 (patch)
tree12f26a43c6f16477bdac1b24a7991599662138e1
parent346f80beb31d1e2a95d31a5997b5a233d08e0645 (diff)
downloaddecky-loader-0474095a40ba6cb729064654d22efd88f91958d6.tar.gz
decky-loader-0474095a40ba6cb729064654d22efd88f91958d6.zip
Potentially fix locale issues (#284)v2.4.6-pre5
-rw-r--r--backend/browser.py4
-rw-r--r--backend/loader.py6
-rw-r--r--backend/plugin.py10
-rw-r--r--backend/settings.py8
-rw-r--r--backend/updater.py8
5 files changed, 18 insertions, 18 deletions
diff --git a/backend/browser.py b/backend/browser.py
index 69f82bdb..f6cae5d3 100644
--- a/backend/browser.py
+++ b/backend/browser.py
@@ -55,7 +55,7 @@ class PluginBrowser:
pluginBinPath = path.join(pluginBasePath, 'bin')
if access(packageJsonPath, R_OK):
- with open(packageJsonPath, 'r') as f:
+ with open(packageJsonPath, "r", encoding="utf-8") as f:
packageJson = json.load(f)
if "remote_binary" in packageJson and len(packageJson["remote_binary"]) > 0:
# create bin directory if needed.
@@ -93,7 +93,7 @@ class PluginBrowser:
def find_plugin_folder(self, name):
for folder in listdir(self.plugin_path):
try:
- with open(path.join(self.plugin_path, folder, 'plugin.json'), 'r') as f:
+ with open(path.join(self.plugin_path, folder, 'plugin.json'), "r", encoding="utf-8") as f:
plugin = json.load(f)
if plugin['name'] == name:
diff --git a/backend/loader.py b/backend/loader.py
index 2eeead36..48a66a8d 100644
--- a/backend/loader.py
+++ b/backend/loader.py
@@ -118,7 +118,7 @@ class Loader:
def handle_frontend_bundle(self, request):
plugin = self.plugins[request.match_info["plugin_name"]]
- with open(path.join(self.plugin_path, plugin.plugin_directory, "dist/index.js"), 'r') as bundle:
+ with open(path.join(self.plugin_path, plugin.plugin_directory, "dist/index.js"), "r", encoding="utf-8") as bundle:
return web.Response(text=bundle.read(), content_type="application/javascript")
def import_plugin(self, file, plugin_directory, refresh=False, batch=False):
@@ -186,7 +186,7 @@ class Loader:
"""
async def load_plugin_main_view(self, request):
plugin = self.plugins[request.match_info["name"]]
- with open(path.join(self.plugin_path, plugin.plugin_directory, plugin.main_view_html), 'r') as template:
+ with open(path.join(self.plugin_path, plugin.plugin_directory, plugin.main_view_html), "r", encoding="utf-8") as template:
template_data = template.read()
ret = f"""
<script src="/legacy/library.js"></script>
@@ -202,7 +202,7 @@ class Loader:
self.logger.info(path)
ret = ""
file_path = path.join(self.plugin_path, plugin.plugin_directory, route_path)
- with open(file_path, 'r') as resource_data:
+ with open(file_path, "r", encoding="utf-8") as resource_data:
ret = resource_data.read()
return web.Response(text=ret)
diff --git a/backend/plugin.py b/backend/plugin.py
index a1d8394a..e21d5bde 100644
--- a/backend/plugin.py
+++ b/backend/plugin.py
@@ -27,9 +27,9 @@ class PluginWrapper:
self.version = None
- json = load(open(path.join(plugin_path, plugin_directory, "plugin.json"), "r"))
+ json = load(open(path.join(plugin_path, plugin_directory, "plugin.json"), "r", encoding="utf-8"))
if path.isfile(path.join(plugin_path, plugin_directory, "package.json")):
- package_json = load(open(path.join(plugin_path, plugin_directory, "package.json"), "r"))
+ package_json = load(open(path.join(plugin_path, plugin_directory, "package.json"), "r", encoding="utf-8"))
self.version = package_json["version"]
@@ -112,7 +112,7 @@ class PluginWrapper:
d["res"] = str(e)
d["success"] = False
finally:
- writer.write((dumps(d)+"\n").encode("utf-8"))
+ writer.write((dumps(d, ensure_ascii=False)+"\n").encode("utf-8"))
await writer.drain()
async def _open_socket_if_not_exists(self):
@@ -140,7 +140,7 @@ class PluginWrapper:
return
async def _(self):
if await self._open_socket_if_not_exists():
- self.writer.write((dumps({"stop": True})+"\n").encode("utf-8"))
+ self.writer.write((dumps({ "stop": True }, ensure_ascii=False)+"\n").encode("utf-8"))
await self.writer.drain()
self.writer.close()
get_event_loop().create_task(_(self))
@@ -151,7 +151,7 @@ class PluginWrapper:
async with self.method_call_lock:
if await self._open_socket_if_not_exists():
self.writer.write(
- (dumps({"method": method_name, "args": kwargs})+"\n").encode("utf-8"))
+ (dumps({ "method": method_name, "args": kwargs }, ensure_ascii=False) + "\n").encode("utf-8"))
await self.writer.drain()
line = bytearray()
while True:
diff --git a/backend/settings.py b/backend/settings.py
index d2cce769..6dedcbbe 100644
--- a/backend/settings.py
+++ b/backend/settings.py
@@ -35,22 +35,22 @@ class SettingsManager:
self.settings = {}
try:
- open(self.path, "x")
+ open(self.path, "x", encoding="utf-8")
except FileExistsError as e:
self.read()
pass
def read(self):
try:
- with open(self.path, "r") as file:
+ with open(self.path, "r", encoding="utf-8") as file:
self.settings = load(file)
except Exception as e:
print(e)
pass
def commit(self):
- with open(self.path, "w+") as file:
- dump(self.settings, file, indent=4)
+ with open(self.path, "w+", encoding="utf-8") as file:
+ dump(self.settings, file, indent=4, ensure_ascii=False)
def getSetting(self, key, default):
return self.settings.get(key, default)
diff --git a/backend/updater.py b/backend/updater.py
index 301ca396..15a93e8a 100644
--- a/backend/updater.py
+++ b/backend/updater.py
@@ -32,7 +32,7 @@ class Updater:
self.allRemoteVers = None
try:
logger.info(getcwd())
- with open(path.join(getcwd(), ".loader.version"), 'r') as version_file:
+ with open(path.join(getcwd(), ".loader.version"), "r", encoding="utf-8") as version_file:
self.localVer = version_file.readline().replace("\n", "")
except:
self.localVer = False
@@ -159,10 +159,10 @@ class Updater:
out.write(data)
except Exception as e:
logger.error(f"Error at %s", exc_info=e)
- with open(path.join(getcwd(), "plugin_loader.service"), 'r') as service_file:
+ with open(path.join(getcwd(), "plugin_loader.service"), "r", encoding="utf-8") as service_file:
service_data = service_file.read()
service_data = service_data.replace("${HOMEBREW_FOLDER}", "/home/"+helpers.get_user()+"/homebrew")
- with open(path.join(getcwd(), "plugin_loader.service"), 'w') as service_file:
+ with open(path.join(getcwd(), "plugin_loader.service"), "w", encoding="utf-8") as service_file:
service_file.write(service_data)
logger.debug("Saved service file")
@@ -191,7 +191,7 @@ class Updater:
self.context.loop.create_task(tab.evaluate_js(f"window.DeckyUpdater.updateProgress({new_progress})", False, False, False))
progress = new_progress
- with open(path.join(getcwd(), ".loader.version"), "w") as out:
+ with open(path.join(getcwd(), ".loader.version"), "w", encoding="utf-8") as out:
out.write(version)
call(['chmod', '+x', path.join(getcwd(), "PluginLoader")])