Пример #1
0
def update_video_feed(video_feed_id):
    try:
        video_feed = VideoFeed.objects.get(pk=video_feed_id)
        video_feed.update()
    except VideoFeed:
        msg = '**update_video_feed**. VideoFeed does not exist. ID: %s' % video_feed_id
        client.create_from_text(msg, logger='celery')
Пример #2
0
def send_new_message_notification(message_id):
    try:
        message = Message.objects.get(pk=message_id)
    except Message.DoesNotExist:
        msg = '**send_new_message_notification**. Message does not exist. ID: %s' % message_id
        client.create_from_text(msg, logger='celery')
        return
    
    user = message.user
    
    if not user.email or not user.is_active or not user.changes_notification:
        return

    to = "%s <%s>" % (user, user.email)
    
    subject = _(u"%(author)s sent you a message on Universal Subtitles: %(subject)s")
    subject = subject % {
        'author': message.author, 
        'subject': message.subject
    }
        
    context = {
        "message": message,
        "domain":  Site.objects.get_current().domain
    }

    send_templated_email(to, subject, "messages/email/message_received.html", context)
Пример #3
0
def js_error_handler(request, *args, **kwargs):

    message = request.POST.get('message', None)
    url = request.POST.get('url', None)

    client.create_from_text(message, level=logging.ERROR, url=url, request=request)
    return HttpResponse('true')
Пример #4
0
def sentry_js_exception(request, stackInfo, url):
    """
    Logs an exception in Sentry. POST the following JSON structure:
        {
            "url": "http://example.com/foo/bar",
            "stackInfo": stack // a JSONified "stack info" object that TraceKit provides.
        }
    (See: https://github.com/csnover/TraceKit)

    For now we just log the JSON string. In the future we could format it into something Sentry understands better.
    """
    def stringify(obj):
        return util.dumps(obj, indent=2)

    stack_info = stackInfo
    message = unicode(stack_info.get('message', 'Unknown error'))
    try:
        message += '\n' + ' '*100 + '\n\nStack trace:\n\n' + stringify(stack_info['stack'])
    except KeyError:
        pass

    kwargs = {
        'url':    url,
        'view':   stack_info.get('name', 'JavaScript'), # The main title of this error.
        'level':  logging.ERROR,
        'logger': 'javascript',
    }

    client.create_from_text(message, **kwargs)
Пример #5
0
def send_new_message_notification(message_id):
    try:
        message = Message.objects.get(pk=message_id)
    except Message.DoesNotExist:
        msg = '**send_new_message_notification**. Message does not exist. ID: %s' % message_id
        client.create_from_text(msg, logger='celery')
        return

    user = message.user

    if not user.email or not user.is_active or not user.changes_notification:
        return

    to = "%s <%s>" % (user, user.email)

    subject = _(
        u"%(author)s sent you a message on Universal Subtitles: %(subject)s")
    subject = subject % {'author': message.author, 'subject': message.subject}

    context = {
        "message": message,
        "domain": Site.objects.get_current().domain,
        "STATIC_URL": settings.STATIC_URL,
    }

    send_templated_email(to, subject, "messages/email/message_received.html",
                         context)
Пример #6
0
def update_video_feed(video_feed_id):
    try:
        video_feed = VideoFeed.objects.get(pk=video_feed_id)
        video_feed.update()
    except VideoFeed:
        msg = '**update_video_feed**. VideoFeed does not exist. ID: %s' % video_feed_id
        client.create_from_text(msg, logger='celery')
Пример #7
0
def sentry_js_exception(request, stackInfo, url):
    """
    Logs an exception in Sentry. POST the following JSON structure:
        {
            "url": "http://example.com/foo/bar",
            "stackInfo": stack // a JSONified "stack info" object that TraceKit provides.
        }
    (See: https://github.com/csnover/TraceKit)

    For now we just log the JSON string. In the future we could format it into something Sentry understands better.
    """
    def stringify(obj):
        return util.dumps(obj, indent=2)

    stack_info = stackInfo
    message = unicode(stack_info.get('message', 'Unknown error'))
    try:
        message += '\n' + ' ' * 100 + '\n\nStack trace:\n\n' + stringify(
            stack_info['stack'])
    except KeyError:
        pass

    kwargs = {
        'url': url,
        'view': stack_info.get('name',
                               'JavaScript'),  # The main title of this error.
        'level': logging.ERROR,
        'logger': 'javascript',
    }

    client.create_from_text(message, **kwargs)
Пример #8
0
def js_error_handler(request, *args, **kwargs):

    message = request.POST.get('message', None)
    url = request.POST.get('url', None)

    client.create_from_text(message,
                            level=logging.ERROR,
                            url=url,
                            request=request)
    return HttpResponse('true')
Пример #9
0
def log_error(message, level=logging.ERROR):
    if sentry_client is not None:
        sentry_client.create_from_text(message, level=level)
    else:
        print "If sentry was set up we would log the following", \
              message