PKH4HDUddstatus/__init__.pyc Vc@s4dZdZdZdZdZdZdZdZdS( s Django Status application. s1.0.5tGPLv3sJosé Antonio Perdiguero Lópezsperdy.hh@gmail.coms&https://github.com/PeRDy/django-statuss`Application that provides an API to check the status of some parts and some utilities like ping.sstatus.apps.StatusN(t__doc__t __version__t __license__t __author__t __email__t__url__t__description__tdefault_app_config(((s8/home/perdy/Development/django-status/status/__init__.pytsPKG4Hustatus/__init__.py# -*- coding: utf-8 -*- """ Django Status application. """ __version__ = '1.0.5' __license__ = 'GPLv3' __author__ = 'José Antonio Perdiguero López' __email__ = 'perdy.hh@gmail.com' __url__ = 'https://github.com/PeRDy/django-status' __description__ = 'Application that provides an API to check the status of some parts and some utilities like ping.' default_app_config = 'status.apps.Status' PKKOGS~Ep p status/check_providers.py# -*- coding: utf-8 -*- """ Built-in check providers. """ import datetime from django.db import connections, OperationalError from django.core.cache import caches as django_caches, InvalidCacheBackendError from status.settings import CACHES from status.utils import FakeChecker try: from celery.task import control celery_inspect = control.inspect() except ImportError: celery_inspect = FakeChecker() def ping(*args, **kwargs): """Check if current application is running. :return: Pong response. """ return {'pong': True} def celery(workers, *args, **kwargs): """Check if given celery workers are running. :param workers: List of workers to be checked. :return: Status of each worker. """ try: ping_response = celery_inspect.ping() or {} active_workers = ping_response.keys() workers_status = {w: w in active_workers for w in workers} except AttributeError: workers_status = None return workers_status def celery_stats(workers, *args, **kwargs): """Retrieve the stats data of given celery workers. :param workers: List of workers. :return: Stats data of each worker. """ try: active_workers = celery_inspect.stats() or {} workers_stats = {k: v for k, v in active_workers.items() if k in workers} except AttributeError: workers_stats = None return workers_stats def databases(*args, **kwargs): """Check database status. :return: Status of each database. """ status = {} for connection in connections.all(): try: connection.connect() status[connection.alias] = connection.is_usable() except OperationalError: status[connection.alias] = False return status def databases_stats(*args, **kwargs): """Retrieve the stats data of each database. :return: Stats data of each database. """ stats = {} for connection in connections.all(): try: connection.connect() except OperationalError: is_usable = False else: is_usable = connection.is_usable() finally: stats[connection.alias] = { 'vendor': connection.vendor, 'is_usable': is_usable, 'allow_thread_sharing': connection.allow_thread_sharing, 'autocommit': connection.autocommit, 'commit_on_exit': connection.commit_on_exit, 'in_atomic_block': connection.in_atomic_block, 'settings': {k: v for k, v in connection.settings_dict.items() if k not in ('USER', 'PASSWORD')} } return stats def caches(*args, **kwargs): """Check caches status. :return: Status of each cache. """ caches_aliases = CACHES.keys() value = datetime.datetime.now().strftime('%d/%m/%Y %H:%M:%S') status = {} for alias in caches_aliases: try: cache = django_caches[alias] cache.set('django_status_test_cache', value) status[alias] = True except InvalidCacheBackendError: status[alias] = False return status PKQlNGO'status/urls.py# -*- coding: utf-8 -*- """ URLs. """ from django.conf.urls import patterns, url from status.views import ProviderAPIView from status import settings urlpatterns = patterns('') providers = [url(r'^api/{}/?$'.format(a), ProviderAPIView.as_view(provider=p, provider_args=args, provider_kwargs=kwargs), name='api_{}'.format(a)) for a, p, args, kwargs in settings.CHECK_PROVIDERS] urlpatterns += providers PKcHGg(status/apps.py# -*- coding: utf-8 -*- """Django application config module. """ from django.apps import AppConfig from django.utils.translation import ugettext_lazy as _ class Status(AppConfig): name = 'status' verbose_name = _('Status') PK-lNG'ފstatus/settings.py# -*- coding: utf-8 -*- """ Settings. """ try: from django.conf import settings INSTALLED_APPS = settings.INSTALLED_APPS CACHES = settings.CACHES except (ImportError, AttributeError): settings = None INSTALLED_APPS = () CACHES = {} # Celery application CELERY_WORKERS = getattr(settings, 'STATUS_CELERY_WORKERS', ()) # Tuple of application name, provider, args, kwargs CHECK_PROVIDERS = ( ('ping', 'status.check_providers.ping', None, None), ('databases', 'status.check_providers.databases', None, None), ('databases/stats', 'status.check_providers.databases_stats', None, None), ('caches', 'status.check_providers.caches', None, None), ) if CELERY_WORKERS: CHECK_PROVIDERS += ( ('celery', 'status.check_providers.celery', None, {'workers': CELERY_WORKERS}), ('celery/stats', 'status.check_providers.celery_stats', None, {'workers': CELERY_WORKERS}), ) CHECK_PROVIDERS += getattr(settings, 'STATUS_CHECK_PROVIDERS', ()) PKNVNG}status/utils.py# -*- coding: utf-8 -*- """ Utils. """ class FakeChecker(object): def __getattribute__(self, item): return lambda *args, **kwargs: None PKuHGN&U]]status/views/__init__.py# -*- coding: utf-8 -*- """ Views for status application. """ from status.views.api import * PK*oNGF F status/views/api.py# -*- coding: utf-8 -*- """ Views for status API. """ import importlib from django.http import JsonResponse from django.utils.decorators import classonlymethod from django.views.generic import View from django.views.generic.base import ContextMixin __all__ = ['ProviderAPIView'] class JSONResponseMixin(object): """ A mixin that can be used to render a JSON response. """ def render_to_json_response(self, context, **response_kwargs): """ Returns a JSON response, transforming 'context' to make the payload. """ return JsonResponse( self.get_data(context), **response_kwargs ) def get_data(self, context): """ Returns an object that will be serialized as JSON by json.dumps(). """ return context or {} class JSONView(JSONResponseMixin, View): """ View that returns a JSON response. """ def render_to_response(self, context, **response_kwargs): return self.render_to_json_response(context, **response_kwargs) class APIView(JSONView, ContextMixin): """ Base class for API views. """ def get(self, request, *args, **kwargs): context = self.get_context_data(**kwargs) return self.render_to_response(context) def post(self, request, *args, **kwargs): return self.get(request, *args, **kwargs) def put(self, request, *args, **kwargs): return self.get(request, *args, **kwargs) def delete(self, request, *args, **kwargs): return self.get(request, *args, **kwargs) class ProviderAPIView(APIView): """ Specific class that uses a given provider. """ provider = None provider_args = None provider_kwargs = None def __init__(self, provider, provider_args, provider_kwargs, **kwargs): if isinstance(provider, str): provider_module, provider_func = provider.rsplit('.', 1) module = importlib.import_module(provider_module) self.provider = getattr(module, provider_func, None) else: self.provider = provider self.provider_args = provider_args or () self.provider_kwargs = provider_kwargs or {} super(ProviderAPIView, self).__init__(**kwargs) def get_context_data(self): return self.provider(*self.provider_args, **self.provider_kwargs) PK^G$u00*status/__pycache__/__init__.cpython-34.pyc .nV@s4dZdZdZdZdZdZdZdZdS) z Django Status application. z1.0.4ZGPLv3uJosé Antonio Perdiguero Lópezzperdy.hh@gmail.comz&https://github.com/PeRDy/django-statusz`Application that provides an API to check the status of some parts and some utilities like ping.zstatus.apps.StatusN)__doc__ __version__ __license__ __author__ __email____url____description__Zdefault_app_configrr8/home/perdy/Development/django-status/status/__init__.pysPK4H. Download-URL: https://github.com/PeRDy/django-status Description: ============= Django Status ============= :Version: 1.0.3 :Status: Production/Stable :Author: José Antonio Perdiguero López Django Status is a application for Django projects that provides an API to check the status of some parts and some utilities like ping requests. Quick start =========== #. Install this package using pip:: pip install django-status #. Add *status* to your **INSTALLED_APPS** settings like this:: INSTALLED_APPS = ( ... 'status', ) #. Add **Django-status** urls to your project urls:: urlpatterns = [ ... url(r'^status/', include('status.urls')), ] Check Providers =============== Django Status provides a mechanism to add new custom check functions through **check providers**. Each check provider will generate a new API method with an URL that uses the name of the provider. These functions must accept \*args and \*\*kwargs and will return a JSON-serializable object through json.dumps() method, for example a ping function:: def ping(*args, **kwargs): return {'pong': True} By default **Django status** provides the follow checks: Ping A ping to application. URL: /api/ping Databases Check if databases are running. URL: /api/databases Databases stats Show stats for all databases. URL: /api/databases/stats Caches Check if caches are running. URL: /api/caches Celery Check if celery workers defined in settings are running. URL: /api/celery Celery stats Show celery worker stats. URL: /api/celery/stats Settings ======== STATUS_CHECK_PROVIDERS ---------------------- List of additional check providers. Each provider consists in a tuple of name, function complete path, args and kwargs. Example:: STATUS_CHECK_PROVIDERS = ( ('test', 'application.module.test_function', [1, 2], {'foo': 'bar'}), ) Default:: STATUS_CHECK_PROVIDERS = () STATUS_CELERY_WORKERS --------------------- List of hostname from celery workers to be checked. Default:: STATUS_CELERY_WORKERS = () Changes ======= v1.0.5 - 20/01/2016 * Fix setup.py problems with requirements file. v1.0.4 - 14/12/2015 * Fix setup.py problems with utf-8 files. v1.0.3 - 14/10/2015 * Fix checkers for celery and celery stats. Now displays if a worker isn't running. v1.0.2 - 14/10/2015 * Update README and meta info. v1.0.0 - 14/10/2015 * Database check. * Database stats. * Cache check. * Celery check. * Celery stats. * First stable version. v0.1.0 - 8/10/2015 * Initial release. Keywords: python,django,database,cache,celery,status,check Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Framework :: Django Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3) Classifier: Natural Language :: English Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 Classifier: Topic :: Software Development :: Libraries :: Python Modules PK4H ÒI+django_status-1.0.5.dist-info/metadata.json{"extensions": {"python.details": {"contacts": [{"email": "perdy.hh@gmail.com", "name": "Jos\u00e9 Antonio Perdiguero L\u00f3pez", "role": "author"}], "document_names": {"description": "DESCRIPTION.rst"}, "project_urls": {"Home": "https://github.com/PeRDy/django-status"}}}, "generator": "bdist_wheel (0.26.0)", "license": "Django Status is a application for Django projects that provides an API to check the status of some parts and some utilities like ping requests.", "metadata_version": "2.0", "name": "django-status", "summary": "Application that provides an API to check the status of some parts and some utilities like ping.", "test_requires": [{"requires": ["tox"]}], "version": "1.0.5"}PKHG&d//&django_status-1.0.5.dist-info/pbr.json{"is_release": false, "git_version": "8d70d60"}PK4HZ&+django_status-1.0.5.dist-info/top_level.txtstatus PK4Hndnn#django_status-1.0.5.dist-info/WHEELWheel-Version: 1.0 Generator: bdist_wheel (0.26.0) Root-Is-Purelib: true Tag: py2-none-any Tag: py3-none-any PK4H6p33&django_status-1.0.5.dist-info/METADATAMetadata-Version: 2.0 Name: django-status Version: 1.0.5 Summary: Application that provides an API to check the status of some parts and some utilities like ping. Home-page: https://github.com/PeRDy/django-status Author: José Antonio Perdiguero López Author-email: perdy.hh@gmail.com License: Django Status is a application for Django projects that provides an API to check the status of some parts and some utilities like ping requests. Copyright (C) 2015 Jose Antonio Perdiguero Lopez This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Download-URL: https://github.com/PeRDy/django-status Description: ============= Django Status ============= :Version: 1.0.3 :Status: Production/Stable :Author: José Antonio Perdiguero López Django Status is a application for Django projects that provides an API to check the status of some parts and some utilities like ping requests. Quick start =========== #. Install this package using pip:: pip install django-status #. Add *status* to your **INSTALLED_APPS** settings like this:: INSTALLED_APPS = ( ... 'status', ) #. Add **Django-status** urls to your project urls:: urlpatterns = [ ... url(r'^status/', include('status.urls')), ] Check Providers =============== Django Status provides a mechanism to add new custom check functions through **check providers**. Each check provider will generate a new API method with an URL that uses the name of the provider. These functions must accept \*args and \*\*kwargs and will return a JSON-serializable object through json.dumps() method, for example a ping function:: def ping(*args, **kwargs): return {'pong': True} By default **Django status** provides the follow checks: Ping A ping to application. URL: /api/ping Databases Check if databases are running. URL: /api/databases Databases stats Show stats for all databases. URL: /api/databases/stats Caches Check if caches are running. URL: /api/caches Celery Check if celery workers defined in settings are running. URL: /api/celery Celery stats Show celery worker stats. URL: /api/celery/stats Settings ======== STATUS_CHECK_PROVIDERS ---------------------- List of additional check providers. Each provider consists in a tuple of name, function complete path, args and kwargs. Example:: STATUS_CHECK_PROVIDERS = ( ('test', 'application.module.test_function', [1, 2], {'foo': 'bar'}), ) Default:: STATUS_CHECK_PROVIDERS = () STATUS_CELERY_WORKERS --------------------- List of hostname from celery workers to be checked. Default:: STATUS_CELERY_WORKERS = () Changes ======= v1.0.5 - 20/01/2016 * Fix setup.py problems with requirements file. v1.0.4 - 14/12/2015 * Fix setup.py problems with utf-8 files. v1.0.3 - 14/10/2015 * Fix checkers for celery and celery stats. Now displays if a worker isn't running. v1.0.2 - 14/10/2015 * Update README and meta info. v1.0.0 - 14/10/2015 * Database check. * Database stats. * Cache check. * Celery check. * Celery stats. * First stable version. v0.1.0 - 8/10/2015 * Initial release. Keywords: python,django,database,cache,celery,status,check Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Framework :: Django Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3) Classifier: Natural Language :: English Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 Classifier: Topic :: Software Development :: Libraries :: Python Modules PK4Hh zz$django_status-1.0.5.dist-info/RECORDdjango_status-1.0.5.dist-info/DESCRIPTION.rst,sha256=5sWEt1a29NeLBngCJOro_9S8G2LewxDuFlIVRqaLv98,4730 django_status-1.0.5.dist-info/METADATA,sha256=LrSJZurAT02sPN_FyLPh5ybD3d8FZYUeittFKO-yDS0,5171 django_status-1.0.5.dist-info/RECORD,, django_status-1.0.5.dist-info/WHEEL,sha256=GrqQvamwgBV4nLoJe0vhYRSWzWsx7xjlt74FT0SWYfE,110 django_status-1.0.5.dist-info/metadata.json,sha256=9L-Pa0VtaXzotA3iOLq_zaoCKO1coFh8WEuYq6yzs_c,695 django_status-1.0.5.dist-info/pbr.json,sha256=XVpetFPZmp9vHTLsiGiixHOwHHddtj4kK0eWGp9yfhM,47 django_status-1.0.5.dist-info/top_level.txt,sha256=QQ8NnND30wGpTtf-SG5gte4Af8pbf8HmvaPchHXnUlw,7 status/__init__.py,sha256=M0boX8WNe9hhmmjOEskNBe6I7PkY2yy0K4WWB40gyRQ,396 status/__init__.pyc,sha256=qQtVRH3f4A6Z0BJkjdse8-1OP122vEPGixNx3pEODdE,612 status/apps.py,sha256=--PoHb6jbchw8TUEIFcXar7CaOHbZ2HE2Dmg33DZCZY,234 status/check_providers.py,sha256=oQ4MLOdqHYPhHmSJV94idLFQHwFZxYA4Z5QRhp20Bbc,3184 status/settings.py,sha256=epHD2jinspcNd_yl5jW-MAAelVzWqWJyYGLRTdJVX2k,987 status/urls.py,sha256=mba3lJiWhxBJdOsSs9edTr09YCVDxuXJSSo_KbDSJ8w,453 status/utils.py,sha256=jcIE9OLlD9k4SWbKTG3DzqYDE0SodIXDdFYxo_ZeqPE,150 status/__pycache__/__init__.cpython-34.pyc,sha256=LU_1wR3br1rxsIv8yEqmvnmxe8DO7cgfI5UO2EES_Jo,560 status/views/__init__.py,sha256=eoZAaveXheCI3tzYzdCC37d08i754MJ49g9IG74s_rI,93 status/views/api.py,sha256=onLvo_SSPDbj3xHY_SZNUKjsBpCzhHQLcMBmVXo-Yj8,2374 PKH4HDUddstatus/__init__.pycPKG4Hustatus/__init__.pyPKKOGS~Ep p Qstatus/check_providers.pyPKQlNGO'status/urls.pyPKcHGg(status/apps.pyPK-lNG'ފstatus/settings.pyPKNVNG} status/utils.pyPKuHGN&U]]status/views/__init__.pyPK*oNGF F `status/views/api.pyPK^G$u00*"status/__pycache__/__init__.cpython-34.pycPK4H