Пример #1
0
    def __init__(self, host, port, hook_name, hook_dir, options, conf):
        assert os.path.isdir(hook_dir)
        timestamp = timestamp_string()
        self.pid = os.getpid()
        fn = '%s-%s-%s-%s.%d' % (
            conf.svn_hook_enabled_prefix,
            hook_name,
            conf.svn_hook_remote_debug_suffix,
            timestamp_string(),
            self.pid,
        )
        path = join_path(hook_dir, fn)
        assert not os.path.exists(path)
        touch_file(path)
        try_remove_file_atexit(path)

        self.path = self.session_file = path
        self.conf = conf
        self.hook_name = hook_name
        self.options = options
        self.old_stdout = sys.stdout
        self.old_stdin = sys.stdin
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.sock.bind((host, port))
        (self.host, self.port) = self.sock.getsockname()
        self.dst_host = ''
        self.dst_port = 0
        self.state = 'listening'
        self._dump_state()

        self.sock.listen(1)
        (clientsocket, address) = self.sock.accept()
        (self.dst_host, self.dst_port) = address
        self.state = 'connected'
        self._dump_state()

        handle = clientsocket.makefile('rw')
        k = self.conf.remote_debug_complete_key
        pdb.Pdb.__init__(self, completekey=k, stdin=handle, stdout=handle)
        sys.stdout = sys.stdin = handle
Пример #2
0
 def _touch(self, path):
     touch_file(path)