diff --git a/lidar_prod/tasks/utils.py b/lidar_prod/tasks/utils.py index 71a864bd..b5ee14ab 100644 --- a/lidar_prod/tasks/utils.py +++ b/lidar_prod/tasks/utils.py @@ -254,28 +254,24 @@ def request_bd_uni_for_building_shapefile( WHERE (reservoir.gcms_territoire = territoire.code) \ AND reservoir.geometrie \ && ST_MakeEnvelope({bbox["x_min"]}, {bbox["y_min"]}, {bbox["x_max"]}, {bbox["y_max"]}, 0) \ - AND (reservoir.nature = 'Château d''eau' OR reservoir.nature = 'Réservoir industriel') \ + AND (unaccent(reservoir.nature) = 'Reservoir industriel' OR unaccent(reservoir.nature) = 'Chateau d''eau') \ AND NOT gcms_detruit""" sql_select_list = [sql_batiment, sql_reservoir] sql_request = sql_territoire + " UNION ".join(sql_select_list) - cmd = [ - "pgsql2shp", - "-f", - shapefile_path, - "-h", - bd_params.host, - "-u", - bd_params.user, - "-P", - bd_params.pwd, - bd_params.bd_name, - sql_request, - ] + cmd = f"""pgsql2shp -f {shapefile_path} \ + -h {bd_params.host} \ + -u {bd_params.user} \ + -P {bd_params.pwd} \ + {bd_params.bd_name} \ + \"{sql_request}\"""" + # This call may yield try: - subprocess.check_output(cmd, stderr=subprocess.STDOUT, timeout=120) + subprocess.check_output( + cmd, shell=True, stderr=subprocess.STDOUT, timeout=120, encoding="utf-8" + ) except subprocess.CalledProcessError as e: # In empty zones, pgsql2shp does not create a shapefile if (