Rev1833, Fix utf8 system paths
This commit is contained in:
parent
6a46181e8e
commit
a0c3d7f8a6
7 changed files with 45 additions and 25 deletions
|
@ -130,7 +130,7 @@ class UiRequestPlugin(object):
|
|||
# Db
|
||||
yield "<br><br><b>Db</b>:<br>"
|
||||
for db in sys.modules["Db.Db"].opened_dbs:
|
||||
yield "- %.3fs: %s<br>" % (time.time() - db.last_query_time, db.db_path)
|
||||
yield "- %.3fs: %s<br>" % (time.time() - db.last_query_time, db.db_path.encode("utf8"))
|
||||
|
||||
# Sites
|
||||
yield "<br><br><b>Sites</b>:"
|
||||
|
@ -220,7 +220,7 @@ class UiRequestPlugin(object):
|
|||
objs = [obj for obj in gc.get_objects() if isinstance(obj, greenlet)]
|
||||
yield "<br>Greenlets (%s):<br>" % len(objs)
|
||||
for obj in objs:
|
||||
yield " - %.1fkb: %s<br>" % (self.getObjSize(obj, hpy), cgi.escape(repr(obj)))
|
||||
yield " - %.1fkb: %s<br>" % (self.getObjSize(obj, hpy), cgi.escape(repr(obj).encode("utf8")))
|
||||
|
||||
from Worker import Worker
|
||||
objs = [obj for obj in gc.get_objects() if isinstance(obj, Worker)]
|
||||
|
@ -401,7 +401,10 @@ class UiRequestPlugin(object):
|
|||
except Exception, err:
|
||||
output("<br><b>! Error: %s</b><br>" % err)
|
||||
taken = time.time() - s
|
||||
multipler = standard / taken
|
||||
if taken > 0:
|
||||
multipler = standard / taken
|
||||
else:
|
||||
multipler = 99
|
||||
if multipler < 0.3:
|
||||
speed = "Sloooow"
|
||||
elif multipler < 0.5:
|
||||
|
|
|
@ -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