aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2015-06-16 14:30:09 -0700
committerMicah Lee <micah@micahflee.com>2015-06-16 14:30:09 -0700
commit19fac71a3ed5003516571e115975eceda2589c7d (patch)
tree6e3f59b5efa358c67a7aeaa197c6f558aa04a53b
parentba424fa4273a200a6f75c3328fd239be7aaa15db (diff)
downloadonionshare-19fac71a3ed5003516571e115975eceda2589c7d.tar.gz
onionshare-19fac71a3ed5003516571e115975eceda2589c7d.zip
figure out the osx_resource_dir only once, to fix issue with cli version in OSX
-rw-r--r--onionshare/helpers.py20
-rw-r--r--onionshare/strings.py2
-rw-r--r--onionshare_gui/common.py2
3 files changed, 10 insertions, 14 deletions
diff --git a/onionshare/helpers.py b/onionshare/helpers.py
index 23799137..8c30c2e2 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 221735be..fe4fc0e4 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 f3d0be5b..60212f0b 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)