How to use the crash.models.Symbols.objects function in crash

To help you get started, we’ve selected a few crash examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Crystalnix / omaha-server / omaha_server / omaha / limitation.py View on Github external
size = Feedback.objects.get_size()
    if size > gpm['Feedback__limit_size'] * 1024 * 1024 * 1024:
        raven.captureMessage("[Limitation]Size limit of feedbacks is exceeded. Current size is %s [%d]" %
                             (filters.filesizeformat(size).replace(u'\xa0', u' '), time.time()),
                             data={'level': 30, 'logger': 'limitation'})
    cache.set('feedbacks_size', size)

    size = Crash.objects.get_size()
    if size > gpm['Crash__limit_size'] * 1024 * 1024 * 1024:
        raven.captureMessage("[Limitation]Size limit of crashes is exceeded. Current size is %s [%d]" %
                             (filters.filesizeformat(size).replace(u'\xa0', u' '), time.time()),
                             data={'level': 30, 'logger': 'limitation'})
    cache.set('crashes_size', size)

    size = Symbols.objects.get_size()
    if size > gpm['Symbols__limit_size'] * 1024 * 1024 * 1024:
        raven.captureMessage("[Limitation]Size limit of symbols is exceeded. Current size is %s [%d]" %
                             (filters.filesizeformat(size).replace(u'\xa0', u' '), time.time()),
                             data={'level': 30, 'logger': 'limitation'})
    cache.set('symbols_size', size)
github Crystalnix / omaha-server / omaha_server / crash / api.py View on Github external
from rest_framework import status
from rest_framework.response import Response

from omaha.api import BaseView
from crash.serializers import SymbolsSerializer, CrashSerializer
from crash.models import Symbols, Crash


class StandardResultsSetPagination(pagination.PageNumberPagination):
    page_size = 10
    page_size_query_param = 'page_size'
    max_page_size = 100


class SymbolsViewSet(BaseView):
    queryset = Symbols.objects.all().order_by('-id')
    serializer_class = SymbolsSerializer

    def create(self, request, *args, **kwargs):
        try:
            return super(SymbolsViewSet, self).create(request, *args, **kwargs)
        except IntegrityError:
            res = {"message": "Duplicate symbol"}
            return Response(data=res, status=status.HTTP_409_CONFLICT)


class CrashViewSet(mixins.ListModelMixin,
                   mixins.RetrieveModelMixin,
                   viewsets.GenericViewSet):
    queryset = Crash.objects.all().order_by('-id')
    serializer_class = CrashSerializer
    pagination_class = StandardResultsSetPagination
github Crystalnix / omaha-server / omaha_server / crash / serializers.py View on Github external
__all__ = ['SymbolsSerializer']


class SymbolsSerializer(serializers.HyperlinkedModelSerializer):
    file = serializers.FileField(required=True)
    debug_id = serializers.CharField(default='', required=False, allow_blank=True)
    debug_file = serializers.CharField(default='', required=False, allow_blank=True)

    class Meta:
        model = Symbols
        fields = ('id', 'file', 'file_size', 'debug_id', 'debug_file',
                  'created', 'modified')
        read_only_fields = ('created', 'modified')
        validators = [
            serializers.UniqueTogetherValidator(
                queryset=Symbols.objects.all(),
                fields=('debug_id', 'debug_file')
            )
        ]

    def create(self, validated_data):
        if not validated_data.get('debug_id') or \
                not validated_data.get('debug_file'):
            file = validated_data['file']
            try:
                head = file.readline().rstrip()
                meta = parse_debug_meta_info(head, exception=serializers.ValidationError)
                validated_data.update(meta)
            except:
                raise serializers.ValidationError(u"The file contains invalid data.")
        if not validated_data.get('file_size'):
            file = validated_data['file']