Пример #1
0
def loop_run_project_command_in_vagrant(project_path, command_to_run,
                                        vagrant_info,
                                        ssh_user=HYPERNODE_VAGRANT_DEFAULT_USER):
    """
    Loop running the project command in the vagrant on input
    :param str project_path: The project path to upload to the vagrant before
    running the specified command in that directory in the vagrant
    :param str command_to_run: The shell command to run in the uploaded
    project_path
    :param dict vagrant_info: The vagrant ssh-config connection details
    :param str ssh_user: The SSH user to use to run the hook as
    :return None:
    """
    log.info("Starting command loop.")
    try:
        while True:
            run_project_command_in_vagrant(
                project_path, command_to_run, vagrant_info, ssh_user=ssh_user
            )
            key = input(
                "\nPress enter to run the run the command again.\n"
                "S + Enter to get a shell.\nCTRL + C to stop the loop.\n> "
            )
            if key and key.strip().lower().startswith('s'):
                get_remote_shell(vagrant_info, ssh_user=ssh_user)

    except (KeyboardInterrupt, EOFError):
        log.info("Interrupt received. Terminating loop.")
Пример #2
0
def loop_run_project_command_in_vagrant(
        project_path,
        command_to_run,
        vagrant_info,
        ssh_user=HYPERNODE_VAGRANT_DEFAULT_USER):
    """
    Loop running the project command in the vagrant on input
    :param str project_path: The project path to upload to the vagrant before
    running the specified command in that directory in the vagrant
    :param str command_to_run: The shell command to run in the uploaded
    project_path
    :param dict vagrant_info: The vagrant ssh-config connection details
    :param str ssh_user: The SSH user to use to run the hook as
    :return None:
    """
    log.info("Starting command loop.")
    try:
        while True:
            run_project_command_in_vagrant(project_path,
                                           command_to_run,
                                           vagrant_info,
                                           ssh_user=ssh_user)
            key = input(
                "\nPress enter to run the run the command again.\n"
                "S + Enter to get a shell.\nCTRL + C to stop the loop.\n> ")
            if key and key.strip().lower().startswith('s'):
                get_remote_shell(vagrant_info, ssh_user=ssh_user)

    except (KeyboardInterrupt, EOFError):
        log.info("Interrupt received. Terminating loop.")
Пример #3
0
def run_project_command_in_vagrant(project_path, command_to_run, vagrant_info,
                                   ssh_user=HYPERNODE_VAGRANT_DEFAULT_USER):
    """
    Upload the project if one is specified and run the command.
    If no command is specified, get a shell.
    :param str project_path: The project path to upload to the vagrant before
    running the specified command in that directory in the vagrant
    :param str command_to_run: The shell command to run in the uploaded
    project_path
    :param dict vagrant_info: The vagrant ssh-config connection details
    :param str ssh_user: The SSH user to use to run the hook as
    :return None:
    """
    # If a project path was specified, upload that directory
    if project_path:
        upload_project_to_vagrant(
            project_path, vagrant_info, ssh_user=ssh_user
        )

    if command_to_run:
        # If a command was specified run that command
        run_command_in_vagrant(
            command_to_run, vagrant_info, ssh_user=ssh_user
        )
    else:
        # Otherwise log in to the remote machine and return control to the user
        get_remote_shell(vagrant_info, ssh_user=ssh_user)
Пример #4
0
def run_project_command_in_vagrant(project_path,
                                   command_to_run,
                                   vagrant_info,
                                   ssh_user=HYPERNODE_VAGRANT_DEFAULT_USER):
    """
    Upload the project if one is specified and run the command.
    If no command is specified, get a shell.
    :param str project_path: The project path to upload to the vagrant before
    running the specified command in that directory in the vagrant
    :param str command_to_run: The shell command to run in the uploaded
    project_path
    :param dict vagrant_info: The vagrant ssh-config connection details
    :param str ssh_user: The SSH user to use to run the hook as
    :return None:
    """
    # If a project path was specified, upload that directory
    if project_path:
        upload_project_to_vagrant(project_path, vagrant_info)

    if command_to_run:
        # If a command was specified run that command
        run_command_in_vagrant(command_to_run, vagrant_info, ssh_user=ssh_user)
    else:
        # Otherwise log in to the remote machine and return control to the user
        get_remote_shell(vagrant_info, ssh_user=ssh_user)