How to use the spidermon.exceptions.NotConfigured function in spidermon

To help you get started, we’ve selected a few spidermon 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 scrapinghub / spidermon / tests / contrib / actions / telegram / test_telegram_action.py View on Github external
def test_fail_if_no_recipients():
    with pytest.raises(NotConfigured):
        SendTelegramMessage(sender_token="token")

    with pytest.raises(NotConfigured):
        SendTelegramMessage(sender_token="token", fake=True)
github scrapinghub / spidermon / spidermon / contrib / actions / slack / __init__.py View on Github external
def __init__(self, sender_token=None, sender_name=None, fake=False):
        sender_token = sender_token or self.sender_token
        if not sender_token:
            raise NotConfigured("You must provide a slack token.")

        self.sender_name = sender_name or self.sender_name
        if not self.sender_name:
            raise NotConfigured("You must provide a slack sender name.")

        self.fake = fake
        self._client = SlackClient(sender_token)
        self._users = None
github scrapinghub / spidermon / spidermon / contrib / actions / reports / s3.py View on Github external
self.aws_access_key = aws_access_key or self.aws_access_key
        self.aws_secret_key = aws_secret_key or self.aws_secret_key
        self.s3_bucket = s3_bucket or self.s3_bucket
        self.s3_region_endpoint = s3_region_endpoint or self.s3_region_endpoint
        self.s3_filename = s3_filename or self.s3_filename
        self.make_public = make_public or self.make_public
        self.content_type = content_type or self.content_type
        if not self.aws_access_key:
            raise NotConfigured("You must provide the AWS Access Key.")
        if not self.aws_secret_key:
            raise NotConfigured("You must provide the AWS Secret Key.")
        if not self.s3_bucket:
            raise NotConfigured("You must define the s3 bucket.")
        if not self.s3_filename:
            raise NotConfigured("You must define the s3 filename.")
github scrapinghub / spidermon / spidermon / contrib / monitors / mixins / job.py View on Github external
def job(self):
        if not self.data.job:
            raise NotConfigured("Job not available!")
        return self.data.job
github scrapinghub / spidermon / spidermon / contrib / actions / sentry / __init__.py View on Github external
project_name="",
        environment="",
    ):
        super(SendSentryMessage, self).__init__()
        self.fake = fake or self.fake
        self.sentry_log_level = sentry_log_level or self.sentry_log_level
        self.sentry_dsn = sentry_dsn or self.sentry_dsn

        self.project_name = project_name or self.project_name
        self.environment = environment or self.environment

        if not self.fake and not self.sentry_dsn:
            raise NotConfigured("Missing SPIDERMON_SENTRY_DSN setting")

        if not self.project_name:
            raise NotConfigured("Missing SPIDERMON_SENTRY_PROJECT_NAME setting")
github scrapinghub / spidermon / spidermon / contrib / actions / email / __init__.py View on Github external
self.subject_template = subject_template or self.subject_template
        self.to = to or self.to
        self.cc = cc or self.cc
        self.bcc = bcc or self.bcc
        self.reply_to = reply_to or self.reply_to
        self.body_text = body_text or self.body_text
        self.body_text_template = body_text_template or self.body_text_template
        self.body_html = body_html or self.body_html
        self.body_html_template = body_html_template or self.body_html_template
        self.fake = fake or self.fake
        if not self.fake and not self.to:
            raise NotConfigured(
                "You must provide at least one recipient for the message."
            )
        if not self.subject:
            raise NotConfigured("You must provide a subject for the message.")
        if not (
            self.body_text or body_text_template or body_html or self.body_html_template
        ):
            raise NotConfigured("You must provide a body for the message.")
github scrapinghub / spidermon / spidermon / contrib / actions / telegram / __init__.py View on Github external
message=None,
        message_template=None,
        fake=None,
    ):
        super(SendTelegramMessage, self).__init__()

        self.fake = fake or self.fake
        self.manager = TelegramMessageManager(
            sender_token=sender_token or self.sender_token, fake=self.fake
        )

        self.recipients = recipients or self.recipients
        self.message = message or self.message
        self.message_template = message_template or self.message_template
        if not self.recipients:
            raise NotConfigured(
                "You must provide at least one recipient for the message."
            )
github scrapinghub / spidermon / spidermon / contrib / monitors / mixins / stats.py View on Github external
def stats(self):
        if not self.data.stats:
            raise NotConfigured("Stats not available!")
        return self.data.stats
github scrapinghub / spidermon / spidermon / contrib / actions / slack / __init__.py View on Github external
def __init__(self, sender_token=None, sender_name=None, fake=False):
        sender_token = sender_token or self.sender_token
        if not sender_token:
            raise NotConfigured("You must provide a slack token.")

        self.sender_name = sender_name or self.sender_name
        if not self.sender_name:
            raise NotConfigured("You must provide a slack sender name.")

        self.fake = fake
        self._client = SlackClient(sender_token)
        self._users = None
github scrapinghub / spidermon / spidermon / contrib / actions / reports / jobs.py View on Github external
def after_render_report(self):
        if not self.data.job:
            raise NotConfigured('Job not available!')
        report_file = StringIO.StringIO(self.report)
        self.add_job_report(
            job_key=self.data.job.key,
            key=self.report_key,
            content_type=self.content_type,
            report_file=report_file,
        )
        report_file.close()