Fix trayicon auto start script write/read with utf8 path

This commit is contained in:
shortcutme 2020-02-20 17:18:59 +01:00
parent 32855d0479
commit fca1033f83
No known key found for this signature in database
GPG Key ID: 5B63BAE6CB9613AE
1 changed files with 9 additions and 9 deletions

View File

@ -140,17 +140,17 @@ class ActionsPlugin(object):
cmd = cmd.replace("start.py", "zeronet.py").replace('"--open_browser"', "").replace('"default_browser"', "").strip() cmd = cmd.replace("start.py", "zeronet.py").replace('"--open_browser"', "").replace('"default_browser"', "").strip()
cmd += ' --open_browser ""' cmd += ' --open_browser ""'
return """ return "\r\n".join([
@echo off '@echo off',
chcp 65001 > nul 'chcp 65001 > nul',
set PYTHONIOENCODING=utf-8 'set PYTHONIOENCODING=utf-8',
cd /D \"%s\" 'cd /D \"%s\"' % cwd,
start "" %s 'start "" %s' % cmd
""" % (cwd, cmd) ])
def isAutorunEnabled(self): def isAutorunEnabled(self):
path = self.getAutorunPath() 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): def titleAutorun(self):
translate = _["Start ZeroNet when Windows starts"] translate = _["Start ZeroNet when Windows starts"]
@ -163,4 +163,4 @@ class ActionsPlugin(object):
if self.isAutorunEnabled(): if self.isAutorunEnabled():
os.unlink(self.getAutorunPath()) os.unlink(self.getAutorunPath())
else: else:
open(self.getAutorunPath(), "w").write(self.formatAutorun()) open(self.getAutorunPath(), "wb").write(self.formatAutorun().encode("utf8"))