Beispiel #1
0
 def run(self):
     while True:
         self.raw_input_wanted.wait()
         self.out_of_raw_input.set()
         self.in_raw_input.set()
         self.out_of_raw_input.clear()
         cmd = None
         try:
             cmd = raw_input(self.prompt)
         except EOFError:
             if self.interrupt_asked:
                 cmd = readline.get_line_buffer()
             else:
                 cmd = chr(4) # Ctrl-D
         if self.interrupt_asked:
             self.prepend_text = cmd
             cmd = None
         self.in_raw_input.clear()
         self.out_of_raw_input.set()
         if cmd:
             if echo_enabled:
                 completion.add_to_history(cmd)
             else:
                 completion.remove_last_history_item()
         set_echo(True)
         if cmd is not None:
             self.input_buffer.add(cmd + '\n')
             write_main_socket('d')
Beispiel #2
0
 def run(self) -> None:
     while True:
         self.raw_input_wanted.wait()
         self.out_of_raw_input.set()
         self.in_raw_input.set()
         self.out_of_raw_input.clear()
         cmd = None
         try:
             cmd = input(self.prompt)
         except EOFError:
             if self.interrupt_asked:
                 cmd = readline.get_line_buffer()
             else:
                 cmd = chr(4)  # Ctrl-D
         if self.interrupt_asked:
             self.prepend_text = cmd
             cmd = None
         self.in_raw_input.clear()
         self.out_of_raw_input.set()
         if cmd:
             if echo_enabled:
                 completion.add_to_history(cmd)
             else:
                 completion.remove_last_history_item()
         set_echo(True)
         if cmd is not None:
             self.input_buffer.add('{}\n'.format(cmd).encode())
             write_main_socket(b'd')
Beispiel #3
0
                'POLYSH_RANK': str(rank),
                'POLYSH_NAME': shell.hostname,
                'POLYSH_DISPLAY_NAME': shell.display_name,
            }
            for name, value in environment_variables.items():
                shell.dispatch_command('export {}={}\n'.format(
                    name, shlex.quote(value)).encode())
            rank += 1

    for shell in dispatchers.all_instances():
        if shell.enabled:
            shell.dispatch_command(
                'export POLYSH_NR_SHELLS={:d}\n'.format(rank).encode())


add_to_history('$POLYSH_RANK $POLYSH_NAME $POLYSH_DISPLAY_NAME')
add_to_history('$POLYSH_NR_SHELLS')


def complete_set_log(line: str, text: str) -> List[str]:
    return complete_local_path(text)


def do_set_log(command: str) -> None:
    command = command.strip()
    if command:
        try:
            remote_dispatcher.options.log_file = open(command, 'a')
        except IOError as e:
            console_output('{}\n'.format(str(e)).encode())
            command = None
Beispiel #4
0
        if shell.enabled:
            environment_variables = {
                'POLYSH_RANK': rank,
                'POLYSH_NAME': shell.hostname,
                'POLYSH_DISPLAY_NAME': shell.display_name,
            }
            for name, value in environment_variables.iteritems():
                value = pipes.quote(str(value))
                shell.dispatch_command('export %s=%s\n' % (name, value))
            rank += 1

    for shell in dispatchers.all_instances():
        if shell.enabled:
            shell.dispatch_command('export POLYSH_NR_SHELLS=%d\n' % rank)

add_to_history('$POLYSH_RANK $POLYSH_NAME $POLYSH_DISPLAY_NAME')
add_to_history('$POLYSH_NR_SHELLS')

def complete_set_log(line, text):
    return complete_local_path(text)

def do_set_log(command):
    """
    Usage: :set_log [LOCAL_PATH]
    Duplicate every console I/O into the given local file.
    If LOCAL_PATH is not given, restore the default behaviour of not logging.
    """
    command = command.strip()
    if command:
        try:
            remote_dispatcher.options.log_file = file(command, 'a')