def validateConfig(self):
        """Check that that passed config contains all the necessary
        parameters to run the Plugin
        """
        cfg_keys = self.cfg.keys()

        for k in self._req_cfg_keys:
            if k not in cfg_keys:
                raise plugins.PluginConfigurationError(
                    "[{:s}] '{:s}' setting not found".format(self.name, k)
                )

        # Set config
        self.endpoint = self.cfg["endpoint"]
        self.discord_text = self.cfg["discord_text"]
        self.send_admin = self.cfg["send_admin"]

        # Sanity
        if self.endpoint is None:
            raise plugins.PluginConfigurationError(
                "[{:s}] Not Configured".format(self.name)
            )

        if len(self.discord_text) < 10:
            raise plugins.PluginConfigurationError(
                "[{:s}] 'discord_text' must be longer than 10 characters".format(
                    self.name
                )
            )
    def validateConfig(self):
        """Check that that passed config contains all the necessary
           parameters to run the Plugin
        """
        cfg_keys = self.cfg.keys()

        for k in self._req_cfg_keys:
            if k not in cfg_keys:
                raise plugins.PluginConfigurationError("[{:s}] {:s} config key not found".format(self.name, k))

        # Set config
        self.host = self.cfg["smtp_host"]
        self.port = self.cfg["smtp_port"]
        self.use_tls = self.cfg["smtp_tls"]
        self.sender = self.cfg["smtp_sender"]
        self.user = self.cfg["smtp_user"]
        self.password = self.cfg["smtp_pass"]

        self.recipients = self.cfg["smtp_recipients"]
        if not isinstance(self.recipients, list):
            raise plugins.PluginConfigurationError("[{:s}] 'smtp_recipients' not configured correctly".format(self.name))

        # Sanity
        if self.host is None or self.user is None or self.recipients is None:
            raise plugins.PluginConfigurationError("[{:s}] Not Configured".format(self.name))
    def validateConfig(self):
        """Check that that passed config contains all the necessary
           parameters to run the Plugin
        """
        cfg_keys = self.cfg.keys()

        for k in self._req_cfg_keys:
            if k not in cfg_keys:
                raise plugins.PluginConfigurationError("[{:s}] '{:s}' setting not found".format(self.name, k))

        # Set config
        self.api_key = self.cfg["api_key"]
        self.api_secret = self.cfg["api_secret"]
        self.access_token = self.cfg["access_token"]
        self.access_secret = self.cfg["access_secret"]
        self.extra_tags = self.cfg["extra_tags"]

        # Sanity
        if self.api_key is None or self.api_secret is None or self.access_token is None or self.access_secret is None:
            raise plugins.PluginConfigurationError("[{:s}] Not Configured".format(self.name))

        if self.extra_tags is None:
            logger.info("[TwitterPlugin] No hashtags defined; Just letting you know")

        elif self.extra_tags is not None and not isinstance(self.extra_tags, list):
            raise plugins.PluginConfigurationError("[{:s}] 'extra_tags' not configured correctly".format(self.name))
    def validateConfig(self):
        """Check that that passed config contains all the necessary
           parameters to run the Plugin
        """
        cfg_keys = self.cfg.keys()

        for k in self._req_cfg_keys:
            if k not in cfg_keys:
                raise plugins.PluginConfigurationError(
                    "[TwitterPlugin] '{:s}' setting not found; Please read documentation"
                    .format(k))

        # Set config
        self.api_key = self.cfg["api_key"]
        self.api_secret = self.cfg["api_secret"]
        self.access_token = self.cfg["access_token"]
        self.access_secret = self.cfg["access_secret"]
        self.tweet_text = self.cfg["tweet_text"]

        # Sanity
        if self.api_key is None or self.api_secret is None or self.access_token is None or self.access_secret is None:
            raise plugins.PluginConfigurationError(
                "[TwitterPlugin] Missing required parameters; Please read documentation"
            )

        if self.tweet_text is None:
            raise plugins.PluginConfigurationError(
                "[TwitterPlugin] No tweet text defined; Please read documentation"
            )
