Skip to content

Commit 0d7a477

Browse files
committed
fix invalid filetypes and exit code for HTTP errors
1 parent 386c8c5 commit 0d7a477

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

mapillary_tools/commands/__main__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ def main():
164164
args.func(argvars)
165165
except requests.HTTPError as ex:
166166
LOG.error("%s: %s", ex.__class__.__name__, api_v4.readable_http_error(ex))
167+
# TODO: standardize exit codes as exceptions.MapillaryUserError
168+
sys.exit(16)
167169

168170
except exceptions.MapillaryUserError as ex:
169171
LOG.error(

mapillary_tools/geotag/geotag_videos_from_exiftool_video.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ def extract(self) -> types.VideoMetadataOrError:
5555
"No GPS data found from the video"
5656
)
5757

58+
filetype = types.FileType.GOPRO if is_gopro else types.FileType.VIDEO
59+
5860
video_metadata = types.VideoMetadata(
5961
self.video_path,
6062
filesize=utils.get_file_size(self.video_path),
61-
filetype=types.FileType.VIDEO,
63+
filetype=filetype,
6264
points=points,
6365
make=make,
6466
model=model,
@@ -92,11 +94,11 @@ def _generate_video_extractors(
9294
)
9395
if rdf_description is None:
9496
exc = exceptions.MapillaryEXIFNotFoundError(
95-
f"The {exiftool_read._DESCRIPTION_TAG} XML element for the image not found"
97+
f"The {exiftool_read._DESCRIPTION_TAG} XML element for the video not found"
9698
)
9799
results.append(
98100
types.describe_error_metadata(
99-
exc, path, filetype=types.FileType.IMAGE
101+
exc, path, filetype=types.FileType.VIDEO
100102
)
101103
)
102104
else:
@@ -140,7 +142,7 @@ def _generate_video_extractors(
140142
)
141143
results.append(
142144
types.describe_error_metadata(
143-
exc, path, filetype=types.FileType.IMAGE
145+
exc, path, filetype=types.FileType.VIDEO
144146
)
145147
)
146148
else:

mapillary_tools/process_geotag_properties.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@
99

1010
from tqdm import tqdm
1111

12-
from mapillary_tools.geotag.options import InterpolationOption, SourcePathOption
13-
1412
from . import constants, exceptions, exif_write, types, utils
15-
from .geotag.factory import parse_source_option, process, SourceOption, SourceType
13+
from .geotag.factory import parse_source_option, process
14+
from .geotag.options import (
15+
InterpolationOption,
16+
SourceOption,
17+
SourcePathOption,
18+
SourceType,
19+
)
1620

1721
LOG = logging.getLogger(__name__)
1822
DEFAULT_GEOTAG_SOURCE_OPTIONS = [

mapillary_tools/upload.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ def upload_progress(payload: uploader.Progress):
250250
type: uploader.EventName = "upload_progress"
251251

252252
if LOG.getEffectiveLevel() <= logging.DEBUG:
253-
# In debug mode, we want to see the progress every 10 seconds
253+
# In debug mode, we want to see the progress every 30 seconds
254254
# instead of every chunk (which is too verbose)
255-
INTERVAL_SECONDS = 10
255+
INTERVAL_SECONDS = 30
256256
now = time.time()
257257
last_upload_progress_debug_at: float | None = T.cast(T.Dict, payload).get(
258258
"_last_upload_progress_debug_at"
@@ -425,11 +425,7 @@ def _load_descs(
425425
metadatas: list[types.Metadata]
426426

427427
if _metadatas_from_process is not None:
428-
metadatas = [
429-
metadata
430-
for metadata in _metadatas_from_process
431-
if not isinstance(metadata, types.ErrorMetadata)
432-
]
428+
metadatas, _ = types.separate_errors(_metadatas_from_process)
433429
else:
434430
metadatas = _load_validate_metadatas_from_desc_path(desc_path, import_paths)
435431

0 commit comments

Comments
 (0)