From a20213f1e834b88646f43ba54b31404f1869bf52 Mon Sep 17 00:00:00 2001 From: "Grant T. Olson" Date: Fri, 23 Aug 2013 13:20:07 -0400 Subject: [PATCH 1/3] Use fast PoW unless we're explicitly a frozen (binary) version of the code --- src/proofofwork.py | 4 ++-- src/shared.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/proofofwork.py b/src/proofofwork.py index f2c32c06..2238eaec 100644 --- a/src/proofofwork.py +++ b/src/proofofwork.py @@ -4,7 +4,7 @@ import hashlib from struct import unpack, pack import sys -from shared import config +from shared import config, frozen #import os def _set_idle(): @@ -71,7 +71,7 @@ def _doFastPoW(target, initialHash): time.sleep(0.2) def run(target, initialHash): - if 'linux' in sys.platform: + if not frozen: return _doFastPoW(target, initialHash) else: return _doSafePoW(target, initialHash) diff --git a/src/shared.py b/src/shared.py index d2b82d11..13d57445 100644 --- a/src/shared.py +++ b/src/shared.py @@ -74,6 +74,11 @@ networkDefaultPayloadLengthExtraBytes = 14000 #To make sending short messages a # namecoin integration to "namecoind". namecoinDefaultRpcPort = "8336" +# When using py2exe or py2app, the variable frozen is added to the sys +# namespace. This can be used to setup a different code path for +# binary distributions vs source distributions. +frozen = getattr(sys,'frozen', None) + def isInSqlInventory(hash): t = (hash,) shared.sqlLock.acquire() From bd489408c71e68430d7d73fcced20c9edd75ca90 Mon Sep 17 00:00:00 2001 From: "Grant T. Olson" Date: Fri, 23 Aug 2013 16:10:57 -0400 Subject: [PATCH 2/3] Actually OSX app maded with py2app can parallelize just fine --- src/proofofwork.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proofofwork.py b/src/proofofwork.py index 2238eaec..946d125a 100644 --- a/src/proofofwork.py +++ b/src/proofofwork.py @@ -71,7 +71,7 @@ def _doFastPoW(target, initialHash): time.sleep(0.2) def run(target, initialHash): - if not frozen: + if frozen == "macosx_app" or not frozen: return _doFastPoW(target, initialHash) else: return _doSafePoW(target, initialHash) From 732d7c999aa968456f819cb83ef6d978992b8a19 Mon Sep 17 00:00:00 2001 From: "Grant T. Olson" Date: Mon, 26 Aug 2013 08:44:15 -0400 Subject: [PATCH 3/3] Allow specification of alternate settings dir via BITMESSAGE_HOME --- src/shared.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/shared.py b/src/shared.py index fb19da26..e39121d2 100644 --- a/src/shared.py +++ b/src/shared.py @@ -126,7 +126,11 @@ def assembleVersionMessage(remoteHost, remotePort, myStreamNumber): def lookupAppdataFolder(): APPNAME = "PyBitmessage" from os import path, environ - if sys.platform == 'darwin': + if "BITMESSAGE_HOME" in environ: + dataFolder = environ["BITMESSAGE_HOME"] + if dataFolder[-1] not in [os.path.sep, os.path.altsep]: + dataFolder += os.path.sep + elif sys.platform == 'darwin': if "HOME" in environ: dataFolder = path.join(os.environ["HOME"], "Library/Application Support/", APPNAME) + '/' else: