Skip to content

Commit

Permalink
Merge branch 'python-package' of github.com:lincolnloop/cabot into li…
Browse files Browse the repository at this point in the history
…ncolnloop-python-package

Conflicts:
	cabot/cabotapp/tests/basic.py
	cabot/cabotapp/views.py
	cabot/urls.py
	requirements.txt
  • Loading branch information
dbuxton committed Aug 3, 2014
2 parents cab908b + 8cf51d5 commit 3872565
Show file tree
Hide file tree
Showing 149 changed files with 120 additions and 85 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ backups/*
static/CACHE/*
node_modules/*
.python-eggs/*
cabot.egg-info
cabot/static/CACHE
.env
.DS_Store
celerybeat-schedule.db
celerybeat-schedule
*.pyc
*.swp
*.orig
.vagrant
conf/*.env
conf/*.env
4 changes: 2 additions & 2 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
web: gunicorn wsgi:application --config gunicorn.conf
celery: celery worker -B -A app.cabotapp.tasks --loglevel=INFO --concurrency=16 -Ofair
web: gunicorn cabot.wsgi:application --config gunicorn.conf
celery: celery worker -B -A cabot --loglevel=INFO --concurrency=16 -Ofair
2 changes: 1 addition & 1 deletion Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
web: python manage.py runserver 0.0.0.0:$PORT
celery: celeryd --loglevel=DEBUG -B -c 8 -Ofair
celery: celery -A cabot worker --loglevel=DEBUG -B -c 8 -Ofair
2 changes: 0 additions & 2 deletions app/.gitignore

This file was deleted.

Empty file.
2 changes: 1 addition & 1 deletion bin/provision
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fi

npm install --no-color -g coffee-script less@1.3 --registry http://registry.npmjs.org/ # eco browserify

/home/vagrant/venv/bin/pip install --timeout=30 --exists-action=w -r /vagrant/requirements.txt --no-use-wheel
/home/vagrant/venv/bin/pip install --timeout=30 --exists-action=w -e /vagrant/ --no-use-wheel

# Start redis
sudo service redis-server restart
Expand Down
5 changes: 5 additions & 0 deletions cabot/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import absolute_import

# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/cabotapp/models.py → cabot/cabotapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.contrib.admin.models import User
from celery.exceptions import SoftTimeLimitExceeded

from jenkins import get_job_status
from .jenkins import get_job_status
from .alert import send_alert
from .calendar import get_events
from .graphite import parse_metric
Expand Down
5 changes: 0 additions & 5 deletions app/cabotapp/tasks.py → cabot/cabotapp/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
from django.conf import settings
from django.utils import timezone


# Add the root to the python path
root = os.path.abspath(os.path.join(settings.PROJECT_ROOT, '../'))
sys.path.append(root)

celery = Celery(__name__)
celery.config_from_object(settings)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions app/cabotapp/tests/basic.py → cabot/cabotapp/tests/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.test import TestCase
from django.contrib.auth.models import User
from django.test.client import Client
from cabotapp.models import (
from cabot.cabotapp.models import (
GraphiteStatusCheck, JenkinsStatusCheck,
HttpStatusCheck, ICMPStatusCheck, Service, Instance, StatusCheckResult)
from cabotapp.views import StatusCheckReportForm
Expand Down Expand Up @@ -166,7 +166,7 @@ def test_calculate_service_status(self):
self.service.update_status()
self.assertEqual(self.service.overall_status, Service.PASSING_STATUS)

@patch('cabotapp.graphite.requests.get', fake_graphite_response)
@patch('cabot.cabotapp.graphite.requests.get', fake_graphite_response)
def test_graphite_run(self):
checkresults = self.graphite_check.statuscheckresult_set.all()
self.assertEqual(len(checkresults), 2)
Expand All @@ -188,7 +188,7 @@ def test_graphite_run(self):
self.assertEqual(self.graphite_check.calculated_status,
Service.CALCULATED_PASSING_STATUS)

@patch('cabotapp.jenkins.requests.get', fake_jenkins_response)
@patch('cabot.cabotapp.jenkins.requests.get', fake_jenkins_response)
def test_jenkins_run(self):
checkresults = self.jenkins_check.statuscheckresult_set.all()
self.assertEqual(len(checkresults), 0)
Expand All @@ -197,7 +197,7 @@ def test_jenkins_run(self):
self.assertEqual(len(checkresults), 1)
self.assertFalse(self.jenkins_check.last_result().succeeded)

@patch('cabotapp.jenkins.requests.get', jenkins_blocked_response)
@patch('cabot.cabotapp.jenkins.requests.get', jenkins_blocked_response)
def test_jenkins_blocked_build(self):
checkresults = self.jenkins_check.statuscheckresult_set.all()
self.assertEqual(len(checkresults), 0)
Expand All @@ -206,7 +206,7 @@ def test_jenkins_blocked_build(self):
self.assertEqual(len(checkresults), 1)
self.assertFalse(self.jenkins_check.last_result().succeeded)

@patch('cabotapp.models.requests.get', throws_timeout)
@patch('cabot.cabotapp.models.requests.get', throws_timeout)
def test_timeout_handling_in_jenkins(self):
checkresults = self.jenkins_check.statuscheckresult_set.all()
self.assertEqual(len(checkresults), 0)
Expand All @@ -217,7 +217,7 @@ def test_timeout_handling_in_jenkins(self):
self.assertIn(u'Error fetching from Jenkins - фиктивная ошибка',
self.jenkins_check.last_result().error)

@patch('cabotapp.models.requests.get', fake_http_200_response)
@patch('cabot.cabotapp.models.requests.get', fake_http_200_response)
def test_http_run(self):
checkresults = self.http_check.statuscheckresult_set.all()
self.assertEqual(len(checkresults), 0)
Expand All @@ -241,7 +241,7 @@ def test_http_run(self):
self.assertEqual(self.http_check.calculated_status,
Service.CALCULATED_FAILING_STATUS)

@patch('cabotapp.models.requests.get', throws_timeout)
@patch('cabot.cabotapp.models.requests.get', throws_timeout)
def test_timeout_handling_in_http(self):
checkresults = self.http_check.statuscheckresult_set.all()
self.assertEqual(len(checkresults), 0)
Expand All @@ -252,7 +252,7 @@ def test_timeout_handling_in_http(self):
self.assertIn(u'Request error occurred: фиктивная ошибка innit',
self.http_check.last_result().error)

@patch('cabotapp.models.requests.get', fake_http_404_response)
@patch('cabot.cabotapp.models.requests.get', fake_http_404_response)
def test_http_run_bad_resp(self):
checkresults = self.http_check.statuscheckresult_set.all()
self.assertEqual(len(checkresults), 0)
Expand Down
File renamed without changes.
17 changes: 17 additions & 0 deletions cabot/celery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from __future__ import absolute_import

import os

from celery import Celery

from django.conf import settings

# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'cabot.settings')

app = Celery('cabot')

# Using a string here means the worker will not have to
# pickle the object when using Windows.
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
6 changes: 3 additions & 3 deletions app/celeryconfig.py → cabot/celeryconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datetime import timedelta

BROKER_URL = os.environ['CELERY_BROKER_URL']
CELERY_IMPORTS = ('app.cabotapp.tasks', )
CELERY_IMPORTS = ('cabot.cabotapp.tasks', )
CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler"
CELERY_TASK_SERIALIZER = "json"
CELERY_ACCEPT_CONTENT = ['json', 'msgpack', 'yaml']
Expand All @@ -11,11 +11,11 @@

CELERYBEAT_SCHEDULE = {
'run-all-checks': {
'task': 'app.cabotapp.tasks.run_all_checks',
'task': 'cabot.cabotapp.tasks.run_all_checks',
'schedule': timedelta(seconds=60),
},
'update-shifts': {
'task': 'app.cabotapp.tasks.update_shifts',
'task': 'cabot.cabotapp.tasks.update_shifts',
'schedule': timedelta(seconds=1800),
},
'clean-db': {
Expand Down
16 changes: 8 additions & 8 deletions app/settings.py → cabot/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import dj_database_url

settings_dir = os.path.dirname(__file__)
PROJECT_ROOT = os.path.abspath(os.path.dirname(settings_dir))
PROJECT_ROOT = os.path.abspath(settings_dir)

TEMPLATE_DEBUG = DEBUG = os.environ.get("DEBUG", False)

Expand Down Expand Up @@ -56,7 +56,7 @@
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in S