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
|
return result
|
||||||
|
|
||||||
|
|
||||||
def app_upgrade(auth, app, url=None, file=None):
|
def app_upgrade(auth, app=[], url=None, file=None):
|
||||||
"""
|
"""
|
||||||
Upgrade app
|
Upgrade app
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
"custom_app_url_required" : "You must provide an URL to upgrade your custom app {:s}",
|
"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_recent_version_required" : "{:s} requires a more recent version of the moulinette",
|
||||||
"app_upgraded" : "{:s} successfully upgraded",
|
"app_upgraded" : "{:s} successfully upgraded",
|
||||||
|
"app_upgrade_failed" : "Unable to upgrade all apps",
|
||||||
"app_id_invalid" : "Invalid app id",
|
"app_id_invalid" : "Invalid app id",
|
||||||
"app_already_installed" : "{:s} is already installed",
|
"app_already_installed" : "{:s} is already installed",
|
||||||
"app_removed" : "{:s} successfully removed",
|
"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}",
|
"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_recent_version_required" : "{:s} nécessite une version plus récente de la moulinette",
|
||||||
"app_upgraded" : "{:s} mis à jour avec succès",
|
"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_id_invalid" : "Id d'application incorrect",
|
||||||
"app_already_installed" : "{:s} est déjà installé",
|
"app_already_installed" : "{:s} est déjà installé",
|
||||||
"app_removed" : "{:s} supprimé avec succès",
|
"app_removed" : "{:s} supprimé avec succès",
|
||||||
|
|
17
tools.py
17
tools.py
|
@ -31,6 +31,7 @@ import getpass
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
import errno
|
import errno
|
||||||
|
import logging
|
||||||
import apt
|
import apt
|
||||||
import apt.progress
|
import apt.progress
|
||||||
|
|
||||||
|
@ -330,7 +331,7 @@ def tools_postinstall(domain, password, dyndns=False):
|
||||||
|
|
||||||
# Enable iptables at boot time
|
# Enable iptables at boot time
|
||||||
os.system('update-rc.d yunohost-firewall defaults')
|
os.system('update-rc.d yunohost-firewall defaults')
|
||||||
|
|
||||||
os.system('touch /etc/yunohost/installed')
|
os.system('touch /etc/yunohost/installed')
|
||||||
|
|
||||||
msignals.display(m18n.n('yunohost_configured'), 'success')
|
msignals.display(m18n.n('yunohost_configured'), 'success')
|
||||||
|
@ -416,6 +417,9 @@ def tools_upgrade(auth, ignore_apps=False, ignore_packages=False):
|
||||||
"""
|
"""
|
||||||
from yunohost.app import app_upgrade
|
from yunohost.app import app_upgrade
|
||||||
|
|
||||||
|
failure = False
|
||||||
|
|
||||||
|
# Retrieve interface
|
||||||
is_api = True if msettings.get('interface') == 'api' else False
|
is_api = True if msettings.get('interface') == 'api' else False
|
||||||
|
|
||||||
if not ignore_packages:
|
if not ignore_packages:
|
||||||
|
@ -449,6 +453,7 @@ def tools_upgrade(auth, ignore_apps=False, ignore_packages=False):
|
||||||
cache.commit(apt.progress.text.AcquireProgress(),
|
cache.commit(apt.progress.text.AcquireProgress(),
|
||||||
apt.progress.base.InstallProgress())
|
apt.progress.base.InstallProgress())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
failure = True
|
||||||
logging.warning('unable to upgrade packages: %s' % str(e))
|
logging.warning('unable to upgrade packages: %s' % str(e))
|
||||||
msignals.display(m18n.n('packages_upgrade_failed'), 'error')
|
msignals.display(m18n.n('packages_upgrade_failed'), 'error')
|
||||||
else:
|
else:
|
||||||
|
@ -459,11 +464,15 @@ def tools_upgrade(auth, ignore_apps=False, ignore_packages=False):
|
||||||
if not ignore_apps:
|
if not ignore_apps:
|
||||||
try:
|
try:
|
||||||
app_upgrade(auth)
|
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')
|
||||||
|
|
||||||
msignals.display(m18n.n('system_upgraded'), 'success')
|
if not failure:
|
||||||
|
msignals.display(m18n.n('system_upgraded'), 'success')
|
||||||
|
|
||||||
# Return API logs if it is an API call
|
# Return API logs if it is an API call
|
||||||
if msettings.get('interface') == 'api':
|
if is_api:
|
||||||
from yunohost.service import service_log
|
from yunohost.service import service_log
|
||||||
return { "log": service_log('yunohost-api', number="100").values()[0] }
|
return { "log": service_log('yunohost-api', number="100").values()[0] }
|
||||||
|
|
Loading…
Add table
Reference in a new issue