Ejemplo n.º 1
0
def run(launchBrowser=False, context=_defaultContext):
    """Runs a `Dibbler` application.  Servers listen for incoming connections
    and route requests through to plugins until a plugin calls `sys.exit()`
    or raises a `SystemExit` exception."""

    if launchBrowser:
        try:
            url = "http://localhost:%d/" % context._HTTPPort
            webbrowser.open_new(url)
        except webbrowser.Error as e:
            print("\n%s.\nPlease point your web browser at %s." % (e, url))
    asyncore.loop(map=context._map)
Ejemplo n.º 2
0
 def runTestServer():
     from spambayes import asyncore
     asyncore.loop()
Ejemplo n.º 3
0
 def runTestServer():
     from spambayes import asyncore
     asyncore.loop()
Ejemplo n.º 4
0
 def runTestServer():
     TestListener()
     asyncore.loop()
Ejemplo n.º 5
0
 def runTestServer():
     TestListener(socketMap=testSocketMap)
     asyncore.loop(map=testSocketMap)
Ejemplo n.º 6
0
        sys.exit()

    for opt, arg in opts:
        if opt == '-h':
            print >>sys.stderr, __doc__
            sys.exit()
        elif opt == '-t':
            state.isTest = True
            state.runTestServer = True

    state.createWorkers()

    if state.runTestServer:
        print "Running a test SMTP server on port 8025..."
        TestListener()
        asyncore.loop()
    else:
        state.isTest = True
        state.buildServerStrings()
        testSocketMap = {}
        def runTestServer():
            TestListener(socketMap=testSocketMap)
            asyncore.loop(map=testSocketMap)
        def runProxy():
            trainer = SMTPTrainer(Classifier(), state)
            BayesSMTPProxyListener('localhost', 8025, ('', 8026), trainer)
            Dibbler.run()
        thread.start_new_thread(runTestServer, ())
        thread.start_new_thread(runProxy, ())
        sb_test_support.unittest_main(argv=sys.argv + ['suite'])
Ejemplo n.º 7
0
 def runTestServer():
     TestListener()
     asyncore.loop()
Ejemplo n.º 8
0
 def runTestServer():
     testSocketMap = {}
     Listener(socketMap=testSocketMap)
     testServerReady.set()
     asyncore.loop(map=testSocketMap)
Ejemplo n.º 9
0
 def runTestServer():
     testSocketMap = {}
     Listener(socketMap=testSocketMap)
     testServerReady.set()
     asyncore.loop(map=testSocketMap)
Ejemplo n.º 10
0
        print >> sys.stderr, str(msg) + '\n\n' + __doc__
        sys.exit()

    state.isTest = True
    runSelfTest = True
    for opt, arg in opts:
        if opt == '-h':
            print >> sys.stderr, __doc__
            sys.exit()
        elif opt == '-t':
            state.isTest = True
            state.runTestServer = True
            runSelfTest = False

    state.createWorkers()

    if runSelfTest:
        print "\nRunning self-test...\n"
        state.buildServerStrings()
        helper()
        print "Self-test passed."  # ...else it would have asserted.

    elif state.runTestServer:
        print "Running a test POP3 server on port 8110..."
        Listener()
        asyncore.loop()


if __name__ == '__main__':
    test_run()
Ejemplo n.º 11
0
 def runTestServer():
     TestListener(socketMap=testSocketMap)
     asyncore.loop(map=testSocketMap)
Ejemplo n.º 12
0
            self.flush()
        return self._handler.close()


def run(launchBrowser=False, context=_defaultContext):
    """Runs a `Dibbler` application.  Servers listen for incoming connections
    and route requests through to plugins until a plugin calls `sys.exit()`
    or raises a `SystemExit` exception."""

    if launchBrowser:
        try:
            url = "http://localhost:%d/" % context._HTTPPort
            webbrowser.open_new(url)
        except webbrowser.Error, e:
            print "\n%s.\nPlease point your web browser at %s." % (e, url)
    asyncore.loop(map=context._map)


def runTestServer(readyEvent=None):
    """Runs the calendar server example, with an added `/shutdown` URL."""
    import calendar

    class Calendar(HTTPPlugin):
        _form = '''<html><body><h3>Calendar Server</h3>
                   <form action='/'>
                   Year: <input type='text' name='year' size='4'>
                   <input type='submit' value='Go'></form>
                   <pre>%s</pre></body></html>'''

        def onHome(self, year=None):
            if year:
Ejemplo n.º 13
0
            self.flush()
        return self._handler.close()


def run(launchBrowser=False, context=_defaultContext):
    """Runs a `Dibbler` application.  Servers listen for incoming connections
    and route requests through to plugins until a plugin calls `sys.exit()`
    or raises a `SystemExit` exception."""

    if launchBrowser:
        try:
            url = "http://localhost:%d/" % context._HTTPPort
            webbrowser.open_new(url)
        except webbrowser.Error, e:
            print "\n%s.\nPlease point your web browser at %s." % (e, url)
    asyncore.loop(map=context._map)


def runTestServer(readyEvent=None):
    """Runs the calendar server example, with an added `/shutdown` URL."""
    import calendar
    class Calendar(HTTPPlugin):
        _form = '''<html><body><h3>Calendar Server</h3>
                   <form action='/'>
                   Year: <input type='text' name='year' size='4'>
                   <input type='submit' value='Go'></form>
                   <pre>%s</pre></body></html>'''

        def onHome(self, year=None):
            if year:
                result = calendar.calendar(int(year))