зеркало из https://github.com/microsoft/lisa.git
Added password processing for execute_async()
This commit is contained in:
Родитель
cfeec66b06
Коммит
1fe34d61c6
|
@ -320,12 +320,18 @@ class Process:
|
|||
self._shell.close()
|
||||
raise
|
||||
|
||||
self.check_and_input_password()
|
||||
|
||||
def check_and_input_password(self) -> None:
|
||||
if (
|
||||
self._sudo
|
||||
and isinstance(self._shell, SshShell)
|
||||
and self._shell.is_sudo_required_password
|
||||
):
|
||||
timer = create_timer()
|
||||
while self.is_running():
|
||||
time.sleep(0.01)
|
||||
if timer.elapsed(False) > 0.5:
|
||||
if not self._shell.connection_info.password:
|
||||
raise RequireUserPasswordException(
|
||||
"Running commands with sudo requires user's password,"
|
||||
|
@ -333,6 +339,7 @@ class Process:
|
|||
)
|
||||
self.input(f"{self._shell.connection_info.password}\n")
|
||||
self._log.debug("The user's password is input")
|
||||
break
|
||||
|
||||
def input(self, content: str) -> None:
|
||||
assert self._process
|
||||
|
@ -347,13 +354,9 @@ class Process:
|
|||
) -> ExecutableResult:
|
||||
timer = create_timer()
|
||||
is_timeout = False
|
||||
has_checked_password = False
|
||||
|
||||
while self.is_running() and timeout >= timer.elapsed(False):
|
||||
time.sleep(0.01)
|
||||
if timer.elapsed(False) > 0.5 and not has_checked_password:
|
||||
self.check_and_input_password()
|
||||
has_checked_password = True
|
||||
|
||||
if timeout < timer.elapsed():
|
||||
if self._process is not None:
|
||||
|
|
Загрузка…
Ссылка в новой задаче