[Pkg-privacy-commits] [onionshare] 26/33: figure out the osx_resource_dir only once, to fix issue with cli version in OSX

Ximin Luo infinity0 at debian.org
Mon Oct 19 14:15:43 UTC 2015


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

infinity0 pushed a commit to branch debian
in repository onionshare.

commit 19fac71a3ed5003516571e115975eceda2589c7d
Author: Micah Lee <micah at micahflee.com>
Date:   Tue Jun 16 14:30:09 2015 -0700

    figure out the osx_resource_dir only once, to fix issue with cli version in OSX
---
 onionshare/helpers.py    | 20 ++++++++------------
 onionshare/strings.py    |  2 +-
 onionshare_gui/common.py |  2 +-
 3 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/onionshare/helpers.py b/onionshare/helpers.py
index 2379913..8c30c2e 100644
--- a/onionshare/helpers.py
+++ b/onionshare/helpers.py
@@ -32,6 +32,13 @@ def get_platform():
         p = 'Tails'
     return p
 
+if get_platform() == 'Darwin':
+    # this is hacky, but it ultimate ends up returning the absolute path to
+    # OnionShare.app/Contents/Resources, based on the location of helpers.py
+    helpers_path = os.path.realpath(os.path.abspath(inspect.getfile(inspect.currentframe())))
+    osx_resources_dir = os.path.dirname(os.path.dirname(helpers_path))
+else:
+    osx_resources_dir = None
 
 def get_onionshare_dir():
     if get_platform() == 'Darwin':
@@ -40,21 +47,10 @@ def get_onionshare_dir():
         onionshare_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
     return onionshare_dir
 
-
-def get_osx_resources_dir():
-    if get_platform() == 'Darwin':
-        # this is hacky, but it ultimate ends up returning the absolute path to
-        # OnionShare.app/Contents/Resources, based on the location of helpers.py
-        helpers_path = os.path.realpath(os.path.abspath(inspect.getfile(inspect.currentframe())))
-        osx_resources_dir = os.path.dirname(os.path.dirname(helpers_path))
-        return osx_resources_dir
-
-    return None
-
 def get_html_path(filename):
     p = platform.system()
     if p == 'Darwin':
-        prefix = os.path.join(get_osx_resources_dir(), 'html')
+        prefix = os.path.join(osx_resources_dir, 'html')
     else:
         prefix = get_onionshare_dir()
     return os.path.join(prefix, filename)
diff --git a/onionshare/strings.py b/onionshare/strings.py
index 221735b..fe4fc0e 100644
--- a/onionshare/strings.py
+++ b/onionshare/strings.py
@@ -31,7 +31,7 @@ def load_strings(default="en"):
     if p == 'Linux' or p == 'Tails':
         locale_dir = os.path.join(sys.prefix, 'share/onionshare/locale')
     elif p == 'Darwin':
-        locale_dir = os.path.join(helpers.get_osx_resources_dir(), 'locale')
+        locale_dir = os.path.join(helpers.osx_resources_dir, 'locale')
     else:
         locale_dir = os.path.join(os.path.dirname(helpers.get_onionshare_dir()), 'locale')
 
diff --git a/onionshare_gui/common.py b/onionshare_gui/common.py
index f3d0be5..60212f0 100644
--- a/onionshare_gui/common.py
+++ b/onionshare_gui/common.py
@@ -36,7 +36,7 @@ def get_image_path(filename):
     if p == 'Linux' or p == 'Tails':
         prefix = os.path.join(sys.prefix, 'share/onionshare/images')
     elif p == 'Darwin':
-        prefix = os.path.join(helpers.get_osx_resources_dir(), 'images')
+        prefix = os.path.join(helpers.osx_resources_dir, 'images')
     else:
         prefix = os.path.join(os.path.dirname(get_onionshare_gui_dir()), 'images')
     return os.path.join(prefix, filename)

-- 
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