wsgi: pep8 whitespace
This commit is contained in:
@@ -31,6 +31,7 @@ _monthname = [None, # Dummy so we can use 1-based month numbers
|
|||||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
||||||
|
|
||||||
|
|
||||||
def format_date_time(timestamp):
|
def format_date_time(timestamp):
|
||||||
"""Formats a unix timestamp into an HTTP standard string."""
|
"""Formats a unix timestamp into an HTTP standard string."""
|
||||||
year, month, day, hh, mm, ss, wd, _y, _z = time.gmtime(timestamp)
|
year, month, day, hh, mm, ss, wd, _y, _z = time.gmtime(timestamp)
|
||||||
@@ -38,11 +39,13 @@ def format_date_time(timestamp):
|
|||||||
_weekdayname[wd], day, _monthname[month], year, hh, mm, ss
|
_weekdayname[wd], day, _monthname[month], year, hh, mm, ss
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Collections of error codes to compare against. Not all attributes are set
|
# Collections of error codes to compare against. Not all attributes are set
|
||||||
# on errno module on all platforms, so some are literals :(
|
# on errno module on all platforms, so some are literals :(
|
||||||
BAD_SOCK = set((errno.EBADF, 10053))
|
BAD_SOCK = set((errno.EBADF, 10053))
|
||||||
BROKEN_SOCK = set((errno.EPIPE, errno.ECONNRESET))
|
BROKEN_SOCK = set((errno.EPIPE, errno.ECONNRESET))
|
||||||
|
|
||||||
|
|
||||||
# special flag return value for apps
|
# special flag return value for apps
|
||||||
class _AlreadyHandled(object):
|
class _AlreadyHandled(object):
|
||||||
|
|
||||||
@@ -54,7 +57,9 @@ class _AlreadyHandled(object):
|
|||||||
|
|
||||||
ALREADY_HANDLED = _AlreadyHandled()
|
ALREADY_HANDLED = _AlreadyHandled()
|
||||||
|
|
||||||
|
|
||||||
class Input(object):
|
class Input(object):
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
rfile,
|
rfile,
|
||||||
content_length,
|
content_length,
|
||||||
@@ -519,8 +524,8 @@ class HttpProtocol(BaseHTTPServer.BaseHTTPRequestHandler):
|
|||||||
self.connection.close()
|
self.connection.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Server(BaseHTTPServer.HTTPServer):
|
class Server(BaseHTTPServer.HTTPServer):
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
socket,
|
socket,
|
||||||
address,
|
address,
|
||||||
@@ -593,6 +598,7 @@ class Server(BaseHTTPServer.HTTPServer):
|
|||||||
def log_message(self, message):
|
def log_message(self, message):
|
||||||
self.log.write(message + '\n')
|
self.log.write(message + '\n')
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import ssl
|
import ssl
|
||||||
ACCEPT_EXCEPTIONS = (socket.error, ssl.SSLError)
|
ACCEPT_EXCEPTIONS = (socket.error, ssl.SSLError)
|
||||||
@@ -602,6 +608,7 @@ except ImportError:
|
|||||||
ACCEPT_EXCEPTIONS = (socket.error,)
|
ACCEPT_EXCEPTIONS = (socket.error,)
|
||||||
ACCEPT_ERRNO = set((errno.EPIPE, errno.EBADF, errno.ECONNRESET))
|
ACCEPT_ERRNO = set((errno.EPIPE, errno.EBADF, errno.ECONNRESET))
|
||||||
|
|
||||||
|
|
||||||
def server(sock, site,
|
def server(sock, site,
|
||||||
log=None,
|
log=None,
|
||||||
environ=None,
|
environ=None,
|
||||||
@@ -617,7 +624,7 @@ def server(sock, site,
|
|||||||
log_format=DEFAULT_LOG_FORMAT,
|
log_format=DEFAULT_LOG_FORMAT,
|
||||||
url_length_limit=MAX_REQUEST_LINE,
|
url_length_limit=MAX_REQUEST_LINE,
|
||||||
debug=True):
|
debug=True):
|
||||||
""" Start up a wsgi server handling requests from the supplied server
|
"""Start up a WSGI server handling requests from the supplied server
|
||||||
socket. This function loops forever. The *sock* object will be closed after server exits,
|
socket. This function loops forever. The *sock* object will be closed after server exits,
|
||||||
but the underlying file descriptor will remain open, so if you have a dup() of *sock*,
|
but the underlying file descriptor will remain open, so if you have a dup() of *sock*,
|
||||||
it will remain usable.
|
it will remain usable.
|
||||||
|
Reference in New Issue
Block a user