Changeset 2462
- Timestamp:
- 06/24/09 00:16:43
- Files:
-
- trunk/cherrypy/_cperror.py (modified) (1 diff)
- trunk/cherrypy/_cplogging.py (modified) (2 diffs)
- trunk/cherrypy/lib/caching.py (modified) (1 diff)
- trunk/cherrypy/test/benchmark.py (modified) (3 diffs)
- trunk/cherrypy/test/test_bus.py (modified) (1 diff)
- trunk/cherrypy/test/test_static.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cperror.py
r2460 r2462 118 118 307: "This resource has moved temporarily to <a href='%s'>%s</a>.", 119 119 }[status] 120 response.body = "<br />\n".join([msg % (u, u) for u in self.urls]) 120 msgs = [msg % (u, u) for u in self.urls] 121 response.body = "<br />\n".join(msgs) 121 122 # Previous code may have set C-L, so we have to reset it 122 123 # (allow finalize to set it). trunk/cherrypy/_cplogging.py
r2460 r2462 7 7 logfmt = logging.Formatter("%(message)s") 8 8 import os 9 import rfc82210 9 import sys 11 10 … … 112 111 """Return now() in Apache Common Log Format (no timezone).""" 113 112 now = datetime.datetime.now() 114 month = rfc822._monthnames[now.month - 1].capitalize() 113 monthnames = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 114 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'] 115 month = monthnames[now.month - 1].capitalize() 115 116 return ('[%02d/%s/%04d:%02d:%02d:%02d]' % 116 117 (now.day, month, now.year, now.hour, now.minute, now.second)) trunk/cherrypy/lib/caching.py
r2460 r2462 138 138 while time: 139 139 now = time.time() 140 # Must make a copy of expirations so it doesn't change size 141 # during iteration 140 142 for expiration_time, objects in self.expirations.items(): 141 143 if expiration_time <= now: trunk/cherrypy/test/benchmark.py
r2437 r2462 218 218 self.output = _cpmodpy.read_process(AB_PATH or "ab", self.args()) 219 219 except: 220 print (_cperror.format_exc())220 print _cperror.format_exc() 221 221 raise 222 222 … … 247 247 row = [c] 248 248 for attr in attrs: 249 val = getattr(sess, attr)249 val = float(getattr(sess, attr)) 250 250 avg[attr] += float(val) 251 251 row.append(val) … … 378 378 print("\nUsing null Request object") 379 379 try: 380 run_standard_benchmarks() 380 try: 381 run_standard_benchmarks() 382 except: 383 print _cperror.format_exc() 384 raise 381 385 finally: 382 386 cherrypy.engine.exit() trunk/cherrypy/test/test_bus.py
r2407 r2462 71 71 72 72 for channel in channels: 73 self.assertRaises( TypeError, b.publish, channel, 123)73 self.assertRaises(wspbus.ChannelFailures, b.publish, channel, 123) 74 74 expected.append(msg % (1, channel, 123)) 75 75 trunk/cherrypy/test/test_static.py
r2437 r2462 2 2 test.prefer_parent_path() 3 3 4 from httplib import HTTPConnection, HTTPSConnection 4 5 try: 5 6 import cStringIO as StringIO … … 33 34 34 35 def tell(self): 35 return repr(self.f.input.tell()) 36 if self.f.input.closed: 37 return '' 38 return repr(self.f.input.tell()).rstrip('L') 36 39 tell.exposed = True 37 40 … … 230 233 body = '' 231 234 remaining = BIGFILE_SIZE 232 # By this point, the webserver has already written one chunk to233 # the socket and queued another. So we start with i=1.234 i = 1235 235 while remaining > 0: 236 i += 1237 s, h, b = helper.webtest.openURL(238 "/tell", headers=[], host=self.HOST, port=self.PORT)239 if remaining != 65536:240 self.assertEqual(long(b), 65536 * i)241 236 data = response.fp.read(65536) 242 237 if not data: … … 244 239 body += data 245 240 remaining -= len(data) 241 242 if self.scheme == "https": 243 newconn = HTTPSConnection 244 else: 245 newconn = HTTPConnection 246 s, h, b = helper.webtest.openURL( 247 "/tell", headers=[], host=self.HOST, port=self.PORT, 248 http_conn=newconn) 249 if not b: 250 # The file was closed on the server. 251 tell_position = BIGFILE_SIZE 252 else: 253 tell_position = int(b) 254 255 expected = len(body) 256 if tell_position >= BIGFILE_SIZE: 257 # We can't exactly control how much content the server asks for. 258 # Fudge it by only checking the first half of the reads. 259 if expected < (BIGFILE_SIZE / 2): 260 self.fail( 261 "The file should have advanced to position %r, but has " 262 "already advanced to the end of the file. It may not be " 263 "streamed as intended, or at the wrong chunk size (64k)" % 264 expected) 265 elif tell_position < expected: 266 self.fail( 267 "The file should have advanced to position %r, but has " 268 "only advanced to position %r. It may not be streamed " 269 "as intended, or at the wrong chunk size (65536)" % 270 (expected, tell_position)) 246 271 247 272 if body != "x" * BIGFILE_SIZE:

