From de126fcdceca9dcbf177170ebfae81aa1aee2d7b Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 2 Jan 2021 20:40:51 +0100 Subject: [PATCH] Don't allow failure for invalid python3 code + fix unsued variables --- .gitlab/ci/lint.gitlab-ci.yml | 1 - src/yunohost/app.py | 2 +- src/yunohost/backup.py | 2 +- .../data_migrations/0019_extend_permissions_features.py | 2 +- src/yunohost/utils/legacy.py | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.gitlab/ci/lint.gitlab-ci.yml b/.gitlab/ci/lint.gitlab-ci.yml index d240a3af6..dabe33d62 100644 --- a/.gitlab/ci/lint.gitlab-ci.yml +++ b/.gitlab/ci/lint.gitlab-ci.yml @@ -14,7 +14,6 @@ lint37: invalidcode37: stage: lint image: "before-install" - allow_failure: true needs: [] script: - tox -e py37-invalidcode diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 669463fcd..c32596fa7 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -831,7 +831,7 @@ def app_install(operation_logger, app, label=None, args=None, no_remove_on_failu logger.error(m18n.n("app_install_failed", app=app_id, error=error)) failure_message_with_debug_instructions = operation_logger.error(error) # Something wrong happened in Yunohost's code (most probably hook_exec) - except Exception as e: + except Exception: import traceback error = m18n.n('unexpected_error', error="\n" + traceback.format_exc()) logger.error(m18n.n("app_install_failed", app=app_id, error=error)) diff --git a/src/yunohost/backup.py b/src/yunohost/backup.py index ad5b995e7..18736ef81 100644 --- a/src/yunohost/backup.py +++ b/src/yunohost/backup.py @@ -1644,7 +1644,7 @@ class BackupMethod(object): try: subprocess.check_call(["mount", "--rbind", src, dest]) subprocess.check_call(["mount", "-o", "remount,ro,bind", dest]) - except Exception as e: + except Exception: logger.warning(m18n.n("backup_couldnt_bind", src=src, dest=dest)) # To check if dest is mounted, use /proc/mounts that # escape spaces as \040 diff --git a/src/yunohost/data_migrations/0019_extend_permissions_features.py b/src/yunohost/data_migrations/0019_extend_permissions_features.py index b20b92e62..6c292e014 100644 --- a/src/yunohost/data_migrations/0019_extend_permissions_features.py +++ b/src/yunohost/data_migrations/0019_extend_permissions_features.py @@ -98,7 +98,7 @@ class MyMigration(Migration): # Migrate old settings migrate_legacy_permission_settings() - except Exception as e: + except Exception: logger.warn(m18n.n("migration_0019_migration_failed_trying_to_rollback")) os.system("systemctl stop slapd") os.system("rm -r /etc/ldap/slapd.d") # To be sure that we don't keep some part of the old config diff --git a/src/yunohost/utils/legacy.py b/src/yunohost/utils/legacy.py index 11d483754..ca187baa1 100644 --- a/src/yunohost/utils/legacy.py +++ b/src/yunohost/utils/legacy.py @@ -22,7 +22,7 @@ class SetupGroupPermissions(): try: objects = ldap.search(target + ",dc=yunohost,dc=org") # ldap search will raise an exception if no corresponding object is found >.> ... - except Exception as e: + except Exception: logger.debug("%s does not exist, no need to delete it" % target) return