Example #1
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)
Example #2
0
        elif opt == '-P':
            state.plugin = load_plugin(arg, state)

    if state.plugin is None:
        print >> sys.stderr, "No plugin argument (-P) was given."
        print >> sys.stderr, __doc__
        sys.exit()

    # Let the user know what they are using...
    v = get_current_version()
    print "%s\n" % (v.get_long_version("SpamBayes Core Proxy"),)

    if 0 <= len(args) <= 2:
        # Normal usage, with optional server name and port number.
        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  >> sys.stderr, \
                   "ERROR: The proxy is already running on this machine."
            print  >> sys.stderr, "Please stop the existing proxy and try again"
            return

        # kick everything off
        try:
            main(state)
        finally:
Example #3
0
        elif opt == '-P':
            state.plugin = load_plugin(arg, state)

    if state.plugin is None:
        print >> sys.stderr, "No plugin argument (-P) was given."
        print >> sys.stderr, __doc__
        sys.exit()

    # Let the user know what they are using...
    v = get_current_version()
    print "%s\n" % (v.get_long_version("SpamBayes Core Proxy"),)

    if 0 <= len(args) <= 2:
        # Normal usage, with optional server name and port number.
        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  >> sys.stderr, \
                   "ERROR: The proxy is already running on this machine."
            print  >> sys.stderr, "Please stop the existing proxy and try again"
            return

        # kick everything off
        try:
            main(state)
        finally: