• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.get_filters函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sentry.utils.get_filters函数的典型用法代码示例。如果您正苦于以下问题:Python get_filters函数的具体用法?Python get_filters怎么用?Python get_filters使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_filters函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: index

def index():
    filters = []
    for filter_ in get_filters():
        filters.append(filter_(request))

    try:
        page = int(request.args.get('p', 1))
    except (TypeError, ValueError):
        page = 1

    query = request.args.get('content')
    is_search = query

    if is_search:
        if uuid_re.match(query):
            # Forward to message if it exists
            try:
                message = Event.objects.get(query)
            except Message.DoesNotExist:
                pass
            else:
                return redirect(message.get_absolute_url())
        message_list = self.get_search_query_set(query)
    else:
        message_list = Group.objects.all()

    sort = request.args.get('sort')
    # if sort == 'date':
    #     message_list = message_list.order_by('-last_seen')
    # elif sort == 'new':
    #     message_list = message_list.order_by('-first_seen')
    # else:
    #     sort = 'priority'
    #     if not is_search:
    #         message_list = message_list.order_by('-score', '-last_seen')

    filters = []

    any_filter = False
    # for filter_ in filters:
    #     if not filter_.is_set():
    #         continue
    #     any_filter = True
        # message_list = filter_.get_query_set(message_list)

    today = datetime.datetime.now()

    has_realtime = page == 1

    return render_template('sentry/index.html', **{
        'has_realtime': has_realtime,
        'message_list': message_list,
        'today': today,
        'query': query,
        'sort': sort,
        'any_filter': any_filter,
        'request': request,
        'filters': filters,
    })
开发者ID:pombredanne,项目名称:sentry,代码行数:59,代码来源:views.py


示例2: register_indexes

def register_indexes():
    """
    Grabs all required indexes from filters and registers them.
    """
    logger = logging.getLogger("sentry.setup")
    for filter_ in get_filters():
        if filter_.column.startswith("data__"):
            MessageIndex.objects.register_index(filter_.column, index_to="group")
            logger.debug("Registered index for for %s" % filter_.column)
开发者ID:primepix,项目名称:django-sentry,代码行数:9,代码来源:models.py


示例3: view_slice

def view_slice(slug):
    slice_ = slices.get(slug)
    
    filters = []
    for filter_ in get_filters(slug):
        filters.append(filter_(request))

    try:
        page = int(request.args.get('p', 1))
    except (TypeError, ValueError):
        page = 1

    query = request.args.get('content')
    is_search = query

    # TODO: this needs to pull in the event list for this slice
    event_list = Group.objects.all()

    sort = request.args.get('sort')
    if sort == 'date':
        event_list = event_list.order_by('-last_seen')
    elif sort == 'new':
        event_list = event_list.order_by('-first_seen')
    elif sort == 'count':
        event_list = event_list.order_by('-count')
    else:
        sort = 'priority'
        event_list = event_list.order_by('-score')

    filters = []

    any_filter = False
    # for filter_ in filters:
    #     if not filter_.is_set():
    #         continue
    #     any_filter = True
        # event_list = filter_.get_query_set(event_list)

    today = datetime.datetime.now()

    has_realtime = page == 1

    return render_template('sentry/slice.html', **{
        'slice_name': slice_['name'],
        'has_realtime': has_realtime,
        'event_list': event_list,
        'today': today,
        'query': query,
        'sort': sort,
        'any_filter': any_filter,
        'request': request,
        'filters': filters,
    })
开发者ID:dmr,项目名称:sentry,代码行数:53,代码来源:views.py


示例4: index

def index(request):
    filters = []
    for filter_ in get_filters():
        filters.append(filter_(request))

    try:
        page = int(request.GET.get("p", 1))
    except (TypeError, ValueError):
        page = 1

    message_list = GroupedMessage.objects.all()

    sort = request.GET.get("sort")
    if sort == "date":
        message_list = message_list.order_by("-last_seen")
    elif sort == "new":
        message_list = message_list.order_by("-first_seen")
    elif sort == "freq":
        message_list = message_list.order_by("-times_seen")
    else:
        sort = "priority"
        message_list = message_list.order_by("-score", "-last_seen")

    # Filters only apply if we're not searching
    any_filter = False
    for filter_ in filters:
        if not filter_.is_set():
            continue
        any_filter = True
        message_list = filter_.get_query_set(message_list)

    today = datetime.datetime.now()

    has_realtime = page == 1

    return render_to_response(
        "sentry/index.html",
        {
            "has_realtime": has_realtime,
            "message_list": message_list,
            "today": today,
            "sort": sort,
            "any_filter": any_filter,
            "request": request,
            "filters": filters,
        },
    )
开发者ID:thanethomson,项目名称:django-sentry,代码行数:47,代码来源:views.py


示例5: index

def index(request):
    filters = []
    for filter_ in get_filters():
        filters.append(filter_(request))
    
    try:
        page = int(request.GET.get('p', 1))
    except (TypeError, ValueError):
        page = 1

    message_list = GroupedMessage.objects.all()

    sort = request.GET.get('sort')
    if sort == 'date':
        message_list = message_list.order_by('-last_seen')
    elif sort == 'new':
        message_list = message_list.order_by('-first_seen')
    elif sort == 'freq':
        message_list = message_list.order_by('-times_seen')
    else:
        sort = 'priority'
        message_list = message_list.order_by('-score', '-last_seen')
    
    # Filters only apply if we're not searching
    any_filter = False
    for filter_ in filters:
        if not filter_.is_set():
            continue
        any_filter = True
        message_list = filter_.get_query_set(message_list)
    
    today = datetime.datetime.now()

    has_realtime = page == 1
    
    return render_to_response('sentry/index.html', {
        'has_realtime': has_realtime,
        'message_list': message_list,
        'today': today,
        'sort': sort,
        'any_filter': any_filter,
        'request': request,
        'filters': filters,
        'throughput': ThrottleSwitch.get_throughput_per_second(),
        'throttling': ThrottleSwitch.is_throttled()
    })
开发者ID:tbarbugli,项目名称:sentry_fork,代码行数:46,代码来源:views.py


示例6: poll

    def poll(request):
        filters = []
        for filter_ in get_filters():
            filters.append(filter_(request))

        message_list = GroupedMessage.objects.all()

        sort = request.GET.get("sort")
        if sort == "date":
            message_list = message_list.order_by("-last_seen")
        elif sort == "new":
            message_list = message_list.order_by("-first_seen")
        elif sort == "freq":
            message_list = message_list.order_by("-times_seen")
        else:
            sort = "priority"
            message_list = message_list.order_by("-score", "-last_seen")

        for filter_ in filters:
            if not filter_.is_set():
                continue
            message_list = filter_.get_query_set(message_list)

        data = [
            (
                m.pk,
                {
                    "html": render_to_string(
                        "sentry/partial/_group.html", {"group": m, "priority": p, "request": request}
                    ).strip(),
                    "title": m.view or m.message_top(),
                    "message": m.error(),
                    "level": m.get_level_display(),
                    "logger": m.logger,
                    "count": m.times_seen,
                    "priority": p,
                },
            )
            for m, p in with_priority(message_list[0:15])
        ]

        response = HttpResponse(json.dumps(data))
        response["Content-Type"] = "application/json"
        return response
开发者ID:WoLpH,项目名称:django-sentry,代码行数:44,代码来源:views.py


示例7: index

def index():
    filter_list = list(get_filters())

    try:
        page = int(request.args.get("p", 1))
    except (TypeError, ValueError):
        page = 1

    event_list = Group.objects.all()

    sort = request.args.get("sort")
    if sort == "date":
        event_list = event_list.order_by("-last_seen")
    elif sort == "new":
        event_list = event_list.order_by("-first_seen")
    elif sort == "count":
        event_list = event_list.order_by("-count")
    else:
        sort = "priority"
        event_list = event_list.order_by("-score")

    any_filter = False
    # for filter_ in filters:
    #     if not filter_.is_set():
    #         continue
    #     any_filter = True
    # event_list = filter_.get_query_set(event_list)

    today = datetime.datetime.now()

    has_realtime = page == 1

    return render_template(
        "sentry/index.html",
        **{
            "has_realtime": has_realtime,
            "event_list": event_list,
            "today": today,
            "sort": sort,
            "any_filter": any_filter,
            "request": request,
            "filter_list": filter_list,
        }
    )
开发者ID:vvangelovski,项目名称:sentry,代码行数:44,代码来源:views.py


