Skip to content

Commit

Permalink
dvc: show "Having any troubles?" only on unexpected errors
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed Aug 30, 2020
1 parent 5268622 commit 37c462f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
14 changes: 4 additions & 10 deletions dvc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ def main(argv=None): # noqa: C901
except DvcException:
ret = 255
logger.exception("")
except OSError as exc:
if exc.errno == errno.EMFILE:
except Exception as exc: # noqa, pylint: disable=broad-except
# pylint: disable=no-member
if isinstance(exc, OSError) and exc.errno == errno.EMFILE:
logger.exception(
"too many open files, please visit "
"{} to see how to handle this "
Expand All @@ -97,17 +98,10 @@ def main(argv=None): # noqa: C901
)
else:
logger.exception("unexpected error")
ret = 255
except Exception: # noqa, pylint: disable=broad-except
logger.exception("unexpected error")
logger.info(FOOTER)
ret = 255

try:
if ret != 0 and (
ret != 1 or getattr(args, "cmd", "") != "check-ignore"
):
logger.info(FOOTER)

if analytics.is_enabled():
analytics.collect_and_send_report(args, ret)

Expand Down
2 changes: 1 addition & 1 deletion tests/func/test_check_ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_check_ignore_non_matching(tmp_dir, dvc, non_matching, caplog):
)
def test_check_ignore_error_args_cases(tmp_dir, dvc, args, caplog):
assert main(["check-ignore"] + args) == 255
assert ("Having any troubles?" in caplog.text) == ("-q" not in args)
assert "Having any troubles?" not in caplog.text


@pytest.mark.parametrize("path,ret", [({"dir": {}}, 0), ({"dir": "files"}, 1)])
Expand Down

0 comments on commit 37c462f

Please sign in to comment.