コード例 #1
0
ファイル: control_commands.py プロジェクト: uuudoc111/polysh
def do_purge(command: str) -> None:
    to_delete = []
    for i in selected_shells(command):
        if not i.enabled:
            to_delete.append(i)
    for i in to_delete:
        i.disconnect()
        i.close()
コード例 #2
0
def do_reset_prompt(command):
    """
    Usage: :reset_prompt [SHELLS...]
    Change the prompt to be recognized by polysh.
    The special characters * ? and [] work as expected.
    """
    for i in selected_shells(command):
        i.dispatch_command(i.init_string)
コード例 #3
0
def do_reset_prompt(command):
    """
    Usage: :reset_prompt [SHELLS...]
    Change the prompt to be recognized by polysh.
    The special characters * ? and [] work as expected.
    """
    for i in selected_shells(command):
        i.dispatch_command(i.init_string)
コード例 #4
0
def do_show_read_buffer(command):
    """
    Usage: :show_read_buffer [SHELLS...]
    Print the data read by remote shells.
    The special characters * ? and [] work as expected.
    """
    for i in selected_shells(command):
        if i.read_in_state_not_started:
            i.print_lines(i.read_in_state_not_started)
            i.read_in_state_not_started = ''
コード例 #5
0
def do_list(command):
    """
    Usage: :list [SHELLS...]
    List remote shells and their states.
    The output consists of: <hostname> <enabled?> <state>: <last printed line>.
    The special characters * ? and [] work as expected.
    """
    instances = [i.get_info() for i in selected_shells(command)]
    dispatchers.format_info(instances)
    console_output(''.join(instances))
コード例 #6
0
def do_show_read_buffer(command):
    """
    Usage: :show_read_buffer [SHELLS...]
    Print the data read by remote shells.
    The special characters * ? and [] work as expected.
    """
    for i in selected_shells(command):
        if i.read_in_state_not_started:
            i.print_lines(i.read_in_state_not_started)
            i.read_in_state_not_started = ''
コード例 #7
0
def do_list(command):
    """
    Usage: :list [SHELLS...]
    List remote shells and their states.
    The output consists of: <hostname> <enabled?> <state>: <last printed line>.
    The special characters * ? and [] work as expected.
    """
    instances = [i.get_info() for i in selected_shells(command)]
    dispatchers.format_info(instances)
    console_output(''.join(instances))
コード例 #8
0
ファイル: control_commands.py プロジェクト: uuudoc111/polysh
def do_reconnect(command: str) -> None:
    selec = selected_shells(command)
    to_reconnect = [
        i for i in selec if i.state == remote_dispatcher.STATE_DEAD
    ]
    for i in to_reconnect:
        i.disconnect()
        i.close()

    hosts = [i.hostname for i in to_reconnect]
    dispatchers.create_remote_dispatchers(hosts)
コード例 #9
0
ファイル: control_commands.py プロジェクト: uuudoc111/polysh
def do_set_debug(command: str) -> None:
    split = command.split()
    if not split:
        console_output(b'Expected at least a letter\n')
        return
    letter = split[0].lower()
    if letter not in ('y', 'n'):
        console_output("Expected 'y' or 'n', got: {}\n".format(
            split[0]).encode())
        return
    debug = letter == 'y'
    for i in selected_shells(' '.join(split[1:])):
        i.debug = debug
コード例 #10
0
def do_purge(command):
    """
    Usage: :purge [SHELLS...]
    Delete disabled remote shells.
    This helps to have a shorter list.
    The special characters * ? and [] work as expected.
    """
    to_delete = []
    for i in selected_shells(command):
        if not i.enabled:
            to_delete.append(i)
    for i in to_delete:
        i.disconnect()
        i.close()
コード例 #11
0
def do_purge(command):
    """
    Usage: :purge [SHELLS...]
    Delete disabled remote shells.
    This helps to have a shorter list.
    The special characters * ? and [] work as expected.
    """
    to_delete = []
    for i in selected_shells(command):
        if not i.enabled:
            to_delete.append(i)
    for i in to_delete:
        i.disconnect()
        i.close()
コード例 #12
0
def do_reconnect(command):
    """
    Usage: :reconnect [SHELLS...]
    Try to reconnect to disconnected remote shells.
    The special characters * ? and [] work as expected.
    """
    selec = selected_shells(command)
    to_reconnect = [i for i in selec if i.state == remote_dispatcher.STATE_DEAD]
    for i in to_reconnect:
        i.disconnect()
        i.close()

    hosts = [i.hostname for i in to_reconnect]
    dispatchers.create_remote_dispatchers(hosts)
