Rev1833, Fix utf8 system paths

This commit is contained in:
shortcutme 2017-01-22 21:22:53 +01:00
parent 6a46181e8e
commit a0c3d7f8a6
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
7 changed files with 45 additions and 25 deletions

View file

@ -118,19 +118,33 @@ class ActionsPlugin(object):
def formatAutorun(self):
args = sys.argv[:]
args.insert(0, sys.executable)
if not getattr(sys, 'frozen', False): # Not frozen
args.insert(0, sys.executable)
cwd = os.getcwd().decode(sys.getfilesystemencoding())
else:
cwd = os.path.dirname(sys.executable).decode(sys.getfilesystemencoding())
if sys.platform == 'win32':
args = ['"%s"' % arg for arg in args]
args = ['"%s"' % arg for arg in args if arg]
cmd = " ".join(args)
# Dont open browser on autorun
cmd = cmd.replace("start.py", "zeronet.py").replace('"--open_browser"', "").replace('"default_browser"', "").strip()
cmd += ' --open_browser ""'
cmd = cmd.decode(sys.getfilesystemencoding())
return "@echo off\ncd /D %s\n%s" % (os.getcwd(), cmd)
return u"""
@echo off
chcp 65001
set PYTHONIOENCODING=utf-8
cd /D \"%s\"
%s
""" % (cwd, 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).read().decode("utf8") == self.formatAutorun()
def titleAutorun(self):
translate = _["Start ZeroNet when Windows starts"]
@ -143,4 +157,4 @@ class ActionsPlugin(object):
if self.isAutorunEnabled():
os.unlink(self.getAutorunPath())
else:
open(self.getAutorunPath(), "w").write(self.formatAutorun())
open(self.getAutorunPath(), "w").write(self.formatAutorun().encode("utf8"))