Esempio n. 1
0
 def to_python(self, value):
     if isinstance(value, basestring) and value:
         try:
             value = pickle.loads(decompress(value))
         except Exception, e:
             logger.exception(e)
             return {}
Esempio n. 2
0
 def to_python(self, value):
     if isinstance(value, basestring) and value:
         try:
             value = pickle.loads(decompress(value))
         except Exception, e:
             logger.exception(e)
             return {}
Esempio n. 3
0
File: node.py Progetto: webZW/sentry
    def to_python(self, value):
        node_id = None
        # If value is a string, we assume this is a value we've loaded from the
        # database, it should be decompressed/unpickled, and we should end up
        # with a dict.
        if value and isinstance(value, six.string_types):
            try:
                value = pickle.loads(decompress(value))
            except Exception as e:
                # TODO this is a bit dangerous as a failure to read/decode the
                # node_id will end up with this record being replaced with an
                # empty value under a new key, potentially orphaning an
                # original value in nodestore. OTOH if we can't decode the info
                # here, the node was already effectively orphaned.
                logger.exception(e)
                value = None

        if value:
            if 'node_id' in value:
                node_id = value.pop('node_id')
                # If the value is now empty, that means that it only had the
                # node_id in it, which means that we should be looking to *load*
                # the event body from nodestore. If it does have other stuff in
                # it, that means we got an event body with a precomputed id in
                # it, and we want to *save* the rest of the body to nodestore.
                if value == {}:
                    value = None
        else:
            # Either we were passed a null/empty value in the constructor, or
            # we failed to decode the value from the database so we have no id
            # to load data from, and no data to save.
            value = None

        return NodeData(self, node_id, value, wrapper=self.wrapper)
Esempio n. 4
0
 def to_python(self, value):
     if isinstance(value, six.string_types) and value:
         try:
             value = pickle.loads(decompress(value))
         except Exception as e:
             logger.exception(e)
             return {}
     elif not value:
         return {}
     return value
Esempio n. 5
0
 def to_python(self, value):
     if isinstance(value, six.string_types) and value:
         try:
             value = pickle.loads(decompress(value))
         except Exception as e:
             logger.exception(e)
             return {}
     elif not value:
         return {}
     return value
Esempio n. 6
0
def decode_and_decompress_data(encoded_data):
    try:
        try:
            return decompress(encoded_data)
        except zlib.error:
            return base64.b64decode(encoded_data)
    except Exception as e:
        # This error should be caught as it suggests that there's a
        # bug somewhere in the client's code.
        logger.info(e, **client_metadata(exception=e))
        raise APIForbidden("Bad data decoding request (%s, %s)" % (e.__class__.__name__, e))
Esempio n. 7
0
def decode_and_decompress_data(encoded_data):
    try:
        try:
            return decompress(encoded_data).decode("utf-8")
        except zlib.error:
            return base64.b64decode(encoded_data).decode("utf-8")
    except Exception as e:
        # This error should be caught as it suggests that there's a
        # bug somewhere in the client's code.
        logger.debug(six.text_type(e), exc_info=True)
        raise APIError("Bad data decoding request (%s, %s)" % (type(e).__name__, e))
Esempio n. 8
0
def decode_and_decompress_data(encoded_data):
    try:
        try:
            return decompress(encoded_data).decode("utf-8")
        except zlib.error:
            return base64.b64decode(encoded_data).decode("utf-8")
    except Exception as e:
        # This error should be caught as it suggests that there's a
        # bug somewhere in the client's code.
        logger.debug(six.text_type(e), exc_info=True)
        raise APIError("Bad data decoding request (%s, %s)" % (type(e).__name__, e))
Esempio n. 9
0
 def decode_and_decompress_data(self, encoded_data):
     try:
         try:
             return decompress(encoded_data)
         except zlib.error:
             return base64.b64decode(encoded_data)
     except Exception as e:
         # This error should be caught as it suggests that there's a
         # bug somewhere in the client's code.
         self.log.info(unicode(e), exc_info=True)
         raise APIError('Bad data decoding request (%s, %s)' %
                        (type(e).__name__, e))
Esempio n. 10
0
def decode_and_decompress_data(encoded_data):
    try:
        try:
            return decompress(encoded_data)
        except zlib.error:
            return base64.b64decode(encoded_data)
    except Exception as e:
        # This error should be caught as it suggests that there's a
        # bug somewhere in the client's code.
        logger.info(e, **client_metadata(exception=e))
        raise APIForbidden('Bad data decoding request (%s, %s)' %
                           (e.__class__.__name__, e))
Esempio n. 11
0
    def save(self, file):
        filename = self.get_path(file['filename'])
        contents = decompress(file['data'])
        del file['data']
        file['path'] = default_storage.save(filename, ContentFile(contents))
        contents = None

        file['size'] = default_storage.size(file['path'])
        if not 'type' in file:
            file['type'] = None

        return file