示例8: poll

    def poll(request):
        filters = []
        for filter_ in get_filters():
            filters.append(filter_(request))

        message_list = GroupedMessage.objects.all()
        
        sort = request.GET.get('sort')
        if sort == 'date':
            message_list = message_list.order_by('-last_seen')
        elif sort == 'new':
            message_list = message_list.order_by('-first_seen')
        elif sort == 'freq':
            message_list = message_list.order_by('-times_seen')
        else:
            sort = 'priority'
            message_list = message_list.order_by('-score', '-last_seen')
        
        for filter_ in filters:
            if not filter_.is_set():
                continue
            message_list = filter_.get_query_set(message_list)
        
        data = [
            (m.pk, {
                'html': render_to_string('sentry/partial/_group.html', {
                    'group': m,
                    'priority': p,
                    'request': request,
                }).strip(),
                'title': m.view or m.message_top(),
                'message': m.error(),
                'level': m.get_level_display(),
                'logger': m.logger,
                'count': m.times_seen,
                'priority': p,
            }) for m, p in with_priority(message_list[0:15])]
        
        response = HttpResponse(json.dumps(data))
        response['Content-Type'] = 'application/json'
        return response
开发者ID:tbarbugli,项目名称:sentry_fork,代码行数:41,代码来源:views.py


示例9: index

def index():
    filter_list = list(get_filters())

    try:
        page = int(request.args.get('p', 1))
    except (TypeError, ValueError):
        page = 1

    event_list = Group.objects.all()

    sort = request.args.get('sort')
    if sort == 'date':
        event_list = event_list.order_by('-last_seen')
    elif sort == 'new':
        event_list = event_list.order_by('-first_seen')
    elif sort == 'count':
        event_list = event_list.order_by('-count')
    else:
        sort = 'priority'
        event_list = event_list.order_by('-score')

    any_filter = False
    # for filter_ in filters:
    #     if not filter_.is_set():
    #         continue
    #     any_filter = True
        # event_list = filter_.get_query_set(event_list)

    today = datetime.datetime.now()

    has_realtime = page == 1
    
    return render_template('sentry/index.html', **{
        'has_realtime': has_realtime,
        'event_list': event_list,
        'today': today,
        'sort': sort,
        'any_filter': any_filter,
        'request': request,
        'filter_list': filter_list,
    })
开发者ID:dimazest,项目名称:sentry,代码行数:41,代码来源:views.py


示例10: ajax_handler

def ajax_handler():
    op = request.form.get('op')

    if op == 'poll':
        filters = []
        for filter_ in get_filters():
            filters.append(filter_(request))

        query = request.args.get('content')
        is_search = query

        if is_search:
            message_list = self.get_search_query_set(query)
        else:
            message_list = GroupedMessage.objects.extra(
                select={
                    'score': GroupedMessage.get_score_clause(),
                }
            )
            if query:
                # You really shouldnt be doing this
                message_list = message_list.filter(
                    Q(view__icontains=query) \
                    | Q(message__icontains=query) \
                    | Q(traceback__icontains=query)
                )

        sort = request.args.get('sort')
        if sort == 'date':
            message_list = message_list.order_by('-last_seen')
        elif sort == 'new':
            message_list = message_list.order_by('-first_seen')
        else:
            sort = 'priority'
            if not is_search:
                message_list = message_list.order_by('-score', '-last_seen')

        for filter_ in filters:
            if not filter_.is_set():
                continue
            message_list = filter_.get_query_set(message_list)

        data = [
            (m.pk, {
                'html': self.render_to_string('sentry/partial/_group.html', {
                    'group': m,
                    'priority': p,
                    'request': request,
                }, request),
                'count': m.times_seen,
                'priority': p,
            }) for m, p in with_priority(message_list[0:15])]

    elif op == 'resolve':
        gid = request.REQUEST.get('gid')
        if not gid:
            abort(403)
        try:
            group = GroupedMessage.objects.get(pk=gid)
        except GroupedMessage.DoesNotExist:
            abort(403)

        GroupedMessage.objects.filter(pk=group.pk).update(status=1)
        group.status = 1

        if not request.is_ajax():
            return redirect(request.environ['HTTP_REFERER'])

        data = [
            (m.pk, {
                'html': self.render_to_string('sentry/partial/_group.html', {
                    'group': m,
                    'request': request,
                }, request),
                'count': m.times_seen,
            }) for m in [group]]
    else:
        abort(400)

    return Response(simplejson.dumps(data), mimetype='application/json')
