Rev1833, Fix utf8 system paths
This commit is contained in:
parent
6a46181e8e
commit
a0c3d7f8a6
7 changed files with 45 additions and 25 deletions
|
@ -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"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue