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
|
# Db
|
||||||
yield "<br><br><b>Db</b>:<br>"
|
yield "<br><br><b>Db</b>:<br>"
|
||||||
for db in sys.modules["Db.Db"].opened_dbs:
|
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
|
# Sites
|
||||||
yield "<br><br><b>Sites</b>:"
|
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)]
|
objs = [obj for obj in gc.get_objects() if isinstance(obj, greenlet)]
|
||||||
yield "<br>Greenlets (%s):<br>" % len(objs)
|
yield "<br>Greenlets (%s):<br>" % len(objs)
|
||||||
for obj in 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
|
from Worker import Worker
|
||||||
objs = [obj for obj in gc.get_objects() if isinstance(obj, Worker)]
|
objs = [obj for obj in gc.get_objects() if isinstance(obj, Worker)]
|
||||||
|
@ -401,7 +401,10 @@ class UiRequestPlugin(object):
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
output("<br><b>! Error: %s</b><br>" % err)
|
output("<br><b>! Error: %s</b><br>" % err)
|
||||||
taken = time.time() - s
|
taken = time.time() - s
|
||||||
multipler = standard / taken
|
if taken > 0:
|
||||||
|
multipler = standard / taken
|
||||||
|
else:
|
||||||
|
multipler = 99
|
||||||
if multipler < 0.3:
|
if multipler < 0.3:
|
||||||
speed = "Sloooow"
|
speed = "Sloooow"
|
||||||
elif multipler < 0.5:
|
elif multipler < 0.5:
|
||||||
|
|
|
@ -118,19 +118,33 @@ class ActionsPlugin(object):
|
||||||
|
|
||||||
def formatAutorun(self):
|
def formatAutorun(self):
|
||||||
args = sys.argv[:]
|
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':
|
if sys.platform == 'win32':
|
||||||
args = ['"%s"' % arg for arg in args]
|
args = ['"%s"' % arg for arg in args if arg]
|
||||||
cmd = " ".join(args)
|
cmd = " ".join(args)
|
||||||
|
|
||||||
# Dont open browser on autorun
|
# Dont open browser on autorun
|
||||||
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 = 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):
|
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).read().decode("utf8") == self.formatAutorun()
|
||||||
|
|
||||||
def titleAutorun(self):
|
def titleAutorun(self):
|
||||||
translate = _["Start ZeroNet when Windows starts"]
|
translate = _["Start ZeroNet when Windows starts"]
|
||||||
|
@ -143,4 +157,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(), "w").write(self.formatAutorun().encode("utf8"))
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Config(object):
|
||||||
|
|
||||||
def __init__(self, argv):
|
def __init__(self, argv):
|
||||||
self.version = "0.5.1"
|
self.version = "0.5.1"
|
||||||
self.rev = 1830
|
self.rev = 1833
|
||||||
self.argv = argv
|
self.argv = argv
|
||||||
self.action = None
|
self.action = None
|
||||||
self.config_file = "zeronet.conf"
|
self.config_file = "zeronet.conf"
|
||||||
|
@ -61,20 +61,22 @@ class Config(object):
|
||||||
else:
|
else:
|
||||||
fix_float_decimals = False
|
fix_float_decimals = False
|
||||||
|
|
||||||
if __file__.endswith("/Contents/Resources/core/src/Config.py"):
|
this_file = os.path.abspath(__file__).replace("\\", "/")
|
||||||
|
|
||||||
|
if this_file.endswith("/Contents/Resources/core/src/Config.py"):
|
||||||
# Running as ZeroNet.app
|
# Running as ZeroNet.app
|
||||||
if __file__.startswith("/Application") or __file__.startswith("/private"):
|
if this_file.startswith("/Application") or this_file.startswith("/private"):
|
||||||
# Runnig from non-writeable directory, put data to Application Support
|
# Runnig from non-writeable directory, put data to Application Support
|
||||||
start_dir = os.path.expanduser("~/Library/Application Support/ZeroNet")
|
start_dir = os.path.expanduser("~/Library/Application Support/ZeroNet").decode(sys.getfilesystemencoding())
|
||||||
else:
|
else:
|
||||||
# Running from writeable directory put data next to .app
|
# Running from writeable directory put data next to .app
|
||||||
start_dir = re.sub("/[^/]+/Contents/Resources/core/src/Config.py", "", __file__)
|
start_dir = re.sub("/[^/]+/Contents/Resources/core/src/Config.py", "", this_file).decode(sys.getfilesystemencoding())
|
||||||
config_file = start_dir + "/zeronet.conf"
|
config_file = start_dir + "/zeronet.conf"
|
||||||
data_dir = start_dir + "/data"
|
data_dir = start_dir + "/data"
|
||||||
log_dir = start_dir + "/log"
|
log_dir = start_dir + "/log"
|
||||||
elif __file__.replace("\\", "/").endswith("/core/src/Config.py"):
|
elif this_file.endswith("/core/src/Config.py"):
|
||||||
# Running as exe or source is at Application Support directory, put var files to outside of core dir
|
# Running as exe or source is at Application Support directory, put var files to outside of core dir
|
||||||
start_dir = __file__.replace("/core/src/Config.py", "")
|
start_dir = this_file.replace("/core/src/Config.py", "").decode(sys.getfilesystemencoding())
|
||||||
config_file = start_dir + "/zeronet.conf"
|
config_file = start_dir + "/zeronet.conf"
|
||||||
data_dir = start_dir + "/data"
|
data_dir = start_dir + "/data"
|
||||||
log_dir = start_dir + "/log"
|
log_dir = start_dir + "/log"
|
||||||
|
|
|
@ -70,13 +70,14 @@ class CryptConnectionManager:
|
||||||
return True # Files already exits
|
return True # Files already exits
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
cmd = "%s req -x509 -newkey rsa:2048 -sha256 -batch -keyout %s -out %s -nodes -config %s" % helper.shellquote(
|
||||||
|
self.openssl_bin,
|
||||||
|
config.data_dir+"/key-rsa.pem",
|
||||||
|
config.data_dir+"/cert-rsa.pem",
|
||||||
|
self.openssl_env["OPENSSL_CONF"]
|
||||||
|
)
|
||||||
proc = subprocess.Popen(
|
proc = subprocess.Popen(
|
||||||
"%s req -x509 -newkey rsa:2048 -sha256 -batch -keyout %s -out %s -nodes -config %s" % helper.shellquote(
|
cmd.encode(sys.getfilesystemencoding()),
|
||||||
self.openssl_bin,
|
|
||||||
config.data_dir+"/key-rsa.pem",
|
|
||||||
config.data_dir+"/cert-rsa.pem",
|
|
||||||
self.openssl_env["OPENSSL_CONF"]
|
|
||||||
),
|
|
||||||
shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, env=self.openssl_env
|
shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, env=self.openssl_env
|
||||||
)
|
)
|
||||||
back = proc.stdout.read().strip()
|
back = proc.stdout.read().strip()
|
||||||
|
|
|
@ -19,8 +19,8 @@ from Plugin import PluginManager
|
||||||
class SiteStorage(object):
|
class SiteStorage(object):
|
||||||
def __init__(self, site, allow_create=True):
|
def __init__(self, site, allow_create=True):
|
||||||
self.site = site
|
self.site = site
|
||||||
self.directory = "%s/%s" % (config.data_dir, self.site.address) # Site data diretory
|
self.directory = u"%s/%s" % (config.data_dir, self.site.address) # Site data diretory
|
||||||
self.allowed_dir = os.path.abspath(self.directory.decode(sys.getfilesystemencoding())) # Only serve file within this dir
|
self.allowed_dir = os.path.abspath(self.directory) # Only serve file within this dir
|
||||||
self.log = site.log
|
self.log = site.log
|
||||||
self.db = None # Db class
|
self.db = None # Db class
|
||||||
self.db_checked = False # Checked db tables since startup
|
self.db_checked = False # Checked db tables since startup
|
||||||
|
|
|
@ -160,7 +160,7 @@ class TorManager:
|
||||||
res_protocol = self.send("PROTOCOLINFO", conn)
|
res_protocol = self.send("PROTOCOLINFO", conn)
|
||||||
cookie_match = re.search('COOKIEFILE="(.*?)"', res_protocol)
|
cookie_match = re.search('COOKIEFILE="(.*?)"', res_protocol)
|
||||||
if cookie_match:
|
if cookie_match:
|
||||||
cookie_file = cookie_match.group(1)
|
cookie_file = cookie_match.group(1).decode("string-escape")
|
||||||
auth_hex = binascii.b2a_hex(open(cookie_file, "rb").read())
|
auth_hex = binascii.b2a_hex(open(cookie_file, "rb").read())
|
||||||
res_auth = self.send("AUTHENTICATE %s" % auth_hex, conn)
|
res_auth = self.send("AUTHENTICATE %s" % auth_hex, conn)
|
||||||
elif config.tor_password:
|
elif config.tor_password:
|
||||||
|
|
|
@ -196,7 +196,7 @@ def openLibrary():
|
||||||
global ssl
|
global ssl
|
||||||
try:
|
try:
|
||||||
if sys.platform.startswith("win"):
|
if sys.platform.startswith("win"):
|
||||||
dll_path = os.path.dirname(__file__) + "/" + "libeay32.dll"
|
dll_path = os.path.dirname(os.path.abspath(__file__)) + "/" + "libeay32.dll"
|
||||||
elif sys.platform == "cygwin":
|
elif sys.platform == "cygwin":
|
||||||
dll_path = "/bin/cygcrypto-1.0.0.dll"
|
dll_path = "/bin/cygcrypto-1.0.0.dll"
|
||||||
elif os.path.isfile("../lib/libcrypto.so"): # ZeroBundle OSX
|
elif os.path.isfile("../lib/libcrypto.so"): # ZeroBundle OSX
|
||||||
|
|
Loading…
Reference in a new issue