[Pkg-privacy-commits] [onionshare] 47/66: Make helpers.get_pyinstaller_resource_path work when package is not frozen, and make tests report real platform to get accurate paths

Ulrike Uhlig u-guest at moszumanska.debian.org
Wed Apr 13 22:17:51 UTC 2016


This is an automated email from the git hooks/post-receive script.

u-guest pushed a commit to branch master
in repository onionshare.

commit e8ce6b1c54854ce4c95fb173105a64c3e37e423f
Author: Micah Lee <micah at micahflee.com>
Date:   Tue Apr 12 10:43:28 2016 -0700

    Make helpers.get_pyinstaller_resource_path work when package is not frozen, and make tests report real platform to get accurate paths
---
 onionshare/helpers.py           | 15 +++++++++------
 test/onionshare_helpers_test.py |  2 ++
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/onionshare/helpers.py b/onionshare/helpers.py
index cb77dd4..977ae37 100644
--- a/onionshare/helpers.py
+++ b/onionshare/helpers.py
@@ -36,13 +36,16 @@ def get_pyinstaller_resource_path(filename):
     """
     Returns the path a resource file in a frozen PyInstall app
     """
-    # Resource path from frozen PyInstaller app
+    # Check if app is "frozen" with pyinstaller
     # https://pythonhosted.org/PyInstaller/#run-time-information
-    p = get_platform()
-    if p == 'Darwin':
-        return os.path.join(os.path.join(os.path.dirname(sys._MEIPASS), 'Resources'), filename)
-    elif p == 'Windows':
-        return os.path.join(sys._MEIPASS, filename)
+    if getattr(sys, 'frozen', False):
+        p = get_platform()
+        if p == 'Darwin':
+            return os.path.join(os.path.join(os.path.dirname(sys._MEIPASS), 'Resources'), filename)
+        elif p == 'Windows':
+            return os.path.join(sys._MEIPASS, filename)
+    else:
+        return os.path.join(os.path.dirname(os.path.dirname(__file__)), filename)
 
 def get_html_path(filename):
     """
diff --git a/test/onionshare_helpers_test.py b/test/onionshare_helpers_test.py
index 3e182d0..b5c16ff 100644
--- a/test/onionshare_helpers_test.py
+++ b/test/onionshare_helpers_test.py
@@ -23,5 +23,7 @@ import test_helpers
 
 def test_get_platform_returns_platform_system():
     """get_platform() returns platform.system() when ONIONSHARE_PLATFORM is not defined"""
+    p = helpers.platform.system
     helpers.platform.system = lambda: 'Sega Saturn'
     assert helpers.get_platform() == 'Sega Saturn'
+    helpers.platform.system = p

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionshare.git



More information about the Pkg-privacy-commits mailing list