Changeset 51661 in webkit
- Timestamp:
- Dec 3, 2009 2:01:14 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r51656 r51661 1 2009-12-03 Yuzo Fujishima <yuzo@google.com> 2 3 Reviewed by Eric Seidel. 4 5 Update pywebsocket to 0.4.3 6 This version logs friendlier and higher-level messages in WARN level, which is used for LayoutTests. 7 Stack trace is logged now in INFO level. 8 https://bugs.webkit.org/show_bug.cgi?id=32097 9 10 * pywebsocket/mod_pywebsocket/dispatch.py: 11 * pywebsocket/mod_pywebsocket/msgutil.py: 12 * pywebsocket/mod_pywebsocket/standalone.py: 13 * pywebsocket/mod_pywebsocket/util.py: 14 * pywebsocket/setup.py: 15 * pywebsocket/test/test_dispatch.py: 16 * pywebsocket/test/test_util.py: 17 1 18 2009-12-03 Sam Weinig <sam@webkit.org> 2 19 -
trunk/WebKitTools/pywebsocket/mod_pywebsocket/dispatch.py
r51406 r51661 161 161 try: 162 162 do_extra_handshake_(request) 163 except Exception: 164 raise DispatchError('%s raised exception: %s' % 165 (_DO_EXTRA_HANDSHAKE_HANDLER_NAME, util.get_stack_trace())) 163 except Exception, e: 164 util.prepend_message_to_exception( 165 '%s raised exception for %s: ' % ( 166 _DO_EXTRA_HANDSHAKE_HANDLER_NAME, 167 request.ws_resource), 168 e) 169 raise 166 170 167 171 def transfer_data(self, request): … … 178 182 try: 179 183 transfer_data_(request) 180 except Exception: 181 raise DispatchError('%s raised exception: %s' % 182 (_TRANSFER_DATA_HANDLER_NAME, util.get_stack_trace())) 184 except Exception, e: 185 util.prepend_message_to_exception( 186 '%s raised exception for %s: ' % ( 187 _TRANSFER_DATA_HANDLER_NAME, request.ws_resource), 188 e) 189 raise 183 190 184 191 def _handler(self, request): -
trunk/WebKitTools/pywebsocket/mod_pywebsocket/msgutil.py
r51406 r51661 40 40 import Queue 41 41 import threading 42 import util 43 44 45 class MsgUtilException(Exception): 46 pass 47 48 49 def _read(request, length): 50 bytes = request.connection.read(length) 51 if not bytes: 52 raise MsgUtilException( 53 'Failed to receive message from %r' % 54 (request.connection.remote_addr,)) 55 return bytes 56 57 58 def _write(request, bytes): 59 try: 60 request.connection.write(bytes) 61 except Exception, e: 62 util.prepend_message_to_exception( 63 'Failed to send message to %r: ' % 64 (request.connection.remote_addr,), 65 e) 66 raise 42 67 43 68 … … 50 75 """ 51 76 52 request.connection.write('\x00' + message.encode('utf-8') + '\xff')77 _write(request, '\x00' + message.encode('utf-8') + '\xff') 53 78 54 79 … … 64 89 # mp_conn.read will block if no bytes are available. 65 90 # Timeout is controlled by TimeOut directive of Apache. 66 frame_type_str = request.connection.read(1)91 frame_type_str = _read(request, 1) 67 92 frame_type = ord(frame_type_str[0]) 68 93 if (frame_type & 0x80) == 0x80: … … 85 110 length = 0 86 111 while True: 87 b_str = request.connection.read(1)112 b_str = _read(request, 1) 88 113 b = ord(b_str[0]) 89 114 length = length * 128 + (b & 0x7f) … … 96 121 bytes = [] 97 122 while length > 0: 98 new_bytes = request.connection.read(length)123 new_bytes = _read(request, length) 99 124 bytes.append(new_bytes) 100 125 length -= len(new_bytes) … … 105 130 bytes = [] 106 131 while True: 107 ch = request.connection.read(1)132 ch = _read(request, 1) 108 133 if ch == delim_char: 109 134 break -
trunk/WebKitTools/pywebsocket/mod_pywebsocket/standalone.py
r51521 r51661 114 114 local_addr = property(get_local_addr) 115 115 116 def get_remote_addr(self): 117 """Getter to mimic mp_conn.remote_addr. 118 119 Setting the property in __init__ won't work because the request 120 handler is not initialized yet there.""" 121 return self._request_handler.client_address 122 remote_addr = property(get_remote_addr) 123 116 124 def write(self, data): 117 125 """Mimic mp_conn.write().""" … … 227 235 except dispatch.DispatchError, e: 228 236 logging.warning('mod_pywebsocket: %s' % e) 237 return False 238 except Exception, e: 239 logging.warning('mod_pywebsocket: %s' % e) 240 logging.info('mod_pywebsocket: %s' % util.get_stack_trace()) 229 241 return False 230 242 return result -
trunk/WebKitTools/pywebsocket/mod_pywebsocket/util.py
r49672 r51661 50 50 51 51 52 def prepend_message_to_exception(message, exc): 53 """Prepend message to the exception.""" 54 55 exc.args = (message + str(exc),) 56 return 57 58 52 59 # vi:sts=4 sw=4 et -
trunk/WebKitTools/pywebsocket/setup.py
r51521 r51661 57 57 packages=[_PACKAGE_NAME], 58 58 url='http://code.google.com/p/pywebsocket/', 59 version='0.4. 2.1',59 version='0.4.3', 60 60 ) 61 61 -
trunk/WebKitTools/pywebsocket/test/test_dispatch.py
r51406 r51661 137 137 138 138 request.ws_origin = 'http://bad.example.com' 139 self.assertRaises(dispatch.DispatchError, 140 dispatcher.do_extra_handshake, request) 139 self.assertRaises(Exception, dispatcher.do_extra_handshake, request) 141 140 142 141 def test_transfer_data(self): … … 194 193 dispatcher.transfer_data(request) 195 194 self.fail() 196 except dispatch.DispatchError, e:195 except Exception, e: 197 196 self.failUnless(str(e).find('Intentional') != -1) 198 except Exception:199 self.fail()200 197 201 198 def test_scan_dir(self): -
trunk/WebKitTools/pywebsocket/test/test_util.py
r49672 r51661 50 50 self.failUnless(trace.find('ZeroDivisionError') != -1) 51 51 52 def test_prepend_message_to_exception(self): 53 exc = Exception('World') 54 self.assertEqual('World', str(exc)) 55 util.prepend_message_to_exception('Hello ', exc) 56 self.assertEqual('Hello World', str(exc)) 57 52 58 53 59 if __name__ == '__main__':
Note: See TracChangeset
for help on using the changeset viewer.