Skip to content

Commit cd301c8

Browse files
committed
ssh: catch EOFError from getpass
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
1 parent f9a6038 commit cd301c8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

dvc_ssh/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@
1313
@wrap_with(threading.Lock())
1414
@memoize
1515
def ask_password(host, user, port, desc):
16-
return getpass.getpass(
17-
f"Enter a {desc} for " f"host '{host}' port '{port}' user '{user}':\n"
18-
)
16+
try:
17+
return getpass.getpass(
18+
f"Enter a {desc} for "
19+
f"host '{host}' port '{port}' user '{user}':\n"
20+
)
21+
except EOFError:
22+
return None
1923

2024

2125
# pylint:disable=abstract-method

0 commit comments

Comments
 (0)