开发者ID:pombredanne,项目名称:sentry,代码行数:80,代码来源:views.py


示例11: process

    def process(self, **kwargs):
        "Processes the message before passing it on to the server"
        from sentry.utils import get_filters

        if kwargs.get('data'):
            # Ensure we're not changing the original data which was passed
            # to Sentry
            kwargs['data'] = kwargs['data'].copy()
        else:
            kwargs['data'] = {}

        if '__sentry__' not in kwargs['data']:
            kwargs['data']['__sentry__'] = {}

        request = kwargs.pop('request', None)
        if isinstance(request, HttpRequest):
            try:
                post_data = not request.POST and request.raw_post_data or request.POST
            except:
                post_data = request.POST

            kwargs['data'].update(dict(
                META=request.META,
                POST=post_data,
                GET=request.GET,
                COOKIES=request.COOKIES,
            ))

            if hasattr(request, 'user'):
                if request.user.is_authenticated():
                    user_info = {
                        'is_authenticated': True,
                        'id': request.user.pk,
                        'username': request.user.username,
                        'email': request.user.email,
                    }
                else:
                    user_info = {
                        'is_authenticated': False,
                    }

                kwargs['data']['__sentry__']['user'] = user_info

            if not kwargs.get('url'):
                kwargs['url'] = request.build_absolute_uri()

        kwargs.setdefault('level', logging.ERROR)
        kwargs.setdefault('server_name', settings.NAME)

        versions = get_versions()
        kwargs['data']['__sentry__']['versions'] = versions

        # Shorten lists/strings
        for k, v in kwargs['data'].iteritems():
            if k == '__sentry__':
                continue
            kwargs['data'][k] = shorten(v)

        # if we've passed frames, lets try to fetch the culprit
        if not kwargs.get('view') and kwargs['data']['__sentry__'].get('frames'):
            # This should be cached
            modules = get_installed_apps()
            if settings.INCLUDE_PATHS:
                modules = set(list(modules) + settings.INCLUDE_PATHS)

            def contains(iterator, value):
                for k in iterator:
                    if value.startswith(k):
                        return True
                return False

            # We iterate through each frame looking for an app in INSTALLED_APPS
            # When one is found, we mark it as last "best guess" (best_guess) and then
            # check it against SENTRY_EXCLUDE_PATHS. If it isnt listed, then we
            # use this option. If nothing is found, we use the "best guess".
            best_guess = None
            view = None
            for frame in kwargs['data']['__sentry__']['frames']:
                try:
                    view = '.'.join([frame['module'], frame['function']])
                except:
                    continue
                if contains(modules, view):
                    if not (contains(settings.EXCLUDE_PATHS, view) and best_guess):
                        best_guess = view
                elif best_guess:
                    break
            if best_guess:
                view = best_guess

            if view:
                kwargs['view'] = view

        # try to fetch the current version
        if kwargs.get('view'):
            # get list of modules from right to left
            parts = kwargs['view'].split('.')
            module_list = ['.'.join(parts[:idx]) for idx in xrange(1, len(parts) + 1)][::-1]
            version = None
            module = None
#.........这里部分代码省略.........
开发者ID:GunioRobot,项目名称:django-sentry,代码行数:101,代码来源:base.py


示例12: ajax_handler

