From 579d5c5b46b5f6599a1633472ccaf4ebca12a6b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Ple=C5=A1a?= Date: Thu, 21 Aug 2025 12:43:08 +0200 Subject: [PATCH 1/2] Fix unhandled exception in exiftool_xml parsing --- mapillary_tools/geotag/utils.py | 2 +- tests/integration/test_process.py | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/mapillary_tools/geotag/utils.py b/mapillary_tools/geotag/utils.py index 8c855914..4dde140f 100644 --- a/mapillary_tools/geotag/utils.py +++ b/mapillary_tools/geotag/utils.py @@ -45,7 +45,7 @@ def index_rdf_description_by_path( for xml_path in utils.find_xml_files(xml_paths): try: etree = ET.parse(xml_path) - except ET.ParseError as ex: + except Exception as ex: verbose = LOG.isEnabledFor(logging.DEBUG) if verbose: LOG.warning("Failed to parse %s", xml_path, exc_info=True) diff --git a/tests/integration/test_process.py b/tests/integration/test_process.py index 8bc6e99a..83468227 100644 --- a/tests/integration/test_process.py +++ b/tests/integration/test_process.py @@ -814,3 +814,26 @@ def test_process_geotag_with_exiftool_xml_pattern(setup_data: py.path.local): ) assert_descs_exact_equal(exiftool_descs, native_descs) + + +def test_process_geotag_with_exiftool_xml_pattern_missing_file( + setup_data: py.path.local, +): + video_path = setup_data.join("videos").join("sample-5s.mp4") + descs = run_process_for_descs( + [ + *[ + "--geotag_source", + json.dumps( + { + "source": "exiftool_xml", + "pattern": str(setup_data.join("gpx").join("%g.xml")), + } + ), + ], + str(video_path), + ] + ) + + assert len(descs) == 1 + assert descs[0]["error"]["type"] == "MapillaryExifToolXMLNotFoundError" From cac044a3a5cf472859a2a388b3cc63cd575b7019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Ple=C5=A1a?= Date: Thu, 21 Aug 2025 15:29:05 +0200 Subject: [PATCH 2/2] Fix fallback when using exiftool_xml option --- mapillary_tools/geotag/factory.py | 1 + tests/integration/test_process.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/mapillary_tools/geotag/factory.py b/mapillary_tools/geotag/factory.py index 0a226b03..44647c10 100644 --- a/mapillary_tools/geotag/factory.py +++ b/mapillary_tools/geotag/factory.py @@ -121,6 +121,7 @@ def _is_reprocessable(metadata: types.MetadataOrError) -> bool: exceptions.MapillaryGeoTaggingError, exceptions.MapillaryVideoGPSNotFoundError, exceptions.MapillaryExiftoolNotFoundError, + exceptions.MapillaryExifToolXMLNotFoundError, ), ): return True diff --git a/tests/integration/test_process.py b/tests/integration/test_process.py index 83468227..d0fb4904 100644 --- a/tests/integration/test_process.py +++ b/tests/integration/test_process.py @@ -837,3 +837,28 @@ def test_process_geotag_with_exiftool_xml_pattern_missing_file( assert len(descs) == 1 assert descs[0]["error"]["type"] == "MapillaryExifToolXMLNotFoundError" + + +def test_process_geotag_with_exiftool_xml_pattern_fallback( + setup_data: py.path.local, +): + video_path = setup_data.join("videos").join("sample-5s.mp4") + descs = run_process_for_descs( + [ + *[ + "--geotag_source", + json.dumps( + { + "source": "exiftool_xml", + "pattern": str(setup_data.join("gpx").join("%g.xml")), + } + ), + ], + *["--geotag_source", "gpx"], + *["--geotag_source", "native"], + str(video_path), + ] + ) + + assert len(descs) == 1 + assert descs[0]["error"]["type"] == "MapillaryVideoGPSNotFoundError"