Allow tests to find share folders when building .deb

This commit is contained in:
Micah Lee 2017-11-20 16:19:04 -08:00
parent 21e1dac2c3
commit d544a0341f
No known key found for this signature in database
GPG key ID: 403C2657CD994F73
3 changed files with 9 additions and 4 deletions

1
.gitignore vendored
View file

@ -27,6 +27,7 @@ pip-log.txt
.coverage .coverage
.tox .tox
nosetests.xml nosetests.xml
.cache
# Translations # Translations
*.mo *.mo

View file

@ -1,11 +1,12 @@
include LICENSE include LICENSE
include README.md include README.md
include BUILD.md include BUILD.md
include resources/* include share/*
include resources/images/* include share/images/*
include resources/locale/* include share/locale/*
include resources/html/* include share/html/*
include install/onionshare.desktop include install/onionshare.desktop
include install/onionshare.appdata.xml include install/onionshare.appdata.xml
include install/onionshare80.xpm include install/onionshare80.xpm
include install/scripts/onionshare-nautilus.py include install/scripts/onionshare-nautilus.py
include test/*.py

View file

@ -69,6 +69,9 @@ def get_resource_path(filename):
if getattr(sys, 'onionshare_dev_mode', False): if getattr(sys, 'onionshare_dev_mode', False):
# Look for resources directory relative to python file # Look for resources directory relative to python file
prefix = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))), 'share') prefix = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))), 'share')
if not os.path.exists(prefix):
# While running tests during stdeb bdist_deb, look 3 directories up for the share folder
prefix = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(prefix)))), 'share')
elif p == 'Linux' and sys.argv and sys.argv[0].startswith(sys.prefix): elif p == 'Linux' and sys.argv and sys.argv[0].startswith(sys.prefix):
# OnionShare is installed systemwide in Linux # OnionShare is installed systemwide in Linux