clean the code

This commit is contained in:
benoitc 2010-03-01 08:57:46 +01:00
parent 49c02c8c4c
commit 6deeeecc80
4 changed files with 6 additions and 26 deletions

View File

@ -3,11 +3,9 @@
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
import ctypes
import logging import logging
import os import os
import re import re
import socket
import StringIO import StringIO
import sys import sys
from urllib import unquote from urllib import unquote

View File

@ -15,7 +15,7 @@ import os
import StringIO import StringIO
import tempfile import tempfile
from gunicorn.util import MAX_BODY, CHUNK_SIZE, read_partial, fsize, fwrite from gunicorn.util import MAX_BODY, CHUNK_SIZE, read_partial
class TeeInput(object): class TeeInput(object):
@ -154,7 +154,10 @@ class TeeInput(object):
self._is_socket = False self._is_socket = False
def _tmp_size(self): def _tmp_size(self):
return fsize(self.tmp) if isinstance(self.tmp, StringIO.StringIO):
return self.tmp.len
else:
return int(os.fstat(self.tmp.fileno())[6])
def _ensure_length(self, buf, length): def _ensure_length(self, buf, length):
if not buf or not self._len: if not buf or not self._len:

View File

@ -17,8 +17,7 @@ from django.core.handlers.wsgi import WSGIHandler
from gunicorn.arbiter import Arbiter from gunicorn.arbiter import Arbiter
from gunicorn.config import Config from gunicorn.config import Config
from gunicorn.main import daemonize, UMASK, configure_logging from gunicorn.main import daemonize, configure_logging
from gunicorn.util import parse_address, to_bytestring
class Command(BaseCommand): class Command(BaseCommand):
option_list = BaseCommand.option_list + ( option_list = BaseCommand.option_list + (

View File

@ -5,13 +5,10 @@
import array import array
import ctypes import ctypes
import errno
import fcntl import fcntl
import os import os
import resource import resource
import select
import socket import socket
import StringIO
import textwrap import textwrap
import time import time
@ -149,23 +146,6 @@ def write_error(sock, msg):
""") % (len(html), html) """) % (len(html), html)
write_nonblock(sock, http) write_nonblock(sock, http)
def fwrite(f, data):
pos = f.tell()
f.seek(fsize(f))
f.write(data)
f.flush()
if hasattr(f, 'fileno'):
os.fsync(f.fileno())
f.seek(0, os.SEEK_END)
f.seek(pos)
def fsize(f):
if isinstance(f, StringIO.StringIO):
return f.len
else:
return int(os.fstat(f.fileno())[6])
def normalize_name(name): def normalize_name(name):
return "-".join([w.lower().capitalize() for w in name.split("-")]) return "-".join([w.lower().capitalize() for w in name.split("-")])