comparison sat/core/constants.py @ 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 bf1b12a8f597
children 5b26033c49a8
comparison
equal deleted inserted replaced
2590:bd9d92bc0d6c 2591:86e57108bd50
171 ## Configuration ## 171 ## Configuration ##
172 if BaseDirectory: # skipped when xdg module is not available (should not happen in backend) 172 if BaseDirectory: # skipped when xdg module is not available (should not happen in backend)
173 if "org.goffi.cagou.cagou" in BaseDirectory.__file__: 173 if "org.goffi.cagou.cagou" in BaseDirectory.__file__:
174 # FIXME: hack to make config read from the right location on Android 174 # FIXME: hack to make config read from the right location on Android
175 # TODO: fix it in a more proper way 175 # TODO: fix it in a more proper way
176
177 # we need to use Android API to get downloads directory
178 import os.path
179 from jnius import autoclass
180 Environment = autoclass("android.os.Environment")
181
176 BaseDirectory = None 182 BaseDirectory = None
177 DEFAULT_CONFIG = { 183 DEFAULT_CONFIG = {
178 'local_dir': '/data/data/org.goffi.cagou.cagou/app', 184 'local_dir': '/data/data/org.goffi.cagou.cagou/app',
179 'media_dir': '/data/data/org.goffi.cagou.cagou/files/app/media', 185 'media_dir': '/data/data/org.goffi.cagou.cagou/files/app/media',
186 # FIXME: temporary location for downloads, need to call API properly
187 'downloads_dir': os.path.join(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath(), APP_NAME_FILE),
180 'pid_dir': '%(local_dir)s', 188 'pid_dir': '%(local_dir)s',
181 'log_dir': '%(local_dir)s', 189 'log_dir': '%(local_dir)s',
182 } 190 }
183 CONFIG_FILES = ['/data/data/org.goffi.cagou.cagou/files/app/android/' + APP_NAME_FILE + '.conf'] 191 CONFIG_FILES = ['/data/data/org.goffi.cagou.cagou/files/app/android/' + APP_NAME_FILE + '.conf']
184 else: 192 else:
185 193
186 ## Configuration ## 194 ## Configuration ##
187 DEFAULT_CONFIG = { 195 DEFAULT_CONFIG = {
188 'media_dir': '/usr/share/' + APP_NAME_FILE + '/media', 196 'media_dir': '/usr/share/' + APP_NAME_FILE + '/media',
189 'local_dir': BaseDirectory.save_data_path(APP_NAME_FILE), 197 'local_dir': BaseDirectory.save_data_path(APP_NAME_FILE),
198 'downloads_dir': '~/Downloads/' + APP_NAME_FILE,
190 'pid_dir': '%(local_dir)s', 199 'pid_dir': '%(local_dir)s',
191 'log_dir': '%(local_dir)s', 200 'log_dir': '%(local_dir)s',
192 } 201 }
193 202
194 # List of the configuration filenames sorted by ascending priority 203 # List of the configuration filenames sorted by ascending priority