Esempio n. 12
0
 def decode_and_decompress_data(self, encoded_data):
     try:
         try:
             return decompress(encoded_data)
         except zlib.error:
             return base64.b64decode(encoded_data)
     except Exception as e:
         # This error should be caught as it suggests that there's a
         # bug somewhere in the client's code.
         self.log.debug(unicode(e), exc_info=True)
         raise APIError('Bad data decoding request (%s, %s)' %
             (type(e).__name__, e)
         )
Esempio n. 13
0
    def to_python(self, value):
        if isinstance(value, six.string_types) and value:
            try:
                value = pickle.loads(decompress(value))
            except Exception as e:
                logger.exception(e)
                value = {}
        elif not value:
            value = {}

        if 'node_id' in value:
            node_id = value.pop('node_id')
            data = None
        else:
            node_id = None
            data = value

        return NodeData(self, node_id, data)
Esempio n. 14
0
    def to_python(self, value):
        if isinstance(value, six.string_types) and value:
            try:
                value = pickle.loads(decompress(value))
            except Exception as e:
                logger.exception(e)
                value = {}
        elif not value:
            value = {}

        if 'node_id' in value:
            node_id = value.pop('node_id')
            data = None
        else:
            node_id = None
            data = value

        return NodeData(self, node_id, data)
Esempio n. 15
0
    def to_python(self, value):
        node_id = None
        # If value is a string, we assume this is a value we've loaded from the
        # database, it should be decompressed/unpickled, and we should end up
        # with a dict.
        if value and isinstance(value, six.string_types):
            try:
                value = pickle.loads(decompress(value))
            except Exception as e:
                # TODO this is a bit dangerous as a failure to read/decode the
                # node_id will end up with this record being replaced with an
                # empty value under a new key, potentially orphaning an
                # original value in nodestore. OTOH if we can't decode the info
                # here, the node was already effectively orphaned.
                logger.exception(e)
                value = None

        if value:
            if 'node_id' in value:
                node_id = value.pop('node_id')
                # If the value is now empty, that means that it only had the
                # node_id in it, which means that we should be looking to *load*
                # the event body from nodestore. If it does have other stuff in
                # it, that means we got an event body with a precomputed id in
                # it, and we want to *save* the rest of the body to nodestore.
                if value == {}:
                    value = None
        else:
            # Either we were passed a null/empty value in the constructor, or
            # we failed to decode the value from the database so we have no id
            # to load data from, and no data to save.
            value = None

        if value is not None and self.wrapper is not None:
            value = self.wrapper(value)

        return NodeData(self, node_id, value)
Esempio n. 16
0
import warnings

from django.utils.text import slugify
from exam import fixture
from uuid import uuid4

from sentry.models import (
    Activity, Event, Group, Organization, OrganizationMember,
    OrganizationMemberTeam, Project, Team, User
)
from sentry.utils.compat import pickle
from sentry.utils.strings import decompress


# an example data blog from Sentry 5.4.1 (db level)
LEGACY_DATA = pickle.loads(decompress("""eJy9WW1v20YS/q5fwfqLpECluMvXFSzjgKK9BrikByR3XwyDXpFLmjVFsnxxbAT57zczS0rUS+LGrU8IYu3s2+yzM8/MrGZxxSYfpo0q2vrJzIpW1YmMVGO+U00jUzWdVHwyiysbBm13IgdaH++yxoB/0mhV0xp9p5GqQtWyVbHRNVmRGre3tXxQBQ26vYW57qT5MK1kLbcNtLzJLK/8SQOyVqYoCVAicJB6bGsJEmahBoz0fGpMWacPKOU4kKFiy/80qm6WcQSLqnppPmR128lcFQ/NUp9sucmKJSmCM52JhO1AIWy42Lhr26pZLZdqE9luYtuKucyxWCJiJSPXEcIPNrFkbJXYjmUnAVOMKyfijnB47FpuYgXehkcy/oesKjNVbQ9oVG6XDHfxJhJOlJcylg8pCnzSPpj8YpnC9yzf4SzwQRdoB4FtW5YfMN63bVsEjo29sEYHZ8UFBBy8PzFekkUYbsu4yxXCyBmCxjmMGs7NESvbZCazseXQjNOb/xWwwH6XFvBgTlSW95le1SdhgNfT1TlKUA+ED9F7lNsqV3hq6LEtHHWnZAyXg23SyOZ0tQVeoW2TxEHJH52qn8KmrcFosMuFZafYEcsWjcD2aKyPoq1q78oYhQGM+ufPH/Gr+MpxPrQyugdDishwyZQcNKUEoUO9HDIkh3Rx0LKTrojarETIHFRj02V5HG4b1MvxUAG5acJKtnco8P+cAebZZlk9gd4FN/1lk7XqxwoUA5dptGEuN7JRZvWEaxK+Va3CqISDPKKdOgK1dC2CBSzWGH0QIrOr4I+afUYXYzDiwjj6fBublfH5AmbyczNpdo/XCjy8hXuCiWFWJOVMyxc42T5WbPzJs6YNt/IxBFjS9m7dqDwxj4QLVN4hM3+QZDQuWaGLVlh1mzyLwnuFELn+5D3aEQDXhu1ThZfrBoOxmyQfk5hLjBJ1eVVnCKdn7cY2UZ1VMLjuioJ8yWOTPR15fLRRhkbnoRu5Ikg2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xr/ywmjV8Rz6HJ6Txx+QDi5gN07mXK4p4h+OGd6Y30RJOGEan8ZKLD1kLiMeoEDh+td8GCgu3O7A4S4t3c0zoeYPKeu4FtecHyA2REYmP6VRVPC/fUejiK973yGeQnnu7IJvsimMf8Hr5plBQ=="""))


