From f67993eb87fde21e4333aff52e033ebdb77a4cd2 Mon Sep 17 00:00:00 2001 From: benoitc Date: Tue, 21 Feb 2012 12:34:50 +0100 Subject: [PATCH] fix testing. Note: it was also a good way to test HUP on master. worked like a charm. --- .../testing/testing/apps/someapp/views.py | 23 +++++++++++-------- gunicorn/management/commands/run_gunicorn.py | 1 - 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/examples/frameworks/django/testing/testing/apps/someapp/views.py b/examples/frameworks/django/testing/testing/apps/someapp/views.py index 780cfdc28..9ad0046d3 100755 --- a/examples/frameworks/django/testing/testing/apps/someapp/views.py +++ b/examples/frameworks/django/testing/testing/apps/someapp/views.py @@ -12,7 +12,7 @@ class MsgForm(forms.Form): subject = forms.CharField(max_length=100) message = forms.CharField() f = forms.FileField() - + def home(request): from django.conf import settings @@ -28,32 +28,35 @@ def home(request): subject = form.cleaned_data['subject'] message = form.cleaned_data['message'] f = request.FILES['f'] - size = int(os.fstat(f.fileno())[6]) + if not hasattr(f, "fileno"): + size = len(f.read()) + else: + size = int(os.fstat(f.fileno())[6]) else: form = MsgForm() - - + + return render_to_response('home.html', { 'form': form, 'subject': subject, 'message': message, 'size': size }, RequestContext(request)) - - + + def acsv(request): rows = [ {'a': 1, 'b': 2}, {'a': 3, 'b': 3} ] - + response = HttpResponse(mimetype='text/csv') response['Content-Disposition'] = 'attachment; filename=report.csv' - + writer = csv.writer(response) writer.writerow(['a', 'b']) - + for r in rows: writer.writerow([r['a'], r['b']]) - + return response diff --git a/gunicorn/management/commands/run_gunicorn.py b/gunicorn/management/commands/run_gunicorn.py index d16f288d3..828716d65 100644 --- a/gunicorn/management/commands/run_gunicorn.py +++ b/gunicorn/management/commands/run_gunicorn.py @@ -70,5 +70,4 @@ def handle(self, addrport=None, *args, **options): options['default_proc_name'] = settings.SETTINGS_MODULE admin_media_path = options.pop('admin_media_path', '') - quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C' DjangoApplicationCommand(options, admin_media_path).run()