def ajax_handler(request):
    op = request.REQUEST.get('op')

    if op == 'notification':
        return render_to_response('sentry/partial/_notification.html', request.GET)
    elif op == 'poll':
        filters = []
        for filter_ in get_filters():
            filters.append(filter_(request))


        message_list = GroupedMessage.objects.all()
        
        sort = request.GET.get('sort')
        if sort == 'date':
            message_list = message_list.order_by('-last_seen')
        elif sort == 'new':
            message_list = message_list.order_by('-first_seen')
        elif sort == 'freq':
            message_list = message_list.order_by('-times_seen')
        else:
            sort = 'priority'
            message_list = message_list.order_by('-score', '-last_seen')
        
        for filter_ in filters:
            if not filter_.is_set():
                continue
            message_list = filter_.get_query_set(message_list)
        
        data = [
            (m.pk, {
                'html': render_to_string('sentry/partial/_group.html', {
                    'group': m,
                    'priority': p,
                    'request': request,
                }).strip(),
                'title': m.view or m.message_top(),
                'message': m.error(),
                'level': m.get_level_display(),
                'logger': m.logger,
                'count': m.times_seen,
                'priority': p,
            }) for m, p in with_priority(message_list[0:15])]

    elif op == 'resolve':
        gid = request.REQUEST.get('gid')
        if not gid:
            return HttpResponseForbidden()
        try:
            group = GroupedMessage.objects.get(pk=gid)
        except GroupedMessage.DoesNotExist:
            return HttpResponseForbidden()
        
        GroupedMessage.objects.filter(pk=group.pk).update(status=1)
        group.status = 1
        
        if not request.is_ajax():
            return HttpResponseRedirect(request.META.get('HTTP_REFERER') or reverse('sentry'))
        
        data = [
            (m.pk, {
                'html': render_to_string('sentry/partial/_group.html', {
                    'group': m,
                    'request': request,
                }).strip(),
                'count': m.times_seen,
            }) for m in [group]]
    else:
        return HttpResponseBadRequest()
        
    response = HttpResponse(simplejson.dumps(data))
    response['Content-Type'] = 'application/json'
    return response
开发者ID:akolechkin,项目名称:django-sentry,代码行数:73,代码来源:views.py


示例13: process

    def process(self, **kwargs):
        "Processes the message before passing it on to the server"
        from sentry.utils import get_filters

        if kwargs.get("data"):
            # Ensure we're not changing the original data which was passed
            # to Sentry
            kwargs["data"] = kwargs["data"].copy()
        else:
            kwargs["data"] = {}

        if "__sentry__" not in kwargs["data"]:
            kwargs["data"]["__sentry__"] = {}

        request = kwargs.pop("request", None)
        if isinstance(request, HttpRequest):
            if not request.POST and request.body:
                post_data = request.body
            else:
                post_data = request.POST

            kwargs["data"].update(dict(META=request.META, POST=post_data, GET=request.GET, COOKIES=request.COOKIES))

            if hasattr(request, "user"):
                if request.user.is_authenticated():
                    user_info = {
                        "is_authenticated": True,
                        "id": request.user.pk,
                        "username": request.user.username,
                        "email": request.user.email,
                    }
                else:
                    user_info = {"is_authenticated": False}

                kwargs["data"]["__sentry__"]["user"] = user_info

            if not kwargs.get("url"):
                kwargs["url"] = request.build_absolute_uri()

        kwargs.setdefault("level", logging.ERROR)
        kwargs.setdefault("server_name", settings.NAME)

        versions = get_versions()
        kwargs["data"]["__sentry__"]["versions"] = versions

        # Shorten lists/strings
        for k, v in kwargs["data"].iteritems():
            if k == "__sentry__":
                continue
            kwargs["data"][k] = shorten(v)

        # if we've passed frames, lets try to fetch the culprit
        if not kwargs.get("view") and kwargs["data"]["__sentry__"].get("frames"):
            # This should be cached
            modules = get_installed_apps()
            if settings.INCLUDE_PATHS:
                modules = set(list(modules) + settings.INCLUDE_PATHS)

            def contains(iterator, value):
                for k in iterator:
                    if value.startswith(k):
                        return True
                return False

            # We iterate through each frame looking for an app in INSTALLED_APPS
            # When one is found, we mark it as last "best guess" (best_guess) and then
            # check it against SENTRY_EXCLUDE_PATHS. If it isnt listed, then we
            # use this option. If nothing is found, we use the "best guess".
            best_guess = None
            view = None
            for frame in kwargs["data"]["__sentry__"]["frames"]:
                try:
                    view = ".".join([frame["module"], frame["function"]])
                except:
                    continue
                if contains(modules, view):
                    if not (contains(settings.EXCLUDE_PATHS, view) and best_guess):
                        best_guess = view
                elif best_guess:
                    break
            if best_guess:
                view = best_guess

            if view:
                kwargs["view"] = view

        # try to fetch the current version
        if kwargs.get("view"):
            # get list of modules from right to left
            parts = kwargs["view"].split(".")
            module_list = [".".join(parts[:idx]) for idx in xrange(1, len(parts) + 1)][::-1]
            version = None
            module = None
            for m in module_list:
                if m in versions:
                    module = m
                    version = versions[m]

            # store our "best guess" for application version
            if version:
#.........这里部分代码省略.........
开发者ID:primepix,项目名称:django-sentry,代码行数:101,代码来源:base.py


