From 562b3b98f6817f6213dada93d24c2a7358d86b69 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 16 Feb 2019 14:37:36 +0100 Subject: [PATCH 1/4] Improve messages when app upgrades start --- locales/en.json | 3 ++- src/yunohost/app.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/locales/en.json b/locales/en.json index 8528c2576..24841311a 100644 --- a/locales/en.json +++ b/locales/en.json @@ -36,7 +36,8 @@ "app_sources_fetch_failed": "Unable to fetch sources files", "app_unknown": "Unknown app", "app_unsupported_remote_type": "Unsupported remote type used for the app", - "app_upgrade_app_name": "Upgrading app {app}…", + "app_upgrade_several_apps": "The following apps will be upgraded : {apps}", + "app_upgrade_app_name": "Now upgrading app {app}…", "app_upgrade_failed": "Unable to upgrade {app:s}", "app_upgrade_some_app_failed": "Unable to upgrade some applications", "app_upgraded": "{app:s} has been upgraded", diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 0bca68787..23b4b49b7 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -586,7 +586,10 @@ def app_upgrade(auth, app=[], url=None, file=None): elif not isinstance(app, list): apps = [app] - logger.info("Upgrading apps %s", ", ".join(app)) + if len(apps) == 0: + raise YunohostError('app_no_upgrade') + if len(apps) > 1: + logger.info(m18n.n("app_upgrade_several_apps", apps=", ".join(app))) for app_instance_name in apps: logger.info(m18n.n('app_upgrade_app_name', app=app_instance_name)) From 7d3319332dbfd3e3ac1527b82fbb763261c2554b Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 16 Feb 2019 14:38:39 +0100 Subject: [PATCH 2/4] Improve message when some upgrades fail --- locales/en.json | 3 ++- src/yunohost/app.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/locales/en.json b/locales/en.json index 24841311a..3681fd847 100644 --- a/locales/en.json +++ b/locales/en.json @@ -24,7 +24,8 @@ "app_location_install_failed": "Unable to install the app in this location because it conflit with the app '{other_app}' already installed on '{other_path}'", "app_location_unavailable": "This url is not available or conflicts with the already installed app(s):\n{apps:s}", "app_manifest_invalid": "Invalid app manifest: {error}", - "app_no_upgrade": "No app to upgrade", + "app_no_upgrade": "No apps to upgrade", + "app_not_upgraded": "The following apps were not upgraded: {apps}", "app_not_correctly_installed": "{app:s} seems to be incorrectly installed", "app_not_installed": "{app:s} is not installed", "app_not_properly_removed": "{app:s} has not been properly removed", diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 23b4b49b7..609bece5e 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -575,6 +575,7 @@ def app_upgrade(auth, app=[], url=None, file=None): raise YunohostError('app_no_upgrade') upgraded_apps = [] + not_upgraded_apps = [] apps = app user_specified_list = True @@ -651,6 +652,7 @@ def app_upgrade(auth, app=[], url=None, file=None): if hook_exec(extracted_app_folder + '/scripts/upgrade', args=args_list, env=env_dict) != 0: msg = m18n.n('app_upgrade_failed', app=app_instance_name) + not_upgraded_apps.append(app_instance_name) logger.error(msg) operation_logger.error(msg) else: @@ -684,8 +686,8 @@ def app_upgrade(auth, app=[], url=None, file=None): hook_callback('post_app_upgrade', args=args_list, env=env_dict) operation_logger.success() - if not upgraded_apps: - raise YunohostError('app_no_upgrade') + if not_upgraded_apps: + raise YunohostError('app_not_upgraded', apps=', '.join(not_upgraded_apps)) app_ssowatconf(auth) From fe37acd315749be005c95f7f0a107b9d8a2afdd2 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 16 Feb 2019 14:45:05 +0100 Subject: [PATCH 3/4] Avoid checking for duplicates --- src/yunohost/app.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 609bece5e..5e7f17b6e 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -574,7 +574,6 @@ def app_upgrade(auth, app=[], url=None, file=None): except YunohostError: raise YunohostError('app_no_upgrade') - upgraded_apps = [] not_upgraded_apps = [] apps = app @@ -587,6 +586,9 @@ def app_upgrade(auth, app=[], url=None, file=None): elif not isinstance(app, list): apps = [app] + # Remove possible duplicates + apps = [app for i,app in enumerate(apps) if apps not in L[:i]] + if len(apps) == 0: raise YunohostError('app_no_upgrade') if len(apps) > 1: @@ -598,9 +600,6 @@ def app_upgrade(auth, app=[], url=None, file=None): if not installed: raise YunohostError('app_not_installed', app=app_instance_name) - if app_instance_name in upgraded_apps: - continue - app_dict = app_info(app_instance_name, raw=True) if file: @@ -680,7 +679,6 @@ def app_upgrade(auth, app=[], url=None, file=None): os.system('cp -R %s/%s %s' % (extracted_app_folder, file_to_copy, app_setting_path)) # So much win - upgraded_apps.append(app_instance_name) logger.success(m18n.n('app_upgraded', app=app_instance_name)) hook_callback('post_app_upgrade', args=args_list, env=env_dict) From fc00b59be4561ab04009c87c49b60ddfe99f9189 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 16 Feb 2019 20:44:50 +0100 Subject: [PATCH 4/4] Add messages before app install, remove, and some messages for backups --- locales/en.json | 7 ++++++- src/yunohost/app.py | 4 ++++ src/yunohost/backup.py | 6 +++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/locales/en.json b/locales/en.json index 3681fd847..34258187e 100644 --- a/locales/en.json +++ b/locales/en.json @@ -35,6 +35,10 @@ "app_requirements_failed": "Unable to meet requirements for {app}: {error}", "app_requirements_unmeet": "Requirements are not met for {app}, the package {pkgname} ({version}) must be {spec}", "app_sources_fetch_failed": "Unable to fetch sources files", + "app_start_install": "Installing application {app}…", + "app_start_remove": "Removing application {app}…", + "app_start_backup": "Collecting files to be backuped for {app}…", + "app_start_restore": "Restoring application {app}…", "app_unknown": "Unknown app", "app_unsupported_remote_type": "Unsupported remote type used for the app", "app_upgrade_several_apps": "The following apps will be upgraded : {apps}", @@ -65,6 +69,7 @@ "ask_path": "Path", "backup_abstract_method": "This backup method hasn't yet been implemented", "backup_action_required": "You must specify something to save", + "backup_actually_backuping": "Now creating a backup archive from the files collected…", "backup_app_failed": "Unable to back up the app '{app:s}'", "backup_applying_method_borg": "Sending all files to backup into borg-backup repository…", "backup_applying_method_copy": "Copying all files to backup…", @@ -101,6 +106,7 @@ "backup_method_copy_finished": "Backup copy finished", "backup_method_custom_finished": "Custom backup method '{method:s}' finished", "backup_method_tar_finished": "Backup tar archive created", + "backup_mount_archive_for_restore": "Preparing archive for restoration…", "backup_no_uncompress_archive_dir": "Uncompress archive directory doesn't exist", "backup_nothings_done": "There is nothing to save", "backup_output_directory_forbidden": "Forbidden output directory. Backups can't be created in /bin, /boot, /dev, /etc, /lib, /root, /run, /sbin, /sys, /usr, /var or /home/yunohost.backup/archives sub-folders", @@ -108,7 +114,6 @@ "backup_output_directory_required": "You must provide an output directory for the backup", "backup_output_symlink_dir_broken": "You have a broken symlink instead of your archives directory '{path:s}'. You may have a specific setup to backup your data on an other filesystem, in this case you probably forgot to remount or plug your hard dirve or usb key.", "backup_php5_to_php7_migration_may_fail": "Could not convert your archive to support php7, your php apps may fail to restore (reason: {error:s})", - "backup_running_app_script": "Running backup script of app '{app:s}'…", "backup_running_hooks": "Running backup hooks…", "backup_system_part_failed": "Unable to backup the '{part:s}' system part", "backup_unable_to_organize_files": "Unable to organize files in the archive with the quick method", diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 5e7f17b6e..f5746fd4b 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -801,6 +801,8 @@ def app_install(operation_logger, auth, app, label=None, args=None, no_remove_on operation_logger.related_to.append(("app", app_id)) operation_logger.start() + logger.info(m18n.n("app_start_install", app=app_id)) + # Create app directory app_setting_path = os.path.join(APPS_SETTING_PATH, app_instance_name) if os.path.exists(app_setting_path): @@ -921,6 +923,8 @@ def app_remove(operation_logger, auth, app): operation_logger.start() + logger.info(m18n.n("app_start_remove", app=app)) + app_setting_path = APPS_SETTING_PATH + app # TODO: display fail messages from script diff --git a/src/yunohost/backup.py b/src/yunohost/backup.py index ed7799fc1..36d732114 100644 --- a/src/yunohost/backup.py +++ b/src/yunohost/backup.py @@ -668,7 +668,7 @@ class BackupManager(): tmp_app_bkp_dir = env_dict["YNH_APP_BACKUP_DIR"] settings_dir = os.path.join(self.work_dir, 'apps', app, 'settings') - logger.debug(m18n.n('backup_running_app_script', app=app)) + logger.info(m18n.n("app_start_backup", app=app)) try: # Prepare backup directory for the app filesystem.mkdir(tmp_app_bkp_dir, 0o750, True, uid='admin') @@ -1242,6 +1242,8 @@ class RestoreManager(): operation_logger = OperationLogger('backup_restore_app', related_to) operation_logger.start() + logger.info(m18n.n("app_start_restore", app=app_instance_name)) + # Check if the app is not already installed if _is_installed(app_instance_name): logger.error(m18n.n('restore_already_installed_app', @@ -2059,6 +2061,7 @@ def backup_create(name=None, description=None, methods=[], backup_manager.collect_files() # Apply backup methods on prepared files + logger.info(m18n.n("backup_actually_backuping")) backup_manager.backup() logger.success(m18n.n('backup_created')) @@ -2127,6 +2130,7 @@ def backup_restore(auth, name, system=[], apps=[], force=False): # Mount the archive then call the restore for each system part / app # # + logger.info(m18n.n("backup_mount_archive_for_restore")) restore_manager.mount() restore_manager.restore()