Пример #1
0
 def rename(self, string):
     """Send to the remote shell, its new name to be shell expanded"""
     if string:
         rename1, rename2 = callbacks.add('rename', self.change_name, False)
         self.dispatch_command('/bin/echo "%s""%s"%s\n' %
                               (rename1, rename2, string))
     else:
         self.change_name(self.hostname)
Пример #2
0
 def rename(self, string):
     """Send to the remote shell, its new name to be shell expanded"""
     if string:
         rename1, rename2 = callbacks.add('rename', self.change_name, False)
         self.dispatch_command('/bin/echo "%s""%s"%s\n' %
                                                  (rename1, rename2, string))
     else:
         self.change_name(self.hostname)
Пример #3
0
 def seen_prompt_cb(self, unused):
     if options.interactive:
         self.change_state(STATE_IDLE)
     elif self.command:
         p1, p2 = callbacks.add(b'real prompt ends', lambda d: None, True)
         self.dispatch_command(b'PS1="' + p1 + b'""' + p2 + b'\n"\n')
         self.dispatch_command(self.command.encode() + b'\n')
         self.dispatch_command(b'exit 2>/dev/null\n')
         self.command = None
Пример #4
0
 def seen_prompt_cb(self, unused):
     if options.interactive:
         self.change_state(STATE_IDLE)
     elif self.command:
         p1, p2 = callbacks.add('real prompt ends', lambda d: None, True)
         self.dispatch_command('PS1="%s""%s\n"\n' % (p1, p2))
         self.dispatch_command(self.command + '\n')
         self.dispatch_command('exit 2>/dev/null\n')
         self.command = None
Пример #5
0
 def __init__(self, path_to_upload, first_destination):
     self.path_to_upload = path_to_upload
     self.trigger1, self.trigger2 = callbacks.add('upload_done',
                                                  self.upload_done,
                                                  False)
     self.first_destination = first_destination
     self.first_destination.drain_and_block_writing()
     remote_dispatcher.remote_dispatcher.__init__(self, '.')
     self.temporary = True
Пример #6
0
 def seen_prompt_cb(self, unused):
     if options.interactive:
         self.change_state(STATE_IDLE)
     elif self.command:
         p1, p2 = callbacks.add('real prompt ends', lambda d: None, True)
         self.dispatch_command('PS1="%s""%s\n"\n' % (p1, p2))
         self.dispatch_command(self.command + '\n')
         self.dispatch_command('exit 2>/dev/null\n')
         self.command = None
Пример #7
0
 def rename(self, name):
     """Send to the remote shell, its new name to be shell expanded"""
     if name:
         # defug callback add?
         rename1, rename2 = callbacks.add(b'rename', self.change_name,
                                          False)
         self.dispatch_command(b'/bin/echo "' + rename1 + b'""' + rename2 +
                               b'"' + name + b'\n')
     else:
         self.change_name(self.hostname.encode())
Пример #8
0
 def set_prompt(self):
     """The prompt is important because we detect the readyness of a process
     by waiting for its prompt."""
     # No right prompt
     command_line = b'PS2=;RPS1=;RPROMPT=;'
     command_line += b'PROMPT_COMMAND=;'
     command_line += b'TERM=ansi;'
     command_line += b'unset HISTFILE;'
     prompt1, prompt2 = callbacks.add(b'prompt', self.seen_prompt_cb, True)
     command_line += b'PS1="' + prompt1 + b'""' + prompt2 + b'\n"\n'
     return command_line
Пример #9
0
 def set_prompt(self):
     """The prompt is important because we detect the readyness of a process
     by waiting for its prompt."""
     # No right prompt
     command_line = 'PS2=;RPS1=;RPROMPT=;'
     command_line += 'PROMPT_COMMAND=;'
     command_line += 'TERM=ansi;'
     command_line += 'unset HISTFILE;'
     prompt1, prompt2 = callbacks.add('prompt', self.seen_prompt_cb, True)
     command_line += 'PS1="%s""%s\n"\n' % (prompt1, prompt2)
     return command_line
Пример #10
0
 def try_start_pity(self):
     host_ports = [child.host_port for child in self.children]
     if len(filter(bool, host_ports)) != len(host_ports):
         return
     host_ports = ' '.join(map(pipes.quote, host_ports))
     if self.should_print_bw:
         opt = '--print-bw'
     else:
         opt = ''
     if self.parent:
         cb = lambda host_port: self.host_port_cb(host_port)
         t1, t2 = callbacks.add('file_transfer', cb, False)
         cmd = CMD_FORWARD % (opt, t1, t2, host_ports)
     elif self.is_upload:
         def start_upload(unused):
             local_uploader(self.path, self.remote_dispatcher)
         t1, t2 = callbacks.add('upload_start', start_upload, False)
         cmd = CMD_UPLOAD_EMIT % (t1, t2, opt, host_ports)
     else:
         cmd = CMD_REPLICATE_EMIT % (tarCreate(self.path), opt, host_ports)
     self.remote_dispatcher.dispatch_command(cmd)