示例14: ajax_handler

def ajax_handler():
    op = request.form.get("op")

    if op == "poll":
        filters = []
        for filter_ in get_filters():
            filters.append(filter_(request))

        event_list = Group.objects

        sort = request.args.get("sort")
        if sort == "date":
            event_list = event_list.order_by("-last_seen")
        elif sort == "new":
            event_list = event_list.order_by("-first_seen")
        elif sort == "count":
            event_list = event_list.order_by("-count")
        else:
            sort = "priority"
            event_list = event_list.order_by("-score")

        # for filter_ in filters:
        #     if not filter_.is_set():
        #         continue
        #     event_list = filter_.get_query_set(event_list)

        data = [
            (
                m.pk,
                {
                    "html": render_template(
                        "sentry/partial/group.html", **{"group": m, "priority": p, "request": request}
                    ),
                    "count": m.times_seen,
                    "priority": p,
                },
            )
            for m, p in with_priority(event_list[0:15])
        ]

    elif op == "resolve":
        gid = request.REQUEST.get("gid")
        if not gid:
            abort(403)
        try:
            group = Group.objects.get(pk=gid)
        except Group.DoesNotExist:
            abort(403)

        group.update(status=1)

        if not request.is_ajax():
            return redirect(request.environ["HTTP_REFERER"])

        data = [
            (
                m.pk,
                {
                    "html": render_template("sentry/partial/group.html", **{"group": m, "request": request}),
                    "count": m.times_seen,
                },
            )
            for m in [group]
        ]
    else:
        abort(400)

    return Response(simplejson.dumps(data), mimetype="application/json")
开发者ID:vvangelovski,项目名称:sentry,代码行数:68,代码来源:views.py


示例15: ajax_handler

def ajax_handler():
    op = request.form.get('op')

    if op == 'poll':
        filters = []
        for filter_ in get_filters():
            filters.append(filter_(request))

        event_list = Group.objects

        sort = request.args.get('sort')
        if sort == 'date':
            event_list = event_list.order_by('-last_seen')
        elif sort == 'new':
            event_list = event_list.order_by('-first_seen')
        elif sort == 'count':
            event_list = event_list.order_by('-count')
        else:
            sort = 'priority'
            event_list = event_list.order_by('-score')

        # for filter_ in filters:
        #     if not filter_.is_set():
        #         continue
        #     event_list = filter_.get_query_set(event_list)

        data = [
            (m.pk, {
                'html': render_template('sentry/partial/group.html', **{
                    'group': m,
                    'priority': p,
                    'request': request,
                }),
                'count': m.times_seen,
                'priority': p,
            }) for m, p in with_priority(event_list[0:15])]

    elif op == 'resolve':
        gid = request.REQUEST.get('gid')
        if not gid:
            abort(403)
        try:
            group = Group.objects.get(pk=gid)
        except Group.DoesNotExist:
            abort(403)

        group.update(status=1)

        if not request.is_ajax():
            return redirect(request.environ['HTTP_REFERER'])

        data = [
            (m.pk, {
                'html': render_template('sentry/partial/group.html', **{
                    'group': m,
                    'request': request,
                }),
                'count': m.times_seen,
            }) for m in [group]]
    else:
        abort(400)

    return Response(simplejson.dumps(data), mimetype='application/json')
开发者ID:dimazest,项目名称:sentry,代码行数:63,代码来源:views.py


