예제 #1
0
def main():
    define("pycurl", default=1, help="Use pycurl")
    define("sslcheck", default=1, help="Verify SSL hostname, on by default")
    args = parse_command_line()
    skip_ssl_validation = False

    if unicode(options.pycurl) == u"0":
        os.environ['USE_SIMPLE_HTTPCLIENT'] = "1"

    if unicode(options.sslcheck) == u"0":
        skip_ssl_validation = True

    # If we don't have any arguments, run the server.
    if not args:
        import tornado.httpclient
        app = init(skip_ssl_validation)
        try:
            app.run()
        finally:
            ForwarderStatus.remove_latest_status()

    else:
        usage = "%s [help|info]. Run with no commands to start the server" % (
                                        sys.argv[0])
        command = args[0]
        if command == 'info':
            logging.getLogger().setLevel(logging.ERROR)
            return ForwarderStatus.print_latest_status()
        elif command == 'help':
            print usage
        else:
            print "Unknown command: %s" % command
            print usage
            return -1
    return 0
예제 #2
0
def main():
    define("pycurl", default=1, help="Use pycurl")
    args = parse_command_line()

    if options.pycurl == 0 or options.pycurl == "0":
        os.environ['USE_SIMPLE_HTTPCLIENT'] = '1'

    # If we don't have any arguments, run the server.
    if not args:
        import tornado.httpclient
        app = init()
        try:
            app.run()
        finally:
            ForwarderStatus.remove_latest_status()
            
    else:
        usage = "%s [help|info]. Run with no commands to start the server" % (
                                        sys.argv[0])
        command = args[0]
        if command == 'info':
            return ForwarderStatus.print_latest_status()
        elif command == 'help':
            print usage
        else:
            print "Unknown command: %s" % command
            print usage
            return -1
    return 0
예제 #3
0
def main():
    define("pycurl", default=1, help="Use pycurl")
    define("sslcheck", default=1, help="Verify SSL hostname, on by default")
    args = parse_command_line()
    skip_ssl_validation = False

    if unicode(options.pycurl) == u"0":
        os.environ['USE_SIMPLE_HTTPCLIENT'] = "1"

    if unicode(options.sslcheck) == u"0":
        skip_ssl_validation = True

    # If we don't have any arguments, run the server.
    if not args:
        import tornado.httpclient
        app = init(skip_ssl_validation)
        try:
            app.run()
        finally:
            ForwarderStatus.remove_latest_status()

    else:
        usage = "%s [help|info]. Run with no commands to start the server" % (
            sys.argv[0])
        command = args[0]
        if command == 'info':
            logging.getLogger().setLevel(logging.ERROR)
            return ForwarderStatus.print_latest_status()
        elif command == 'help':
            print usage
        else:
            print "Unknown command: %s" % command
            print usage
            return -1
    return 0
예제 #4
0
파일: ddagent.py 프로젝트: jkoppe/dd-agent
def main():
    define("pycurl", default=1, help="Use pycurl")
    args = parse_command_line()

    if options.pycurl == 0 or options.pycurl == "0":
        os.environ['USE_SIMPLE_HTTPCLIENT'] = '1'

    # If we don't have any arguments, run the server.
    if not args:
        import tornado.httpclient
        app = init()
        try:
            app.run()
        finally:
            ForwarderStatus.remove_latest_status()

    else:
        usage = "%s [help|info]. Run with no commands to start the server" % (
            sys.argv[0])
        command = args[0]
        if command == 'info':
            ForwarderStatus.print_latest_status()
        elif command == 'help':
            print usage
        else:
            print "Unknown command: %s" % command
            print usage
            return -1
    return 0
예제 #5
0
def main():
    # Deprecation notice
    from utils.deprecations import deprecate_old_command_line_tools
    deprecate_old_command_line_tools()

    define("sslcheck", default=1, help="Verify SSL hostname, on by default")
    define("use_simple_http_client",
           default=0,
           help="Use Tornado SimpleHTTPClient instead of CurlAsyncHTTPClient")
    args = parse_command_line()
    skip_ssl_validation = False
    use_simple_http_client = False

    if unicode(options.sslcheck) == u"0":
        skip_ssl_validation = True

    if unicode(options.use_simple_http_client) == u"1":
        use_simple_http_client = True

    # If we don't have any arguments, run the server.
    if not args:
        app = init(skip_ssl_validation,
                   use_simple_http_client=use_simple_http_client)
        try:
            app.run()
        except Exception:
            log.exception("Uncaught exception in the forwarder")
        finally:
            ForwarderStatus.remove_latest_status()

    else:
        usage = "%s [help|info]. Run with no commands to start the server" % (
            sys.argv[0])
        command = args[0]
        if command == 'info':
            logging.getLogger().setLevel(logging.ERROR)
            return ForwarderStatus.print_latest_status()
        elif command == 'help':
            print usage
        else:
            print "Unknown command: %s" % command
            print usage
            return -1
    return 0
