-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from mwarkentin/settings_checkers
Allow custom checkers via the WATCHMAN_CHECKS setting
- Loading branch information
Showing
10 changed files
with
222 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,9 @@ Credits | |
Development Lead | ||
---------------- | ||
|
||
* Michael Warkentin <[email protected]> | ||
* Michael Warkentin <[email protected]> - https://github.com/mwarkentin | ||
|
||
Contributors | ||
------------ | ||
|
||
None yet. Why not be the first? | ||
* Keryn Knight - https://github.com/kezabelle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
watchman | ||
======== | ||
|
||
.. toctree:: | ||
:maxdepth: 4 | ||
|
||
watchman |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
watchman package | ||
================ | ||
|
||
Submodules | ||
---------- | ||
|
||
watchman.checks module | ||
---------------------- | ||
|
||
.. automodule:: watchman.checks | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
watchman.decorators module | ||
-------------------------- | ||
|
||
.. automodule:: watchman.decorators | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
watchman.models module | ||
---------------------- | ||
|
||
.. automodule:: watchman.models | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
watchman.settings module | ||
------------------------ | ||
|
||
.. automodule:: watchman.settings | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
watchman.urls module | ||
-------------------- | ||
|
||
.. automodule:: watchman.urls | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
watchman.utils module | ||
--------------------- | ||
|
||
.. automodule:: watchman.utils | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
watchman.views module | ||
--------------------- | ||
|
||
.. automodule:: watchman.views | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
|
||
Module contents | ||
--------------- | ||
|
||
.. automodule:: watchman | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
from django.conf import settings | ||
|
||
|
||
# TODO: these should not be module level. | ||
WATCHMAN_TOKEN = getattr(settings, 'WATCHMAN_TOKEN', None) | ||
WATCHMAN_TOKEN_NAME = getattr(settings, 'WATCHMAN_TOKEN_NAME', 'watchman-token') | ||
DEFAULT_CHECKS = ( | ||
'watchman.checks.caches_status', | ||
'watchman.checks.databases_status', | ||
) | ||
|
||
WATCHMAN_CHECKS = getattr(settings, 'WATCHMAN_CHECKS', DEFAULT_CHECKS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
try: # try for Django 1.7+ first. | ||
from django.utils.module_loading import import_string | ||
except ImportError: # < Django 1.7 | ||
try: | ||
from django.utils.module_loading import import_by_path as import_string | ||
except ImportError: # < Django 1.5.3 (including 1.4 LTS) | ||
import sys | ||
from django.utils import six | ||
from django.utils.importlib import import_module | ||
from django.core.exceptions import ImproperlyConfigured | ||
|
||
def import_string(dotted_path, error_prefix=''): | ||
try: | ||
module_path, class_name = dotted_path.rsplit('.', 1) | ||
except ValueError: | ||
raise ImproperlyConfigured("%s%s doesn't look like a module path" % ( | ||
error_prefix, dotted_path)) | ||
try: | ||
module = import_module(module_path) | ||
except ImportError as e: | ||
msg = '%sError importing module %s: "%s"' % ( | ||
error_prefix, module_path, e) | ||
six.reraise(ImproperlyConfigured, ImproperlyConfigured(msg), | ||
sys.exc_info()[2]) | ||
try: | ||
attr = getattr(module, class_name) | ||
except AttributeError: | ||
raise ImproperlyConfigured('%sModule "%s" does not define a "%s" attribute/class' % ( | ||
error_prefix, module_path, class_name)) | ||
return attr | ||
|
||
|
||
def get_checks(paths_to_checks): | ||
for python_path in paths_to_checks: | ||
yield import_string(python_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters