Skip to content

Commit

Permalink
ssh: catch EOFError from getpass
Browse files Browse the repository at this point in the history
If getpass is unable to get input from stderror or stdin, it will raise this error.

Similar to how we do it in dvc https://github.com/iterative/dvc/blob/04e891cef929567794ade4e0c2a1bf399666f66e/dvc/ui/__init__.py#L268
  • Loading branch information
efiop committed Aug 10, 2023
1 parent f9a6038 commit cd301c8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions dvc_ssh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@
@wrap_with(threading.Lock())
@memoize
def ask_password(host, user, port, desc):
return getpass.getpass(
f"Enter a {desc} for " f"host '{host}' port '{port}' user '{user}':\n"
)
try:
return getpass.getpass(
f"Enter a {desc} for "
f"host '{host}' port '{port}' user '{user}':\n"
)
except EOFError:
return None


# pylint:disable=abstract-method
Expand Down

0 comments on commit cd301c8

Please sign in to comment.