Ticket #6385: colorize.diff
File colorize.diff, 2.1 KB (added by , 17 years ago) |
---|
-
django/core/servers/basehttp.py
6 6 This is a simple server for use in testing or debugging Django apps. It hasn't 7 7 been reviewed for security issues. Don't use it for production use. 8 8 """ 9 9 from django.core.management.color import color_style 10 10 from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer 11 11 import mimetypes 12 12 import os … … 443 443 444 444 def close(self): 445 445 try: 446 self.request_handler.log_request(self.status.split(' ',1)[0], self.bytes_sent) 446 style = color_style() 447 status_code = self.status.split(' ',1)[0] 448 if status_code.startswith('2'): 449 status_code = style.SUCCESS(status_code) 450 elif status_code.startswith('3'): 451 status_code = style.REDIRECT(status_code) 452 elif status_code.startswith('4'): 453 status_code = style.CLIENT_ERROR(status_code) 454 elif status_code.startswith('5'): 455 status_code = style.SERVER_ERROR(status_code) 456 self.request_handler.log_request(status_code, self.bytes_sent) 447 457 finally: 448 458 try: 449 459 if hasattr(self.result,'close'): -
django/core/management/color.py
20 20 style.SQL_COLTYPE = termcolors.make_style(fg='green') 21 21 style.SQL_KEYWORD = termcolors.make_style(fg='yellow') 22 22 style.SQL_TABLE = termcolors.make_style(opts=('bold',)) 23 # HTTP STATUS CODES 24 style.SUCCESS = termcolors.make_style(fg='green', opts=('bold',)) # 2xx 25 style.REDIRECT = termcolors.make_style(fg='blue', opts=('bold',)) # 3xx 26 style.CLIENT_ERROR = termcolors.make_style(fg='yellow', opts=('bold',)) # 4xx 27 style.SERVER_ERROR = termcolors.make_style(fg='red', opts=('bold',)) # 5xx 23 28 return style 24 29 25 30 def no_style():