Beispiel #1
0
def validate_backends():
    from sentry import (
        buffer, digests, nodestore, quotas, ratelimits, search, tsdb
    )

    backends = (
        buffer,
        digests,
        nodestore,
        quotas,
        ratelimits,
        search,
        tsdb,
    )

    for backend in backends:
        try:
            backend.validate()
        except AttributeError as exc:
            from .importer import ConfigurationError
            from sentry.utils.settings import reraise_as
            reraise_as(ConfigurationError(
                '{} service failed to call validate()\n{}'.format(
                    backend.__name__,
                    six.text_type(exc),
                )
            ))
Beispiel #2
0
def validate_backends():
    from sentry import (buffer, digests, nodestore, quotas, ratelimits, search,
                        tsdb)

    backends = (
        buffer,
        digests,
        nodestore,
        quotas,
        ratelimits,
        search,
        tsdb,
    )

    for backend in backends:
        try:
            backend.validate()
        except AttributeError as exc:
            from .importer import ConfigurationError
            from sentry.utils.settings import reraise_as
            reraise_as(
                ConfigurationError(
                    '{} service failed to call validate()\n{}'.format(
                        backend.__name__,
                        six.text_type(exc),
                    )))
Beispiel #3
0
def setup_services(validate=True):
    from sentry import (
        analytics,
        buffer,
        digests,
        newsletter,
        nodestore,
        quotas,
        ratelimits,
        search,
        tagstore,
        tsdb,
    )
    from .importer import ConfigurationError
    from sentry.utils.settings import reraise_as

    service_list = (
        analytics,
        buffer,
        digests,
        newsletter,
        nodestore,
        quotas,
        ratelimits,
        search,
        tagstore,
        tsdb,
    )

    for service in service_list:
        if validate:
            try:
                service.validate()
            except AttributeError as exc:
                reraise_as(
                    ConfigurationError(
                        u"{} service failed to call validate()\n{}".format(
                            service.__name__, six.text_type(exc)
                        )
                    )
                )
        try:
            service.setup()
        except AttributeError as exc:
            if not hasattr(service, "setup") or not callable(service.setup):
                reraise_as(
                    ConfigurationError(
                        u"{} service failed to call setup()\n{}".format(
                            service.__name__, six.text_type(exc)
                        )
                    )
                )
            raise
Beispiel #4
0
def setup_services(validate=True):
    from sentry import (
        analytics, buffer, digests, newsletter, nodestore, quotas, ratelimits,
        search, tsdb
    )
    from .importer import ConfigurationError
    from sentry.utils.settings import reraise_as

    service_list = (
        analytics,
        buffer,
        digests,
        newsletter,
        nodestore,
        quotas,
        ratelimits,
        search,
        tsdb,
    )

    for service in service_list:
        if validate:
            try:
                service.validate()
            except AttributeError as exc:
                reraise_as(ConfigurationError(
                    '{} service failed to call validate()\n{}'.format(
                        service.__name__,
                        six.text_type(exc),
                    )
                ))
        try:
            service.setup()
        except AttributeError as exc:
            if not hasattr(service, 'setup') or not callable(service.setup):
                reraise_as(ConfigurationError(
                    '{} service failed to call setup()\n{}'.format(
                        service.__name__,
                        six.text_type(exc),
                    )
                ))
            raise
Beispiel #5
0
    def load_module(self, fullname):
        # Check to make sure it's not already in sys.modules in case of a reload()
        if fullname in sys.modules:
            return sys.modules[fullname]  # pragma: no cover

        try:
            mod = self._load_module(fullname)
        except Exception as e:
            from sentry.utils.settings import reraise_as
            msg = six.text_type(e)
            if msg:
                msg = '%s: %s' % (type(e).__name__, msg)
            else:
                msg = type(e).__name__
            reraise_as(ConfigurationError(msg))
        else:
            # Install into sys.modules explicitly
            sys.modules[fullname] = mod
            if self.callback is not None:
                self.callback(mod)
            return mod
Beispiel #6
0
    def load_module(self, fullname):
        # Check to make sure it's not already in sys.modules in case of a reload()
        if fullname in sys.modules:
            return sys.modules[fullname]  # pragma: no cover

        try:
            mod = self._load_module(fullname)
        except Exception as e:
            from sentry.utils.settings import reraise_as
            msg = six.text_type(e)
            if msg:
                msg = '%s: %s' % (type(e).__name__, msg)
            else:
                msg = type(e).__name__
            reraise_as(ConfigurationError(msg))
        else:
            # Install into sys.modules explicitly
            sys.modules[fullname] = mod
            if self.callback is not None:
                self.callback(mod)
            return mod
Beispiel #7
0
 def load_module(self, fullname):
     try:
         return self._load_module(fullname)
     except Exception as e:
         from sentry.utils.settings import reraise_as
         reraise_as(ConfigurationError(unicode(e)))