diff --git a/ping/checks.py b/ping/checks.py index 85e0f55..4d72f20 100644 --- a/ping/checks.py +++ b/ping/checks.py @@ -1,5 +1,6 @@ +from importlib import import_module + from django.conf import settings -from django.utils.importlib import import_module from django.core.exceptions import ImproperlyConfigured from ping.defaults import * @@ -11,7 +12,7 @@ def checks(request): for that check. """ response_dict = {} - + #Taken straight from Django #If there is a better way, I don't know it for path in getattr(settings, 'PING_CHECKS', PING_DEFAULT_CHECKS): @@ -25,7 +26,7 @@ def checks(request): func = getattr(mod, attr) except AttributeError: raise ImproperlyConfigured('Module "%s" does not define a "%s" callable' % (module, attr)) - + key, value = func(request) response_dict[key] = value @@ -33,7 +34,7 @@ def checks(request): #DEFAULT SYSTEM CHECKS -#Database +#Database def check_database_sessions(request): from django.contrib.sessions.models import Session try: @@ -55,7 +56,7 @@ def check_database_sites(request): CACHE_KEY = 'django-ping-test' CACHE_VALUE = 'abc123' -def check_cache_set(request): +def check_cache_set(request): from django.core.cache import cache try: cache.set(CACHE_KEY, CACHE_VALUE, 30) @@ -63,7 +64,7 @@ def check_cache_set(request): except: return 'cache_set', False -def check_cache_get(request): +def check_cache_get(request): from django.core.cache import cache try: data = cache.get(CACHE_KEY) @@ -76,7 +77,7 @@ def check_cache_get(request): #User -def check_user_exists(request): +def check_user_exists(request): from django.contrib.auth.models import User try: username = request.GET.get('username') @@ -95,7 +96,7 @@ def check_celery(request): now = time() datetimenow = datetime.now() expires = datetimenow + timedelta(seconds=getattr(settings, 'PING_CELERY_TIMEOUT', PING_CELERY_TIMEOUT)) - + try: task = sample_task.apply_async(expires=expires) while expires > datetime.now(): diff --git a/ping/urls.py b/ping/urls.py index 78d7c37..0ff7a2f 100644 --- a/ping/urls.py +++ b/ping/urls.py @@ -1,7 +1,6 @@ -from django.conf.urls.defaults import patterns, include, url +from django.conf.urls import patterns, include, url from ping.views import status urlpatterns = patterns('', url(r'^$', status, name='status'), ) - diff --git a/ping/views.py b/ping/views.py index 82cacd4..e462029 100644 --- a/ping/views.py +++ b/ping/views.py @@ -1,6 +1,7 @@ +import json + from django.http import HttpResponse from django.conf import settings -from django.utils import simplejson from django.contrib.auth.decorators import login_required from django.views.decorators.csrf import csrf_exempt @@ -14,10 +15,10 @@ def status(request): """ Returns a simple HttpResponse """ - + response = "