Skip to content

Commit

Permalink
Added log for process input
Browse files Browse the repository at this point in the history
  • Loading branch information
paull committed Jan 8, 2025
1 parent 4b8bca8 commit b5f7865
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lisa/util/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,15 @@ def check_and_input_password(self) -> None:
"Running commands with sudo requires user's password,"
" but no password is provided."
)
self.input(f"{self._shell.connection_info.password}\n")
self.input(f"{self._shell.connection_info.password}\n", False)
self._log.debug("The user's password is input")
break

def input(self, content: str) -> None:
def input(self, content: str, is_log_input: bool = True) -> None:
assert self._process, "The process object is None, the process may end."
self._log.debug(f"Inputting {len(content)} chars to process.")
if is_log_input:
self._log.debug(f"input content: {content}")
self._process.stdin_write(content)

def wait_result(
Expand Down Expand Up @@ -466,11 +468,12 @@ def kill(self) -> None:
self._process.send_signal(signal.SIGTERM)
else:
# windows
task_kill = "taskkill"
kill_process = Process(
self._id_, self._shell, parent_logger=self._log
task_kill, self._shell, parent_logger=self._log
)
kill_process.start(
"taskkill /F /T /PID " + str(self._process.pid),
f"{task_kill} /F /T /PID " + str(self._process.pid),
no_info_log=True,
)
kill_process.wait_result(1)
Expand Down

0 comments on commit b5f7865

Please sign in to comment.