Exemplo n.º 1
0
Arquivo: aq.py Projeto: piojo/aquilon
        else:
            print >> sys.stderr, "Unhandled transport method ", transport.method
            sys.exit(1)

        # handle failed requests
        if status_thread:
            status_thread.waiting_for_request = False
        res = conn.getresponse()

    except (httplib.HTTPException, socket.error), e:
        # noauth connections
        if not hasattr(conn, "getError"):
            print >> sys.stderr, "Error: %s" % e
            sys.exit(1)
        # KNC connections
        msg = conn.getError()
        host_failed = "Failed to connect to %s" % host
        port_failed = "%s port %s" % (host_failed, port)
        if msg.find("Connection refused") >= 0:
            print >> sys.stderr, "%s: Connection refused." % port_failed
        elif msg.find("Connection timed out") >= 0:
            print >> sys.stderr, "%s: Connection timed out." % port_failed
        elif msg.find("Unknown host") >= 0:
            print >> sys.stderr, "%s: Unknown host." % host_failed
        else:
            print >> sys.stderr, "Error: %s: %s" % (repr(e), msg)
        sys.exit(1)

    if status_thread:
        if globalOptions.get("slowstatus"):
            status_thread.start()
Exemplo n.º 2
0
        else:
            print >>sys.stderr, "Unhandled transport method ", transport.method
            sys.exit(1)

        # handle failed requests
        if status_thread:
            status_thread.waiting_for_request = False
        res = conn.getresponse()

    except (httplib.HTTPException, socket.error), e:
        # noauth connections
        if not hasattr(conn, "getError"):
            print >>sys.stderr, "Error: %s" % e
            sys.exit(1)
        # KNC connections
        msg = conn.getError()
        host_failed = "Failed to connect to %s" % host
        port_failed = "%s port %s" % (host_failed, port)
        if msg.find('Connection refused') >= 0:
            print >>sys.stderr, "%s: Connection refused." % port_failed
        elif msg.find('Connection timed out') >= 0:
            print >>sys.stderr, "%s: Connection timed out." % port_failed
        elif msg.find('Unknown host') >= 0:
            print >>sys.stderr, "%s: Unknown host." % host_failed
        else:
            print >>sys.stderr, "Error: %s: %s" % (repr(e), msg)
        sys.exit(1)

    if status_thread:
        if globalOptions.get("slowstatus"):
            status_thread.start()