コード例 #13
0
ファイル: control_commands.py プロジェクト: uuudoc111/polysh
def do_send_ctrl(command: str) -> None:
    split = command.split()
    if not split:
        console_output(b'Expected at least a letter\n')
        return
    letter = split[0]
    if len(letter) != 1:
        console_output(
            'Expected a single letter, got: {}\n'.format(letter).encode())
        return
    control_letter = chr(ord(letter.lower()) - ord('a') + 1)
    for i in selected_shells(' '.join(split[1:])):
        if i.enabled:
            i.dispatch_write(control_letter.encode())
コード例 #14
0
def do_reconnect(command):
    """
    Usage: :reconnect [SHELLS...]
    Try to reconnect to disconnected remote shells.
    The special characters * ? and [] work as expected.
    """
    selec = selected_shells(command)
    to_reconnect = [
        i for i in selec if i.state == remote_dispatcher.STATE_DEAD
    ]
    for i in to_reconnect:
        i.disconnect()
        i.close()

    hosts = [i.hostname for i in to_reconnect]
    dispatchers.create_remote_dispatchers(hosts)
コード例 #15
0
def do_set_debug(command):
    """
    Usage: :set_debug y|n [SHELLS...]
    Enable or disable debugging output for remote shells.
    The first argument is 'y' to enable the debugging output, 'n' to
    disable it.
    The remaining optional arguments are the selected shells.
    The special characters * ? and [] work as expected.
    """
    split = command.split()
    if not split:
        console_output('Expected at least a letter\n')
        return
    letter = split[0].lower()
    if letter not in ('y', 'n'):
        console_output("Expected 'y' or 'n', got: %s\n" % split[0])
        return
    debug = letter == 'y'
    for i in selected_shells(' '.join(split[1:])):
        i.debug = debug
コード例 #16
0
def do_set_debug(command):
    """
    Usage: :set_debug y|n [SHELLS...]
    Enable or disable debugging output for remote shells.
    The first argument is 'y' to enable the debugging output, 'n' to
    disable it.
    The remaining optional arguments are the selected shells.
    The special characters * ? and [] work as expected.
    """
    split = command.split()
    if not split:
        console_output('Expected at least a letter\n')
        return
    letter = split[0].lower()
    if letter not in ('y', 'n'):
        console_output("Expected 'y' or 'n', got: %s\n" % split[0])
        return
    debug = letter == 'y'
    for i in selected_shells(' '.join(split[1:])):
        i.debug = debug
コード例 #17
0
def do_send_ctrl(command):
    """
    Usage: :send_ctrl LETTER [SHELLS...]
    Send a control character to remote shells.
    The first argument is the control character to send like c, d or z.
    Note that these three control characters can be sent simply by typing them
    into polysh.
    The remaining optional arguments are the destination shells.
    The special characters * ? and [] work as expected.
    """
    split = command.split()
    if not split:
        console_output('Expected at least a letter\n')
        return
    letter = split[0]
    if len(letter) != 1:
        console_output('Expected a single letter, got: %s\n' % letter)
        return
    control_letter = chr(ord(letter.lower()) - ord('a') + 1)
    for i in selected_shells(' '.join(split[1:])):
        if i.enabled:
            i.dispatch_write(control_letter)
コード例 #18
0
def do_send_ctrl(command):
    """
    Usage: :send_ctrl LETTER [SHELLS...]
    Send a control character to remote shells.
    The first argument is the control character to send like c, d or z.
    Note that these three control characters can be sent simply by typing them
    into polysh.
    The remaining optional arguments are the destination shells.
    The special characters * ? and [] work as expected.
    """
    split = command.split()
    if not split:
        console_output('Expected at least a letter\n')
        return
    letter = split[0]
    if len(letter) != 1:
        console_output('Expected a single letter, got: %s\n' % letter)
        return
    control_letter = chr(ord(letter.lower()) - ord('a') + 1)
    for i in selected_shells(' '.join(split[1:])):
        if i.enabled:
            i.dispatch_write(control_letter)
コード例 #19
0
ファイル: control_commands.py プロジェクト: uuudoc111/polysh
def do_show_read_buffer(command: str) -> None:
    for i in selected_shells(command):
        if i.read_in_state_not_started:
            i.print_lines(i.read_in_state_not_started)
            i.read_in_state_not_started = b''
コード例 #20
0
ファイル: control_commands.py プロジェクト: uuudoc111/polysh
def do_reset_prompt(command: str) -> None:
    for i in selected_shells(command):
        i.dispatch_command(i.init_string)
コード例 #21
0
ファイル: control_commands.py プロジェクト: uuudoc111/polysh
def do_list(command: str) -> None:
    instances = [i.get_info() for i in selected_shells(command)]
    flat_instances = dispatchers.format_info(instances)
    console_output(b''.join(flat_instances))