fixed data path on ubuntu

xkb
sezanzeb 4 years ago committed by sezanzeb
parent 6c2160ff4e
commit 6dd056541c

@ -30,6 +30,9 @@ import pkg_resources
from keymapper.logger import logger
logged = False
def get_data_path(filename=''):
"""Depending on the installation prefix, return the data dir.
@ -58,8 +61,10 @@ def get_data_path(filename=''):
'/usr/share/key-mapper'
]
print('source_path', source_path)
if '/site-packages' not in source_path:
global logged
data_path = None
# python3.8/dist-packages python3.7/site-packages, /usr/share, /usr/local/share, endless options
if '-packages' not in source_path and 'python' not in source_path:
# probably installed with -e, running from the cloned git source
data_path = os.path.join(source_path, 'data')
else:
@ -68,6 +73,12 @@ def get_data_path(filename=''):
if os.path.exists(candidate):
data_path = candidate
break
logger.error('Could not find the application data')
if data_path is None:
logger.error('Could not find the application data')
sys.exit(1)
if not logged:
logger.debug('Found data at "%s"', data_path)
logged = True
return os.path.join(data_path, filename)

Loading…
Cancel
Save