class Fixtures(object):
    @fixture
    def projectkey(self):
        return self.create_project_key(project=self.project)

    @fixture
    def user(self):
        return self.create_user('admin@localhost', is_superuser=True)

    @fixture
    def organization(self):
        # XXX(dcramer): ensure that your org slug doesnt match your team slug
        # and the same for your project slug
Esempio n. 17
0
import warnings

from django.utils.text import slugify
from exam import fixture
from uuid import uuid4

from sentry.models import (Activity, Event, Group, Organization,
                           OrganizationMember, OrganizationMemberTeam, Project,
                           Team, User)
from sentry.utils.compat import pickle
from sentry.utils.strings import decompress

# an example data blog from Sentry 5.4.1 (db level)
LEGACY_DATA = pickle.loads(
    decompress(
        """eJy9WW1v20YS/q5fwfqLpECluMvXFSzjgKK9BrikByR3XwyDXpFLmjVFsnxxbAT57zczS0rUS+LGrU8IYu3s2+yzM8/MrGZxxSYfpo0q2vrJzIpW1YmMVGO+U00jUzWdVHwyiysbBm13IgdaH++yxoB/0mhV0xp9p5GqQtWyVbHRNVmRGre3tXxQBQ26vYW57qT5MK1kLbcNtLzJLK/8SQOyVqYoCVAicJB6bGsJEmahBoz0fGpMWacPKOU4kKFiy/80qm6WcQSLqnppPmR128lcFQ/NUp9sucmKJSmCM52JhO1AIWy42Lhr26pZLZdqE9luYtuKucyxWCJiJSPXEcIPNrFkbJXYjmUnAVOMKyfijnB47FpuYgXehkcy/oesKjNVbQ9oVG6XDHfxJhJOlJcylg8pCnzSPpj8YpnC9yzf4SzwQRdoB4FtW5YfMN63bVsEjo29sEYHZ8UFBBy8PzFekkUYbsu4yxXCyBmCxjmMGs7NESvbZCazseXQjNOb/xWwwH6XFvBgTlSW95le1SdhgNfT1TlKUA+ED9F7lNsqV3hq6LEtHHWnZAyXg23SyOZ0tQVeoW2TxEHJH52qn8K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rm8v/yrzb1+5oq9HGwiBBVfvK0OSoH8J068sVLWYfJYEnL2hMHKeDZ5lCjBND4Y2oQhevYlf7zCkDE4f1DtRNfX4CXtcqM87iMJFZ3ldOQowJAEIUWMFU1XVZ/4CYgF9+i5iJMPaJgaaJvj2bL2gBNjAuPgkh4XIo0zXhXuqi/4qe5u3vIN3xDxXccnZUyi1cNttWZQ2l4hM9xusinmJPdZ+GtWrKroaIb/TDUN2Qlg2rMiP/4NY+sQb8whCfHcLQWK+NaRhimAjD6YpOt6Nl/NFFPWbtjOaPakRO2XQYYqHZAvfBVPzhATOd/vzGvhc6jRl9/zEr5mhInNGjRhji80c/9wU/53Dm6GX64NSv5NKDYY8UFt17nVB4oouvF6nVH10GSPar7Arg9Xr/ywmjV8Rz6HJ6Txx+QDi5gN07mXK4p4h+OGd6Y30RJOGEan8ZKLD1kLiMeoEDh+td8GCgu3O7A4S4t3c0zoeYPKeu4FtecHyA2REYmP6VRVPC/fUejiK973yGeQnnu7IJvsimMf8Hr5plBQ=="""
    ))


class Fixtures(object):
    @fixture
    def projectkey(self):
        return self.create_project_key(project=self.project)

    @fixture
    def user(self):
        return self.create_user('admin@localhost', is_superuser=True)

    @fixture
    def organization(self):
        # XXX(dcramer): ensure that your org slug doesnt match your team slug
Esempio n. 18
0
 def _get_bytes_multi(self, id_list):
     return {
         n.id: decompress(n.data)
         for n in Node.objects.filter(id__in=id_list)
     }
Esempio n. 19
0
 def _get_bytes(self, id):
     try:
         data = Node.objects.get(id=id).data
         return decompress(data)
     except Node.DoesNotExist:
         return None