예제 #6
0
파일: ddagent.py 프로젝트: hkaj/dd-agent
def main():
    # Deprecation notice
    from utils.deprecations import deprecate_old_command_line_tools
    deprecate_old_command_line_tools()

    define("sslcheck", default=1, help="Verify SSL hostname, on by default")
    define("use_simple_http_client", default=0, help="Use Tornado SimpleHTTPClient instead of CurlAsyncHTTPClient")
    args = parse_command_line()
    skip_ssl_validation = False
    use_simple_http_client = False

    if unicode(options.sslcheck) == u"0":
        skip_ssl_validation = True

    if unicode(options.use_simple_http_client) == u"1":
        use_simple_http_client = True

    # If we don't have any arguments, run the server.
    if not args:
        import tornado.httpclient
        app = init(skip_ssl_validation, use_simple_http_client=use_simple_http_client)
        try:
            app.run()
        except Exception:
            log.exception("Uncaught exception in the forwarder")
        finally:
            ForwarderStatus.remove_latest_status()

    else:
        usage = "%s [help|info]. Run with no commands to start the server" % (sys.argv[0])
        command = args[0]
        if command == 'info':
            logging.getLogger().setLevel(logging.ERROR)
            return ForwarderStatus.print_latest_status()
        elif command == 'help':
            print usage
        else:
            print "Unknown command: %s" % command
            print usage
            return -1
    return 0
예제 #7
0
def main():
    define("pycurl", default=1, help="Use pycurl")
    define("sslcheck", default=1, help="Verify SSL hostname, on by default")
    args = parse_command_line()

    if unicode(options.pycurl) == u"0":
        os.environ['USE_SIMPLE_HTTPCLIENT'] = "1"

    if unicode(options.sslcheck) == u"0":
        # monkey-patch the AsyncHTTPClient code
        import tornado.simple_httpclient
        tornado.simple_httpclient.match_hostname = lambda x, y: None
        print(
            "Skipping SSL hostname validation, useful when using a transparent proxy"
        )

    # If we don't have any arguments, run the server.
    if not args:
        import tornado.httpclient
        app = init()
        try:
            app.run()
        finally:
            ForwarderStatus.remove_latest_status()

    else:
        usage = "%s [help|info]. Run with no commands to start the server" % (
            sys.argv[0])
        command = args[0]
        if command == 'info':
            logging.getLogger().setLevel(logging.ERROR)
            return ForwarderStatus.print_latest_status()
        elif command == 'help':
            print usage
        else:
            print "Unknown command: %s" % command
            print usage
            return -1
    return 0
예제 #8
0
def main():
    define("pycurl", default=1, help="Use pycurl")
    define("sslcheck", default=1, help="Verify SSL hostname, on by default")
    args = parse_command_line()

    if unicode(options.pycurl) == u"0":
        os.environ["USE_SIMPLE_HTTPCLIENT"] = "1"

    if unicode(options.sslcheck) == u"0":
        # monkey-patch the AsyncHTTPClient code
        import tornado.simple_httpclient

        tornado.simple_httpclient.match_hostname = lambda x, y: None
        print ("Skipping SSL hostname validation, useful when using a transparent proxy")

    # If we don't have any arguments, run the server.
    if not args:
        import tornado.httpclient

        app = init()
        try:
            app.run()
        finally:
            ForwarderStatus.remove_latest_status()

    else:
        usage = "%s [help|info]. Run with no commands to start the server" % (sys.argv[0])
        command = args[0]
        if command == "info":
            logging.getLogger().setLevel(logging.ERROR)
            return ForwarderStatus.print_latest_status()
        elif command == "help":
            print usage
        else:
            print "Unknown command: %s" % command
            print usage
            return -1
    return 0