Toujours supprimer le LAS temporaire du repli PDAL, même en échec
This commit is contained in:
@ -312,6 +312,7 @@ def _read_with_pdal(laz_file):
|
||||
import tempfile
|
||||
import os
|
||||
|
||||
tmp_path = None
|
||||
try:
|
||||
# Convert COPC to LAS via PDAL, then read with laspy
|
||||
with tempfile.NamedTemporaryFile(suffix='.las', delete=False) as tmp:
|
||||
@ -331,18 +332,10 @@ def _read_with_pdal(laz_file):
|
||||
|
||||
if result.returncode != 0:
|
||||
logger.warning(f" PDAL conversion échouée: {result.stderr[:200]}")
|
||||
try:
|
||||
os.unlink(tmp_path)
|
||||
except Exception:
|
||||
pass
|
||||
return None
|
||||
|
||||
import laspy
|
||||
las = laspy.read(tmp_path)
|
||||
try:
|
||||
os.unlink(tmp_path)
|
||||
except Exception:
|
||||
pass
|
||||
if len(las.points) == 0:
|
||||
logger.warning(f" PDAL: conversion réussie mais 0 points")
|
||||
return None
|
||||
@ -351,6 +344,14 @@ def _read_with_pdal(laz_file):
|
||||
except Exception as e:
|
||||
logger.warning(f" PDAL fallback échoué: {e}")
|
||||
return None
|
||||
finally:
|
||||
# Toujours supprimer le LAS temporaire, même en cas d'exception
|
||||
# (timeout subprocess, laspy.read échoué…) : sinon fuite de ~Go.
|
||||
if tmp_path:
|
||||
try:
|
||||
os.unlink(tmp_path)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def detect_ground_method(laz_file):
|
||||
|
||||
Reference in New Issue
Block a user