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
# install requirements from github | |
pip install git+ssh://git@github.com:dcramer/sentry.git@2.0#egg=raven==2.0.0-DEV | |
pip install git+ssh://git@github.com:dcramer/raven.git@2.0#egg=sentry==2.0.0-DEV | |
# start sentry webserver | |
sentry start | |
# add raven to whatever app | |
# e.g. Django: | |
INSTALLED_APPS = ( |
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
# create a dummy heroku app | |
heroku create --stack cedar | |
# add sentry | |
heroku addons:add sentry | |
# fetch your config | |
heroku config | grep SENTRY_DSN | |
# configure your application via http://getsentry.com/guide/ |
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
def ManagerMock(manager, return_value=None): | |
""" | |
>>> objects = ManagerMock(Post.objects, ['queryset', 'result']) | |
>>> assert objects.filter() == objects.all() | |
""" | |
return_value = return_value or [] | |
class ManagerMock(mock.MagicMock): | |
def _get_child_mock(self, **kwargs): |
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
Getting Play to work: | |
- Change Gemfile.lock's version of mocha to be 0.11.1 | |
- Open iTunes -> select iTunes DJ -> Start playing a song | |
Some caveats: | |
- iTunes Match songs (that are not on disk) won't queue | |
- Frontend seems sluggish, but it could be the machine it's on (not super powerful, but should be able to keep up) |
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
class Lock(object): | |
""" | |
Uses the defined cache backend to create a lock. | |
>>> with Lock('key name'): | |
>>> # do something | |
""" | |
def __init__(self, lock_key, timeout=10, cache=None): | |
if cache is None: | |
self.cache = _cache |
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
with cache.Lock('key name'[, timeout]): | |
# do something that usually has a race thats too hard to solve | |
# best example | |
def get_or_create(model, **kwargs): | |
with cache.Lock('get_or_create:%s:%s' % (model, make_key(kwargs)): | |
model.objects.get_or_create(**kwargs) |
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
""" | |
raven.contrib.django.views | |
~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details. | |
:license: BSD, see LICENSE for more details. | |
""" | |
import itertools | |
from django.conf import settings |
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
django-debug-toolbar==0.9.4 | |
django-data-tools==0.1 | |
django-devserver==0.3 | |
nashvegas==0.8-disqus-6 | |
Sphinx>=1.0.7 | |
piplint==0.1.1 | |
amqplib==1.0.2 | |
anyjson==0.3.1 | |
argparse==1.1 |
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
#1: Connection method | |
with connections['default'].sscursor(): | |
Foo.objects.all() | |
^^ this sucks because we make assumptions about where Foo routes | |
#2: QuerySet method | |
Foo.objects.all().sscursor() |
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
@mock.patch('modeldict.base.time') | |
def test_switch_creation(self, time_mod): | |
self.mydict['hello'] = 'foo' | |
self.assertEquals(self.cache.set.call_count, 2) | |
time_mod.time.return_value = 1344893511 | |
print time_mod.mock_calls | |
print self.cache.set.mock_calls | |
self.cache.set.assert_any_call(self.mydict.cache_key, {u'hello': u'foo'}) | |
self.cache.set.assert_any_call(self.mydict.last_updated_cache_key, time_mod.time.return_value) |