From 81c19cd1d6cd007878204227c1172a94707af4f1 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sun, 9 Oct 2016 21:34:03 +0200 Subject: [PATCH 1/3] [enh] no cli option to avoid removing an application on installation failure --- data/actionsmap/yunohost.yml | 3 +++ src/yunohost/app.py | 28 +++++++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 5a1465258..126993076 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -436,6 +436,9 @@ app: -a: full: --args help: Serialized arguments for app script (i.e. "domain=domain.tld&path=/path") + -n: + full: --no-remove-on-fail + help: Debug option to avoid removing the app on a filed installation ### app_remove() TODO: Write help remove: diff --git a/src/yunohost/app.py b/src/yunohost/app.py index caa38e95b..5ac0cb971 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -440,7 +440,7 @@ def app_upgrade(auth, app=[], url=None, file=None): logger.success(m18n.n('upgrade_complete')) -def app_install(auth, app, label=None, args=None): +def app_install(auth, app, label=None, args=None, no_remove_on_fail=False): """ Install apps @@ -448,6 +448,7 @@ def app_install(auth, app, label=None, args=None): app -- Name, local path or git URL of the app to install label -- Custom name for the app args -- Serialize arguments for app installation + no_remove_on_fail -- Debug option to avoid removing the app on a filed installation """ from yunohost.hook import hook_add, hook_remove, hook_exec @@ -541,19 +542,20 @@ def app_install(auth, app, label=None, args=None): logger.exception(m18n.n('unexpected_error')) finally: if install_retcode != 0: - # Setup environment for remove script - env_dict_remove = {} - env_dict_remove["YNH_APP_ID"] = app_id - env_dict_remove["YNH_APP_INSTANCE_NAME"] = app_instance_name - env_dict_remove["YNH_APP_INSTANCE_NUMBER"] = str(instance_number) + if not no_remove_on_fail: + # Setup environment for remove script + env_dict_remove = {} + env_dict_remove["YNH_APP_ID"] = app_id + env_dict_remove["YNH_APP_INSTANCE_NAME"] = app_instance_name + env_dict_remove["YNH_APP_INSTANCE_NUMBER"] = str(instance_number) - # Execute remove script - remove_retcode = hook_exec( - os.path.join(extracted_app_folder, 'scripts/remove'), - args=[app_instance_name], env=env_dict_remove) - if remove_retcode != 0: - logger.warning(m18n.n('app_not_properly_removed', - app=app_instance_name)) + # Execute remove script + remove_retcode = hook_exec( + os.path.join(extracted_app_folder, 'scripts/remove'), + args=[app_instance_name], env=env_dict_remove) + if remove_retcode != 0: + logger.warning(m18n.n('app_not_properly_removed', + app=app_instance_name)) # Clean tmp folders shutil.rmtree(app_setting_path) From 76a294b28438e12b2d29f381ad941dc2bacf3bc8 Mon Sep 17 00:00:00 2001 From: Moul Date: Wed, 12 Oct 2016 09:39:05 +0200 Subject: [PATCH 2/3] =?UTF-8?q?[fix]=20typo:=20install=20filed=20=E2=80=93?= =?UTF-8?q?>=20failed.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/actionsmap/yunohost.yml | 2 +- src/yunohost/app.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 126993076..56b28cf38 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -438,7 +438,7 @@ app: help: Serialized arguments for app script (i.e. "domain=domain.tld&path=/path") -n: full: --no-remove-on-fail - help: Debug option to avoid removing the app on a filed installation + help: Debug option to avoid removing the app on a failed installation ### app_remove() TODO: Write help remove: diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 5ac0cb971..f85e9f191 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -448,7 +448,7 @@ def app_install(auth, app, label=None, args=None, no_remove_on_fail=False): app -- Name, local path or git URL of the app to install label -- Custom name for the app args -- Serialize arguments for app installation - no_remove_on_fail -- Debug option to avoid removing the app on a filed installation + no_remove_on_fail -- Debug option to avoid removing the app on a failed installation """ from yunohost.hook import hook_add, hook_remove, hook_exec From a7289c447adab0ab170e684b4866d322994b2778 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Mon, 28 Nov 2016 14:54:13 +0100 Subject: [PATCH 3/3] [fix] typo --- data/actionsmap/yunohost.yml | 2 +- src/yunohost/app.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 56b28cf38..e5af4ee6b 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -437,7 +437,7 @@ app: full: --args help: Serialized arguments for app script (i.e. "domain=domain.tld&path=/path") -n: - full: --no-remove-on-fail + full: --no-remove-on-failure help: Debug option to avoid removing the app on a failed installation ### app_remove() TODO: Write help diff --git a/src/yunohost/app.py b/src/yunohost/app.py index f85e9f191..b70b6388a 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -440,7 +440,7 @@ def app_upgrade(auth, app=[], url=None, file=None): logger.success(m18n.n('upgrade_complete')) -def app_install(auth, app, label=None, args=None, no_remove_on_fail=False): +def app_install(auth, app, label=None, args=None, no_remove_on_failure=False): """ Install apps @@ -448,7 +448,7 @@ def app_install(auth, app, label=None, args=None, no_remove_on_fail=False): app -- Name, local path or git URL of the app to install label -- Custom name for the app args -- Serialize arguments for app installation - no_remove_on_fail -- Debug option to avoid removing the app on a failed installation + no_remove_on_failure -- Debug option to avoid removing the app on a failed installation """ from yunohost.hook import hook_add, hook_remove, hook_exec @@ -542,7 +542,7 @@ def app_install(auth, app, label=None, args=None, no_remove_on_fail=False): logger.exception(m18n.n('unexpected_error')) finally: if install_retcode != 0: - if not no_remove_on_fail: + if not no_remove_on_failure: # Setup environment for remove script env_dict_remove = {} env_dict_remove["YNH_APP_ID"] = app_id