summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2016-06-10 17:13:50 -0700
committerGitHub <noreply@github.com>2016-06-10 17:13:50 -0700
commit7073c207b8a165d51792ca0c80d01a4af72842fe (patch)
treebb818bf887e929fe788335a17cc8771dc4df2e00
parent9bfde7dfcc317e516dc6f03724c40d35baa45970 (diff)
parent3d13c1aa27536f967fe13330422373928660273e (diff)
downloadonionshare-7073c207b8a165d51792ca0c80d01a4af72842fe.tar.gz
onionshare-7073c207b8a165d51792ca0c80d01a4af72842fe.zip
Merge pull request #277 from jvoisin/simplify_get_resource_path
Simplify get_resource_path
-rw-r--r--onionshare/helpers.py18
1 files changed, 6 insertions, 12 deletions
diff --git a/onionshare/helpers.py b/onionshare/helpers.py
index ae58488a..f91543db 100644
--- a/onionshare/helpers.py
+++ b/onionshare/helpers.py
@@ -34,20 +34,14 @@ def get_resource_path(filename):
systemwide, and whether regardless of platform
"""
p = get_platform()
- if p == 'Linux':
+ if p == 'Linux' and sys.argv and sys.argv[0].startswith('/usr/bin/onionshare'):
# OnionShare is installed systemwide in Linux
- if len(sys.argv) > 0 and sys.argv[0].startswith('/usr/bin/onionshare'):
- resources_dir = os.path.join(sys.prefix, 'share/onionshare')
- # Look for resources directory relative to python file
- else:
- resources_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))), 'resources')
- else:
- # Check if app is "frozen" with pyinstaller
+ resources_dir = os.path.join(sys.prefix, 'share/onionshare')
+ elif getattr(sys, 'frozen', False): # Check if app is "frozen" with pyinstaller
# https://pythonhosted.org/PyInstaller/#run-time-information
- if getattr(sys, 'frozen', False):
- resources_dir = sys._MEIPASS
- else:
- resources_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))), 'resources')
+ resources_dir = sys._MEIPASS
+ else: # Look for resources directory relative to python file
+ resources_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))), 'resources')
return os.path.join(resources_dir, filename)