Exemple #5
0
    def validateConfig(self):
        """Check that that passed config contains all the necessary
        parameters to run the Plugin
        """
        cfg_keys = self.cfg.keys()

        for k in self._req_cfg_keys:
            if k not in cfg_keys:
                if (k == "smtp_user" and "SMTP_USER" in os.environ) or (
                        k == "smtp_pass" and "SMTP_PASS" in os.environ):
                    continue
                raise plugins.PluginConfigurationError(
                    "[{:s}] {:s} config key not found".format(self.name, k))

        # Set config
        self.host = self.cfg["smtp_host"]
        self.port = self.cfg["smtp_port"]
        self.use_tls = self.cfg["smtp_tls"]
        self.sender = self.cfg["smtp_sender"]
        if "SMTP_USER" in os.environ:
            self.user = os.environ.get("SMTP_USER")
        else:
            self.user = self.cfg["smtp_user"]
        if "SMTP_PASS" in os.environ:
            self.password = os.environ.get("SMTP_PASS")
        else:
            self.password = self.cfg["smtp_pass"]
        # this parameter is optional, so we check if it is not set,
        # and if not set we set it to False (default value)
        if "smtp_nologin" not in self.cfg:
            self.cfg["smtp_nologin"] = False

        self.nologin = self.cfg["smtp_nologin"]

        # this parameter is optional, so we check if it is not set,
        # and if not set we set it to None
        if "smtp_sender_name" not in self.cfg:
            self.cfg["smtp_sender_name"] = None

        self.sender_name = self.cfg["smtp_sender_name"]

        self.recipients = self.cfg["smtp_recipients"]
        if not isinstance(self.recipients, list):
            raise plugins.PluginConfigurationError(
                "[{:s}] 'smtp_recipients' not configured correctly".format(
                    self.name))

        # Sanity check, when nologin is enabled smtp_user is not required
        if self.nologin and (self.host is None or self.recipients is None):
            raise plugins.PluginConfigurationError(
                "[{:s}] Not Configured".format(self.name))
        # Sanity check, when nologin is disabled, smtp_user is required
        elif not self.nologin and (self.host is None or self.user is None
                                   or self.recipients is None):
            raise plugins.PluginConfigurationError(
                "[{:s}] Not Configured".format(self.name))
    def validateConfig(self):
        """Check that that passed config contains all the necessary
        parameters to run the Plugin
        """
        cfg_keys = self.cfg.keys()

        for k in self._req_cfg_keys:
            if k not in cfg_keys:
                raise plugins.PluginConfigurationError(
                    "[{:s}] '{:s}' setting not found".format(self.name, k))

        # Set config
        self.endpoint = self.cfg["endpoint"]
        self.token = self.cfg["token"]

        # Sanity
        if self.endpoint is None or self.token is None:
            raise plugins.PluginConfigurationError(
                "[{:s}] Not Configured".format(self.name))
    def validateConfig(self):
        """Check that that passed config contains all the necessary
           parameters to run the Plugin
        """
        cfg_keys = self.cfg.keys()

        for k in self._req_cfg_keys:
            if k not in cfg_keys:
                raise plugins.PluginConfigurationError(
                    "[{:s}] '{:s}' setting not found".format(self.name, k))

        # Set config
        self.chat_ids = self.cfg["chat_ids"]
        self.bot_api_key = self.cfg["bot_api_key"]

        # Sanity
        if self.chat_ids is None or self.bot_api_key is None:
            raise plugins.PluginConfigurationError(
                "[{:s}] Not Configured".format(self.name))

        # ChatIds must be a list
        if not isinstance(self.chat_ids, list):
            raise plugins.PluginConfigurationError(
                "[{:s}] 'chat_ids' must be in list format".format(self.name))
    def validateConfig(self):
        """Check that that passed config contains all the necessary
           parameters to run the Plugin
        """
        cfg_keys = self.cfg.keys()

        # Upgrade notification
        if "chat_ids" in cfg_keys:
            raise plugins.PluginConfigurationError(
                "[{:s}] 'chat_ids' no longer supported; Please see upgrading instructions."
                .format(self.name))

        # Check for required config parameters
        for k in self._req_cfg_keys:
            if k not in cfg_keys:
                raise plugins.PluginConfigurationError(
                    "[{:s}] '{:s}' setting not found".format(self.name, k))

        # Set config
        self.admin_chat_ids = self.cfg["admin_chat_ids"]
        self.payouts_chat_ids = self.cfg["payouts_chat_ids"]
        self.bot_api_key = self.cfg["bot_api_key"]
        self.telegram_text = self.cfg["telegram_text"]

        # Sanity; Admin chat ids required at minimum
        if self.admin_chat_ids is None or self.bot_api_key is None:
            raise plugins.PluginConfigurationError(
                "[{:s}] Not Configured".format(self.name))

        # adminChatIds must be a list
        if not isinstance(self.admin_chat_ids, list):
            raise plugins.PluginConfigurationError(
                "[{:s}] 'admin_chat_ids' must be in list format".format(
                    self.name))

        # Same for publicChatIds
        if not isinstance(self.payouts_chat_ids, list):
            raise plugins.PluginConfigurationError(
                "[{:s}] 'payouts_chat_ids' must be in list format".format(
                    self.name))

        # Text must be longer than 10 characters
        if len(self.telegram_text) < 10:
            raise plugins.PluginConfigurationError(
                "[{:s}] 'telegram_text' must longer than 10 characters".format(
                    self.name))