34
37
Support symlinks, and priorize local (relative) data/ dir.
36
39
module = os.path.dirname(__file__)
37
result = os.path.abspath(os.path.join(module, os.path.pardir,
38
os.path.pardir, 'data'))
40
local = os.path.abspath(os.path.join(module, os.path.pardir,
41
os.path.pardir, DATA_SUFFIX))
42
data_dirs = [local] + [os.path.join(p, 'ubuntuone-control-panel')
43
for p in xdg.BaseDirectory.xdg_data_dirs]
44
for result in data_dirs:
45
result = os.path.abspath(result)
46
logger.debug('get_data_dir: trying use data dir at %r (exists? %s)',
47
result, os.path.exists(result))
48
if os.path.exists(result):
49
logger.info('get_data_dir: returning dir located at %r.', result)
52
# try to load DATA_DIR from installation path
54
# pylint: disable=F0401, E0611
55
from ubuntuone.controlpanel.constants import DATA_DIR
58
msg = 'get_data_dir: can not build a valid data path. Giving up.' \
59
'__file__ is %r, data_dirs are %r, constants module unavailable.'
60
logger.error(msg, __file__, data_dirs)
42
63
def get_data_file(filename):