From 03f4da2df4bcdb4438944f768970f17c6dab6364 Mon Sep 17 00:00:00 2001 From: Alex38Lyon <55714436+Alex38Lyon@users.noreply.github.com> Date: Wed, 14 Oct 2026 23:12:00 +0200 Subject: [PATCH] update --- Scripts/pyDatatoMergin/Lib/Librairies.py | 5 +- Scripts/pyDatatoMergin/pyDatatoMergin.log | 138 +++++++++++----------- Scripts/pyDatatoMergin/pyDatatoMergin.py | 46 +------- 3 files changed, 76 insertions(+), 113 deletions(-) diff --git a/Scripts/pyDatatoMergin/Lib/Librairies.py b/Scripts/pyDatatoMergin/Lib/Librairies.py index 0f9863f..1126298 100644 --- a/Scripts/pyDatatoMergin/Lib/Librairies.py +++ b/Scripts/pyDatatoMergin/Lib/Librairies.py @@ -4,7 +4,7 @@ Librairies générales pour pyDatatoMergin.py ############################################################################################# """ -import logging, sys, re, hashlib # noqa: I001 +import logging, sys, re, hashlib, os # noqa: I001 logger = logging.getLogger("Logger") @@ -90,7 +90,8 @@ class Colors: UNDERLINE = "\033[4m" -INTERACTIF = sys.stdout.isatty() and sys.stderr.isatty() +# INTERACTIF = sys.stdout.isatty() and sys.stderr.isatty() +INTERACTIF = sys.stdout.isatty() and sys.stderr.isatty() and os.environ.get("TERM", "").lower() != "dumb" ################################################################################################# diff --git a/Scripts/pyDatatoMergin/pyDatatoMergin.log b/Scripts/pyDatatoMergin/pyDatatoMergin.log index 95ff6fb..c56378c 100644 --- a/Scripts/pyDatatoMergin/pyDatatoMergin.log +++ b/Scripts/pyDatatoMergin/pyDatatoMergin.log @@ -1,69 +1,69 @@ -2026-10-14 22:42:00,253 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════ -2026-10-14 22:42:00,253 - INFO - INFORMATIONS DU PROJET MERGIN MAPS -2026-10-14 22:42:00,253 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════ -2026-10-14 22:42:00,389 - INFO - Projet : ARR -2026-10-14 22:42:00,391 - INFO - Identifiant : 1707d35a-d99f-47a9-a714-519d7d9c147e -2026-10-14 22:42:00,391 - INFO - Version : v17 -2026-10-14 22:42:00,391 - INFO - Créé le : 2026-08-19T09:31:30Z -2026-10-14 22:42:00,391 - INFO - Mis à jour : 2026-10-14T08:39:10Z -2026-10-14 22:42:00,392 - INFO - Taille totale : 128415971 Octets -2026-10-14 22:42:00,392 - INFO - Public : True -2026-10-14 22:42:00,392 - INFO - Nbre de fichiers : 14 -2026-10-14 22:42:00,392 - INFO - Taille totale : 122.47 Mo -2026-10-14 22:42:00,393 - INFO - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -2026-10-14 22:42:00,393 - INFO - 20260819_115533.jpeg 2.632 Mo -2026-10-14 22:42:00,393 - INFO - ARR.gpkg 93.309 Mo -2026-10-14 22:42:00,393 - INFO - ARR.qgs 0.713 Mo -2026-10-14 22:42:00,393 - INFO - ARR_attachments.zip 0.002 Mo -2026-10-14 22:42:00,394 - INFO - Inventaire Cavités.gpkg 0.660 Mo -2026-10-14 22:42:00,394 - INFO - JPEG_20260819_113638_3152669861975410066.jpg 3.024 Mo -2026-10-14 22:42:00,394 - INFO - JPEG_20260819_113919_5886287470656202827.jpg 3.034 Mo -2026-10-14 22:42:00,394 - INFO - JPEG_20260819_121951_8365685850227103103.jpg 2.974 Mo -2026-10-14 22:42:00,394 - INFO - JPEG_20260819_122929_1446792337025110147.jpg 3.007 Mo -2026-10-14 22:42:00,394 - INFO - JPEG_20260819_123117_33265926990508961.jpg 2.516 Mo -2026-10-14 22:42:00,394 - INFO - JPEG_20260819_124915_3186813976814177670.jpg 2.899 Mo -2026-10-14 22:42:00,395 - INFO - JPEG_20260819_125124_7007318829424129864.jpg 3.165 Mo -2026-10-14 22:42:00,395 - INFO - Tests/areas2dMasked.gpkg 4.531 Mo -2026-10-14 22:42:00,395 - INFO - karstpro_etude.json 0.001 Mo -2026-10-14 22:42:00,395 - INFO - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -2026-10-14 22:42:00,395 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════ -2026-10-14 22:42:00,395 - INFO - Envoi des données GitHub vers Mergin Maps -2026-10-14 22:42:00,396 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════ -2026-10-14 22:42:00,396 - INFO - [1/5] Téléchargement desfichiers depuis le GitHub : Alex38Lyon/Synthese-PSM_LARRA@main:Outputs/SHP/QGis_GPKG_Files/areas2dMasked.gpkg -2026-10-14 22:42:00,481 - INFO - Téléchargement GitHub : Alex38Lyon/Synthese-PSM_LARRA/main, chemin Outputs/SHP/QGis_GPKG_Files/areas2dMasked.gpkg -2026-10-14 22:42:01,300 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 4751360 octets. -2026-10-14 22:42:01,302 - INFO - [2/5] Synchronisation du projet local existant : D:\08_GitHub\Synthese-PSM_LARRA\Scripts\pyDatatoMergin\Temp_mergin\Projet -2026-10-14 22:42:02,080 - INFO - [3/5] Copie des fichiers D:\08_GitHub\Synthese-PSM_LARRA\Scripts\pyDatatoMergin\Temp_mergin\Github\areas2dMasked.gpkg -2026-10-14 22:42:02,085 - INFO - + Tests\areas2dMasked.gpkg -2026-10-14 22:42:02,086 - INFO - [4/5] Push vers Mergin Maps... -2026-10-14 22:42:02,442 - WARNING - Aucune modification à envoyer. -2026-10-14 22:42:02,442 - INFO - [5/5] Push terminé. Nettoyage... -2026-10-14 22:42:02,444 - INFO - Envoi terminé avec succès. -2026-10-14 22:42:02,444 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════ -2026-10-14 22:42:02,444 - INFO - INFORMATIONS DU PROJET MERGIN MAPS -2026-10-14 22:42:02,444 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════ -2026-10-14 22:42:02,590 - INFO - Projet : ARR -2026-10-14 22:42:02,591 - INFO - Identifiant : 1707d35a-d99f-47a9-a714-519d7d9c147e -2026-10-14 22:42:02,592 - INFO - Version : v17 -2026-10-14 22:42:02,592 - INFO - Créé le : 2026-08-19T09:31:30Z -2026-10-14 22:42:02,593 - INFO - Mis à jour : 2026-10-14T08:39:10Z -2026-10-14 22:42:02,593 - INFO - Taille totale : 128415971 Octets -2026-10-14 22:42:02,594 - INFO - Public : True -2026-10-14 22:42:02,595 - INFO - Nbre de fichiers : 14 -2026-10-14 22:42:02,595 - INFO - Taille totale : 122.47 Mo -2026-10-14 22:42:02,596 - INFO - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -2026-10-14 22:42:02,597 - INFO - 20260819_115533.jpeg 2.632 Mo -2026-10-14 22:42:02,597 - INFO - ARR.gpkg 93.309 Mo -2026-10-14 22:42:02,597 - INFO - ARR.qgs 0.713 Mo -2026-10-14 22:42:02,598 - INFO - ARR_attachments.zip 0.002 Mo -2026-10-14 22:42:02,598 - INFO - Inventaire Cavités.gpkg 0.660 Mo -2026-10-14 22:42:02,599 - INFO - JPEG_20260819_113638_3152669861975410066.jpg 3.024 Mo -2026-10-14 22:42:02,599 - INFO - JPEG_20260819_113919_5886287470656202827.jpg 3.034 Mo -2026-10-14 22:42:02,600 - INFO - JPEG_20260819_121951_8365685850227103103.jpg 2.974 Mo -2026-10-14 22:42:02,600 - INFO - JPEG_20260819_122929_1446792337025110147.jpg 3.007 Mo -2026-10-14 22:42:02,601 - INFO - JPEG_20260819_123117_33265926990508961.jpg 2.516 Mo -2026-10-14 22:42:02,601 - INFO - JPEG_20260819_124915_3186813976814177670.jpg 2.899 Mo -2026-10-14 22:42:02,602 - INFO - JPEG_20260819_125124_7007318829424129864.jpg 3.165 Mo -2026-10-14 22:42:02,602 - INFO - Tests/areas2dMasked.gpkg 4.531 Mo -2026-10-14 22:42:02,602 - INFO - karstpro_etude.json 0.001 Mo -2026-10-14 22:42:02,603 - INFO - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +2026-10-14 23:11:20,301 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════ +2026-10-14 23:11:20,301 - INFO - INFORMATIONS DU PROJET MERGIN MAPS +2026-10-14 23:11:20,302 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════ +2026-10-14 23:11:20,513 - INFO - Projet : ARR +2026-10-14 23:11:20,514 - INFO - Identifiant : 1707d35a-d99f-47a9-a714-519d7d9c147e +2026-10-14 23:11:20,515 - INFO - Version : v17 +2026-10-14 23:11:20,515 - INFO - Créé le : 2026-08-19T09:31:30Z +2026-10-14 23:11:20,515 - INFO - Mis à jour : 2026-10-14T08:39:10Z +2026-10-14 23:11:20,515 - INFO - Taille totale : 128415971 Octets +2026-10-14 23:11:20,515 - INFO - Public : True +2026-10-14 23:11:20,515 - INFO - Nbre de fichiers : 14 +2026-10-14 23:11:20,516 - INFO - Taille totale : 122.47 Mo +2026-10-14 23:11:20,516 - INFO - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +2026-10-14 23:11:20,516 - INFO - 20260819_115533.jpeg 2.632 Mo +2026-10-14 23:11:20,516 - INFO - ARR.gpkg 93.309 Mo +2026-10-14 23:11:20,516 - INFO - ARR.qgs 0.713 Mo +2026-10-14 23:11:20,516 - INFO - ARR_attachments.zip 0.002 Mo +2026-10-14 23:11:20,516 - INFO - Inventaire Cavités.gpkg 0.660 Mo +2026-10-14 23:11:20,517 - INFO - JPEG_20260819_113638_3152669861975410066.jpg 3.024 Mo +2026-10-14 23:11:20,517 - INFO - JPEG_20260819_113919_5886287470656202827.jpg 3.034 Mo +2026-10-14 23:11:20,517 - INFO - JPEG_20260819_121951_8365685850227103103.jpg 2.974 Mo +2026-10-14 23:11:20,517 - INFO - JPEG_20260819_122929_1446792337025110147.jpg 3.007 Mo +2026-10-14 23:11:20,517 - INFO - JPEG_20260819_123117_33265926990508961.jpg 2.516 Mo +2026-10-14 23:11:20,517 - INFO - JPEG_20260819_124915_3186813976814177670.jpg 2.899 Mo +2026-10-14 23:11:20,518 - INFO - JPEG_20260819_125124_7007318829424129864.jpg 3.165 Mo +2026-10-14 23:11:20,518 - INFO - Tests/areas2dMasked.gpkg 4.531 Mo +2026-10-14 23:11:20,518 - INFO - karstpro_etude.json 0.001 Mo +2026-10-14 23:11:20,518 - INFO - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +2026-10-14 23:11:20,518 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════ +2026-10-14 23:11:20,518 - INFO - Envoi des données GitHub vers Mergin Maps +2026-10-14 23:11:20,518 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════ +2026-10-14 23:11:20,519 - INFO - [1/5] Téléchargement desfichiers depuis le GitHub : Alex38Lyon/Synthese-PSM_LARRA@main:Outputs/SHP/QGis_GPKG_Files/areas2dMasked.gpkg +2026-10-14 23:11:20,632 - INFO - Téléchargement GitHub : Alex38Lyon/Synthese-PSM_LARRA/main, chemin Outputs/SHP/QGis_GPKG_Files/areas2dMasked.gpkg +2026-10-14 23:11:21,616 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 4751360 octets. +2026-10-14 23:11:21,619 - INFO - [2/5] Synchronisation du projet local existant : D:\08_GitHub\Synthese-PSM_LARRA\Scripts\pyDatatoMergin\Temp_mergin\Projet +2026-10-14 23:11:22,459 - INFO - [3/5] Copie des fichiers D:\08_GitHub\Synthese-PSM_LARRA\Scripts\pyDatatoMergin\Temp_mergin\Github\areas2dMasked.gpkg +2026-10-14 23:11:22,472 - INFO - + Tests\areas2dMasked.gpkg +2026-10-14 23:11:22,473 - INFO - [4/5] Push vers Mergin Maps... +2026-10-14 23:11:22,846 - WARNING - Aucune modification à envoyer. +2026-10-14 23:11:22,847 - INFO - [5/5] Push terminé. Nettoyage... +2026-10-14 23:11:22,849 - INFO - Envoi terminé avec succès. +2026-10-14 23:11:22,849 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════ +2026-10-14 23:11:22,849 - INFO - INFORMATIONS DU PROJET MERGIN MAPS +2026-10-14 23:11:22,850 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════ +2026-10-14 23:11:22,984 - INFO - Projet : ARR +2026-10-14 23:11:22,985 - INFO - Identifiant : 1707d35a-d99f-47a9-a714-519d7d9c147e +2026-10-14 23:11:22,985 - INFO - Version : v17 +2026-10-14 23:11:22,986 - INFO - Créé le : 2026-08-19T09:31:30Z +2026-10-14 23:11:22,986 - INFO - Mis à jour : 2026-10-14T08:39:10Z +2026-10-14 23:11:22,987 - INFO - Taille totale : 128415971 Octets +2026-10-14 23:11:22,988 - INFO - Public : True +2026-10-14 23:11:22,988 - INFO - Nbre de fichiers : 14 +2026-10-14 23:11:22,989 - INFO - Taille totale : 122.47 Mo +2026-10-14 23:11:22,990 - INFO - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +2026-10-14 23:11:22,990 - INFO - 20260819_115533.jpeg 2.632 Mo +2026-10-14 23:11:22,991 - INFO - ARR.gpkg 93.309 Mo +2026-10-14 23:11:22,991 - INFO - ARR.qgs 0.713 Mo +2026-10-14 23:11:22,992 - INFO - ARR_attachments.zip 0.002 Mo +2026-10-14 23:11:22,993 - INFO - Inventaire Cavités.gpkg 0.660 Mo +2026-10-14 23:11:22,993 - INFO - JPEG_20260819_113638_3152669861975410066.jpg 3.024 Mo +2026-10-14 23:11:22,994 - INFO - JPEG_20260819_113919_5886287470656202827.jpg 3.034 Mo +2026-10-14 23:11:22,995 - INFO - JPEG_20260819_121951_8365685850227103103.jpg 2.974 Mo +2026-10-14 23:11:22,995 - INFO - JPEG_20260819_122929_1446792337025110147.jpg 3.007 Mo +2026-10-14 23:11:22,996 - INFO - JPEG_20260819_123117_33265926990508961.jpg 2.516 Mo +2026-10-14 23:11:22,996 - INFO - JPEG_20260819_124915_3186813976814177670.jpg 2.899 Mo +2026-10-14 23:11:22,997 - INFO - JPEG_20260819_125124_7007318829424129864.jpg 3.165 Mo +2026-10-14 23:11:22,998 - INFO - Tests/areas2dMasked.gpkg 4.531 Mo +2026-10-14 23:11:22,998 - INFO - karstpro_etude.json 0.001 Mo +2026-10-14 23:11:22,999 - INFO - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/Scripts/pyDatatoMergin/pyDatatoMergin.py b/Scripts/pyDatatoMergin/pyDatatoMergin.py index 2a08ec5..b31e143 100644 --- a/Scripts/pyDatatoMergin/pyDatatoMergin.py +++ b/Scripts/pyDatatoMergin/pyDatatoMergin.py @@ -34,7 +34,8 @@ def suivre_transfert(job, verifier, titre: str) -> None: return precedent = 0 - interactif = sys.stdout.isatty() + # interactif = sys.stdout.isatty() + interactif = sys.stdout.isatty() and sys.stderr.isatty() and bool(os.environ.get("TERM", "")) and os.environ.get("TERM") != "dumb" if interactif: with alive_bar(taille_totale, title=f"{Colors.YELLOW}{titre}{Colors.ENDC}", stats=True, dual_line=True, scale="SI", unit="o") as barre: @@ -162,46 +163,6 @@ def lister_fichiers_github(session: requests.Session, depot: str, branche: str, ############################################################################################################################################ -def telecharger_depuis_githubOld(depot: str, branche: str, chemin: str, dossier_cible: Path, token: str | None = None) -> Path: - """Télécharge uniquement un fichier ou un dossier d'un dépôt GitHub. - - chemin : chemin dans le dépôt, ex. 'data/gpkg' ou 'data/couche.gpkg' ('' = tout le dépôt) - Retourne le fichier ou le dossier local téléchargé. - """ - - chemin = chemin.strip("/") - - if dossier_cible.exists(): - shutil.rmtree(dossier_cible) - dossier_cible.mkdir(parents=True) - - with requests.Session() as session: - fichiers = lister_fichiers_github(session, depot, branche, chemin, token) - if not fichiers: - raise ValueError(f"Aucun fichier trouvé dans : {chemin or '/'}") - - # Un seul fichier demandé : on le garde à plat ; sinon on conserve l'arborescence relative au dossier demandé. - est_fichier = len(fichiers) == 1 and fichiers[0]["path"] == chemin - base = chemin.rpartition("/")[0] if est_fichier else chemin - total = sum(f.get("size", 0) for f in fichiers) or None - - with alive_bar(total, title=f"{Colors.YELLOW}Téléchargement GitHub{Colors.ENDC}", stats=True, scale="SI", unit="o") as barre: - for fichier in fichiers: - relatif = fichier["path"][len(base) :].lstrip("/") if base else fichier["path"] - local = dossier_cible / relatif - local.parent.mkdir(parents=True, exist_ok=True) - - url = f"{GITHUB_API}/repos/{depot}/contents/{quote(fichier['path'])}" - with session.get(url, params={"ref": branche}, headers=_entetes_github(token, brut=True), stream=True, timeout=120) as r: - r.raise_for_status() - with open(local, "wb") as f: - for morceau in r.iter_content(chunk_size=1024 * 256): - f.write(morceau) - barre(len(morceau)) - - return dossier_cible / Path(chemin).name if est_fichier else dossier_cible - - def telecharger_depuis_github(depot: str, branche: str, chemin: str, dossier_cible: Path, token: str | None = None) -> Path: """Télécharge uniquement un fichier ou un dossier d'un dépôt GitHub. @@ -224,7 +185,8 @@ def telecharger_depuis_github(depot: str, branche: str, chemin: str, dossier_cib est_fichier = len(fichiers) == 1 and fichiers[0]["path"] == chemin base = chemin.rpartition("/")[0] if est_fichier else chemin total = sum(f.get("size", 0) for f in fichiers) or None - interactif = sys.stdout.isatty() + # interactif = sys.stdout.isatty() + interactif = sys.stdout.isatty() and sys.stderr.isatty() and bool(os.environ.get("TERM", "")) and os.environ.get("TERM") != "dumb" precedent = 0 def telecharger_fichiers(barre=None) -> None: