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)
def runTestServer(): from spambayes import asyncore asyncore.loop()
def runTestServer(): TestListener() asyncore.loop()
def runTestServer(): TestListener(socketMap=testSocketMap) asyncore.loop(map=testSocketMap)
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'])
def runTestServer(): testSocketMap = {} Listener(socketMap=testSocketMap) testServerReady.set() asyncore.loop(map=testSocketMap)
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()
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:
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))