Beispiel #1
0
    def load_plugins(self):
        """
        Populate plugin lists from settings.PLUGINS.

        """

        for plugin_path in settings.PLUGINS:
            try:
                try:
                    pg_module, pg_classname = plugin_path.rsplit('.', 1)
                except ValueError, e:
                    raise exceptions.ImproperlyConfigured(
                        '%s isn\'t a plugin module' % plugin_path)

                try:
                    mod = importlib.import_module(pg_module)
                except ImportError, e:
                    raise exceptions.ImproperlyConfigured(
                        'Error importing plugin %s: "%s"' % (pg_module, e))

                try:
                    pg_class = getattr(mod, pg_classname)
                except AttributeError, e:
                    raise exceptions.ImproperlyConfigured(
                        'Plugins module "%s" does not define a "%s" class' %
                        (pg_module, pg_classname))
Beispiel #2
0
    def __init__(self, *args, **kwargs):
        self.ticket_url = getattr(settings, 'TICKETBOT_TICKET_URL', None)
        if not self.ticket_url:
            raise exceptions.ImproperlyConfigured(
                "You need to specify TICKETBOT_TICKET_URL in settings.py.")

        self.changeset_url = getattr(settings, 'TICKETBOT_CHANGESET_URL', None)
        if not self.changeset_url:
            raise exceptions.ImproperlyConfigured(
                "You need to specify TICKETBOT_CHANGESET_URL in settings.py.")

        super(TicketBotPlugin, self).__init__(self.name, *args, **kwargs)
Beispiel #3
0
    def __init__(self, *args, **kwargs):
        backend = getattr(settings, 'SHORTENER_BACKEND', None)
        if not backend:
            raise exceptions.ImproperlyConfigured(
                "You need to specify SHORTENER_BACKEND in settings.py. Valid backends include: %s"
                % ', '.join(VALID_BACKENDS))
        elif backend not in VALID_BACKENDS:
            raise exceptions.ImproperlyConfigured(
                "You must specify a valid backend. Valid backends include: %s"
                % ', '.join(VALID_BACKENDS))
        else:
            self.backend = backend

        if backend == 'bitly' and not getattr(
                settings, 'SHORTENER_LOGIN', None) and not getattr(
                    settings, 'SHORTENER_API_KEY', None):
            raise exceptions.ImproperlyConfigured(
                "You need to specify SHORTENER_LOGIN and SHORTENER_API_KEY when using bit.ly"
            )

        super(ShortenPlugin, self).__init__(self.name, self.command, *args,
                                            **kwargs)