Mercurial > libervia-backend
changeset 2591:86e57108bd50
core (constants): new downloads_dir config option (default path where files can be downloaded):
use Android API to find downloads_dir on this platform
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 25 May 2018 10:51:59 +0200 |
parents | bd9d92bc0d6c |
children | c0401a72cbb4 |
files | sat/core/constants.py |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/sat/core/constants.py Tue May 22 10:07:33 2018 +0200 +++ b/sat/core/constants.py Fri May 25 10:51:59 2018 +0200 @@ -173,10 +173,18 @@ if "org.goffi.cagou.cagou" in BaseDirectory.__file__: # FIXME: hack to make config read from the right location on Android # TODO: fix it in a more proper way + + # we need to use Android API to get downloads directory + import os.path + from jnius import autoclass + Environment = autoclass("android.os.Environment") + BaseDirectory = None DEFAULT_CONFIG = { 'local_dir': '/data/data/org.goffi.cagou.cagou/app', 'media_dir': '/data/data/org.goffi.cagou.cagou/files/app/media', + # FIXME: temporary location for downloads, need to call API properly + 'downloads_dir': os.path.join(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath(), APP_NAME_FILE), 'pid_dir': '%(local_dir)s', 'log_dir': '%(local_dir)s', } @@ -187,6 +195,7 @@ DEFAULT_CONFIG = { 'media_dir': '/usr/share/' + APP_NAME_FILE + '/media', 'local_dir': BaseDirectory.save_data_path(APP_NAME_FILE), + 'downloads_dir': '~/Downloads/' + APP_NAME_FILE, 'pid_dir': '%(local_dir)s', 'log_dir': '%(local_dir)s', }