From f4335624fcb9a590ec87857c7e782a628173391a Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 5 Sep 2021 14:21:55 +0200 Subject: [PATCH] =?UTF-8?q?Script=20migration:=20traite=20d=C3=A9partement?= =?UTF-8?q?s=20nomm=C3=A9s=20en=20minuscules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/import_scodoc7_user_db.py | 11 +++++------ tools/migrate_from_scodoc7.sh | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/tools/import_scodoc7_user_db.py b/tools/import_scodoc7_user_db.py index c36f13fbc..1cd7774f8 100644 --- a/tools/import_scodoc7_user_db.py +++ b/tools/import_scodoc7_user_db.py @@ -51,18 +51,17 @@ def import_scodoc7_user_db(scodoc7_db="dbname=SCOUSERS"): ) # Set roles: # ScoDoc7 roles are stored as 'AdminRT,EnsRT' + # ou, dans les rares cas où le dept est en minuscules + # "Ensgeii,Admingeii" if u7["roles"]: roles7 = u7["roles"].split(",") else: roles7 = [] for role_dept in roles7: - # Cas particulier RespPeRT - m = re.match(r"^(-?RespPe)([A-Z][A-Za-z0-9]*?)$", role_dept) + # Migre les rôles RespPeX, EnsX, AdminX, SecrX et ignore les autres + m = re.match(r"^(-?Ens|-?Secr|-?ResPe|-?Admin)(.*)$", role_dept) if not m: - # Cas général: eg EnsRT - m = re.match(r"^(-?[A-Za-z0-9]+?)([A-Z][A-Za-z0-9]*?)$", role_dept) - if not m: - msg = f"User {user_name}: invalid role '{role_dept}' (ignoring)" + msg = f"User {user_name}: role inconnu '{role_dept}' (ignoré)" current_app.logger.warning(msg) messages.append(msg) else: diff --git a/tools/migrate_from_scodoc7.sh b/tools/migrate_from_scodoc7.sh index 43e914e4f..537d0be08 100755 --- a/tools/migrate_from_scodoc7.sh +++ b/tools/migrate_from_scodoc7.sh @@ -193,8 +193,8 @@ su -c "(cd $SCODOC_DIR && source venv/bin/activate && flask import-scodoc7-users # (ils ne sont d'ailleurs plus utilisés par ScoDoc 9) for f in "$SCODOC_VAR_DIR"/config/depts/*.cfg do - dept=$(basename "${f%.*}") - db_name=$(echo "SCO$dept" | tr "[:lower:]" "[:upper:]") + dept=$(basename "${f%.*}") # le nom du dept peut-être en minuscules et/ou majuscules (geii, GEII...) + db_name=$(echo "SCO$dept" | tr "[:lower:]" "[:upper:]") # nom de BD toujours en majuscule echo echo "----------------------------------------------" echo "| MIGRATION DU DEPARTEMENT $dept"