figure out the osx_resource_dir only once, to fix issue with cli version in OSX

This commit is contained in:
Micah Lee 2015-06-16 14:30:09 -07:00
parent ba424fa427
commit 19fac71a3e
3 changed files with 10 additions and 14 deletions

View file

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

View file

@ -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')

View file

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