comparison setup.py @ 1580:070b56a0b2f6

better version of demo setup
author Richard Jones <richard@users.sourceforge.net>
date Thu, 10 Apr 2003 04:33:02 +0000
parents 80519db85eac
children 7c1a9b72f7fb
comparison
equal deleted inserted replaced
1579:07a6b8587bc2 1580:070b56a0b2f6
14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
18 # 18 #
19 # $Id: setup.py,v 1.45 2003-04-07 03:47:44 richard Exp $ 19 # $Id: setup.py,v 1.46 2003-04-10 04:33:02 richard Exp $
20 20
21 from distutils.core import setup, Extension 21 from distutils.core import setup, Extension
22 from distutils.util import get_platform 22 from distutils.util import get_platform
23 from distutils.command.build_scripts import build_scripts 23 from distutils.command.build_scripts import build_scripts
24 24
239 init.write_select_db(home, 'anydbm') 239 init.write_select_db(home, 'anydbm')
240 240
241 # figure basic params for server 241 # figure basic params for server
242 hostname = socket.gethostname() 242 hostname = socket.gethostname()
243 port = 8080 243 port = 8080
244 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
245 s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
246 while 1: 244 while 1:
247 print 'Trying to set up web server on port %d ...'%port, 245 print 'Trying to set up web server on port %d ...'%port,
246 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
247 s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
248 try: 248 try:
249 s.bind((hostname, port)) 249 s.connect((hostname, port))
250 except socket.error, error: 250 except socket.error, e:
251 if error.errno != errno.EADDRINUSE: 251 if not hasattr(e, 'args') or e.args[0] != errno.ECONNREFUSED:
252 raise 252 raise
253 print 'should be ok.'
254 break
255 else:
256 s.close()
253 print 'already in use.' 257 print 'already in use.'
254 port += 100 258 port += 100
255 else:
256 print 'should be ok.'
257 break
258 url = 'http://%s:%s/demo/'%(hostname, port) 259 url = 'http://%s:%s/demo/'%(hostname, port)
259 260
260 # write the config 261 # write the config
261 f = open(os.path.join(home, 'config.py'), 'r') 262 f = open(os.path.join(home, 'config.py'), 'r')
262 s = f.read().replace('http://tracker.example/cgi-bin/roundup.cgi/bugs/', 263 s = f.read().replace('http://tracker.example/cgi-bin/roundup.cgi/bugs/',
281 from roundup.scripts.roundup_server import RoundupRequestHandler 282 from roundup.scripts.roundup_server import RoundupRequestHandler
282 RoundupRequestHandler.TRACKER_HOMES = {'demo': home} 283 RoundupRequestHandler.TRACKER_HOMES = {'demo': home}
283 httpd = BaseHTTPServer.HTTPServer((hostname, port), RoundupRequestHandler) 284 httpd = BaseHTTPServer.HTTPServer((hostname, port), RoundupRequestHandler)
284 print 'Server running - connect to:\n %s'%url 285 print 'Server running - connect to:\n %s'%url
285 print 'You may log in as "demo"/"demo" or "admin"/"admin".' 286 print 'You may log in as "demo"/"demo" or "admin"/"admin".'
287 print 'Hit Control-C to stop the server.'
286 try: 288 try:
287 httpd.serve_forever() 289 httpd.serve_forever()
288 except KeyboardInterrupt: 290 except KeyboardInterrupt:
289 print 'Keyboard Interrupt: exiting' 291 print 'Keyboard Interrupt: exiting'
290 292

Roundup Issue Tracker: http://roundup-tracker.org/