1717
1818"""Command-line script that runs a server over roundup.cgi.client.
1919
20- $Id: roundup_server.py,v 1.38 2004-02-15 21:44:02 richard Exp $
20+ $Id: roundup_server.py,v 1.39 2004-02-15 21:55:10 richard Exp $
2121"""
2222__docformat__ = 'restructuredtext'
2323
7070r3fPdUcIYeyEfLSAJ0LeAUZHCAt8Al/8/kLIEWDB5YDj0wm8fAP6fVfo
7171''' .strip ()))
7272
73- class RoundupHTTPServer (SafeLogging , BaseHTTPServer .HTTPServer ):
74- def log_message (self , format , * args ):
75- ''' Try to use the logging package, otherwise *safely* log to
76- stderr.
77- '''
78- try :
79- BaseHTTPServer .HTTPServer .log_message (self , format , * args )
80- except IOError :
81- # stderr is no longer viable, we can't log
82- pass
83-
8473class RoundupRequestHandler (BaseHTTPServer .BaseHTTPRequestHandler ):
8574 TRACKER_HOMES = TRACKER_HOMES
8675 ROUNDUP_USER = ROUNDUP_USER
@@ -223,6 +212,16 @@ def address_string(self):
223212 host , port = self .client_address
224213 return socket .getfqdn (host )
225214
215+ def log_message (self , format , * args ):
216+ ''' Try to *safely* log to stderr.
217+ '''
218+ try :
219+ BaseHTTPServer .BaseHTTPRequestHandler .log_message (self ,
220+ format , * args )
221+ except IOError :
222+ # stderr is no longer viable
223+ pass
224+
226225def error ():
227226 exc_type , exc_value = sys .exc_info ()[:2 ]
228227 return _ ('Error: %s: %s' % (exc_type , exc_value ))
@@ -240,7 +239,8 @@ def error():
240239
241240 SvcShutdown = "ServiceShutdown"
242241
243- class RoundupService (win32serviceutil .ServiceFramework , RoundupHTTPServer ):
242+ class RoundupService (win32serviceutil .ServiceFramework ,
243+ BaseHTTPServer .HTTPServer ):
244244 ''' A Roundup standalone server for Win32 by Ewout Prangsma
245245 '''
246246 _svc_name_ = "Roundup Bug Tracker"
@@ -252,7 +252,7 @@ def __init__(self, args):
252252 # appending, unbuffered
253253 sys .stdout = sys .stderr = open (LOGFILE , 'a' , 0 )
254254 win32serviceutil .ServiceFramework .__init__ (self , args )
255- RoundupHTTPServer .__init__ (self , self .address ,
255+ BaseHTTPServer . HTTPServer .__init__ (self , self .address ,
256256 RoundupRequestHandler )
257257
258258 # Create the necessary NT Event synchronization objects...
@@ -341,7 +341,7 @@ def usage(message=''):
341341 -p: sets the port to listen on (default: %(port)s)
342342 -u: sets the uid to this user after listening on the port
343343 -g: sets the gid to this group after listening on the port
344- -l: sets a filename to log to (instead of stdout)
344+ -l: sets a filename to log to (instead of stderr / stdout)
345345 -d: run the server in the background and on UN*X write the server's PID
346346 to the nominated file. The -l option *must* be specified if this
347347 option is.
@@ -445,7 +445,7 @@ def run(port=PORT, success_message=None):
445445 # 1024 if started as root
446446 address = (hostname , port )
447447 try :
448- httpd = RoundupHTTPServer (address , RoundupRequestHandler )
448+ httpd = BaseHTTPServer . HTTPServer (address , RoundupRequestHandler )
449449 except socket .error , e :
450450 if e [0 ] == errno .EADDRINUSE :
451451 raise socket .error , \
0 commit comments