mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] Fix app upgrade issue and handle errors in tools_upgrade
This commit is contained in:
parent
c018bb0710
commit
ce5be021d3
4 changed files with 16 additions and 5 deletions
2
app.py
2
app.py
|
@ -261,7 +261,7 @@ def app_map(app=None, raw=False, user=None):
|
|||
return result
|
||||
|
||||
|
||||
def app_upgrade(auth, app, url=None, file=None):
|
||||
def app_upgrade(auth, app=[], url=None, file=None):
|
||||
"""
|
||||
Upgrade app
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
"custom_app_url_required" : "You must provide an URL to upgrade your custom app {:s}",
|
||||
"app_recent_version_required" : "{:s} requires a more recent version of the moulinette",
|
||||
"app_upgraded" : "{:s} successfully upgraded",
|
||||
"app_upgrade_failed" : "Unable to upgrade all apps",
|
||||
"app_id_invalid" : "Invalid app id",
|
||||
"app_already_installed" : "{:s} is already installed",
|
||||
"app_removed" : "{:s} successfully removed",
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
"custom_app_url_required" : "Vous devez spécifier une URL pour mettre à jour votre application locale {:s}",
|
||||
"app_recent_version_required" : "{:s} nécessite une version plus récente de la moulinette",
|
||||
"app_upgraded" : "{:s} mis à jour avec succès",
|
||||
"app_upgrade_failed" : "Impossible de mettre à jour toutes les applications",
|
||||
"app_id_invalid" : "Id d'application incorrect",
|
||||
"app_already_installed" : "{:s} est déjà installé",
|
||||
"app_removed" : "{:s} supprimé avec succès",
|
||||
|
|
13
tools.py
13
tools.py
|
@ -31,6 +31,7 @@ import getpass
|
|||
import requests
|
||||
import json
|
||||
import errno
|
||||
import logging
|
||||
import apt
|
||||
import apt.progress
|
||||
|
||||
|
@ -416,6 +417,9 @@ def tools_upgrade(auth, ignore_apps=False, ignore_packages=False):
|
|||
"""
|
||||
from yunohost.app import app_upgrade
|
||||
|
||||
failure = False
|
||||
|
||||
# Retrieve interface
|
||||
is_api = True if msettings.get('interface') == 'api' else False
|
||||
|
||||
if not ignore_packages:
|
||||
|
@ -449,6 +453,7 @@ def tools_upgrade(auth, ignore_apps=False, ignore_packages=False):
|
|||
cache.commit(apt.progress.text.AcquireProgress(),
|
||||
apt.progress.base.InstallProgress())
|
||||
except Exception as e:
|
||||
failure = True
|
||||
logging.warning('unable to upgrade packages: %s' % str(e))
|
||||
msignals.display(m18n.n('packages_upgrade_failed'), 'error')
|
||||
else:
|
||||
|
@ -459,11 +464,15 @@ def tools_upgrade(auth, ignore_apps=False, ignore_packages=False):
|
|||
if not ignore_apps:
|
||||
try:
|
||||
app_upgrade(auth)
|
||||
except: pass
|
||||
except Exception as e:
|
||||
failure = True
|
||||
logging.warning('unable to upgrade apps: %s' % str(e))
|
||||
msignals.display(m18n.n('app_upgrade_failed'), 'error')
|
||||
|
||||
if not failure:
|
||||
msignals.display(m18n.n('system_upgraded'), 'success')
|
||||
|
||||
# Return API logs if it is an API call
|
||||
if msettings.get('interface') == 'api':
|
||||
if is_api:
|
||||
from yunohost.service import service_log
|
||||
return { "log": service_log('yunohost-api', number="100").values()[0] }
|
||||
|
|
Loading…
Add table
Reference in a new issue