From 82276c3e7525e9ab5e51869a76974cf89c974445 Mon Sep 17 00:00:00 2001 From: jlgijsbers Date: Sat, 25 Oct 2003 11:41:06 +0000 Subject: [PATCH] Use roundup_server script in demo.py to reduce duplication (first part of fixing bug #798659). git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1937 57a73879-2fb5-44c3-a270-3262357dd7e2 --- demo.py | 25 ++++++++++++------------- roundup/scripts/roundup_server.py | 11 +++++++---- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/demo.py b/demo.py index b047e84..bf288e2 100644 --- a/demo.py +++ b/demo.py @@ -2,7 +2,7 @@ # # Copyright (c) 2003 Richard Jones (richard@mechanicalcat.net) # -# $Id: demo.py,v 1.5 2003-07-28 23:17:50 richard Exp $ +# $Id: demo.py,v 1.6 2003-10-25 11:41:06 jlgijsbers Exp $ import sys, os, string, re, urlparse import shutil, socket, errno, BaseHTTPServer @@ -81,18 +81,17 @@ def run_demo(): port = int(port) # ok, so start up the server - from roundup.scripts.roundup_server import RoundupRequestHandler - RoundupRequestHandler.TRACKER_HOMES = {'demo': home} - httpd = BaseHTTPServer.HTTPServer((hostname, port), RoundupRequestHandler) - print 'Server running - connect to:\n %s'%url - print '1. Log in as "demo"/"demo" or "admin"/"admin".' - print '2. Hit Control-C to stop the server.' - print '3. Re-start the server by running "python demo.py" again.' - print '4. Re-initialise the server by running "python demo.py nuke".' - try: - httpd.serve_forever() - except KeyboardInterrupt: - print 'Keyboard Interrupt: exiting' + from roundup.scripts import roundup_server + roundup_server.RoundupRequestHandler.TRACKER_HOMES = {'demo': home} + + success_message = '''Server running - connect to: + %s +1. Log in as "demo"/"demo" or "admin"/"admin". +2. Hit Control-C to stop the server. +3. Re-start the server by running "python demo.py" again. +4. Re-initialise the server by running "python demo.py nuke".''' % url + + roundup_server.run(port, success_message) if __name__ == '__main__': run_demo() diff --git a/roundup/scripts/roundup_server.py b/roundup/scripts/roundup_server.py index 97b6a5d..f87ce02 100644 --- a/roundup/scripts/roundup_server.py +++ b/roundup/scripts/roundup_server.py @@ -16,7 +16,7 @@ # """ HTTP Server that serves roundup. -$Id: roundup_server.py,v 1.30 2003-10-25 11:20:17 jlgijsbers Exp $ +$Id: roundup_server.py,v 1.31 2003-10-25 11:41:06 jlgijsbers Exp $ """ # python version check @@ -263,7 +263,7 @@ def daemonize(pidfile): os.dup2(devnull, 1) os.dup2(devnull, 2) -def run(): +def run(port=8080, success_message=None): ''' Script entry point - handle args and figure out what to to. ''' # time out after a minute if we can @@ -272,7 +272,6 @@ def run(): socket.setdefaulttimeout(60) hostname = '' - port = 8080 pidfile = None logfile = None try: @@ -368,7 +367,11 @@ def run(): # appending, unbuffered sys.stdout = sys.stderr = open(logfile, 'a', 0) - print _('Roundup server started on %(address)s')%locals() + if success_message: + print success_message + else: + print _('Roundup server started on %(address)s')%locals() + try: httpd.serve_forever() except KeyboardInterrupt: -- 2.30.2