From 68f8ca5d870ff7868871e009dbd0dca1c92b23f7 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 11 Aug 2020 18:27:49 -0400 Subject: [PATCH] BF: download-url: Widen exception around add_url_to_file call 6c59334d4 (RF: Avoid batch mode for a single file in download-url, 2019-12-10) made the add_url_to_file() call use batch=False if only one URL is given. In this case, a failed addurl call will result in a CommandError rather than a AnnexBatchCommandError, which is derived from CommandError. --- datalad/interface/download_url.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/datalad/interface/download_url.py b/datalad/interface/download_url.py index 2ea34f0cea..1d856a2e67 100644 --- a/datalad/interface/download_url.py +++ b/datalad/interface/download_url.py @@ -30,10 +30,13 @@ from ..distribution.dataset import require_dataset from ..distribution.dataset import resolve_path from ..dochelpers import exc_str -from ..support.annexrepo import AnnexRepo, AnnexBatchCommandError +from ..support.annexrepo import AnnexRepo from ..support.param import Parameter from ..support.constraints import EnsureStr, EnsureNone -from ..support.exceptions import NoDatasetFound +from ..support.exceptions import ( + CommandError, + NoDatasetFound, +) from logging import getLogger lgr = getLogger('datalad.api.download-url') @@ -243,7 +246,7 @@ def __call__(urls, dataset=None, path=None, overwrite=False, batch=len(annex_paths) > 1, # bypass URL size check, we already have the file options=['--relaxed']) - except AnnexBatchCommandError as exc: + except CommandError as exc: lgr.warning("Registering %s with %s failed: %s", path, url, exc_str(exc))