How to use the aexpect.ShellTimeoutError function in aexpect

To help you get started, we’ve selected a few aexpect examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github avocado-framework / avocado-vt / virttest / utils_test / __init__.py View on Github external
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)")
github avocado-framework / avocado-vt / virttest / utils_test / __init__.py View on Github external
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)")
github autotest / autotest / client / virt / virt_test_utils.py View on Github external
# 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:
github avocado-framework / avocado-vt / virttest / utils_net.py View on Github external
# 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: