Example #1
0
    http_server.register(CoreUserInterface(state))
    Dibbler.run(launchBrowser=state.launch_ui)

# ===================================================================
# __main__ driver.
# ===================================================================

def run():
    # Read the arguments.
    try:
        opts, args = getopt.getopt(sys.argv[1:], 'hbd:p:l:u:o:P:')
    except getopt.error, msg:
        print >> sys.stderr, str(msg) + '\n\n' + __doc__
        sys.exit()

    state = CoreState()
    state.plugin = None

    for opt, arg in opts:
        if opt == '-h':
            print >> sys.stderr, __doc__
            sys.exit()
        elif opt == '-b':
            state.launch_ui = True
        # '-p' and '-d' are handled by the storage.database_type call
        # below, in case you are wondering why they are missing.
        elif opt == '-l':
            state.proxyPorts = [_addressAndPort(a) for a in arg.split(',')]
        elif opt == '-u':
            state.ui_port = int(arg)
        elif opt == '-o':
Example #2
0
    http_server.register(CoreUserInterface(state))
    Dibbler.run(launchBrowser=state.launch_ui)

# ===================================================================
# __main__ driver.
# ===================================================================

def run():
    # Read the arguments.
    try:
        opts, args = getopt.getopt(sys.argv[1:], 'hbd:p:l:u:o:P:')
    except getopt.error, msg:
        print >> sys.stderr, str(msg) + '\n\n' + __doc__
        sys.exit()

    state = CoreState()
    state.plugin = None

    for opt, arg in opts:
        if opt == '-h':
            print >> sys.stderr, __doc__
            sys.exit()
        elif opt == '-b':
            state.launch_ui = True
        # '-p' and '-d' are handled by the storage.database_type call
        # below, in case you are wondering why they are missing.
        elif opt == '-l':
            state.proxyPorts = [_addressAndPort(a) for a in arg.split(',')]
        elif opt == '-u':
            state.ui_port = int(arg)
        elif opt == '-o':
Example #3
0
 def run():

    try:

        opts, args = getopt.getopt(sys.argv[1:], 'hbd:p:l:u:o:P:')

    except getopt.error as msg:

        print(str(msg) + '\n\n' + __doc__, file=sys.stderr)

        sys.exit()

    state = CoreState()

    state.plugin = None

    for opt, arg in opts:

        if opt == '-h':

            print(__doc__, file=sys.stderr)

            sys.exit()

        elif opt == '-b':

            state.launch_ui = True

        elif opt == '-l':

            state.proxyPorts = [_addressAndPort(a) for a in arg.split(',')]

        elif opt == '-u':

            state.ui_port = int(arg)

        elif opt == '-o':

            options.set_from_cmdline(arg, sys.stderr)

        elif opt == '-P':

            state.plugin = load_plugin(arg, state)

    if state.plugin is None:

        print("No plugin argument (-P) was given.", file=sys.stderr)

        print(__doc__, file=sys.stderr)

        sys.exit()

    v = get_current_version()

    print("%s\n" % (v.get_long_version("SpamBayes Core Proxy"),))

    if 0 <= len(args) <= 2:

        if len(args) == 1:

            state.servers = [(args[0], 110)]

        elif len(args) == 2:

            state.servers = [(args[0], int(args[1]))]

        try:

            state.prepare()

        except AlreadyRunningException:

            print("ERROR: The proxy is already running on this machine.", file=sys.stderr)

            print("Please stop the existing proxy and try again", file=sys.stderr)

            return

        try:

            main(state)

        finally:

            state.close()

    else:

        print(__doc__, file=sys.stderr)