Code

proper fix this time
authorrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Sun, 15 Feb 2004 21:55:10 +0000 (21:55 +0000)
committerrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Sun, 15 Feb 2004 21:55:10 +0000 (21:55 +0000)
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@2089 57a73879-2fb5-44c3-a270-3262357dd7e2

roundup/scripts/roundup_server.py

index c40a71c02b7616c8be4fc98bfe74103cf3f737c8..5a9c5096ff9f6f89c24dae842b7606f7793e4734 100644 (file)
@@ -17,7 +17,7 @@
 
 """Command-line script that runs a server over roundup.cgi.client.
 
-$Id: roundup_server.py,v 1.38 2004-02-15 21:44:02 richard Exp $
+$Id: roundup_server.py,v 1.39 2004-02-15 21:55:10 richard Exp $
 """
 __docformat__ = 'restructuredtext'
 
@@ -70,17 +70,6 @@ AoFAtVo1m825XO7hSODOYrH4kHbxxGAwwODBGI/H6DBs5LNara7yl8slGjIcDsHpdrunU6PRCAP2
 r3fPdUcIYeyEfLSAJ0LeAUZHCAt8Al/8/kLIEWDB5YDj0wm8fAP6fVfo
 '''.strip()))
 
-class RoundupHTTPServer(SafeLogging, BaseHTTPServer.HTTPServer):
-    def log_message(self, format, *args):
-        ''' Try to use the logging package, otherwise *safely* log to
-            stderr.
-        '''
-        try:
-            BaseHTTPServer.HTTPServer.log_message(self, format, *args)
-        except IOError:
-            # stderr is no longer viable, we can't log
-            pass
-
 class RoundupRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
     TRACKER_HOMES = TRACKER_HOMES
     ROUNDUP_USER = ROUNDUP_USER
@@ -223,6 +212,16 @@ class RoundupRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
             host, port = self.client_address
             return socket.getfqdn(host)
 
+    def log_message(self, format, *args):
+        ''' Try to *safely* log to stderr.
+        '''
+        try:
+            BaseHTTPServer.BaseHTTPRequestHandler.log_message(self,
+                format, *args)
+        except IOError:
+            # stderr is no longer viable
+            pass
+
 def error():
     exc_type, exc_value = sys.exc_info()[:2]
     return _('Error: %s: %s' % (exc_type, exc_value))
@@ -240,7 +239,8 @@ else:
 
     SvcShutdown = "ServiceShutdown"
 
-    class RoundupService(win32serviceutil.ServiceFramework, RoundupHTTPServer):
+    class RoundupService(win32serviceutil.ServiceFramework,
+            BaseHTTPServer.HTTPServer):
         ''' A Roundup standalone server for Win32 by Ewout Prangsma
         '''
         _svc_name_ = "Roundup Bug Tracker"
@@ -252,7 +252,7 @@ else:
                 # appending, unbuffered
                 sys.stdout = sys.stderr = open(LOGFILE, 'a', 0)
             win32serviceutil.ServiceFramework.__init__(self, args)
-            RoundupHTTPServer.__init__(self, self.address, 
+            BaseHTTPServer.HTTPServer.__init__(self, self.address, 
                 RoundupRequestHandler)
 
             # Create the necessary NT Event synchronization objects...
@@ -341,7 +341,7 @@ options:
  -p: sets the port to listen on (default: %(port)s)
  -u: sets the uid to this user after listening on the port
  -g: sets the gid to this group after listening on the port
- -l: sets a filename to log to (instead of stdout)
+ -l: sets a filename to log to (instead of stderr / stdout)
  -d: run the server in the background and on UN*X write the server's PID
      to the nominated file. The -l option *must* be specified if this
      option is.
@@ -445,7 +445,7 @@ def run(port=PORT, success_message=None):
         # 1024 if started as root
         address = (hostname, port)
         try:
-            httpd = RoundupHTTPServer(address, RoundupRequestHandler)
+            httpd = BaseHTTPServer.HTTPServer(address, RoundupRequestHandler)
         except socket.error, e:
             if e[0] == errno.EADDRINUSE:
                 raise socket.error, \