def _log_to_recent_project_actions(p, user_id, action_time, message): """Log actions that refer to projects to a queue of most recent actions. We use redis' list for that. We skip actions that refer to private projects. """ from transifex.projects.models import Project if p.private: return private_slugs = Project.objects.filter( private=True ).values_list('slug', flat=True) for slug in private_slugs: if ('/projects/p/%s/' % slug) in message: return key = 'event_feed' data = { 'name': force_unicode(p)[:200], 'user_id': user_id, 'action_time': action_time, 'message': message } try: r = TxRedisMapper() r.lpush(key, data=data) r.ltrim(key, 0, 11) except ConnectionError, e: logger.critical("Cannot connect to redis: %s" % e, exc_info=True) raise
def _log_to_queues(o, user_id, action_time, message): """Log actions to redis' queues.""" from transifex.projects.models import Project try: if isinstance(o, Project): _log_to_recent_project_actions(o, user_id, action_time, message) except ConnectionError, e: logger.critical("Cannot connect to redis: %s" % e, exc_info=True) return
def setUp(self): logger.critical("This will delete everything in db=1 i n redis.") self.r = TxRedisMapper(db=1)
def wrapper(*args, **kwargs): try: return func(*args, **kwargs) except ConnectionError, e: logger.critical("Cannot connect to redis: %s" % e, exc_info=True)