diff options
author | Will Kahn-Greene <willkg@mozilla.com> | 2013-04-25 10:58:30 -0400 |
---|---|---|
committer | James Socol <me@jamessocol.com> | 2013-04-25 10:58:30 -0400 |
commit | f28f6c988fc087388577cd5e8df28ca8d648c0e3 (patch) | |
tree | a236649bfda23104c2ff9425e36acaddd362d68d | |
parent | e81fb4dea2077f6e9e873d07db831bbf931df174 (diff) | |
download | pystatsd-f28f6c988fc087388577cd5e8df28ca8d648c0e3.tar.gz |
Fix #24, import with Django 1.5 on the PYTHONPATH.
Django >=1.5 raises a different exception than previous versions when it
is installed on the PYTHONPATH but is not actually configured. This
catches that exception.
-rw-r--r-- | statsd/__init__.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/statsd/__init__.py b/statsd/__init__.py index 325fd9d..1b690f7 100644 --- a/statsd/__init__.py +++ b/statsd/__init__.py @@ -4,6 +4,14 @@ import socket try: from django.conf import settings + from django.core.exceptions import ImproperlyConfigured + try: + # This handles the case where Django >=1.5 is in the python path + # but this particular project is not a django project. In + # that case, settings aren't configured. + getattr(settings, 'STATSD_HOST', 'localhost') + except ImproperlyConfigured: + settings = None except ImportError: settings = None |