[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

eric at webkit.org eric at webkit.org
Thu Apr 8 00:16:10 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit bb54348d04265262d80385b685b9795cc7acc947
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 3 22:01:14 2009 +0000

    2009-12-03  Yuzo Fujishima  <yuzo at google.com>
    
            Reviewed by Eric Seidel.
    
            Update pywebsocket to 0.4.3
            This version logs friendlier and higher-level messages in WARN level, which is used for LayoutTests.
            Stack trace is logged now in INFO level.
            https://bugs.webkit.org/show_bug.cgi?id=32097
    
            * pywebsocket/mod_pywebsocket/dispatch.py:
            * pywebsocket/mod_pywebsocket/msgutil.py:
            * pywebsocket/mod_pywebsocket/standalone.py:
            * pywebsocket/mod_pywebsocket/util.py:
            * pywebsocket/setup.py:
            * pywebsocket/test/test_dispatch.py:
            * pywebsocket/test/test_util.py:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51661 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 75803d4..13142e9 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,20 @@
+2009-12-03  Yuzo Fujishima  <yuzo at google.com>
+
+        Reviewed by Eric Seidel.
+
+        Update pywebsocket to 0.4.3
+        This version logs friendlier and higher-level messages in WARN level, which is used for LayoutTests.
+        Stack trace is logged now in INFO level.
+        https://bugs.webkit.org/show_bug.cgi?id=32097
+
+        * pywebsocket/mod_pywebsocket/dispatch.py:
+        * pywebsocket/mod_pywebsocket/msgutil.py:
+        * pywebsocket/mod_pywebsocket/standalone.py:
+        * pywebsocket/mod_pywebsocket/util.py:
+        * pywebsocket/setup.py:
+        * pywebsocket/test/test_dispatch.py:
+        * pywebsocket/test/test_util.py:
+
 2009-12-03  Sam Weinig  <sam at webkit.org>
 
         Reviewed by Gavin Barraclough.
diff --git a/WebKitTools/pywebsocket/mod_pywebsocket/dispatch.py b/WebKitTools/pywebsocket/mod_pywebsocket/dispatch.py
index 87a7315..bf9a856 100644
--- a/WebKitTools/pywebsocket/mod_pywebsocket/dispatch.py
+++ b/WebKitTools/pywebsocket/mod_pywebsocket/dispatch.py
@@ -160,9 +160,13 @@ class Dispatcher(object):
         do_extra_handshake_, unused_transfer_data = self._handler(request)
         try:
             do_extra_handshake_(request)
-        except Exception:
-            raise DispatchError('%s raised exception: %s' %
-                    (_DO_EXTRA_HANDSHAKE_HANDLER_NAME, util.get_stack_trace()))
+        except Exception, e:
+            util.prepend_message_to_exception(
+                    '%s raised exception for %s: ' % (
+                            _DO_EXTRA_HANDSHAKE_HANDLER_NAME,
+                            request.ws_resource),
+                    e)
+            raise
 
     def transfer_data(self, request):
         """Let a handler transfer_data with a Web Socket client.
@@ -177,9 +181,12 @@ class Dispatcher(object):
         unused_do_extra_handshake, transfer_data_ = self._handler(request)
         try:
             transfer_data_(request)
-        except Exception:
-            raise DispatchError('%s raised exception: %s' %
-                    (_TRANSFER_DATA_HANDLER_NAME, util.get_stack_trace()))
+        except Exception, e:
+            util.prepend_message_to_exception(
+                    '%s raised exception for %s: ' % (
+                            _TRANSFER_DATA_HANDLER_NAME, request.ws_resource),
+                    e)
+            raise
 
     def _handler(self, request):
         try:
diff --git a/WebKitTools/pywebsocket/mod_pywebsocket/msgutil.py b/WebKitTools/pywebsocket/mod_pywebsocket/msgutil.py
index 9fa9b59..90ae715 100644
--- a/WebKitTools/pywebsocket/mod_pywebsocket/msgutil.py
+++ b/WebKitTools/pywebsocket/mod_pywebsocket/msgutil.py
@@ -39,6 +39,31 @@ not suitable because they don't allow direct raw bytes writing/reading.
 
 import Queue
 import threading
+import util
+
+
+class MsgUtilException(Exception):
+    pass
+
+
+def _read(request, length):
+    bytes = request.connection.read(length)
+    if not bytes:
+        raise MsgUtilException(
+                'Failed to receive message from %r' %
+                        (request.connection.remote_addr,))
+    return bytes
+
+
+def _write(request, bytes):
+    try:
+        request.connection.write(bytes)
+    except Exception, e:
+        util.prepend_message_to_exception(
+                'Failed to send message to %r: ' %
+                        (request.connection.remote_addr,),
+                e)
+        raise
 
 
 def send_message(request, message):
@@ -49,7 +74,7 @@ def send_message(request, message):
         message: unicode string to send.
     """
 
-    request.connection.write('\x00' + message.encode('utf-8') + '\xff')
+    _write(request, '\x00' + message.encode('utf-8') + '\xff')
 
 
 def receive_message(request):
@@ -63,7 +88,7 @@ def receive_message(request):
         # Read 1 byte.
         # mp_conn.read will block if no bytes are available.
         # Timeout is controlled by TimeOut directive of Apache.
-        frame_type_str = request.connection.read(1)
+        frame_type_str = _read(request, 1)
         frame_type = ord(frame_type_str[0])
         if (frame_type & 0x80) == 0x80:
             # The payload length is specified in the frame.
@@ -84,7 +109,7 @@ def receive_message(request):
 def _payload_length(request):
     length = 0
     while True:
-        b_str = request.connection.read(1)
+        b_str = _read(request, 1)
         b = ord(b_str[0])
         length = length * 128 + (b & 0x7f)
         if (b & 0x80) == 0:
@@ -95,7 +120,7 @@ def _payload_length(request):
 def _receive_bytes(request, length):
     bytes = []
     while length > 0:
-        new_bytes = request.connection.read(length)
+        new_bytes = _read(request, length)
         bytes.append(new_bytes)
         length -= len(new_bytes)
     return ''.join(bytes)
@@ -104,7 +129,7 @@ def _receive_bytes(request, length):
 def _read_until(request, delim_char):
     bytes = []
     while True:
-        ch = request.connection.read(1)
+        ch = _read(request, 1)
         if ch == delim_char:
             break
         bytes.append(ch)
diff --git a/WebKitTools/pywebsocket/mod_pywebsocket/standalone.py b/WebKitTools/pywebsocket/mod_pywebsocket/standalone.py
index efc0e9d..6217585 100644
--- a/WebKitTools/pywebsocket/mod_pywebsocket/standalone.py
+++ b/WebKitTools/pywebsocket/mod_pywebsocket/standalone.py
@@ -113,6 +113,14 @@ class _StandaloneConnection(object):
                 self._request_handler.server.server_port)
     local_addr = property(get_local_addr)
 
+    def get_remote_addr(self):
+        """Getter to mimic mp_conn.remote_addr.
+
+        Setting the property in __init__ won't work because the request
+        handler is not initialized yet there."""
+        return self._request_handler.client_address
+    remote_addr = property(get_remote_addr)
+
     def write(self, data):
         """Mimic mp_conn.write()."""
         return self._request_handler.wfile.write(data)
@@ -227,6 +235,10 @@ class WebSocketRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
             except dispatch.DispatchError, e:
                 logging.warning('mod_pywebsocket: %s' % e)
                 return False
+            except Exception, e:
+                logging.warning('mod_pywebsocket: %s' % e)
+                logging.info('mod_pywebsocket: %s' % util.get_stack_trace())
+                return False
         return result
 
     def log_request(self, code='-', size='-'):
diff --git a/WebKitTools/pywebsocket/mod_pywebsocket/util.py b/WebKitTools/pywebsocket/mod_pywebsocket/util.py
index 4835298..0ea8053 100644
--- a/WebKitTools/pywebsocket/mod_pywebsocket/util.py
+++ b/WebKitTools/pywebsocket/mod_pywebsocket/util.py
@@ -49,4 +49,11 @@ def get_stack_trace():
     return out.getvalue()
 
 
+def prepend_message_to_exception(message, exc):
+    """Prepend message to the exception."""
+
+    exc.args = (message + str(exc),)
+    return
+
+
 # vi:sts=4 sw=4 et
diff --git a/WebKitTools/pywebsocket/setup.py b/WebKitTools/pywebsocket/setup.py
index fcdf238..df05fef 100644
--- a/WebKitTools/pywebsocket/setup.py
+++ b/WebKitTools/pywebsocket/setup.py
@@ -56,7 +56,7 @@ setup(author='Yuzo Fujishima',
       name=_PACKAGE_NAME,
       packages=[_PACKAGE_NAME],
       url='http://code.google.com/p/pywebsocket/',
-      version='0.4.2.1',
+      version='0.4.3',
       )
 
 
diff --git a/WebKitTools/pywebsocket/test/test_dispatch.py b/WebKitTools/pywebsocket/test/test_dispatch.py
index d31d6bd..b19d706 100644
--- a/WebKitTools/pywebsocket/test/test_dispatch.py
+++ b/WebKitTools/pywebsocket/test/test_dispatch.py
@@ -136,8 +136,7 @@ class DispatcherTest(unittest.TestCase):
         dispatcher.do_extra_handshake(request)  # Must not raise exception.
 
         request.ws_origin = 'http://bad.example.com'
-        self.assertRaises(dispatch.DispatchError,
-                          dispatcher.do_extra_handshake, request)
+        self.assertRaises(Exception, dispatcher.do_extra_handshake, request)
 
     def test_transfer_data(self):
         dispatcher = dispatch.Dispatcher(_TEST_HANDLERS_DIR, None)
@@ -193,10 +192,8 @@ class DispatcherTest(unittest.TestCase):
         try:
             dispatcher.transfer_data(request)
             self.fail()
-        except dispatch.DispatchError, e:
+        except Exception, e:
             self.failUnless(str(e).find('Intentional') != -1)
-        except Exception:
-            self.fail()
 
     def test_scan_dir(self):
         disp = dispatch.Dispatcher(_TEST_HANDLERS_DIR, None)
diff --git a/WebKitTools/pywebsocket/test/test_util.py b/WebKitTools/pywebsocket/test/test_util.py
index 8058b6d..83e2635 100644
--- a/WebKitTools/pywebsocket/test/test_util.py
+++ b/WebKitTools/pywebsocket/test/test_util.py
@@ -49,6 +49,12 @@ class UtilTest(unittest.TestCase):
             self.failUnless(trace.startswith('Traceback'))
             self.failUnless(trace.find('ZeroDivisionError') != -1)
 
+    def test_prepend_message_to_exception(self):
+        exc = Exception('World')
+        self.assertEqual('World', str(exc))
+        util.prepend_message_to_exception('Hello ', exc)
+        self.assertEqual('Hello World', str(exc))
+
 
 if __name__ == '__main__':
     unittest.main()

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list