def _send_email(self):
        try:
            if not self.accumulation:
                return
            with Emailer(self.settings) as emailer:
                # WHO ARE WE SENDING TO
                emails = Data()
                for template, params in self.accumulation:
                    content = expand_template(template, params)
                    emails[literal_field(
                        self.settings.to_address)] += [content]
                    for c in self.cc:
                        if any(d in params.params.error for d in c.contains):
                            emails[literal_field(c.to_address)] += [content]

                # SEND TO EACH
                for to_address, content in emails.items():
                    emailer.send_email(source=self.settings.from_address,
                                       to_addresses=listwrap(to_address),
                                       subject=self.settings.subject,
                                       body="\n\n".join(content),
                                       format="text")

            self.accumulation = []
        except Exception as e:
            Log.warning("Could not send", e)
        finally:
            self.next_send = Date.now() + self.settings.average_interval * (
                2 * randoms.float())
예제 #2
0
    def test_floor_mod_identity(self):
        for i in range(100):
            x = randoms.float() * 200 - 100.0
            m = abs(random.gauss(0, 5))

            self.assertAlmostEqual(mo_math.floor(x, m) + mo_math.mod(x, m),
                                   x,
                                   places=7)
예제 #3
0
    def test_floor_mod_identity_w_ints(self):
        for i in range(100):
            x = randoms.float() * 200 - 100.0
            m = floor(abs(random.gauss(0, 5)))

            if m == 0:
                self.assertEqual(mo_math.floor(x, m), None)
                self.assertEqual(mo_math.mod(x, m), None)
            else:
                self.assertAlmostEqual(mo_math.floor(x, m) + mo_math.mod(x, m),
                                       x,
                                       places=7)