From fca1033f83e9b82e94733e1e7452bf88f61cc377 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Thu, 20 Feb 2020 17:18:59 +0100 Subject: [PATCH] Fix trayicon auto start script write/read with utf8 path --- plugins/Trayicon/TrayiconPlugin.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/Trayicon/TrayiconPlugin.py b/plugins/Trayicon/TrayiconPlugin.py index e9b12a26..622f742a 100644 --- a/plugins/Trayicon/TrayiconPlugin.py +++ b/plugins/Trayicon/TrayiconPlugin.py @@ -140,17 +140,17 @@ class ActionsPlugin(object): cmd = cmd.replace("start.py", "zeronet.py").replace('"--open_browser"', "").replace('"default_browser"', "").strip() cmd += ' --open_browser ""' - return """ - @echo off - chcp 65001 > nul - set PYTHONIOENCODING=utf-8 - cd /D \"%s\" - start "" %s - """ % (cwd, cmd) + return "\r\n".join([ + '@echo off', + 'chcp 65001 > nul', + 'set PYTHONIOENCODING=utf-8', + 'cd /D \"%s\"' % cwd, + 'start "" %s' % cmd + ]) def isAutorunEnabled(self): path = self.getAutorunPath() - return os.path.isfile(path) and open(path).read() == self.formatAutorun() + return os.path.isfile(path) and open(path, "rb").read().decode("utf8") == self.formatAutorun() def titleAutorun(self): translate = _["Start ZeroNet when Windows starts"] @@ -163,4 +163,4 @@ class ActionsPlugin(object): if self.isAutorunEnabled(): os.unlink(self.getAutorunPath()) else: - open(self.getAutorunPath(), "w").write(self.formatAutorun()) + open(self.getAutorunPath(), "wb").write(self.formatAutorun().encode("utf8"))