mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-07-11 11:31:58 +00:00
Potentially fix locale issues (#284)
This commit is contained in:
+2
-2
@@ -55,7 +55,7 @@ class PluginBrowser:
|
|||||||
pluginBinPath = path.join(pluginBasePath, 'bin')
|
pluginBinPath = path.join(pluginBasePath, 'bin')
|
||||||
|
|
||||||
if access(packageJsonPath, R_OK):
|
if access(packageJsonPath, R_OK):
|
||||||
with open(packageJsonPath, 'r') as f:
|
with open(packageJsonPath, "r", encoding="utf-8") as f:
|
||||||
packageJson = json.load(f)
|
packageJson = json.load(f)
|
||||||
if "remote_binary" in packageJson and len(packageJson["remote_binary"]) > 0:
|
if "remote_binary" in packageJson and len(packageJson["remote_binary"]) > 0:
|
||||||
# create bin directory if needed.
|
# create bin directory if needed.
|
||||||
@@ -93,7 +93,7 @@ class PluginBrowser:
|
|||||||
def find_plugin_folder(self, name):
|
def find_plugin_folder(self, name):
|
||||||
for folder in listdir(self.plugin_path):
|
for folder in listdir(self.plugin_path):
|
||||||
try:
|
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)
|
plugin = json.load(f)
|
||||||
|
|
||||||
if plugin['name'] == name:
|
if plugin['name'] == name:
|
||||||
|
|||||||
+3
-3
@@ -118,7 +118,7 @@ class Loader:
|
|||||||
def handle_frontend_bundle(self, request):
|
def handle_frontend_bundle(self, request):
|
||||||
plugin = self.plugins[request.match_info["plugin_name"]]
|
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")
|
return web.Response(text=bundle.read(), content_type="application/javascript")
|
||||||
|
|
||||||
def import_plugin(self, file, plugin_directory, refresh=False, batch=False):
|
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):
|
async def load_plugin_main_view(self, request):
|
||||||
plugin = self.plugins[request.match_info["name"]]
|
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()
|
template_data = template.read()
|
||||||
ret = f"""
|
ret = f"""
|
||||||
<script src="/legacy/library.js"></script>
|
<script src="/legacy/library.js"></script>
|
||||||
@@ -202,7 +202,7 @@ class Loader:
|
|||||||
self.logger.info(path)
|
self.logger.info(path)
|
||||||
ret = ""
|
ret = ""
|
||||||
file_path = path.join(self.plugin_path, plugin.plugin_directory, route_path)
|
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()
|
ret = resource_data.read()
|
||||||
|
|
||||||
return web.Response(text=ret)
|
return web.Response(text=ret)
|
||||||
|
|||||||
+5
-5
@@ -27,9 +27,9 @@ class PluginWrapper:
|
|||||||
|
|
||||||
self.version = None
|
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")):
|
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"]
|
self.version = package_json["version"]
|
||||||
|
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ class PluginWrapper:
|
|||||||
d["res"] = str(e)
|
d["res"] = str(e)
|
||||||
d["success"] = False
|
d["success"] = False
|
||||||
finally:
|
finally:
|
||||||
writer.write((dumps(d)+"\n").encode("utf-8"))
|
writer.write((dumps(d, ensure_ascii=False)+"\n").encode("utf-8"))
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
|
|
||||||
async def _open_socket_if_not_exists(self):
|
async def _open_socket_if_not_exists(self):
|
||||||
@@ -140,7 +140,7 @@ class PluginWrapper:
|
|||||||
return
|
return
|
||||||
async def _(self):
|
async def _(self):
|
||||||
if await self._open_socket_if_not_exists():
|
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()
|
await self.writer.drain()
|
||||||
self.writer.close()
|
self.writer.close()
|
||||||
get_event_loop().create_task(_(self))
|
get_event_loop().create_task(_(self))
|
||||||
@@ -151,7 +151,7 @@ class PluginWrapper:
|
|||||||
async with self.method_call_lock:
|
async with self.method_call_lock:
|
||||||
if await self._open_socket_if_not_exists():
|
if await self._open_socket_if_not_exists():
|
||||||
self.writer.write(
|
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()
|
await self.writer.drain()
|
||||||
line = bytearray()
|
line = bytearray()
|
||||||
while True:
|
while True:
|
||||||
|
|||||||
+4
-4
@@ -35,22 +35,22 @@ class SettingsManager:
|
|||||||
self.settings = {}
|
self.settings = {}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
open(self.path, "x")
|
open(self.path, "x", encoding="utf-8")
|
||||||
except FileExistsError as e:
|
except FileExistsError as e:
|
||||||
self.read()
|
self.read()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
try:
|
try:
|
||||||
with open(self.path, "r") as file:
|
with open(self.path, "r", encoding="utf-8") as file:
|
||||||
self.settings = load(file)
|
self.settings = load(file)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def commit(self):
|
def commit(self):
|
||||||
with open(self.path, "w+") as file:
|
with open(self.path, "w+", encoding="utf-8") as file:
|
||||||
dump(self.settings, file, indent=4)
|
dump(self.settings, file, indent=4, ensure_ascii=False)
|
||||||
|
|
||||||
def getSetting(self, key, default):
|
def getSetting(self, key, default):
|
||||||
return self.settings.get(key, default)
|
return self.settings.get(key, default)
|
||||||
|
|||||||
+4
-4
@@ -32,7 +32,7 @@ class Updater:
|
|||||||
self.allRemoteVers = None
|
self.allRemoteVers = None
|
||||||
try:
|
try:
|
||||||
logger.info(getcwd())
|
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", "")
|
self.localVer = version_file.readline().replace("\n", "")
|
||||||
except:
|
except:
|
||||||
self.localVer = False
|
self.localVer = False
|
||||||
@@ -159,10 +159,10 @@ class Updater:
|
|||||||
out.write(data)
|
out.write(data)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error at %s", exc_info=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_file.read()
|
||||||
service_data = service_data.replace("${HOMEBREW_FOLDER}", "/home/"+helpers.get_user()+"/homebrew")
|
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)
|
service_file.write(service_data)
|
||||||
|
|
||||||
logger.debug("Saved service file")
|
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))
|
self.context.loop.create_task(tab.evaluate_js(f"window.DeckyUpdater.updateProgress({new_progress})", False, False, False))
|
||||||
progress = new_progress
|
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)
|
out.write(version)
|
||||||
|
|
||||||
call(['chmod', '+x', path.join(getcwd(), "PluginLoader")])
|
call(['chmod', '+x', path.join(getcwd(), "PluginLoader")])
|
||||||
|
|||||||
Reference in New Issue
Block a user