1717
1818"""Command-line script that runs a server over roundup.cgi.client.
1919
20- $Id: roundup_server.py,v 1.37 2004-02-11 23:55:10 richard Exp $
20+ $Id: roundup_server.py,v 1.38 2004-02-15 21:44:02 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+
7384class RoundupRequestHandler (BaseHTTPServer .BaseHTTPRequestHandler ):
7485 TRACKER_HOMES = TRACKER_HOMES
7586 ROUNDUP_USER = ROUNDUP_USER
@@ -229,8 +240,7 @@ def error():
229240
230241 SvcShutdown = "ServiceShutdown"
231242
232- class RoundupService (win32serviceutil .ServiceFramework ,
233- BaseHTTPServer .HTTPServer ):
243+ class RoundupService (win32serviceutil .ServiceFramework , RoundupHTTPServer ):
234244 ''' A Roundup standalone server for Win32 by Ewout Prangsma
235245 '''
236246 _svc_name_ = "Roundup Bug Tracker"
@@ -242,7 +252,7 @@ def __init__(self, args):
242252 # appending, unbuffered
243253 sys .stdout = sys .stderr = open (LOGFILE , 'a' , 0 )
244254 win32serviceutil .ServiceFramework .__init__ (self , args )
245- BaseHTTPServer . HTTPServer .__init__ (self , self .address ,
255+ RoundupHTTPServer .__init__ (self , self .address ,
246256 RoundupRequestHandler )
247257
248258 # Create the necessary NT Event synchronization objects...
@@ -435,7 +445,7 @@ def run(port=PORT, success_message=None):
435445 # 1024 if started as root
436446 address = (hostname , port )
437447 try :
438- httpd = BaseHTTPServer . HTTPServer (address , RoundupRequestHandler )
448+ httpd = RoundupHTTPServer (address , RoundupRequestHandler )
439449 except socket .error , e :
440450 if e [0 ] == errno .EADDRINUSE :
441451 raise socket .error , \
0 commit comments