Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added logging the input content for process by default #3593

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lisa/util/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,16 @@ 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}")
else:
self._log.debug(f"Inputting {len(content)} chars to process.")
LiliDeng marked this conversation as resolved.
Show resolved Hide resolved
self._process.stdin_write(content)

def wait_result(
Expand Down Expand Up @@ -466,11 +469,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
Loading