mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-30 09:46:15 -05:00
Simplify get_resource_path
This commit is contained in:
parent
9bfde7dfcc
commit
3d13c1aa27
@ -34,19 +34,13 @@ def get_resource_path(filename):
|
|||||||
systemwide, and whether regardless of platform
|
systemwide, and whether regardless of platform
|
||||||
"""
|
"""
|
||||||
p = get_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
|
# 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')
|
resources_dir = os.path.join(sys.prefix, 'share/onionshare')
|
||||||
# Look for resources directory relative to python file
|
elif getattr(sys, 'frozen', False): # Check if app is "frozen" with pyinstaller
|
||||||
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
|
|
||||||
# https://pythonhosted.org/PyInstaller/#run-time-information
|
# https://pythonhosted.org/PyInstaller/#run-time-information
|
||||||
if getattr(sys, 'frozen', False):
|
|
||||||
resources_dir = sys._MEIPASS
|
resources_dir = sys._MEIPASS
|
||||||
else:
|
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')
|
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)
|
return os.path.join(resources_dir, filename)
|
||||||
|
Loading…
Reference in New Issue
Block a user