From e4e46d195fed215602b92b8acb41668d4bb319ca Mon Sep 17 00:00:00 2001 From: Eugene MechanisM Date: Thu, 29 Nov 2012 05:35:18 +0400 Subject: [PATCH] Update django/uwsgi_admin/views.py Convert tabs to spaces, fix messages. --- django/uwsgi_admin/views.py | 56 ++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/django/uwsgi_admin/views.py b/django/uwsgi_admin/views.py index 22c997966d..97bb5d4e82 100644 --- a/django/uwsgi_admin/views.py +++ b/django/uwsgi_admin/views.py @@ -6,37 +6,43 @@ from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect +from django.contrib import messages + def index(request): - workers = uwsgi.workers() - total_load = time.time() - uwsgi.started_on - for w in workers: - w['load'] = (100 * (w['running_time']/1000))/total_load - w['last_spawn_str'] = time.ctime(w['last_spawn']) + workers = uwsgi.workers() + total_load = time.time() - uwsgi.started_on + for w in workers: + w['load'] = (100 * (w['running_time']/1000))/total_load + w['last_spawn_str'] = time.ctime(w['last_spawn']) - jobs = [] + jobs = [] if 'spooler' in uwsgi.opt: - spooler_jobs = uwsgi.spooler_jobs() - for j in spooler_jobs: - jobs.append({'file': j, 'env': uwsgi.parsefile(j)}) - - return render_to_response('uwsgi.html', {'masterpid': uwsgi.masterpid(), - 'started_on': time.ctime(uwsgi.started_on), - 'buffer_size': uwsgi.buffer_size, - 'total_requests': uwsgi.total_requests(), - 'numproc': uwsgi.numproc, - 'workers': workers, - 'jobs': jobs, - }, RequestContext(request, {})) + spooler_jobs = uwsgi.spooler_jobs() + for j in spooler_jobs: + jobs.append({'file': j, 'env': uwsgi.parsefile(j)}) + + return render_to_response('uwsgi.html', {'masterpid': uwsgi.masterpid(), + 'started_on': time.ctime(uwsgi.started_on), + 'buffer_size': uwsgi.buffer_size, + 'total_requests': uwsgi.total_requests(), + 'numproc': uwsgi.numproc, + 'workers': workers, + 'jobs': jobs, + }, RequestContext(request, {})) index = staff_member_required(index) def reload(request): - if uwsgi.masterpid() > 0: - uwsgi.reload() - request.user.message_set.create(message="uWSGI reloaded") - else: - request.user.message_set.create(message="The uWSGI master process is not active") + if uwsgi.masterpid() > 0: + uwsgi.reload() + messages.add_message(request, messages.SUCCESS, + 'uWSGI reloaded', + fail_silently=True) + else: + messages.add_message(request, messages.ERROR, + 'The uWSGI master process is not active', + fail_silently=True) - return HttpResponseRedirect(reverse(index)) + return HttpResponseRedirect(reverse(index)) -reload = staff_member_required(reload) +reload = staff_member_required(reload) \ No newline at end of file