Exemple #1
0
 def tearDown(self):
     unregister(self.plugin_cls)
     super(TrelloPluginTest, self).tearDown()
    slug = 'sentry_smart_mailer'
    conf_key = 'sentry_smart_mailer'
    version = sentry_smart_mailer.VERSION
    author = "Tommaso Barbugli"
    author_url = "https://github.com/tbarbugli/sentry_smart_mailer"

    def should_notify(self, group):
        return SwitchManager.send_email(group=group, logger_name=group.logger)

    def post_process(self, group, event, is_new, is_sample, **kwargs):
        lock_key = 'lock_mail:%s' % group.id
        try:
            with Lock(lock_key, timeout=0.5):
                self._post_process(group, event, is_new, is_sample, **kwargs)
        except UnableToGetLock:
            pass

    def _post_process(self, group, event, is_new, is_sample, **kwargs):
        if not self.should_notify(group):
            return
        try:
            email_sent_at = list(get_last_email_sent_at(group))
        except:
            email_sent_at = []
        self.notify_users(group, event)
        email_sent_at.append((datetime.now(), group.times_seen or 1))
        set_last_email_sent_at(group, email_sent_at[-5:])

register(SmartMailer)
unregister(MailProcessor)
    author = "Tommaso Barbugli"
    author_url = "https://github.com/tbarbugli/sentry_smart_mailer"

    def should_notify(self, group):
        return SwitchManager.send_email(group=group, logger_name=group.logger)

    def post_process(self, group, event, is_new, is_sample, **kwargs):
        lock_key = 'lock_mail:%s' % group.id
        try:
            with Lock(lock_key, timeout=0.5):
                group = Group.objects.get(pk=group.pk)
                self._post_process(group, event, is_new, is_sample, **kwargs)
        except UnableToGetLock:
            pass

    def _post_process(self, group, event, is_new, is_sample, **kwargs):
        if not self.should_notify(group):
            return
        try:
            email_sent_at = list(group.last_email_sent)
        except:
            email_sent_at = []
        self.notify_users(group, event)
        email_sent_at.append((datetime.now(), group.times_seen or 1))
        group.last_email_sent = email_sent_at[-5:]
        group.save()


register(SmartMailer)
unregister(MailProcessor)
Exemple #4
0
 def tearDown(self):
     unregister(self.plugin_cls)
     super(JIRAPluginTest, self).tearDown()