This commit is contained in:
Alex38Lyon committed 2026-10-18 09:53:05 +02:00
1 parent 7549547a64
commit 442be56b70
12 files changed
+387 -66

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
"""#####################################################################################################################################
# #
# Variables globales de pyDatatoMergin.py #
# #
#####################################################################################################################################"""
Version = "2026 10 16"
Output_log = "./pyDatatoMergin.log"
Temp_folder = "Temp_mergin"
Debug_log = True
Dest_project = "mergin/ARR" # mergin/Synthese_Folly-Puaire-Criou" # "mergin/LAKORA" # "mergin/ARR"
# Valeurs pas défaut si pas de fichier ini
Github_repo = "Alex38Lyon/Synthese-PSM_LARRA"
Github_path = "Outputs/SHP/QGis_GPKG_Files/areas2dMasked.gpkg" # sous-dossier du dépôt contenant les .gpkg
Github_branch = "main"
Liste_copie = []
+468
View File
@@ -0,0 +1,468 @@
"""
#############################################################################################
Librairies générales pour pyDatatoMergin.py
#############################################################################################
"""
import logging, sys, re, hashlib, os, configparser # noqa: I001
from pathlib import Path
from parameter_expansion import expand # type: ignore
from Lib import GlobalData
logger = logging.getLogger("Logger")
#################################################################################################
# Couleurs ANSI par niveau de log
#################################################################################################
COLOR_CODES = {
logging.DEBUG: "\033[94m", # Bleu
logging.INFO: "\033[92m", # Vert
logging.WARNING: "\033[95m", # MAGENTA
logging.ERROR: "\033[91m", # Rouge
logging.CRITICAL: "\033[1;91m", # Rouge vif
}
RESET = "\033[0m"
#################################################################################################
# Coloration des messages d'aide d'arg #
#################################################################################################
def colored_help(parser):
"""
Affiche l'aide colorée pour les arguments de la ligne de commande.
Args:
parser (argparse.ArgumentParser): Le parseur d'arguments.
Returns:
None
"""
# Captures the help output
help_text = parser.format_help()
# Coloration des différentes parties
colored_help_text = (
help_text.replace("usage:", f"{Colors.ERROR}Usage:{Colors.ENDC}")
.replace("options:", f"{Colors.GREEN}Options:{Colors.ENDC}")
.replace(", --help", f"{Colors.BLUE}, --help:{Colors.ENDC}")
.replace("elp:", f"{Colors.BLUE}elp{Colors.ENDC}")
.replace("show this help message and exit", "Voir ce message et terminer")
)
# Surligner les arguments
for action in parser._actions:
if action.option_strings:
# Colorer les options (--xyz)
for opt in action.option_strings:
colored_help_text = (
colored_help_text.replace(opt, f"{Colors.BLUE}{opt}{Colors.ENDC}")
.replace("--help", f"{Colors.BLUE}--help:{Colors.ENDC}")
.replace("python", f"{Colors.BLUE}python{Colors.ENDC}")
)
# Imprimer le texte coloré
print(colored_help_text)
sys.exit(1)
#################################################################################################
# Codes de couleur ANSI
#################################################################################################
class Colors:
BLACK = "\033[90m"
RED = "\033[91m"
GREEN = "\033[92m"
YELLOW = "\033[93m"
BLUE = "\033[94m"
MAGENTA = "\033[95m"
CYAN = "\033[96m"
WHITE = "\033[97m"
TITRE = "\033[30m\033[42m"
TITRE_2 = "\033[37m\033[42m"
ERROR = "\033[91m"
WARNING = "\033[95m"
HEADER = "\033[96m"
DEBUG = "\033[94m" # Bleu
INFO = "\033[92m" # Vert
CRITICAL = "\033[1;91m" # Rouge vif
ENDC = "\033[0m"
BOLD = "\033[1m"
UNDERLINE = "\033[4m"
#################################################################################################
# Fonction de configuration du logger
#################################################################################################
def setup_logger(logfile="app.log", debug_log=False):
logger = logging.getLogger("Logger")
logger.setLevel(logging.DEBUG)
logger.handlers.clear()
logger.propagate = False
min_level = logging.DEBUG if debug_log else logging.INFO
class MaxLevelFilter(logging.Filter):
def __init__(self, max_level):
super().__init__()
self.max_level = max_level
def filter(self, record):
return record.levelno < self.max_level
# stdout : DEBUG, INFO et WARNING
stdout_handler = logging.StreamHandler(sys.stdout)
stdout_handler.setLevel(min_level)
stdout_handler.addFilter(MaxLevelFilter(logging.ERROR))
stdout_handler.setFormatter(ConsoleFormatter("%(levelname)s: %(message)s"))
logger.addHandler(stdout_handler)
# stderr : ERROR et CRITICAL uniquement
stderr_handler = logging.StreamHandler(sys.stderr)
stderr_handler.setLevel(logging.ERROR)
stderr_handler.setFormatter(ConsoleFormatter("%(levelname)s: %(message)s"))
logger.addHandler(stderr_handler)
# Fichier de log
file_handler = logging.FileHandler(logfile, encoding="utf-8")
file_handler.setLevel(min_level)
file_handler.setFormatter(FileFormatter("%(asctime)s - %(levelname)s - %(message)s"))
logger.addHandler(file_handler)
return logger
#################################################################################################
class AnsiStrippingStream:
"""Supprime les codes ANSI des sorties en mode non interactif."""
def __init__(self, stream):
self.stream = stream
def write(self, text):
return self.stream.write(strip_ansi_codes(text))
def flush(self):
return self.stream.flush()
def isatty(self):
return self.stream.isatty()
def fileno(self):
return self.stream.fileno()
def __getattr__(self, name):
return getattr(self.stream, name)
INTERACTIF = sys.stdout.isatty() and sys.stderr.isatty() and os.environ.get("TERM", "").lower() != "dumb"
if not INTERACTIF:
sys.stdout = AnsiStrippingStream(sys.stdout)
sys.stderr = AnsiStrippingStream(sys.stderr)
#################################################################################################
# Formatter pour la console avec couleurs
#################################################################################################
class ConsoleFormatter(logging.Formatter):
def format(self, record):
message = super().format(record)
if INTERACTIF:
color = COLOR_CODES.get(record.levelno, "")
return f"{color}{message}{RESET}"
return strip_ansi_codes(message)
#################################################################################################
# Supprime les codes ANSI (pour l'écriture dans les fichiers ou en mode non interactif)
#################################################################################################
def strip_ansi_codes(text):
ansi_escape = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])")
return ansi_escape.sub("", text)
#################################################################################################
# Formatter pour le fichier avec "!!!" sur les erreurs
#################################################################################################
class FileFormatter(logging.Formatter):
def format(self, record):
clean_msg = strip_ansi_codes(record.getMessage())
prefix = "!!! " if record.levelno >= logging.ERROR else ""
record_copy = logging.LogRecord(
name=record.name,
level=record.levelno,
pathname=record.pathname,
lineno=record.lineno,
msg=f"{prefix}{clean_msg}",
args=(),
exc_info=record.exc_info,
func=record.funcName,
sinfo=record.stack_info,
)
return super().format(record_copy)
#################################################################################################
def release_log_file(logger):
handlers = logger.handlers[:]
for handler in handlers:
if isinstance(handler, logging.FileHandler):
handler.close()
logger.removeHandler(handler)
################################################################################################
def get_sha256(file_path):
"""Calcule le hash SHA-256 d'un fichier.
Args:
file_path (str): Le chemin vers le fichier.
Returns:
str: Le hash SHA-256 du fichier.
"""
sha256 = hashlib.sha256()
with open(file_path, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
sha256.update(chunk)
return sha256.hexdigest()
#################################################################################################
def load_config_old(configIni="config.ini", profile="Default"):
"""
Charge un fichier de configuration .ini et initialise les variables globales.
Args:
configIni: Nom du fichier de configuration.
profile: Nom du profil Survey_Data à utiliser.
Exemple : Depot_Data:ARR
"""
try:
# Chemin potentiel du fichier config
config_file = Path(__file__).resolve().parent / configIni
# config_file = os.path.join(os.path.dirname(__file__), configIni)
if not os.path.isfile(config_file):
config_file = configIni
config = configparser.ConfigParser()
config.read(config_file, encoding="utf-8")
# ----------------------------------------------------------
# Sélection du profil Depot_Data
# ----------------------------------------------------------
depot_section = f"Depot_Data:{profile}"
if depot_section in config:
depot_cfg = config[depot_section]
elif "Depot_Data" in config:
# Compatibilité ancienne configuration
depot_cfg = config["Depot_Data"]
if profile != "Default":
logger.error(
f"Projet '{Colors.ENDC}{profile}{Colors.ERROR}' inexistant, utilisation du profil par défaut {Colors.ENDC}[Depot_Data]{Colors.ERROR} section."
)
profile = "Default"
else:
logger.error(f"Section {Colors.ENDC}[{depot_section}]{Colors.ERROR}, inexistant et aucun profil par défaut {Colors.ENDC}[Depot_Data]{Colors.ERROR}")
raise ValueError()
# ----------------------------------------------------------
# Lecture Depot_Data
# ----------------------------------------------------------
depot_keys = {
"Dest_project": "Dest_project",
"Github_repo": "Github_repo",
"Github_path": "Github_path",
"Github_branch": "Github_branch",
"Dest_folder": "Dest_folder",
}
for key, attr in depot_keys.items():
if key in depot_cfg:
value = expand(depot_cfg[key])
setattr(GlobalData, attr, value)
return config_file
except (OSError, configparser.Error, ValueError) as e:
logger.critical(f"Lecture du fichier: {Colors.ENDC}{configIni}{Colors.CRITICAL} impossible : {Colors.ENDC}{e}")
sys.exit(0)
def load_config(configIni="config.ini", profile="Default"):
"""
Charge un fichier de configuration .ini et initialise les variables globales.
Args:
configIni: Nom ou chemin du fichier de configuration.
profile: Profil Depot_Data à utiliser.
Exemple : "Default" ou "LAKORA".
Returns:
Chemin du fichier de configuration lu.
"""
try:
# ----------------------------------------------------------
# Recherche du fichier config
# ----------------------------------------------------------
config_file = Path(__file__).resolve().parent / configIni
if not config_file.is_file():
config_file = Path(configIni)
if not config_file.is_file():
raise FileNotFoundError(f"Fichier introuvable : {config_file}")
config = configparser.ConfigParser()
config.read(config_file, encoding="utf-8")
# ----------------------------------------------------------
# Sélection du profil Depot_Data
# ----------------------------------------------------------
depot_section = "Depot_Data" if profile == "Default" else f"Depot_Data:{profile}"
if depot_section in config:
depot_cfg = config[depot_section]
elif "Depot_Data" in config:
depot_cfg = config["Depot_Data"]
if profile != "Default":
logger.error(
f"Projet '{Colors.ENDC}{profile}{Colors.ERROR}' inexistant, utilisation du profil par défaut {Colors.ENDC}[Depot_Data]{Colors.ERROR}."
)
profile = "Default"
else:
raise ValueError(f"Section [{depot_section}] inexistante et aucun profil par défaut [Depot_Data].")
# ----------------------------------------------------------
# Lecture des paramètres classiques
# ----------------------------------------------------------
depot_keys = {"Dest_project": "Dest_project", "Github_repo": "Github_repo", "Github_branch": "Github_branch"}
for key, attr in depot_keys.items():
if key in depot_cfg:
value = expand(depot_cfg[key])
setattr(GlobalData, attr, value)
# ----------------------------------------------------------
# Lecture des paires source / destination
# ----------------------------------------------------------
Liste_copie = []
for key, value in depot_cfg.items():
if not key.startswith("liste_copie"):
continue
# Vérifier le nom Liste_copie suivi d'un numéro
suffix = key[11:]
if not suffix.isdigit():
continue
# Séparer la source et la destination
if "|" not in value:
raise ValueError(f"{key} invalide dans [{depot_section}] : séparateur '|' manquant.")
source, destination = (part.strip() for part in value.split("|", maxsplit=1))
if not source or not destination:
raise ValueError(f"{key} invalide dans [{depot_section}] : source ou destination vide.")
Liste_copie.append((int(suffix), expand(source), expand(destination)))
# Trier les paires par numéro
Liste_copie.sort(key=lambda Liste_copie: Liste_copie[0])
# Stocker uniquement les couples (source, destination)
GlobalData.Liste_copie = [(source, destination) for _, source, destination in Liste_copie]
logger.debug(
f"{Colors.ENDC}{len(GlobalData.Liste_copie)}{Colors.DEBUG} couple(s) source/destination chargé(s) pour le profil [{Colors.ENDC}{depot_section}{Colors.DEBUG}]."
)
return config_file
except (OSError, configparser.Error, ValueError) as e:
logger.critical(f"Lecture du fichier {Colors.ENDC}{configIni}{Colors.CRITICAL} impossible : {Colors.ENDC}{e}")
sys.exit(1)
#################################################################################################
# fonction pour réduire l'affichage des chemins long #
#################################################################################################
def safe_relpath(path, base_dir=Path(__file__).parent, max_depth=4, max_name_len=50, prefix="~"):
"""
Retourne un chemin lisible et sûr pour affichage (logs / UI).
- Compatible Windows / Linux / macOS
- Tronque la profondeur du chemin
- Tronque le nom de fichier si trop long
- Ne lève jamais d'exception
"""
# ── 1. Résolution du chemin ──────────────────────────────────────────────
try:
path = Path(path).expanduser().resolve()
except (OSError, configparser.Error, ValueError):
return str(path)
try:
base = Path(base_dir).expanduser().resolve() if base_dir else Path.cwd().resolve()
except (OSError, configparser.Error, ValueError):
base = None
# ── 2. Nom du fichier / dossier (tronqué) ─────────────────────────────────
name = path.name or str(path)
if len(name) > max_name_len:
stem = path.stem[: max(1, max_name_len - 6)]
name = f"{stem}...{path.suffix}"
# ── 3. Construction des parties ──────────────────────────────────────────
try:
if base:
rel = path.relative_to(base)
parts = list(rel.parts)
else:
raise ValueError
except (OSError, configparser.Error, ValueError):
parts = list(path.parts)
# ── 4. Cas path == base → "." ────────────────────────────────────────────
if not parts:
parts = ["."]
# ── 5. Limitation de profondeur ──────────────────────────────────────────
if isinstance(max_depth, int) and max_depth > 0 and len(parts) > max_depth:
parts = parts[-max_depth:]
parts.insert(0, prefix)
# ── 6. Remplacement du nom final ──────────────────────────────────────────
if parts and parts[-1] not in (".", os.sep):
parts[-1] = name
# ── 7. Construction finale sûre ──────────────────────────────────────────
try:
return os.path.join(*parts)
except (OSError, configparser.Error, ValueError):
return name
+13
View File
@@ -0,0 +1,13 @@
pyDatatoMergin.py
=================
** Création de l’environnement virtuel **
py -3.13 -m venv "D:\08_GitHub\.venv"
** Activer l’environnement virtuel (Powershell) **
. "D:\08_GitHub\.venv\Scripts\Activate.ps1"
+71
View File
@@ -0,0 +1,71 @@
#############################################################################################
# config.ini : Fichier de configuration pour le script pyDatatoMergin.py #
#############################################################################################
# Profil par défaut
[Depot_Data]
Dest_project = mergin/ARR
Github_repo = Alex38Lyon/Synthese-PSM_LARRA
Github_branch = main
Liste_copie1 = Outputs/SHP/QGis_GPKG_Files/ | Tests
Liste_copie2 = Outputs/DB_Synthese-PSM_LARRA.sql | Tests_Base_de_donnees
Liste_copie3 = Outputs/SHP/Stations.shp | Tests/SIG/Stations
[Depot_Data:LAKORA]
Dest_project = mergin/LAKORA
Github_repo = Alex38Lyon/Synthese-PSM_LARRA
Github_branch = main
Liste_copie1 = Outputs/SHP/QGis_GPKG_Files/ | Tests
Liste_copie2 = Outputs/DB_Synthese-PSM_LARRA.sql | Tests_Base_de_donnees2
Liste_copie3 = Outputs/SHP/Stations.shp | Tests
[Depot_Data:ARR]
Dest_project = mergin/ARR
Github_repo = Alex38Lyon/Synthese-PSM_LARRA
Github_branch = main
Liste_copie1 = Outputs/SHP/QGis_GPKG_Files/ | Tests
Liste_copie2 = Outputs/DB_Synthese-PSM_LARRA.sql | Tests_Base_de_donnees1
Liste_copie3 = Outputs/DB_Synthese-PSM_LARRA_Dat | Tests_Base_de_donnees2
[Depot_Data:Synthese_PSM_Larra_Full]
Dest_project = mergin/Synthese_PSM_Larra_Full
Github_repo = Alex38Lyon/Synthese-PSM_LARRA
Github_branch = main
Liste_copie1 = Outputs/SHP/QGis_GPKG_Files/areas2dMasked.gpkg | "01 Dessins/01.00 Synthèse Therion"
Liste_copie2 = Outputs/SHP/QGis_GPKG_Files/lines2dMasked.gpkg | "01 Dessins/01.00 Synthèse Therion"
Liste_copie3 = Outputs/SHP/QGis_GPKG_Files/outline2d.gpkg | "01 Dessins/01.00 Synthèse Therion"
Liste_copie4 = Outputs/SHP/QGis_GPKG_Files/points2d.gpkg | "01 Dessins/01.00 Synthèse Therion"
Liste_copie5 = Outputs/SHP/QGis_GPKG_Files/shots3d.gpkg | "00 Polygonales"
Liste_copie6 = Outputs/SHP/QGis_GPKG_Files/stations3d.gpkg | "00 Polygonales"
Liste_copie7 = Outputs/SHP/QGis_GPKG_Files/walls3d.gpkg | "00 Polygonales"
Liste_copie8 = Outputs/SHP/QGis_GPKG_Files/pyThtoQgis.log | "00 Polygonales"
[Depot_Data:Synthese_PSM_Larra_Light]
Dest_project = mergin/Synthese_PSM_Larra_Light
Github_repo = Alex38Lyon/Synthese-PSM_LARRA
Github_branch = main
Liste_copie1 = Outputs/SHP/QGis_GPKG_Files/shots3d.gpkg | "00 Polygonales"
Liste_copie2 = Outputs/SHP/QGis_GPKG_Files/stations3d.gpkg | "00 Polygonales"
Liste_copie3 = Outputs/SHP/QGis_GPKG_Files/walls3d.gpkg | "00 Polygonales"
Liste_copie4 = Outputs/SHP/QGis_GPKG_Files/pyThtoQgis.log | "00 Polygonales"
[Depot_Data:Synthese_Folly-Puaire-Criou]
Dest_project = mergin/Synthese_Folly-Puaire-Criou
Github_repo = robertxa/Topographies-Samoens_Folly
Github_branch = master
Liste_copie1 = Outputs/SHP/GPKG/areas2dMasekd.gpkg | 00_Dessin
Liste_copie2 = Outputs/SHP/GPKG/points2dAlt.gpkg | 00_Dessin
Liste_copie3 = Outputs/SHP/GPKG/lines2dMasekd.gpkg | 00_Dessin
Liste_copie4 = Outputs/SHP/GPKG/walls3d.gpkg | 00_Dessin
Liste_copie5 = Outputs/SHP/GPKG/outline2d.gpkg | 00_Dessin
Liste_copie6 = Outputs/SHP/GPKG/shots3d.gpkg | 00_Dessin
Liste_copie7 = Outputs/SHP/GPKG/stations3dAlt.gpkg | 02_Cavites
Liste_copie8 = Outputs/SHP/GPKG/SynclinalJB-Entrances.gpkg | 02_Cavites
Liste_copie9 = Outputs/SHP/GPKG/SystemeA21-Entrances.gpkg | 02_Cavites
Liste_copie10 = Outputs/SHP/GPKG/SystemeAV-Entrances.gpkg | 02_Cavites
Liste_copie11 = Outputs/SHP/GPKG/SystemeCP-Entrances.gpkg | 02_Cavites
Liste_copie12 = Outputs/SHP/GPKG/SystemMirolda-Entrances.gpkg | 02_Cavites
Liste_copie13 = Outputs/SHP/GPKG/SystemMirolda-Entrances.gpkg | 02_Cavites
Liste_copie14 = Outputs/SHP/GPKG/BigCaves-info.gpkg | 03_Legende
Liste_copie15 = Outputs/SHP/GPKG/Systems-info.gpkg | 03_Legende
+312
View File
@@ -0,0 +1,312 @@
2026-10-18 09:28:03,943 - DEBUG - 9 couple(s) source/destination chargé(s) pour le profil [Depot_Data:ARR].
2026-10-18 09:28:05,249 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════
2026-10-18 09:28:05,249 - INFO - Synthèse initiale des informations du projet Mergin Maps
2026-10-18 09:28:05,250 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════
2026-10-18 09:28:05,458 - INFO - Projet : ARR
2026-10-18 09:28:05,458 - INFO - Identifiant : 1707d35a-d99f-47a9-a714-519d7d9c147e
2026-10-18 09:28:05,459 - INFO - Version : v17
2026-10-18 09:28:05,459 - INFO - Créé le : 2026-08-19T09:31:30Z
2026-10-18 09:28:05,460 - INFO - Mis à jour : 2026-10-14T08:39:10Z
2026-10-18 09:28:05,461 - INFO - Public : True
2026-10-18 09:28:05,462 - INFO - Nbre de fichiers : 14
2026-10-18 09:28:05,464 - INFO - Taille totale : 128415971 Octets (122.47 Mo)
2026-10-18 09:28:05,465 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════
2026-10-18 09:28:05,466 - INFO - Envoi des données GitHub vers Mergin Maps
2026-10-18 09:28:05,468 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════
2026-10-18 09:28:05,470 - INFO - [1/5] Téléchargement des fichiers source depuis le GitHub : Alex38Lyon/Synthese-PSM_LARRA@main
2026-10-18 09:28:05,470 - INFO - Téléchargement de : Outputs/SHP/QGis_GPKG_Files/ vers Tests2
2026-10-18 09:28:23,286 - INFO - Téléchargement GitHub terminé : 8 fichier(s), 112390692 octets.
2026-10-18 09:28:23,295 - INFO - Téléchargement de : Outputs/DB_Synthese-PSM_LARRA.sql vers Base_de_donnees1
2026-10-18 09:28:26,252 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 16082638 octets.
2026-10-18 09:28:26,258 - INFO - Téléchargement de : Outputs/DB_Synthese-PSM_LARRA_Dat vers Base_de_donnees2
2026-10-18 09:28:33,264 - INFO - Téléchargement GitHub terminé : 4 fichier(s), 34460188 octets.
2026-10-18 09:28:33,273 - INFO - Téléchargement de : Outputs/readme.md vers .
2026-10-18 09:28:34,201 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 23690 octets.
2026-10-18 09:28:34,211 - INFO - Téléchargement de : Outputs/SHP/QGis_GPKG_Files/points2d.gpkg vers 01 Dessins\01.00 Synthèse Therion
2026-10-18 09:28:36,931 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 3989504 octets.
2026-10-18 09:28:36,939 - INFO - Téléchargement de : Outputs/SHP/QGis_GPKG_Files/shots3d.gpkg vers 00 Polygonales
2026-10-18 09:28:46,321 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 19320832 octets.
2026-10-18 09:28:46,325 - INFO - Téléchargement de : Outputs/SHP/QGis_GPKG_Files/stations3d.gpkg vers 00 Polygonales
2026-10-18 09:28:49,449 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 14516224 octets.
2026-10-18 09:28:49,451 - INFO - Téléchargement de : Outputs/SHP/QGis_GPKG_Files/walls3d.gpkg vers 00 Polygonales
2026-10-18 09:28:55,921 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 19693568 octets.
2026-10-18 09:28:55,925 - INFO - Téléchargement de : Outputs/SHP/QGis_GPKG_Files/pyThtoQgis.log vers 00 Polygonales
2026-10-18 09:28:56,650 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 98852 octets.
2026-10-18 09:28:56,652 - INFO - [2/5] Synchronisation du projet Mergin Maps existant : ~\pyThtoMergin\Temp_mergin\mergin\ARR
2026-10-18 09:28:56,654 - INFO - [3/5] Copie des fichiers à mettre à jour ~\Scripts\pyThtoMergin\Temp_mergin\AddedFiles
2026-10-18 09:28:56,669 - INFO - + Tests2\areas2dMasked.gpkg
2026-10-18 09:28:56,696 - INFO - + Tests2\lines2dMasked.gpkg
2026-10-18 09:28:56,707 - INFO - + Tests2\outline2d.gpkg
2026-10-18 09:28:56,717 - INFO - + Tests2\points2d.gpkg
2026-10-18 09:28:56,722 - INFO - + Tests2\pyThtoQgis.log
2026-10-18 09:28:56,742 - INFO - + Tests2\shots3d.gpkg
2026-10-18 09:28:56,752 - INFO - + Tests2\stations3d.gpkg
2026-10-18 09:28:56,769 - INFO - + Tests2\walls3d.gpkg
2026-10-18 09:28:56,789 - INFO - + Base_de_donnees1\DB_Synthese-PSM_LARRA.sql
2026-10-18 09:28:56,800 - INFO - + Base_de_donnees2\DB_Synthese-PSM_LARRA.dat
2026-10-18 09:28:56,803 - INFO - + Base_de_donnees2\DB_Synthese-PSM_LARRA.mak
2026-10-18 09:28:56,812 - INFO - + Base_de_donnees2\DB_Synthese-PSM_LARRA.plt
2026-10-18 09:28:56,821 - INFO - + Base_de_donnees2\DB_Synthese-PSM_LARRA_Dat.db
2026-10-18 09:28:56,828 - INFO - + readme.md
2026-10-18 09:28:56,835 - INFO - + 01 Dessins\01.00 Synthèse Therion\points2d.gpkg
2026-10-18 09:28:56,854 - INFO - + 00 Polygonales\shots3d.gpkg
2026-10-18 09:28:56,864 - INFO - + 00 Polygonales\stations3d.gpkg
2026-10-18 09:28:56,877 - INFO - + 00 Polygonales\walls3d.gpkg
2026-10-18 09:28:56,880 - INFO - + 00 Polygonales\pyThtoQgis.log
2026-10-18 09:28:56,880 - INFO - [4/5] Envoi vers Mergin Maps...
2026-10-18 09:28:56,880 - DEBUG - Mode debug, aucune modification envoyée sur le serveur Mergin Maps
2026-10-18 09:28:56,881 - INFO - [5/5] Envoi terminé, nettoyage des dossiers temporaires...
2026-10-18 09:28:56,881 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════
2026-10-18 09:28:56,881 - INFO - Détail des informations du projet Mergin Maps mis à jour
2026-10-18 09:28:56,882 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════
2026-10-18 09:28:57,085 - INFO - Projet : ARR
2026-10-18 09:28:57,086 - INFO - Identifiant : 1707d35a-d99f-47a9-a714-519d7d9c147e
2026-10-18 09:28:57,086 - INFO - Version : v17
2026-10-18 09:28:57,087 - INFO - Créé le : 2026-08-19T09:31:30Z
2026-10-18 09:28:57,089 - INFO - Mis à jour : 2026-10-14T08:39:10Z
2026-10-18 09:28:57,090 - INFO - Public : True
2026-10-18 09:28:57,090 - INFO - Nbre de fichiers : 14
2026-10-18 09:28:57,091 - INFO - Taille totale : 128415971 Octets (122.47 Mo)
2026-10-18 09:28:57,091 - INFO - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2026-10-18 09:28:57,092 - INFO - 20260819_115533.jpeg 2.632 Mo
2026-10-18 09:28:57,092 - INFO - ARR.gpkg 93.309 Mo
2026-10-18 09:28:57,093 - INFO - ARR.qgs 0.713 Mo
2026-10-18 09:28:57,093 - INFO - ARR_attachments.zip 0.002 Mo
2026-10-18 09:28:57,094 - INFO - Inventaire Cavités.gpkg 0.660 Mo
2026-10-18 09:28:57,095 - INFO - JPEG_20260819_113638_3152669861975410066.jpg 3.024 Mo
2026-10-18 09:28:57,095 - INFO - JPEG_20260819_113919_5886287470656202827.jpg 3.034 Mo
2026-10-18 09:28:57,096 - INFO - JPEG_20260819_121951_8365685850227103103.jpg 2.974 Mo
2026-10-18 09:28:57,096 - INFO - JPEG_20260819_122929_1446792337025110147.jpg 3.007 Mo
2026-10-18 09:28:57,096 - INFO - JPEG_20260819_123117_33265926990508961.jpg 2.516 Mo
2026-10-18 09:28:57,097 - INFO - JPEG_20260819_124915_3186813976814177670.jpg 2.899 Mo
2026-10-18 09:28:57,097 - INFO - JPEG_20260819_125124_7007318829424129864.jpg 3.165 Mo
2026-10-18 09:28:57,097 - INFO - Tests/areas2dMasked.gpkg 4.531 Mo
2026-10-18 09:28:57,098 - INFO - karstpro_etude.json 0.001 Mo
2026-10-18 09:28:57,098 - INFO - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2026-10-18 09:48:14,411 - DEBUG - 15 couple(s) source/destination chargé(s) pour le profil [Depot_Data:Synthese_Folly-Puaire-Criou].
2026-10-18 09:48:15,202 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════
2026-10-18 09:48:15,203 - INFO - Synthèse initiale des informations du projet Mergin Maps
2026-10-18 09:48:15,203 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════
2026-10-18 09:48:15,539 - INFO - Projet : Synthese_Folly-Puaire-Criou
2026-10-18 09:48:15,540 - INFO - Identifiant : 61f9ebfe-317e-4cc6-906e-ec013208c256
2026-10-18 09:48:15,541 - INFO - Version : v94
2026-10-18 09:48:15,541 - INFO - Créé le : 2024-11-18T10:03:04Z
2026-10-18 09:48:15,542 - INFO - Mis à jour : 2026-10-07T17:23:27Z
2026-10-18 09:48:15,542 - INFO - Public : True
2026-10-18 09:48:15,543 - INFO - Nbre de fichiers : 129
2026-10-18 09:48:15,544 - INFO - Taille totale : 756091063 Octets (721.06 Mo)
2026-10-18 09:48:15,545 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════
2026-10-18 09:48:15,545 - INFO - Envoi des données GitHub vers Mergin Maps
2026-10-18 09:48:15,546 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════
2026-10-18 09:48:15,549 - INFO - [1/5] Téléchargement des fichiers source depuis le GitHub : robertxa/Topographies-Samoens_Folly@master
2026-10-18 09:48:15,550 - INFO - Téléchargement de : Outputs/SHP/GPKG/areas2dMasked.gpkg vers 00_Dessin
2026-10-18 09:48:16,082 - ERROR - !!! Le dossier temporaire est conservé pour diagnostic :
2026-10-18 09:48:16,082 - ERROR - !!! D:\08_GitHub\Synthese-PSM_LARRA\Scripts\pyThtoMergin\Temp_mergin
2026-10-18 09:49:14,918 - DEBUG - 15 couple(s) source/destination chargé(s) pour le profil [Depot_Data:Synthese_Folly-Puaire-Criou].
2026-10-18 09:49:15,684 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════
2026-10-18 09:49:15,685 - INFO - Synthèse initiale des informations du projet Mergin Maps
2026-10-18 09:49:15,685 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════
2026-10-18 09:49:15,973 - INFO - Projet : Synthese_Folly-Puaire-Criou
2026-10-18 09:49:15,973 - INFO - Identifiant : 61f9ebfe-317e-4cc6-906e-ec013208c256
2026-10-18 09:49:15,973 - INFO - Version : v94
2026-10-18 09:49:15,973 - INFO - Créé le : 2024-11-18T10:03:04Z
2026-10-18 09:49:15,974 - INFO - Mis à jour : 2026-10-07T17:23:27Z
2026-10-18 09:49:15,974 - INFO - Public : True
2026-10-18 09:49:15,974 - INFO - Nbre de fichiers : 129
2026-10-18 09:49:15,974 - INFO - Taille totale : 756091063 Octets (721.06 Mo)
2026-10-18 09:49:15,975 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════
2026-10-18 09:49:15,975 - INFO - Envoi des données GitHub vers Mergin Maps
2026-10-18 09:49:15,975 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════
2026-10-18 09:49:15,976 - INFO - [1/5] Téléchargement des fichiers source depuis le GitHub : robertxa/Topographies-Samoens_Folly@master
2026-10-18 09:49:15,976 - INFO - Téléchargement de : Outputs/SHP/GPKG/areas2dMasekd.gpkg vers 00_Dessin
2026-10-18 09:49:17,096 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 1236992 octets.
2026-10-18 09:49:17,098 - INFO - Téléchargement de : Outputs/SHP/GPKG/points2dAlt.gpkg vers 00_Dessin
2026-10-18 09:49:18,192 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 4902912 octets.
2026-10-18 09:49:18,193 - INFO - Téléchargement de : Outputs/SHP/GPKG/lines2dMasekd.gpkg vers 00_Dessin
2026-10-18 09:49:23,843 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 28553216 octets.
2026-10-18 09:49:23,845 - INFO - Téléchargement de : Outputs/SHP/GPKG/walls3d.gpkg vers 00_Dessin
2026-10-18 09:49:27,053 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 25882624 octets.
2026-10-18 09:49:27,055 - INFO - Téléchargement de : Outputs/SHP/GPKG/outline2d.gpkg vers 00_Dessin
2026-10-18 09:49:29,415 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 15769600 octets.
2026-10-18 09:49:29,420 - INFO - Téléchargement de : Outputs/SHP/GPKG/shots3d.gpkg vers 00_Dessin
2026-10-18 09:49:30,975 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 6905856 octets.
2026-10-18 09:49:30,979 - INFO - Téléchargement de : Outputs/SHP/GPKG/stations3dAlt.gpkg vers 02_Cavites
2026-10-18 09:49:32,463 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 6860800 octets.
2026-10-18 09:49:32,465 - INFO - Téléchargement de : Outputs/SHP/GPKG/SynclinalJB-Entrances.gpkg vers 02_Cavites
2026-10-18 09:49:33,159 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 98304 octets.
2026-10-18 09:49:33,163 - INFO - Téléchargement de : Outputs/SHP/GPKG/SystemeA21-Entrances.gpkg vers 02_Cavites
2026-10-18 09:49:33,862 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 98304 octets.
2026-10-18 09:49:33,864 - INFO - Téléchargement de : Outputs/SHP/GPKG/SystemeAV-Entrances.gpkg vers 02_Cavites
2026-10-18 09:49:34,459 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 98304 octets.
2026-10-18 09:49:34,460 - INFO - Téléchargement de : Outputs/SHP/GPKG/SystemeCP-Entrances.gpkg vers 02_Cavites
2026-10-18 09:49:35,068 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 98304 octets.
2026-10-18 09:49:35,070 - INFO - Téléchargement de : Outputs/SHP/GPKG/SystemMirolda-Entrances.gpkg vers 02_Cavites
2026-10-18 09:49:35,650 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 98304 octets.
2026-10-18 09:49:35,651 - INFO - Téléchargement de : Outputs/SHP/GPKG/SystemMirolda-Entrances.gpkg vers 02_Cavites
2026-10-18 09:49:35,961 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 98304 octets.
2026-10-18 09:49:35,962 - INFO - Téléchargement de : Outputs/SHP/GPKG/BigCaves-info.gpkg vers 03_Legende
2026-10-18 09:49:37,062 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 98304 octets.
2026-10-18 09:49:37,064 - INFO - Téléchargement de : Outputs/SHP/GPKG/Systems-info.gpkg vers 03_Legende
2026-10-18 09:49:37,611 - INFO - Téléchargement GitHub terminé : 1 fichier(s), 98304 octets.
2026-10-18 09:49:37,614 - INFO - [2/5] Synchronisation du projet Mergin Maps existant : ~\pyThtoMergin\Temp_mergin\mergin\Synthese_Folly-Puaire-Criou
2026-10-18 09:49:37,615 - INFO - [3/5] Copie des fichiers à mettre à jour ~\Scripts\pyThtoMergin\Temp_mergin\AddedFiles
2026-10-18 09:49:37,619 - INFO - + 00_Dessin\areas2dMasekd.gpkg
2026-10-18 09:49:37,627 - INFO - + 00_Dessin\points2dAlt.gpkg
2026-10-18 09:49:37,645 - INFO - + 00_Dessin\lines2dMasekd.gpkg
2026-10-18 09:49:37,671 - INFO - + 00_Dessin\walls3d.gpkg
2026-10-18 09:49:37,687 - INFO - + 00_Dessin\outline2d.gpkg
2026-10-18 09:49:37,700 - INFO - + 00_Dessin\shots3d.gpkg
2026-10-18 09:49:37,710 - INFO - + 02_Cavites\stations3dAlt.gpkg
2026-10-18 09:49:37,716 - INFO - + 02_Cavites\SynclinalJB-Entrances.gpkg
2026-10-18 09:49:37,719 - INFO - + 02_Cavites\SystemeA21-Entrances.gpkg
2026-10-18 09:49:37,724 - INFO - + 02_Cavites\SystemeAV-Entrances.gpkg
2026-10-18 09:49:37,730 - INFO - + 02_Cavites\SystemeCP-Entrances.gpkg
2026-10-18 09:49:37,733 - INFO - + 02_Cavites\SystemMirolda-Entrances.gpkg
2026-10-18 09:49:37,736 - INFO - + 02_Cavites\SystemMirolda-Entrances.gpkg
2026-10-18 09:49:37,738 - INFO - + 03_Legende\BigCaves-info.gpkg
2026-10-18 09:49:37,741 - INFO - + 03_Legende\Systems-info.gpkg
2026-10-18 09:49:37,741 - INFO - [4/5] Envoi vers Mergin Maps...
2026-10-18 09:49:37,741 - DEBUG - Mode debug, aucune modification envoyée sur le serveur Mergin Maps
2026-10-18 09:49:37,741 - INFO - [5/5] Envoi terminé, nettoyage des dossiers temporaires...
2026-10-18 09:49:37,741 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════
2026-10-18 09:49:37,742 - INFO - Détail des informations du projet Mergin Maps mis à jour
2026-10-18 09:49:37,742 - INFO - ═══════════════════════════════════════════════════════════════════════════════════════════════
2026-10-18 09:49:37,992 - INFO - Projet : Synthese_Folly-Puaire-Criou
2026-10-18 09:49:37,992 - INFO - Identifiant : 61f9ebfe-317e-4cc6-906e-ec013208c256
2026-10-18 09:49:37,993 - INFO - Version : v94
2026-10-18 09:49:37,993 - INFO - Créé le : 2024-11-18T10:03:04Z
2026-10-18 09:49:37,993 - INFO - Mis à jour : 2026-10-07T17:23:27Z
2026-10-18 09:49:37,994 - INFO - Public : True
2026-10-18 09:49:37,994 - INFO - Nbre de fichiers : 129
2026-10-18 09:49:37,995 - INFO - Taille totale : 756091063 Octets (721.06 Mo)
2026-10-18 09:49:37,995 - INFO - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2026-10-18 09:49:37,995 - INFO - 00_Dessin/areas2dMasekd.gpkg 1.641 Mo
2026-10-18 09:49:37,996 - INFO - 00_Dessin/lines2dMasekd.gpkg 39.070 Mo
2026-10-18 09:49:37,996 - INFO - 00_Dessin/points2dAlt.gpkg 5.352 Mo
2026-10-18 09:49:37,997 - INFO - 00_Dessin/walls3d.gpkg 31.676 Mo
2026-10-18 09:49:37,997 - INFO - 01_Polygonale/shots3d.gpkg 8.422 Mo
2026-10-18 09:49:37,998 - INFO - 02_Cavites/SynclinalJB-Entrances.gpkg 0.094 Mo
2026-10-18 09:49:37,998 - INFO - 02_Cavites/SystemMirolda-Entrances.gpkg 0.094 Mo
2026-10-18 09:49:37,998 - INFO - 02_Cavites/SystemeA21-Entrances.gpkg 0.094 Mo
2026-10-18 09:49:37,999 - INFO - 02_Cavites/SystemeAV-Entrances.gpkg 0.094 Mo
2026-10-18 09:49:37,999 - INFO - 02_Cavites/SystemeCP-Entrances.gpkg 0.094 Mo
2026-10-18 09:49:38,000 - INFO - 02_Cavites/VieuxTrous-withAlt3.gpkg 0.137 Mo
2026-10-18 09:49:38,000 - INFO - 02_Cavites/stations3dAlt.gpkg 8.277 Mo
2026-10-18 09:49:38,001 - INFO - 03_Legende/BigCaves-info.gpkg 0.094 Mo
2026-10-18 09:49:38,002 - INFO - 03_Legende/Folly-Cartouche.jpg.aux.xml 0.002 Mo
2026-10-18 09:49:38,002 - INFO - 03_Legende/Folly-Cartouche.jpg.points 0.002 Mo
2026-10-18 09:49:38,002 - INFO - 03_Legende/Folly-Cartouche_modifié.tif 12.935 Mo
2026-10-18 09:49:38,003 - INFO - 03_Legende/Folly-Cartouche_modifié.tif.aux.xml 0.001 Mo
2026-10-18 09:49:38,003 - INFO - 03_Legende/Folly-Cartouche_modifié.tif.ovr 32.310 Mo
2026-10-18 09:49:38,004 - INFO - 03_Legende/Systems-info.gpkg 0.094 Mo
2026-10-18 09:49:38,004 - INFO - 03_Legende/by-nc-nd.png 0.020 Mo
2026-10-18 09:49:38,005 - INFO - 04_Prospections/Photos_entrees/20260905_111532.jpg 10.849 Mo
2026-10-18 09:49:38,005 - INFO - 04_Prospections/Photos_entrees/20260905_121742.jpg 10.994 Mo
2026-10-18 09:49:38,005 - INFO - 04_Prospections/Photos_entrees/20260905_135341.jpg 6.886 Mo
2026-10-18 09:49:38,006 - INFO - 04_Prospections/Photos_entrees/20260905_185402.jpg 10.433 Mo
2026-10-18 09:49:38,006 - INFO - 04_Prospections/Photos_entrees/IMG-20260909-WA0044.jpg 1.107 Mo
2026-10-18 09:49:38,006 - INFO - 04_Prospections/Photos_entrees/JPEG_20260905_090145_5053031136853358175.jpg 3.592 Mo
2026-10-18 09:49:38,006 - INFO - 04_Prospections/Photos_entrees/JPEG_20260905_121544_4946827557172064904.jpg 4.890 Mo
2026-10-18 09:49:38,007 - INFO - 04_Prospections/Photos_entrees/JPEG_20260905_124430_1955309953428376512.jpg 3.991 Mo
2026-10-18 09:49:38,007 - INFO - 04_Prospections/Photos_entrees/JPEG_20260905_125114_3410204003189233662.jpg 4.391 Mo
2026-10-18 09:49:38,007 - INFO - 04_Prospections/Photos_entrees/JPEG_20260905_131449_7465959482970259071.jpg 4.305 Mo
2026-10-18 09:49:38,008 - INFO - 04_Prospections/Photos_entrees/JPEG_20260905_140153_2122409591475107505.jpg 3.456 Mo
2026-10-18 09:49:38,008 - INFO - 04_Prospections/Photos_entrees/JPEG_20260905_153436_7773210411732533580.jpg 5.409 Mo
2026-10-18 09:49:38,008 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_093050_4863670314965595474.jpg 4.027 Mo
2026-10-18 09:49:38,009 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_093635_5479679904344645328.jpg 3.947 Mo
2026-10-18 09:49:38,009 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_094030_7656678739334534769.jpg 3.900 Mo
2026-10-18 09:49:38,009 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_095726_2639364801324209654.jpg 4.347 Mo
2026-10-18 09:49:38,010 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_100157_8321289991535721081.jpg 5.367 Mo
2026-10-18 09:49:38,010 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_100553_5348548942130856148.jpg 4.775 Mo
2026-10-18 09:49:38,010 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_101356_4873638495705664525.jpg 5.008 Mo
2026-10-18 09:49:38,011 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_101746_6557668662638516766.jpg 5.075 Mo
2026-10-18 09:49:38,011 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_102303_5693900851867106548.jpg 3.564 Mo
2026-10-18 09:49:38,011 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_110512_2210769318001691275.jpg 5.099 Mo
2026-10-18 09:49:38,012 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_111554_6969877519448043897.jpg 4.046 Mo
2026-10-18 09:49:38,012 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_112511_3310497289340038422.jpg 7.152 Mo
2026-10-18 09:49:38,012 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_115431_5518321783481652673.jpg 3.888 Mo
2026-10-18 09:49:38,013 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_121303_5473587878557326338.jpg 6.350 Mo
2026-10-18 09:49:38,013 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_121739_528147722775535254.jpg 3.392 Mo
2026-10-18 09:49:38,013 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_124554_4868079246617476940.jpg 4.070 Mo
2026-10-18 09:49:38,013 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_131141_6427618171441780766.jpg 6.001 Mo
2026-10-18 09:49:38,014 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_131315_5401134733595847354.jpg 5.358 Mo
2026-10-18 09:49:38,014 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_141342_8190689509358581647.jpg 5.306 Mo
2026-10-18 09:49:38,014 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_145244_3552918964593441589.jpg 4.905 Mo
2026-10-18 09:49:38,015 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_145927_6844140333328882727.jpg 4.957 Mo
2026-10-18 09:49:38,015 - INFO - 04_Prospections/Photos_entrees/JPEG_20260906_151624_8735738839076591704.jpg 5.596 Mo
2026-10-18 09:49:38,015 - INFO - 04_Prospections/Photos_entrees/JPEG_20260909_144020_7030182998762926089.jpg 7.673 Mo
2026-10-18 09:49:38,016 - INFO - 04_Prospections/Photos_entrees/JPEG_20260909_145013_9183354724471446816.jpg 3.878 Mo
2026-10-18 09:49:38,016 - INFO - 04_Prospections/Photos_entrees/JPEG_20260909_150112_1045711275475893141.jpg 8.477 Mo
2026-10-18 09:49:38,016 - INFO - 04_Prospections/Photos_entrees/JPEG_20260909_152410_7142908514868884811.jpg 5.111 Mo
2026-10-18 09:49:38,017 - INFO - 04_Prospections/Photos_entrees/JPEG_20260909_152722_6436501499817532112.jpg 4.856 Mo
2026-10-18 09:49:38,017 - INFO - 04_Prospections/Photos_entrees/JPEG_20260909_153041_7166507665625609442.jpg 4.228 Mo
2026-10-18 09:49:38,017 - INFO - 04_Prospections/Photos_entrees/JPEG_20260909_154354_1665667581420092868.jpg 4.210 Mo
2026-10-18 09:49:38,018 - INFO - 04_Prospections/Photos_entrees/JPEG_20260909_155040_1213919286731602620.jpg 4.178 Mo
2026-10-18 09:49:38,018 - INFO - 04_Prospections/Photos_entrees/JPEG_20260909_155555_1620398383999262049.jpg 5.683 Mo
2026-10-18 09:49:38,018 - INFO - 04_Prospections/Photos_entrees/JPEG_20260909_155847_1662834540454505364.jpg 4.734 Mo
2026-10-18 09:49:38,019 - INFO - 04_Prospections/Photos_entrees/JPEG_20260909_160459_5854394878033691657.jpg 4.982 Mo
2026-10-18 09:49:38,019 - INFO - 04_Prospections/Photos_entrees/JPEG_20260909_160852_2468322604635228352.jpg 0.000 Mo
2026-10-18 09:49:38,019 - INFO - 04_Prospections/Photos_entrees/JPEG_20260909_161057_2303890591036112064.jpg 4.899 Mo
2026-10-18 09:49:38,020 - INFO - 04_Prospections/Photos_entrees/JPEG_20260909_161542_4007283344007429412.jpg 5.280 Mo
2026-10-18 09:49:38,020 - INFO - 04_Prospections/Photos_entrees/JPEG_20260909_162559_5781813717125952271.jpg 4.695 Mo
2026-10-18 09:49:38,020 - INFO - 04_Prospections/Photos_entrees/JPEG_20260909_163316_4495407811095148578.jpg 4.028 Mo
2026-10-18 09:49:38,021 - INFO - 04_Prospections/Photos_entrees/JPEG_20260909_164612_1160119729373932382.jpg 4.022 Mo
2026-10-18 09:49:38,021 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_104853_801223106792575127.jpg 6.026 Mo
2026-10-18 09:49:38,021 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_110113_572088524215767497.jpg 3.224 Mo
2026-10-18 09:49:38,022 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_110548_6528916722039767177.jpg 2.359 Mo
2026-10-18 09:49:38,022 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_110723_2415862424029981791.jpg 6.000 Mo
2026-10-18 09:49:38,022 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_110856_541213821134432814.jpg 5.814 Mo
2026-10-18 09:49:38,023 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_112148_2557300077262514896.jpg 5.926 Mo
2026-10-18 09:49:38,023 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_112448_3040469123055458117.jpg 5.227 Mo
2026-10-18 09:49:38,023 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_112748_6703047802447944653.jpg 3.528 Mo
2026-10-18 09:49:38,024 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_113853_8857290264131311098.jpg 5.450 Mo
2026-10-18 09:49:38,024 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_114338_2715666616005667626.jpg 4.621 Mo
2026-10-18 09:49:38,024 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_121413_4222665988574656766.jpg 6.411 Mo
2026-10-18 09:49:38,025 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_125134_4529828893370015844.jpg 5.435 Mo
2026-10-18 09:49:38,025 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_125308_1499425568413585382.jpg 4.801 Mo
2026-10-18 09:49:38,025 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_130227_3766093931755238780.jpg 4.759 Mo
2026-10-18 09:49:38,026 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_131522_3777698422154287209.jpg 3.100 Mo
2026-10-18 09:49:38,026 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_131801_482725351920497875.jpg 5.688 Mo
2026-10-18 09:49:38,026 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_132955_32538423008202788.jpg 4.558 Mo
2026-10-18 09:49:38,027 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_134415_2620277665037031494.jpg 6.318 Mo
2026-10-18 09:49:38,029 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_140359_6499137072242062339.jpg 5.528 Mo
2026-10-18 09:49:38,029 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_140445_6473652240857622263.jpg 4.893 Mo
2026-10-18 09:49:38,030 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_141117_1265138821413478841.jpg 3.586 Mo
2026-10-18 09:49:38,030 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_142030_4546971906788304357.jpg 5.099 Mo
2026-10-18 09:49:38,030 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_143840_9189782455360025562.jpg 3.810 Mo
2026-10-18 09:49:38,030 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_144443_3678357507747603572.jpg 6.023 Mo
2026-10-18 09:49:38,031 - INFO - 04_Prospections/Photos_entrees/JPEG_20260911_144705_4748437264238054175.jpg 4.191 Mo
2026-10-18 09:49:38,031 - INFO - 04_Prospections/Photos_entrees/JPEG_20260912_113322_907414819668612972.jpg 5.588 Mo
2026-10-18 09:49:38,031 - INFO - 04_Prospections/Photos_entrees/desktop.ini 0.000 Mo
2026-10-18 09:49:38,032 - INFO - 04_Prospections/Prospection-Bossetan-LIDAR.gpkg 0.188 Mo
2026-10-18 09:49:38,032 - INFO - 04_Prospections/Prospection-CP-LIDAR.gpkg 0.141 Mo
2026-10-18 09:49:38,032 - INFO - 04_Prospections/Prospection-Criou1.gpkg 0.133 Mo
2026-10-18 09:49:38,033 - INFO - 04_Prospections/Prospection-Criou2.gpkg 0.250 Mo
2026-10-18 09:49:38,033 - INFO - 04_Prospections/Prospection-DR-LIDAR.gpkg 0.117 Mo
2026-10-18 09:49:38,033 - INFO - 04_Prospections/Prospection-Folly-LP-Lidar.gpkg 0.180 Mo
2026-10-18 09:49:38,034 - INFO - 04_Prospections/Prospection-Folly-LS-Lidar.gpkg 0.242 Mo
2026-10-18 09:49:38,034 - INFO - 04_Prospections/Prospection-Folly-Lidar.gpkg 0.160 Mo
2026-10-18 09:49:38,034 - INFO - 04_Prospections/Prospection-JB-LIDAR.gpkg 0.102 Mo
2026-10-18 09:49:38,035 - INFO - 04_Prospections/Prospection-SanBet-LIDAR.gpkg 0.133 Mo
2026-10-18 09:49:38,035 - INFO - 04_Prospections/Prospection-Suets-LIDAR.gpkg 0.102 Mo
2026-10-18 09:49:38,035 - INFO - 04_Prospections/Prospection-T-LIDAR.gpkg 0.176 Mo
2026-10-18 09:49:38,036 - INFO - 04_Prospections/Prospection-Tuets-LIDAR.gpkg 0.102 Mo
2026-10-18 09:49:38,036 - INFO - 06_Fonds_de_carte/IGN-Scan25-Samoens-UTM32-compr.tif 29.954 Mo
2026-10-18 09:49:38,036 - INFO - 06_Fonds_de_carte/IGN-Scan25-Samoens-UTM32-compr.tif.aux.xml 1.431 Mo
2026-10-18 09:49:38,037 - INFO - 06_Fonds_de_carte/IGN-Scan25-Samoens-UTM32-compr.tif.ovr 54.009 Mo
2026-10-18 09:49:38,037 - INFO - 06_Fonds_de_carte/OSM_Courbes_de_niveau.gpkg 1.746 Mo
2026-10-18 09:49:38,037 - INFO - 06_Fonds_de_carte/OSM_Ombrage.tif 15.339 Mo
2026-10-18 09:49:38,037 - INFO - 06_Fonds_de_carte/OSM_Ombrage.tif.aux.xml 0.001 Mo
2026-10-18 09:49:38,038 - INFO - 06_Fonds_de_carte/OSM_Ombrage.tif.ovr 84.157 Mo
2026-10-18 09:49:38,038 - INFO - 06_Fonds_de_carte/OSM_buildings.gpkg 2.273 Mo
2026-10-18 09:49:38,038 - INFO - 06_Fonds_de_carte/OSM_landuse.gpkg 0.352 Mo
2026-10-18 09:49:38,039 - INFO - 06_Fonds_de_carte/OSM_natural.gpkg 0.363 Mo
2026-10-18 09:49:38,039 - INFO - 06_Fonds_de_carte/OSM_places.gpkg 0.160 Mo
2026-10-18 09:49:38,039 - INFO - 06_Fonds_de_carte/OSM_points.gpkg 0.230 Mo
2026-10-18 09:49:38,040 - INFO - 06_Fonds_de_carte/OSM_roads.gpkg 1.609 Mo
2026-10-18 09:49:38,040 - INFO - 06_Fonds_de_carte/OSM_waterways.gpkg 0.738 Mo
2026-10-18 09:49:38,040 - INFO - 06_Fonds_de_carte/Surfaces_Géologiques_Simplifées.gpkg 0.344 Mo
2026-10-18 09:49:38,040 - INFO - Synthese-Folly-Puaire-Criou.qgz 0.503 Mo
2026-10-18 09:49:38,041 - INFO - mergin-config.json 0.000 Mo
2026-10-18 09:49:38,041 - INFO - qgis_cfg.xml 0.001 Mo
2026-10-18 09:49:38,041 - INFO - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
@@ -0,0 +1,38 @@
{
"folders": [
{
"path": "."
}
],
"settings": {
"python-envs.defaultEnvManager": "ms-python.python:system",
"cSpell.words": [
"ansi",
"Criou",
"Datato",
"dotenv",
"ENDC",
"entetes",
"github",
"Github",
"gpkg",
"LAKORA",
"Larra",
"LARRA",
"Masekd",
"Maseked",
"mergin",
"Mergin",
"Nbre",
"Puaire",
"Qgis",
"reponse",
"robertxa",
"Samoens",
"sinfo",
"Synthese",
"telecharger",
"Therion"
]
}
}
+566
View File
@@ -0,0 +1,566 @@
#!/usr/bin/env python3
"""#####################################################################################################################################
# #
# #
#####################################################################################################################################"""
import argparse, shutil, os, sys, subprocess, time, logging, requests # noqa: I001
from urllib.parse import quote
from pathlib import Path
from dotenv import load_dotenv
from alive_progress import alive_bar # type: ignore
from mergin import MerginClient # type: ignore
from mergin.client_pull import download_project_async, download_project_is_running, download_project_finalize # type: ignore
from mergin.client_push import push_project_async, push_project_is_running, push_project_finalize # type: ignore
from Lib.Librairies import setup_logger, Colors, AnsiStrippingStream, load_config, colored_help, safe_relpath
from Lib import GlobalData
GITHUB_API = "https://api.github.com"
INTERACTIF = sys.stdout.isatty() and sys.stderr.isatty() and os.environ.get("TERM", "").lower() != "dumb"
if not INTERACTIF:
sys.stdout = AnsiStrippingStream(sys.stdout)
sys.stderr = AnsiStrippingStream(sys.stderr)
############################################################################################################################################
def suivre_transfert(job, verifier, titre: str) -> None:
"""Affiche la progression et le débit d'un transfert Mergin Maps."""
taille_totale = job.total_size
if taille_totale <= 0:
while verifier(job):
time.sleep(0.2)
logger.info(f"{Colors.ENDC}{titre}{Colors.INFO} : transfert terminé.")
return
precedent = 0
interactif = sys.stdout.isatty() and sys.stderr.isatty() and os.environ.get("TERM", "").lower() != "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:
while verifier(job):
actuel = job.transferred_size
delta = actuel - precedent
if delta > 0:
barre(delta)
precedent = actuel
time.sleep(0.2)
# Comptabilise les derniers octets transférés.
delta = job.transferred_size - precedent
if delta > 0:
barre(delta)
else:
logger.info(f"{Colors.ENDC}{titre}{Colors.INFO} : transfert démarré ({Colors.ENDC}{taille_totale}{Colors.INFO} octets).")
while verifier(job):
actuel = job.transferred_size
delta = actuel - precedent
if delta > 0:
precedent = actuel
logger.debug(
f"({Colors.ENDC}{titre}{Colors.DEBUG} : {Colors.ENDC}{actuel * 100 / taille_totale:.1f}{Colors.DEBUG} ({Colors.ENDC}{actuel}{Colors.DEBUG} / {Colors.ENDC}{taille_totale}{Colors.DEBUG} octets)"
)
time.sleep(0.2)
logger.info(f"{Colors.ENDC}{titre}{Colors.INFO} : transfert terminé.")
############################################################################################################################################
def telecharger_avec_progression(client: MerginClient, projet: str, dossier: Path) -> None:
"""Télécharge un projet Mergin Maps avec suivi de progression."""
job = download_project_async(client, projet, str(dossier))
suivre_transfert(job, download_project_is_running, "Téléchargement")
download_project_finalize(job)
############################################################################################################################################
def envoyer_avec_progression(client: MerginClient, dossier: Path) -> None:
"""Envoie les modifications vers Mergin Maps avec suivi."""
if GlobalData.Debug_log == False:
job = push_project_async(client, str(dossier))
if job is None:
logger.warning("Aucune modification à envoyer.")
return
suivre_transfert(job, push_project_is_running, "Envoi vers Mergin")
push_project_finalize(job)
else:
logger.debug("Mode debug, aucune modification envoyée sur le serveur Mergin Maps")
############################################################################################################################################
def supprimer_dossier_temporaire(dossier: Path, tentatives: int = 5) -> bool:
"""Supprime un dossier temporaire en réessayant si un fichier est verrouillé."""
for tentative in range(tentatives):
try:
shutil.rmtree(dossier)
logger.info(f"Dossier temporaire supprimé : {Colors.ENDC}{dossier}")
return True
except PermissionError as erreur:
if tentative == tentatives - 1:
logger.warning(f"Suppression impossible, dossier conservé : {Colors.ENDC}{dossier}{Colors.WARNING},{Colors.ENDC}{erreur}")
return False
time.sleep(1)
return False
############################################################################################################################################
def fermer_journaux_mergin() -> None:
"""Ferme les gestionnaires de fichiers de journalisation Mergin."""
loggers = [logging.getLogger()]
loggers.extend(logging.Logger.manager.loggerDict.values())
for logger in loggers:
if not isinstance(logger, logging.Logger):
continue
for handler in logger.handlers[:]:
if isinstance(handler, logging.FileHandler):
handler.flush()
handler.close()
logger.removeHandler(handler)
############################################################################################################################################
def _entetes_github(token: str | None, brut: bool = False) -> dict:
accept = "application/vnd.github.raw+json" if brut else "application/vnd.github+json"
entetes = {"Accept": accept, "X-GitHub-Api-Version": "2022-11-28"}
if token:
entetes["Authorization"] = f"Bearer {token}"
return entetes
############################################################################################################################################
def lister_fichiers_github(session: requests.Session, depot: str, branche: str, chemin: str, token: str | None) -> list[dict]:
"""Liste récursivement les fichiers d'un dossier GitHub (ou le fichier lui-même)."""
url = f"{GITHUB_API}/repos/{depot}/contents/{quote(chemin)}"
reponse = session.get(url, params={"ref": branche}, headers=_entetes_github(token), timeout=60)
if reponse.status_code == 404:
try:
detail = reponse.json().get("message", "Ressource introuvable")
except ValueError:
detail = reponse.text
raise FileNotFoundError(
f"GitHub : {detail}\nDépôt : {depot}\nBranche : {branche}\nChemin : {chemin}\nVérifie que le chemin existe dans cette branche."
)
reponse.raise_for_status()
contenu = reponse.json()
if isinstance(contenu, dict): # le chemin désigne un fichier
return [contenu]
fichiers = []
for entree in contenu:
if entree["type"] == "file":
fichiers.append(entree)
elif entree["type"] == "dir":
fichiers.extend(lister_fichiers_github(session, depot, branche, entree["path"], token))
return fichiers
############################################################################################################################################
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.
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)
dossier_cible.mkdir(parents=True, exist_ok=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 fichier demandé : destination à plat ; sinon, conserver l'arborescence.
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() and sys.stderr.isatty() and os.environ.get("TERM", "").lower() != "dumb"
precedent = 0
def telecharger_fichiers(barre=None) -> None:
nonlocal precedent
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 reponse:
reponse.raise_for_status()
with open(local, "wb") as sortie:
for morceau in reponse.iter_content(chunk_size=1024 * 256):
if not morceau:
continue
sortie.write(morceau)
precedent += len(morceau)
if barre:
barre(len(morceau))
# else:
# logger.debug(
# "GitHub : %s — %.1f %% (%s / %s octets)", fichier["path"], precedent * 100 / total if total else 0, precedent, total or "?"
# )
if interactif:
with alive_bar(total, title=f"{Colors.YELLOW}Téléchargement GitHub{Colors.ENDC}", stats=True, scale="SI", unit="o") as barre:
telecharger_fichiers(barre)
else:
telecharger_fichiers()
logger.info(f"Téléchargement GitHub terminé : {Colors.ENDC}{len(fichiers)}{Colors.INFO} fichier(s), {Colors.ENDC}{precedent}{Colors.INFO} octets.")
return dossier_cible / Path(chemin).name if est_fichier else dossier_cible
############################################################################################################################################
def sync_mergin(
projet: str, client: MerginClient, depot: str, branche: str = "main", liste=GlobalData.Liste_copie, temp_folder: Path = "", token: str | None = None
):
"""#####################################################################################################################################
Télécharge un fichier ou un dossier depuis GitHub puis l'envoie vers Mergin Maps.
Le dossier temporaire est conservé en cas d'erreur.
La copie GitHub est supprimée après un succès complet.
#####################################################################################################################################"""
if temp_folder == "":
temp_folder = Path(__file__).parent / GlobalData.Temp_folder
logger.info("═" * 95)
logger.info((f"{Colors.YELLOW}Envoi des données GitHub vers Mergin Maps").center(99))
logger.info("═" * 95)
dossier_temporaire = Path(temp_folder).resolve()
dossier_temporaire.mkdir(parents=True, exist_ok=True)
dossier_github = dossier_temporaire / "AddedFiles"
dossier_projet = dossier_temporaire / projet
sources = []
try:
# 1. Téléchargement du fichier ou dossier nécessaire depuis GitHub.
logger.info(f"[1/5]{Colors.INFO} Téléchargement des fichiers source depuis le GitHub : {Colors.ENDC}{depot}@{branche}")
for chemin_GitHub, _Dest_GitHub in liste:
_Dest_GitHub = Path(_Dest_GitHub)
if _Dest_GitHub.is_absolute() or ".." in _Dest_GitHub.parts:
raise ValueError(f"La destination {Colors.ENDC}{_Dest_GitHub.parts}{Colors.ERROR} doit être un chemin relatif.")
if ".mergin" in _Dest_GitHub.parts:
raise ValueError(f"Le dossier {Colors.ENDC}.mergin{Colors.ERROR} est réservé à Mergin Maps.")
logger.info(f"Téléchargement de : {Colors.ENDC}{chemin_GitHub}{Colors.INFO} vers {Colors.ENDC}{_Dest_GitHub}")
source = telecharger_depuis_github(depot, branche, chemin_GitHub, dossier_github / _Dest_GitHub, token)
sources.append((source, _Dest_GitHub))
# 2. Projet Mergin local.
if not (dossier_projet / ".mergin").is_dir():
logger.info(f"[2/5]{Colors.INFO} Téléchargement initial du projet Mergin Maps: {Colors.ENDC}{safe_relpath(dossier_projet)}")
telecharger_avec_progression(client, projet, dossier_projet)
else:
logger.info(f"[2/5] {Colors.INFO}Synchronisation du projet Mergin Maps existant : {Colors.ENDC}{safe_relpath(dossier_projet)}")
if not GlobalData.Debug_log:
client.sync_project(str(dossier_projet))
# 3. Copie des fichiers GitHub dans le projet Mergin.
logger.info(f"[3/5]{Colors.INFO} Copie des fichiers à mettre à jour {Colors.ENDC}{safe_relpath(dossier_github)}")
for source, destination in sources:
cible = dossier_projet / destination
cible.mkdir(parents=True, exist_ok=True)
if source.is_file():
fichiers = [(source, cible / source.name)]
elif source.is_dir():
fichiers = [
(f, cible / f.relative_to(source))
for f in source.rglob("*")
if f.is_file() and ".mergin" not in f.relative_to(source).parts and "__pycache__" not in f.relative_to(source).parts
]
else:
raise ValueError(f"Source non prise en charge : {Colors.ENDC}{source}")
if not fichiers:
raise ValueError("Aucun fichier à envoyer.")
for origine, destination_fichier in fichiers:
destination_fichier.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(origine, destination_fichier)
logger.info(f" + {Colors.ENDC}{destination_fichier.relative_to(dossier_projet)}")
# 4. Push vers le serveur.
logger.info(f"[4/5]{Colors.INFO} Envoi vers Mergin Maps...")
envoyer_avec_progression(client, dossier_projet)
# 5. Nettoyage de la copie GitHub uniquement après succès.
logger.info(f"[5/5]{Colors.INFO} Envoi terminé, nettoyage des dossiers temporaires...")
if not (sys.stdout.isatty() and sys.stderr.isatty() and os.environ.get("TERM", "").lower() != "dumb"):
shutil.rmtree(dossier_github, ignore_errors=True)
shutil.rmtree(dossier_projet, ignore_errors=True)
# logger.info("Envoi terminé avec succès.")
except Exception:
logger.error("Le dossier temporaire est conservé pour diagnostic :")
logger.error(f"{Colors.ENDC}{dossier_temporaire}")
raise
############################################################################################################################################
def envoyer_dossier_old_fichiers_locaux(
source: Path, projet: str, client: MerginClient, destination: str = "", dossier_temporaire: Path = Path(__file__).parent / GlobalData.Temp_folder
):
"""#####################################################################################################################################
Envoie un fichier ou un dossier vers Mergin Maps.
Le dossier temporaire est supprimé au début du traitement.
Il est conservé en cas d'erreur et supprimé après un succès complet. #
# #
#####################################################################################################################################"""
logger.info("═" * 95)
logger.info(f"{Colors.YELLOW}Envoie des donnée vers Mergin Maps")
logger.info("═" * 95)
source = Path(source).resolve()
dossier_temporaire = Path(dossier_temporaire).resolve()
destination = Path(destination)
if not source.exists():
raise FileNotFoundError(f"Source introuvable : {Colors.ENDC}{source}")
if destination.is_absolute() or ".." in destination.parts:
raise ValueError("La destination doit être un chemin relatif.")
if ".mergin" in destination.parts:
raise ValueError("Le dossier .mergin est réservé à Mergin Maps.")
if dossier_temporaire == source or source in dossier_temporaire.parents:
raise ValueError("Le dossier temporaire ne doit pas se trouver dans la source.")
dossier_temporaire.mkdir(parents=True, exist_ok=True)
dossier_temporaire = dossier_temporaire / "Projet"
try:
if not (dossier_temporaire / ".mergin").is_dir():
logger.info(f"[1/4]{Colors.YELLOW} Téléchargement initial du projet : {Colors.ENDC}{dossier_temporaire}")
telecharger_avec_progression(client, projet, dossier_temporaire)
else:
logger.info(f"[1/4] {Colors.YELLOW}Synchronisation du projet local existant : {Colors.ENDC}{dossier_temporaire}")
client.sync_project(str(dossier_temporaire))
# 2. Copier le fichier ou les fichiers source.
logger.info(f"[2/4]{Colors.YELLOW} Copie des fichiers {Colors.ENDC}{source}")
cible = dossier_temporaire / destination
cible.mkdir(parents=True, exist_ok=True)
if source.is_file():
fichiers = [(source, cible / source.name)]
elif source.is_dir():
fichiers = [
(f, cible / f.relative_to(source))
for f in source.rglob("*")
if f.is_file() and ".mergin" not in f.relative_to(source).parts and "__pycache__" not in f.relative_to(source).parts
]
else:
raise ValueError(f"Source non prise en charge : {Colors.ENDC}{source}")
if not fichiers:
raise ValueError("Aucun fichier à envoyer.")
for origine, destination_fichier in fichiers:
destination_fichier.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(origine, destination_fichier)
logger.info(f" + {Colors.ENDC}{destination_fichier.relative_to(dossier_temporaire)}")
# 3. Synchroniser avec le serveur.
logger.info(f"[3/4]{Colors.YELLOW} Push vers Mergin Maps...")
# client.sync_project(str(dossier_temporaire))
envoyer_avec_progression(client, dossier_temporaire)
# 4. Nettoyer uniquement après le succès.
logger.info(f"[4/4]{Colors.YELLOW} Push terminé. Nettoyage...")
# fermer_journaux_mergin()
# supprimer_dossier_temporaire(dossier_temporaire)
logger.info("Envoi terminé avec succès.")
except Exception:
logger.error("ERREUR : le dossier temporaire est conservé pour diagnostic :")
logger.error(f"{Colors.ENDC}{dossier_temporaire}")
raise
############################################################################################################################################
def information_depot_mergin(projet, client, detail=True):
"""#####################################################################################################################################
# Affiche les informations d'un projet Mergin Maps.
projet : nom complet du projet, sous la forme 'espace/nom_projet',
ou chemin du dossier local du projet.
client : instance de MerginClient. #
# #
#####################################################################################################################################"""
logger.info("═" * 95)
if detail:
logger.info((f"{Colors.YELLOW}Détail des informations du projet Mergin Maps mis à jour").center(99))
else:
logger.info((f"{Colors.YELLOW}Synthèse initiale des informations du projet Mergin Maps").center(99))
logger.info("═" * 95)
# Récupération des informations distantes
try:
info = client.project_info(str(projet))
except Exception as e: # noqa: BLE001
logger.error(f"Erreur lors de la récupération du projet : {Colors.ENDC}{e}")
return
logger.info(f"Projet : {Colors.ENDC}{info.get('name', projet)}")
logger.info(f"Identifiant : {Colors.ENDC}{info.get('id', 'Non renseigné')}")
logger.info(f"Version : {Colors.ENDC}{info.get('version', 'Non renseignée')}")
logger.info(f"Créé le : {Colors.ENDC}{info.get('created', 'Non renseigné')}")
logger.info(f"Mis à jour : {Colors.ENDC}{info.get('updated', 'Non renseigné')}")
logger.info(f"Public : {Colors.ENDC}{info.get('public', 'Non renseigné')}")
# Liste des fichiers distants
fichiers = info.get("files", [])
logger.info(f"Nbre de fichiers : {Colors.ENDC}{len(fichiers)}")
tailleTotale = 0.0
if fichiers:
for fichier in fichiers:
taille = fichier.get("size", 0)
tailleTotale += taille
logger.info(
f"Taille totale : {Colors.ENDC}{info.get('disk_usage', 'Non renseignée')}{Colors.INFO} Octets ({Colors.ENDC}{tailleTotale / (1024 * 1024):.2f}{Colors.INFO} Mo)"
)
if detail:
logger.info("━" * 95)
for fichier in sorted(fichiers, key=lambda f: f.get("path", "")):
chemin = fichier.get("path", "?")
taille = fichier.get("size", 0)
taille_mo = taille / (1024 * 1024)
logger.info(f"{Colors.ENDC}{chemin:<83} {Colors.CYAN}{taille_mo:>8.3f}{Colors.INFO} Mo")
logger.info("━" * 95)
else:
logger.warning("Aucun fichier répertorié dans les informations reçues.")
############################################################################################################################################
# Main fonction #
# #
############################################################################################################################################
if __name__ == "__main__":
if os.name == "nt":
subprocess.run("cls", shell=True, check=False)
elif os.environ.get("TERM"):
subprocess.run(["clear"], check=False)
parser = argparse.ArgumentParser(
description=f"{Colors.BLUE}Envoi de fichiers vers Mergin Maps, version: {Colors.ENDC}{GlobalData.Version} ",
formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.print_help = colored_help.__get__(parser)
parser.add_argument("--projet", required=True, help=f"{Colors.GREEN}Projet MerginMaps pour envoyer mettre à jour les fichiers")
parser.epilog = (
f"{Colors.GREEN}Merci de compléter {Colors.BLUE}config.ini{Colors.GREEN} dans le dossier source pour définir la configuration{Colors.ENDC}\n\n"
f"{Colors.GREEN}Examples:{Colors.ENDC}\n"
f"\t> python pyDatatoMergin.py --projet ARR\n"
f"\t> python pyDatatoMergin.py --projet LAKORA\n"
)
args = parser.parse_args()
logger = setup_logger(GlobalData.Output_log, GlobalData.Debug_log)
config_file = load_config(profile=args.projet)
fichier_env = Path(__file__).resolve().parent / ".env"
load_dotenv(fichier_env)
url = os.getenv("MERGIN_URL")
login = os.getenv("MERGIN_USERNAME")
password = os.getenv("MERGIN_PASSWORD")
githubToken = os.getenv("GITHUB_TOKEN")
githubDepot = os.getenv("GITHUB_DEPOT")
if githubDepot != GlobalData.Github_repo:
githubToken = None
titre = [
f"{Colors.TITRE}╔{'═' * 99}",
"║" + ("Synchronisation des fichiers github vers Mergin Maps").center(99),
"║" + (f"Contact : {Colors.TITRE_2}alexandre.pont@yahoo.fr{Colors.TITRE}").center(119),
"║" + (f"Version : {Colors.TITRE_2}{GlobalData.Version}{Colors.TITRE}").center(119),
"║" + (f"Serveur Mergin Maps : {Colors.TITRE_2}{url}{Colors.TITRE}").center(119),
"║" + (f"Projet Mergin Maps : {Colors.TITRE_2}{GlobalData.Dest_project}{Colors.TITRE}").center(119),
"║" + (f"Dépôt GitHub : {Colors.TITRE_2}{GlobalData.Github_repo}{Colors.TITRE}").center(119),
"║" + (f"Fichier ou dossier GitHub : {Colors.TITRE_2}{GlobalData.Github_path}{Colors.TITRE}").center(119),
"║" + (f"Fichier log : {Colors.TITRE_2}{safe_relpath(GlobalData.Output_log)}{Colors.TITRE}").center(119),
f"╚{'═' * 99}",
]
for i in range(10):
fin = "╗" if i == 0 else "╝" if i == 9 else "║"
print(f"{Colors.TITRE}" + titre[i].ljust(100) + f"{fin}{Colors.ENDC}")
if not login or not password or not url:
logger.error("Définir MERGIN_URL, MERGIN_USERNAME et MERGIN_PASSWORD dans fichier .env")
sys.exit("")
client = MerginClient(url=url, login=login, password=password)
information_depot_mergin(GlobalData.Dest_project, client, False)
sync_mergin(GlobalData.Dest_project, client, depot=GlobalData.Github_repo, branche=GlobalData.Github_branch, liste=GlobalData.Liste_copie)
information_depot_mergin(GlobalData.Dest_project, client)
+6
View File
@@ -0,0 +1,6 @@
[tool.ruff]
line-length = 160
[tool.ruff.format]
skip-magic-trailing-comma = true