Пример #1
0
def check_email():
    comm_ids = [_id(x) for x in Es.by_name('comms').get_bearers()]
    list_ids = [_id(x) for x in Es.by_name('lists-opted').get_bearers()]
    with open('check-email.template') as f:
        template_text = cStringIO()
        for line in f:
            if line.endswith("\\\n"):
                template_text.write(line[:-2])
            else:
                template_text.write(line)
        templ = Template(template_text.getvalue())
    for m in args_to_users(sys.argv[1:]):
        rels = m.get_related()
        rels = sorted(rels, key=lambda x: Es.entity_humanName(x['with']))
        comms = []
        lists = []
        others = []
        for rel in rels:
            if Es.relation_is_virtual(rel):
                continue
            if _id(rel['with']) in comm_ids:
                comms.append(rel)
            elif _id(rel['with']) in list_ids:
                lists.append(rel)
            else:
                others.append(rel)
        print(m.name)
        em = templ.render(Context({
            'u': m,
            'comms': comms,
            'lists': lists,
            'others': others}))
        send_mail('Controle Karpe Noktem ledenadministratie',
                  em, '*****@*****.**',
                  [m.primary_email])
Пример #2
0
 def test_can_write_different_values(self):
     writer = UnicodeCSVWriter(open_file=cStringIO())
     s = u'ünįcodē'
     rows = [
         [s, unicodeobj(s), 123,
          datetime.date.today()],
     ]
     writer.writerows(rows)
     self.assertRaises(TypeError, writer.writerows, [object()])
Пример #3
0
 def test_can_write_different_values(self):
     writer = UnicodeCSVWriter(open_file=cStringIO())
     s = u'ünįcodē'
     class unicodeobj(object):
         def __str__(self):
             return s
         def __unicode__(self):
             return s
     rows = [[s, unicodeobj(), 123, datetime.date.today()], ]
     writer.writerows(rows)
     self.assertRaises(TypeError, writer.writerows, [object()])
 def line_stats_text(self):
     if self._line_stats_text is None and DJ_PROFILE_USE_LINE_PROFILER:
         lstats = self.statobj.line_stats
         if self.func in lstats.timings:
             out = cStringIO()
             fn, lineno, name = self.func
             show_func(fn, lineno, name, lstats.timings[self.func], lstats.unit, stream=out)
             self._line_stats_text = out.getvalue()
         else:
             self._line_stats_text = False
     return self._line_stats_text
 def line_stats_text(self):
     if self._line_stats_text is None:
         lstats = self.statobj.line_stats
         if self.func in lstats.timings:
             out = cStringIO()
             fn, lineno, name = self.func
             try:
                 show_func(fn, lineno, name, lstats.timings[self.func], lstats.unit, stream=out)
                 self._line_stats_text = out.getvalue()
             except ZeroDivisionError:
                 self._line_stats_text = "There was a ZeroDivisionError, total_time was probably zero"
         else:
             self._line_stats_text = False
     return self._line_stats_text
Пример #6
0
 def line_stats_text(self):
     if self._line_stats_text is None and DJ_PROFILE_USE_LINE_PROFILER:
         lstats = self.statobj.line_stats
         if self.func in lstats.timings:
             out = cStringIO()
             fn, lineno, name = self.func
             show_func(fn,
                       lineno,
                       name,
                       lstats.timings[self.func],
                       lstats.unit,
                       stream=out)
             self._line_stats_text = out.getvalue()
         else:
             self._line_stats_text = False
     return self._line_stats_text
Пример #7
0
 def line_stats_text(self):
     if self._line_stats_text is None:
         lstats = self.statobj.line_stats
         if self.func in lstats.timings:
             out = cStringIO()
             fn, lineno, name = self.func
             try:
                 show_func(fn,
                           lineno,
                           name,
                           lstats.timings[self.func],
                           lstats.unit, stream=out)
                 self._line_stats_text = out.getvalue()
             except ZeroDivisionError:
                 self._line_stats_text = ("There was a ZeroDivisionError, "
                                          "total_time was probably zero")
         else:
             self._line_stats_text = False
     return self._line_stats_text
    def test_rendergraph_with_cycle(self):
        import sys

        # raises due to get_nodepaths() in _resolve_dependencies()
        self.assertRaises(
            CycleNodeException, lambda: self.setDeps({
                'A': {
                    'depends': ['f_ag#comp']
                },
                'G': {
                    'depends': ['f_ga#comp']
                },
            }))
        self.assertEqual(ComputedFieldsModelType._graph.is_cyclefree, False)
        stdout = sys.stdout
        sys.stdout = cStringIO()
        call_command('rendergraph', 'output', verbosity=0)
        # should have printed cycle info on stdout
        self.assertIn('Warning -  1 cycles in dependencies found:',
                      sys.stdout.getvalue())
        sys.stdout = stdout