示例16: process

    def process(self, **kwargs):
        "Processes the message before passing it on to the server"
        from sentry.utils import get_filters

        if kwargs.get('data'):
            # Ensure we're not changing the original data which was passed
            # to Sentry
            kwargs['data'] = kwargs['data'].copy()

        request = kwargs.pop('request', None)
        if request:
            if not kwargs.get('data'):
                kwargs['data'] = {}
            
            if not request.POST and request.raw_post_data:
                post_data = request.raw_post_data
            else:
                post_data = request.POST

            kwargs['data'].update(dict(
                META=request.META,
                POST=post_data,
                GET=request.GET,
                COOKIES=request.COOKIES,
            ))

            if not kwargs.get('url'):
                kwargs['url'] = request.build_absolute_uri()

        kwargs.setdefault('level', logging.ERROR)
        kwargs.setdefault('server_name', settings.NAME)

        # save versions of all installed apps
        if 'data' not in kwargs or '__sentry__' not in (kwargs['data'] or {}):
            if kwargs.get('data') is None:
                kwargs['data'] = {}
            kwargs['data']['__sentry__'] = {}

        versions = get_versions()
        kwargs['data']['__sentry__']['versions'] = versions

        # Shorten lists/strings
        for k, v in kwargs['data'].iteritems():
            if k == '__sentry__':
                continue
            kwargs['data'][k] = shorten(v)

        if kwargs.get('view'):
            # get list of modules from right to left
            parts = kwargs['view'].split('.')
            module_list = ['.'.join(parts[:idx]) for idx in xrange(1, len(parts)+1)][::-1]
            version = None
            module = None
            for m in module_list:
                if m in versions:
                    module = m
                    version = versions[m]

            # store our "best guess" for application version
            if version:
                kwargs['data']['__sentry__'].update({
                    'version': version,
                    'module': module,
                })

        if 'checksum' not in kwargs:
            checksum = construct_checksum(**kwargs)
        else:
            checksum = kwargs['checksum']

        (is_thrashing, message_id) = self.check_throttle(checksum)

        if is_thrashing:
            if request and message_id:
                # attach the sentry object to the request
                request.sentry = {
                    'id': message_id,
                    'thrashed': True,
                }
            
            return message_id
            
        for filter_ in get_filters():
            kwargs = filter_(None).process(kwargs) or kwargs
        
        # create ID client-side so that it can be passed to application
        message_id = uuid.uuid4().hex
        kwargs['message_id'] = message_id

        # Make sure all data is coerced
        kwargs['data'] = transform(kwargs['data'])

        if 'timestamp' not in kwargs:
            kwargs['timestamp'] = datetime.datetime.now()

        self.send(**kwargs)
        
        if request:
            # attach the sentry object to the request
            request.sentry = {
#.........这里部分代码省略.........
开发者ID:ramusus,项目名称:django-sentry,代码行数:101,代码来源:base.py


示例17: ajax_handler

def ajax_handler(request):
    op = request.REQUEST.get("op")

    if op == "notification":
        return render_to_response("sentry/partial/_notification.html", request.GET)
    elif op == "poll":
        filters = []
        for filter_ in get_filters():
            filters.append(filter_(request))

        message_list = GroupedMessage.objects.all()

        sort = request.GET.get("sort")
        if sort == "date":
            message_list = message_list.order_by("-last_seen")
        elif sort == "new":
            message_list = message_list.order_by("-first_seen")
        elif sort == "freq":
            message_list = message_list.order_by("-times_seen")
        else:
            sort = "priority"
            message_list = message_list.order_by("-score", "-last_seen")

        for filter_ in filters:
            if not filter_.is_set():
                continue
            message_list = filter_.get_query_set(message_list)

        data = [
            (
                m.pk,
                {
                    "html": render_to_string(
                        "sentry/partial/_group.html", {"group": m, "priority": p, "request": request}
                    ).strip(),
                    "title": m.view or m.message_top(),
                    "message": m.error(),
                    "level": m.get_level_display(),
                    "logger": m.logger,
                    "count": m.times_seen,
                    "priority": p,
                },
            )
            for m, p in with_priority(message_list[0:15])
        ]

    elif op == "resolve":
        gid = request.REQUEST.get("gid")
        if not gid:
            return HttpResponseForbidden()
        try:
            group = GroupedMessage.objects.get(pk=gid)
        except GroupedMessage.DoesNotExist:
            return HttpResponseForbidden()

        GroupedMessage.objects.filter(pk=group.pk).update(status=1)
        group.status = 1

        if not request.is_ajax():
            return HttpResponseRedirect(request.META.get("HTTP_REFERER") or reverse("sentry"))

        data = [
            (
                m.pk,
                {
                    "html": render_to_string("sentry/partial/_group.html", {"group": m, "request": request}).strip(),
                    "count": m.times_seen,
                },
            )
            for m in [group]
        ]
    else:
        return HttpResponseBadRequest()

    response = HttpResponse(json.dumps(data))
    response["Content-Type"] = "application/json"
    return response
开发者ID:thanethomson,项目名称:django-sentry,代码行数:77,代码来源:views.py



注:本文中的sentry.utils.get_filters函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.is_float函数代码示例发布时间:2022-05-27
下一篇:
Python preprocess_event.delay函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap