diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 291d8c77a..3b2a6d24f 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -36,6 +36,7 @@ import urlparse import errno import subprocess from collections import OrderedDict +from urllib import urlretrieve from moulinette.core import MoulinetteError from moulinette.utils.log import getActionLogger @@ -100,14 +101,13 @@ def app_fetchlist(url=None, name=None): raise MoulinetteError(errno.EINVAL, m18n.n('custom_appslist_name_required')) - list_file = '%s/%s.json' % (repo_path, name) - if os.system('wget "%s" -O "%s.tmp"' % (url, list_file)) != 0: - os.remove('%s.tmp' % list_file) + try: + urlretrieve(url, '%s/%s.json' % (repo_path, name)) + except Exception as e: + # I don't know how to put e into the MoulinetteError stuff + print e raise MoulinetteError(errno.EBADR, m18n.n('appslist_retrieve_error')) - # Rename fetched temp list - os.rename('%s.tmp' % list_file, list_file) - open("/etc/cron.d/yunohost-applist-%s" % name, "w").write('00 00 * * * root yunohost app fetchlist -u %s -n %s > /dev/null 2>&1\n' % (url, name)) logger.success(m18n.n('appslist_fetched'))