diff --git a/plugins/Stats/StatsPlugin.py b/plugins/Stats/StatsPlugin.py
index 75a0d4c5..426d17fa 100644
--- a/plugins/Stats/StatsPlugin.py
+++ b/plugins/Stats/StatsPlugin.py
@@ -130,7 +130,7 @@ class UiRequestPlugin(object):
# Db
yield "
Db:
"
for db in sys.modules["Db.Db"].opened_dbs:
- yield "- %.3fs: %s
" % (time.time() - db.last_query_time, db.db_path)
+ yield "- %.3fs: %s
" % (time.time() - db.last_query_time, db.db_path.encode("utf8"))
# Sites
yield "
Sites:"
@@ -220,7 +220,7 @@ class UiRequestPlugin(object):
objs = [obj for obj in gc.get_objects() if isinstance(obj, greenlet)]
yield "
Greenlets (%s):
" % len(objs)
for obj in objs:
- yield " - %.1fkb: %s
" % (self.getObjSize(obj, hpy), cgi.escape(repr(obj)))
+ yield " - %.1fkb: %s
" % (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("
! Error: %s
" % 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:
diff --git a/plugins/Trayicon/TrayiconPlugin.py b/plugins/Trayicon/TrayiconPlugin.py
index 95ad4b50..a3da23ff 100644
--- a/plugins/Trayicon/TrayiconPlugin.py
+++ b/plugins/Trayicon/TrayiconPlugin.py
@@ -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"))
diff --git a/src/Config.py b/src/Config.py
index 9e8617fc..7259c4e5 100644
--- a/src/Config.py
+++ b/src/Config.py
@@ -10,7 +10,7 @@ class Config(object):
def __init__(self, argv):
self.version = "0.5.1"
- self.rev = 1830
+ self.rev = 1833
self.argv = argv
self.action = None
self.config_file = "zeronet.conf"
@@ -61,20 +61,22 @@ class Config(object):
else:
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
- 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
- start_dir = os.path.expanduser("~/Library/Application Support/ZeroNet")
+ start_dir = os.path.expanduser("~/Library/Application Support/ZeroNet").decode(sys.getfilesystemencoding())
else:
# 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"
data_dir = start_dir + "/data"
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
- 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"
data_dir = start_dir + "/data"
log_dir = start_dir + "/log"
diff --git a/src/Crypt/CryptConnection.py b/src/Crypt/CryptConnection.py
index 61d96acc..b30c7e49 100644
--- a/src/Crypt/CryptConnection.py
+++ b/src/Crypt/CryptConnection.py
@@ -70,13 +70,14 @@ class CryptConnectionManager:
return True # Files already exits
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(
- "%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"]
- ),
+ cmd.encode(sys.getfilesystemencoding()),
shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, env=self.openssl_env
)
back = proc.stdout.read().strip()
diff --git a/src/Site/SiteStorage.py b/src/Site/SiteStorage.py
index aaa35ae6..1c7b6151 100644
--- a/src/Site/SiteStorage.py
+++ b/src/Site/SiteStorage.py
@@ -19,8 +19,8 @@ from Plugin import PluginManager
class SiteStorage(object):
def __init__(self, site, allow_create=True):
self.site = site
- self.directory = "%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.directory = u"%s/%s" % (config.data_dir, self.site.address) # Site data diretory
+ self.allowed_dir = os.path.abspath(self.directory) # Only serve file within this dir
self.log = site.log
self.db = None # Db class
self.db_checked = False # Checked db tables since startup
diff --git a/src/Tor/TorManager.py b/src/Tor/TorManager.py
index 7816b280..08478f50 100644
--- a/src/Tor/TorManager.py
+++ b/src/Tor/TorManager.py
@@ -160,7 +160,7 @@ class TorManager:
res_protocol = self.send("PROTOCOLINFO", conn)
cookie_match = re.search('COOKIEFILE="(.*?)"', res_protocol)
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())
res_auth = self.send("AUTHENTICATE %s" % auth_hex, conn)
elif config.tor_password:
diff --git a/src/lib/opensslVerify/opensslVerify.py b/src/lib/opensslVerify/opensslVerify.py
index 1ad970e0..8c9bffe7 100644
--- a/src/lib/opensslVerify/opensslVerify.py
+++ b/src/lib/opensslVerify/opensslVerify.py
@@ -196,7 +196,7 @@ def openLibrary():
global ssl
try:
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":
dll_path = "/bin/cygcrypto-1.0.0.dll"
elif os.path.isfile("../lib/libcrypto.so"): # ZeroBundle OSX