mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
get: use new exception from public api
This commit is contained in:
+2
-17
@@ -3,7 +3,7 @@ import logging
|
||||
|
||||
from .base import append_doc_link
|
||||
from .base import CmdBaseNoRepo
|
||||
from dvc.exceptions import DvcException, NotDvcRepoError
|
||||
from dvc.exceptions import DvcException
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -18,23 +18,8 @@ class CmdGet(CmdBaseNoRepo):
|
||||
self.args.path, repo=self.args.url, rev=self.args.rev
|
||||
)
|
||||
logger.info(url)
|
||||
except NotDvcRepoError:
|
||||
# NOTE: there's no way to get direct links to files inside
|
||||
# git repository.
|
||||
logger.exception(
|
||||
"Could not show url for '{}' from '{}'. ".format(
|
||||
self.args.path, self.args.url
|
||||
)
|
||||
+ "Only DVC repository is supported currently.",
|
||||
exc_info=None,
|
||||
)
|
||||
return 1
|
||||
except DvcException:
|
||||
logger.exception(
|
||||
"failed to show url for '{}' from '{}'".format(
|
||||
self.args.path, self.args.url
|
||||
)
|
||||
)
|
||||
logger.exception("failed to show url")
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
@@ -203,7 +203,7 @@ def test_get_url_not_existing(tmp_dir, erepo_dir, caplog):
|
||||
main(["get", fspath(erepo_dir), "not-existing-file", "--show-url"])
|
||||
== 1
|
||||
)
|
||||
assert "failed to show url for 'not-existing-file'" in caplog.text
|
||||
assert "failed to show url" in caplog.text
|
||||
|
||||
|
||||
def test_get_url_git_only_repo(tmp_dir, scm, caplog):
|
||||
@@ -211,4 +211,4 @@ def test_get_url_git_only_repo(tmp_dir, scm, caplog):
|
||||
|
||||
with caplog.at_level(logging.ERROR):
|
||||
assert main(["get", fspath(tmp_dir), "foo", "--show-url"]) == 1
|
||||
assert "Only DVC repository is supported currently" in caplog.text
|
||||
assert "failed to show url" in caplog.text
|
||||
|
||||
Reference in New Issue
Block a user