Skip to content

Commit

Permalink
Merging pull request 120
Browse files Browse the repository at this point in the history
Signed-off-by: Lukáš Doktor <[email protected]>

* github.com:autotest/aexpect:
  remote_login: Fix problem of losing logs before setting output_func
  • Loading branch information
ldoktor committed Mar 14, 2023
2 parents 5182d37 + 2629dea commit b16da4e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions aexpect/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,22 +411,24 @@ def remote_login(client, host, port, username, password, prompt, linesep="\n",
cmd = f"nc {' '.join(extra_params)} {host} {port}"
else:
raise LoginBadClientError(client)
output_params = ()
if log_filename:
output_params = (log_filename,)
log_filename = os.path.basename(log_filename)

if verbose:
LOG.debug("Login command: '%s'", cmd)
session = RemoteSession(cmd, linesep=linesep, output_prefix=host,
session = RemoteSession(cmd, linesep=linesep, output_func=log_function,
output_params=output_params, output_prefix=host,
prompt=prompt, status_test_command=status_test_command,
client=client, host=host, port=port,
username=username, password=password)
session.set_log_file(log_filename)
try:
handle_prompts(session, username, password, prompt, timeout)
except Exception:
session.close()
raise
if log_filename:
session.set_output_func(log_function)
session.set_output_params((log_filename,))
session.set_log_file(os.path.basename(log_filename))
return session


Expand Down

0 comments on commit b16da4e

Please sign in to comment.