Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if server_process.is_alive():
utils_misc.kill_process_tree(server_process.get_pid(),
signal.SIGINT)
server_process.close()
# Remove the result dir produced by server_process.
server_result = os.path.join(autotest_path,
"results",
os.path.basename(server_control_path))
if os.path.isdir(server_result):
utils_misc.safe_rmdir(server_result)
# Remove the control file for server.
if os.path.exists(server_control_path):
os.remove(server_control_path)
except aexpect.ShellTimeoutError:
if vm.is_alive():
get_results(destination_autotest_path)
get_results_summary()
raise exceptions.TestError("Timeout elapsed while waiting for job to "
"complete")
else:
raise exceptions.TestError("Autotest job on guest failed "
"(VM terminated during job)")
except aexpect.ShellProcessTerminatedError:
if ignore_session_terminated:
try:
vm.verify_alive()
except Exception:
get_results(destination_autotest_path)
raise exceptions.TestError("Autotest job on guest failed "
"(VM terminated during job)")
if server_process.is_alive():
utils_misc.kill_process_tree(server_process.get_pid(),
signal.SIGINT)
server_process.close()
# Remove the result dir produced by server_process.
job_tag = os.path.basename(server_control_path)
server_result = os.path.join(autotest_path,
"results", job_tag)
if os.path.isdir(server_result):
utils_misc.safe_rmdir(server_result)
# Remove the control file for server.
if os.path.exists(server_control_path):
os.remove(server_control_path)
except aexpect.ShellTimeoutError:
if vm.is_alive():
get_results(destination_autotest_path)
get_results_summary()
raise exceptions.TestError("Timeout elapsed while waiting "
"for job to complete")
else:
raise exceptions.TestError("Autotest job on guest failed "
"(VM terminated during job)")
except aexpect.ShellProcessTerminatedError:
if ignore_session_terminated:
try:
vm.verify_alive()
except Exception:
get_results(destination_autotest_path)
raise exceptions.TestError("Autotest job on guest failed "
"(VM terminated during job)")
# Because ping have the ability to catch the SIGINT signal so we can
# always get the packet loss ratio even if timeout.
if process.is_alive():
virt_utils.kill_process_tree(process.get_pid(), signal.SIGINT)
status = process.get_status()
output = process.get_output()
process.close()
return status, output
else:
output = ""
try:
output = session.cmd_output(command, timeout=timeout,
print_func=output_func)
except aexpect.ShellTimeoutError:
# Send ctrl+c (SIGINT) through ssh session
session.send("\003")
try:
output2 = session.read_up_to_prompt(print_func=output_func)
output += output2
except aexpect.ExpectTimeoutError, e:
output += e.output
# We also need to use this session to query the return value
session.send("\003")
session.sendline(session.status_test_command)
try:
o2 = session.read_up_to_prompt()
except aexpect.ExpectError:
status = -1
else:
# Because ping have the ability to catch the SIGINT signal so we can
# always get the packet loss ratio even if timeout.
if process.is_alive():
utils_misc.kill_process_tree(process.get_pid(), signal.SIGINT)
status = process.get_status()
output = process.get_output()
process.close()
return status, output
else:
output = ""
try:
output = session.cmd_output(command, timeout=timeout,
print_func=output_func)
except aexpect.ShellTimeoutError:
# Send ctrl+c (SIGINT) through ssh session
session.send("\003")
try:
output2 = session.read_up_to_prompt(print_func=output_func)
output += output2
except aexpect.ExpectTimeoutError as e:
output += e.output
# We also need to use this session to query the return value
session.send("\003")
session.sendline(session.status_test_command)
try:
o2 = session.read_up_to_prompt()
except aexpect.ExpectError:
status = -1
else: