Esempio n. 1
0
 def __init__(self, program, ctl):
     threading.Thread.__init__(self)
     import http_client
     self.killed = False
     self.program = program
     self.ctl = ctl
     self.listener = http_client.Listener()
     self.output_handler = http_client.HTTPHandler(self.listener,
                                                   self.ctl.options.username,
                                                   self.ctl.options.password)
     self.error_handler = http_client.HTTPHandler(self.listener,
                                                  self.ctl.options.username,
                                                  self.ctl.options.password)
Esempio n. 2
0
    def _tailf(self, path):
        if not self.ctl.upcheck():
            return

        self.ctl.output('==> Press Ctrl-C to exit <==')

        username = self.ctl.options.username
        password = self.ctl.options.password
        try:
            # Python's urllib2 (at least as of Python 2.4.2) isn't up
            # to this task; it doesn't actually implement a proper
            # HTTP/1.1 client that deals with chunked responses (it
            # always sends a Connection: close header).  We use a
            # homegrown client based on asyncore instead.  This makes
            # me sad.
            import http_client
            if self.listener is None:
                listener = http_client.Listener()
            else:
                listener = self.listener # for unit tests
            handler = http_client.HTTPHandler(listener, username, password)
            handler.get(self.ctl.options.serverurl, path)
            asyncore.loop()
        except KeyboardInterrupt:
            handler.close()
            self.ctl.output('')
            return