[enh] Support success info with criticla upgrades

This commit is contained in:
ljf 2019-03-22 15:32:51 +01:00
parent ad0f65aad7
commit ac05ae6557

View file

@ -665,15 +665,17 @@ def tools_upgrade(operation_logger, auth, ignore_apps=False, ignore_packages=Fal
MOULINETTE_LOCK = "/var/run/moulinette_yunohost.lock" MOULINETTE_LOCK = "/var/run/moulinette_yunohost.lock"
wait_until_end_of_yunohost_command = "(while [ -f {} ]; do sleep 2; done)".format(MOULINETTE_LOCK) wait_until_end_of_yunohost_command = "(while [ -f {} ]; do sleep 2; done)".format(MOULINETTE_LOCK)
mark_success = "(echo 'success: true' | tee -a {})".format(operation_logger.md_path)
update_log_metadata = "sed -i \"s/ended_at: .*$/ended_at: $(date -u +'%Y-%m-%d %H:%M:%S.%N')/\" {}" update_log_metadata = "sed -i \"s/ended_at: .*$/ended_at: $(date -u +'%Y-%m-%d %H:%M:%S.%N')/\" {}"
update_log_metadata = update_log_metadata.format(operation_logger.md_path) update_log_metadata = update_log_metadata.format(operation_logger.md_path)
# TODO : i18n # TODO : i18n
upgrade_completed = "YunoHost package upgrade completed ! Press [enter] to get the command line back" upgrade_completed = "YunoHost package upgrade completed ! Press [enter] to get the command line back"
command = "({} && {} && {}; echo '{}') &".format(wait_until_end_of_yunohost_command, command = "({} && {} && {}; {}; echo '{}') &".format(wait_until_end_of_yunohost_command,
command, command,
update_log_metadata, mark_success,
upgrade_completed) update_log_metadata,
upgrade_completed)
logger.debug("Running command :\n{}".format(command)) logger.debug("Running command :\n{}".format(command))
os.system(command) os.system(command)
@ -685,7 +687,7 @@ def tools_upgrade(operation_logger, auth, ignore_apps=False, ignore_packages=Fal
# as "hold" to avoid accidental deletion of it... # as "hold" to avoid accidental deletion of it...
# (so, only unhold it during the upgrade) # (so, only unhold it during the upgrade)
if not failure: elif not failure:
logger.info(m18n.n('done')) logger.info(m18n.n('done'))
operation_logger.success() operation_logger.success()