Skip to content
Browse files

Update to latest versions of dependencies, better error messages, a b…

…it of doc and config cleanup.
  • Loading branch information...
1 parent c93ccd0 commit c37cc8b590b1e4c40bcb3ed9ef5c93078d4fdb5f @grigorescu committed
Showing with 47 additions and 36 deletions.
  1. +20 −14 Brownian/settings.py
  2. +5 −4 Brownian/urls.py
  3. +1 −1 Brownian/view/templates/home.html
  4. +1 −0 Brownian/view/utils/es.py
  5. +10 −7 Brownian/view/views.py
  6. +1 −1 Brownian/wsgi.py
  7. +0 −1 README.md
  8. +6 −5 requirements.txt
  9. +3 −3 setup.py
View
34 Brownian/settings.py
@@ -3,9 +3,11 @@
# How many results per page.
PAGE_SIZE=30
-# When running in an actual web server, edit this to the directory Brownian is being installed in.
-# e.g. https://server/Brownian -> DAJAXICE_MEDIA_PREFIX="Brownian/dajaxice"
-DAJAXICE_MEDIA_PREFIX="dajaxice"
+# Default time range. Options are: "15m", "1h", "4h", "12h", "1d", "2d", "7d", "all"
+DEFAULT_TIME_RANGE="1h"
+
+# URL base for static files - trailing slash, please:
+STATIC_URL = '/static/'
# ElasticSearch settings
@@ -37,7 +39,15 @@
TIME_ZONE = 'US/Eastern'
-# Django settings for Brownian project.
+# Database config
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ # The full path to your SQLite database *file*
+ 'NAME': '/Users/vladg/Projects/Brownian/Brownian_temp_data'
+ },
+ }
DEBUG = True
TEMPLATE_DEBUG = DEBUG
@@ -45,15 +55,12 @@
ADMINS = ( # ('Your Name', 'your_email@example.com'),
)
-MANAGERS = ADMINS
+# End of commonly modified settings
+#
+###################################
-DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.sqlite3',
- # The full path to your SQLite database *file*
- 'NAME': '/opt/Brownian/Brownian_temp_data'
- },
- }
+
+MANAGERS = ADMINS
SESSION_COOKIE_AGE = 300
@@ -67,12 +74,11 @@
MEDIA_URL = ''
STATIC_ROOT = ''
-# Trailing slash, please:
-STATIC_URL = '/static/'
STATICFILES_DIRS = ( )
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
+ 'dajaxice.finders.DajaxiceFinder',
)
SECRET_KEY = '62a=4)pj*u&*aj*1d4f+!tpq5uf@!82t2cx(pu7)_12=)afv6$'
View
9 Brownian/urls.py
@@ -1,9 +1,10 @@
from django.conf.urls import patterns, url, include
-from django.conf import settings
-from dajaxice.core import dajaxice_autodiscover
-dajaxice_autodiscover()
+from dajaxice.core import dajaxice_config
+from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns = patterns('',
- (r'^dajaxice/', include('dajaxice.urls')),
+ url(dajaxice_config.dajaxice_url, include('dajaxice.urls')),
url(r'^$', 'Brownian.view.views.query', name='query'),
)
+
+urlpatterns += staticfiles_urlpatterns()
View
2 Brownian/view/templates/home.html
@@ -25,7 +25,7 @@
</form>
</div>
{% if error %}
- <div class="alert">
+ <div class="alert alert-error">
<button class="close" data-dismiss="alert">×</button>
<strong>Error!</strong> {{ error }}
</div>
View
1 Brownian/view/utils/es.py
@@ -8,6 +8,7 @@
def getIndices():
"""Get a list of all bro indices
"""
+
result = Request(index="@bro-meta")._doRequest({"size": 65535})
indices = []
for hit in result["hits"]["hits"]:
View
17 Brownian/view/views.py
@@ -1,6 +1,6 @@
from django.shortcuts import render
import utils.es
-import requests
+from django.conf import settings
def query(request):
""" This page is the main query interface.
@@ -16,15 +16,17 @@ def query(request):
# If we have a blank time window, just return the past 15 minutes.
time = params.get("time", "")
- if time == "": time = "15m"
+ if time == "": time = settings.DEFAULT_TIME_RANGE
data["time"] = time
if request.session.get('indices', False):
indices = request.session.get('indices')
else:
try:
indices = utils.es.getIndices()
- except requests.ConnectionError:
- raise requests.ConnectionError("Could not connect to ElasticSearch server to fetch indices.")
+ except:
+ data["error"] = "Could not connect to server - please check ELASTICSEARCH_SERVER in settings.py"
+ indices = []
+ return render(request, "home.html", data)
request.session['indices'] = indices
result = utils.es.indicesFromTime(time, indices)
@@ -34,13 +36,14 @@ def query(request):
data["start"] = 0
if not selectedIndices:
- data["error"] = "No indices found in that time range."
+ data["error"] = "No indices found in that time range - please adjust your time range."
return render(request, "home.html", data)
try:
data["hits"] = utils.es.getCounts(utils.es.queryEscape(query), index=selectedIndices)
- except requests.ConnectionError:
- raise requests.ConnectionError("Could not connect to ElasticSearch server for query.")
+ except:
+ data["error"] = "Could not connect to ElasticSearch server for query - please check ElasticSearch cluster health."
+ return render(request, "home.html", data)
# To make the Javascript easier, we strip off the # from the currently open tab.
# If we don't have an open tab, default to conn.
View
2 Brownian/wsgi.py
@@ -7,7 +7,7 @@
import site, os
-site.addsitedir(BROWNIAN_PATH + '/lib/python' + PYTHON_VER + '/site-packages/Brownian/wsgi.py')
+site.addsitedir(BROWNIAN_PATH + '/lib/python' + PYTHON_VER + '/site-packages')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Brownian.settings")
View
1 README.md
@@ -71,7 +71,6 @@ Running the Production Server with Apache
1. Install mod_wsgi
+ Edit ```BROWNIAN_PATH``` at the top of Brownian/lib/python2.X/site-packages/Brownian/wsgi.py to the location of your virtualenv directory.
+ If you're not using Python 2.7, edit ```PYTHON_VER``` at the top of wsgi.py.
-+ If you're not installing Brownian to the server's root directory, edit ```DAJAXICE_MEDIA_PREFIX``` in settings.py.
+ If you'd like to have your static files somewhere other than ```/static```, change ```STATIC_URL``` in settings.py. Please make sure to leave a trailing slash.
+ In settings.py, modify the ```DATABASES``` setting to the path you'd like a small SQLite database created (your Apache user will need write permissions to both the file and the parent directory).
+ To create the database, in your virtualenv, run ```./bin/django-admin.py syncdb```.
View
11 requirements.txt
@@ -1,6 +1,7 @@
-Django==1.4
-django-dajax==0.8.4
-django-dajaxice==0.2
+Django==1.4.1
+django-dajax==0.9.1
+django-dajaxice==0.5
nose==1.1.2
-requests==0.13.1
-pytz==2012c
+pytz==2012d
+requests==0.13.6
+wsgiref==0.1.2
View
6 setup.py
@@ -1,9 +1,9 @@
from setuptools import setup
setup(
name = "Brownian",
- version = "0.4-r81",
+ version = "0.4-r83",
packages = ["Brownian", "Brownian.view", "Brownian.view.templatetags", "Brownian.view.utils"],
- install_requires = ["Django", "django-dajax", "django-dajaxice", "requests", "nose", "pytz"],
+ install_requires = ["Django==1.4.1", "django-dajax==0.9.1", "django-dajaxice==0.5", "requests==0.13.6", "nose", "pytz"],
package_data = {'Brownian.view':
['static/css/*.css',
'static/img/*.png',
@@ -15,4 +15,4 @@
include_package_data = True,
zip_safe = False,
test_suite = "Brownian.view.tests",
-)
+)

0 comments on commit c37cc8b

Please sign in to comment.
Something went wrong with that request. Please try again.