diff --git a/changelog.md b/changelog.md index c5d0e45..405ad6b 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,12 @@ ## x.y.z +## 2.2.5 + +CHANGED: +- Valhalla build config: increase default isochrone limits +- subprocess : check return code and raise Runtime exception if not 0 + ## 2.2.4 CHANGED: diff --git a/r2gg/__about__.py b/r2gg/__about__.py index 10db08c..d0c640c 100644 --- a/r2gg/__about__.py +++ b/r2gg/__about__.py @@ -34,7 +34,7 @@ __uri_tracker__ = f"{__uri_repository__}issues/" __uri__ = __uri_repository__ -__version__ = "2.2.4" +__version__ = "2.2.5" __version_info__ = tuple( [ int(num) if num.isdigit() else num diff --git a/r2gg/_main.py b/r2gg/_main.py index fa86d17..d242d41 100644 --- a/r2gg/_main.py +++ b/r2gg/_main.py @@ -407,16 +407,20 @@ def valhalla_convert(config, resource, logger, build_lua_from_cost_config = True start_command = time.time() valhalla_build_config_args = ["valhalla_build_config", "--mjolnir-tile-dir", source["storage"]["dir"], - "--mjolnir-tile-extract", source["storage"]["tar"]] + "--mjolnir-tile-extract", source["storage"]["tar"], + # Modification des limites par défaut du service : 10h pour isochrone et 1000km pour iso distance + # contre 2h et 200km par défaut + "--service-limits-isochrone-max-time-contour", "600", + "--service-limits-isochrone-max-distance-contour", "1000", + # Ajout de l'autorisation à exclure les ponts/tunnels/péages + "--service-limits-allow-hard-exclusions", "True"] subprocess_execution(valhalla_build_config_args, logger, outfile = source["storage"]["config"]) # Nécessaire le temps que le fichier s'écrive... time.sleep(1) - # Ajout du graph custom dans la config valhalla + # Ajout du graph custom dans la config valhalla (impossible via les paramètres du build_config) with open(source["storage"]["config"], "r") as valhalla_config: config_dict = json.load(valhalla_config) config_dict["mjolnir"]["graph_lua_name"] = source["costs"][0]["compute"]["storage"]["file"] - # Ajout de l'autorisation à exclure les ponts/tunnels/péages - config_dict["service_limits"]["allow_hard_exclusions"] = True with open(source["storage"]["config"], "w") as valhalla_config: valhalla_config.write(json.dumps(config_dict)) diff --git a/r2gg/_subprocess_execution.py b/r2gg/_subprocess_execution.py index 343acda..d2817b5 100644 --- a/r2gg/_subprocess_execution.py +++ b/r2gg/_subprocess_execution.py @@ -14,7 +14,8 @@ def subprocess_execution(args, logger, outfile = None): """ try: str_args = [str(arg) for arg in args] - logger.info('Subprocess: \"' + " ".join(str_args) + '\"') + subprocess_arg = " ".join(str_args) + logger.info('Subprocess: \"' + subprocess_arg + '\"') if outfile is not None: with open(outfile, "w") as out: process = subprocess.Popen( @@ -32,6 +33,12 @@ def subprocess_execution(args, logger, outfile = None): process_output, _ = process.communicate() logger.info(process_output.decode("utf-8")) + returncode = process.returncode + if process.returncode != 0: + error_msg = f"Invalid returncode {returncode} for subprocess '{subprocess_arg}'" + logger.error(error_msg) + raise RuntimeError(error_msg) + except (OSError, subprocess.CalledProcessError) as exception: logger.info('Exception occured: ' + str(exception))