Exemplo n.º 1
0
 def _format_expl(self, expl):
     lines = expl.rstrip().split('\n')[-self._config.error_lines:]
     if self._email_format == 'html':
         return six.u('<pre>{}</pre>').format('\n'.join(lines))
     else:
         return six.u('\n{}').format(
             six.u('\n').join(map(six.u('      {}').format, lines)))
 def test_generate_unicode_email(self):
     generate_email(
         sender='*****@*****.**',
         subject=six.u('sübjéct'),
         message=six.u("你好"),
         recipients=['*****@*****.**'],
         image_png=None,
     )
Exemplo n.º 3
0
 def _format_task(self, task_tuple):
     task, failure_count, disable_count, scheduling_count = task_tuple
     counts = [
         _plural_format('{} failure{}', failure_count),
         _plural_format('{} disable{}', disable_count),
         _plural_format('{} scheduling failure{}', scheduling_count),
     ]
     count_str = six.u(', ').join(filter(None, counts))
     return six.u('{} ({})').format(task, count_str)
Exemplo n.º 4
0
 def _format_task(self, task_tuple):
     task, failure_count, disable_count, scheduling_count = task_tuple
     counts = [
         _plural_format('{} failure{}', failure_count),
         _plural_format('{} disable{}', disable_count),
         _plural_format('{} scheduling failure{}', scheduling_count),
     ]
     count_str = six.u(', ').join(filter(None, counts))
     return six.u('{} ({})').format(task, count_str)
Exemplo n.º 5
0
 def _key(self, task_name, family, unbatched_args):
     if self._config.batch_mode == 'all':
         return task_name
     elif self._config.batch_mode == 'family':
         return family
     elif self._config.batch_mode == 'unbatched_params':
         param_str = six.u(', ').join(six.u('{}={}').format(*kv) for kv in six.iteritems(unbatched_args))
         return six.u('{}({})').format(family, param_str)
     else:
         raise ValueError('Unknown batch mode for batch notifier: {}'.format(
             self._config.batch_mode))
Exemplo n.º 6
0
 def _key(self, task_name, family, unbatched_args):
     if self._config.batch_mode == 'all':
         return task_name
     elif self._config.batch_mode == 'family':
         return family
     elif self._config.batch_mode == 'unbatched_params':
         param_str = six.u(', ').join(six.u('{}={}').format(*kv) for kv in six.iteritems(unbatched_args))
         return six.u('{}({})').format(family, param_str)
     else:
         raise ValueError('Unknown batch mode for batch notifier: {}'.format(
             self._config.batch_mode))
Exemplo n.º 7
0
 def _email_body(self, fail_counts, disable_counts, scheduling_counts, fail_expls):
     expls = {
         (name, fail_count, disable_counts[name], scheduling_counts[name]): self._expl_body(fail_expls[name])
         for name, fail_count in six.iteritems(fail_counts)
     }
     expl_groups = sorted(self._task_expl_groups(expls), key=self._expls_key)
     body_lines = []
     for tasks, msg in expl_groups:
         body_lines.append(self._format_tasks(tasks))
         body_lines.append(msg)
     body = six.u('\n').join(filter(None, body_lines)).rstrip()
     if self._email_format == 'html':
         return six.u('<ul>\n{}\n</ul>').format(body)
     else:
         return body
Exemplo n.º 8
0
 def _email_body(self, fail_counts, disable_counts, scheduling_counts, fail_expls):
     expls = {
         (name, fail_count, disable_counts[name], scheduling_counts[name]): self._expl_body(fail_expls[name])
         for name, fail_count in six.iteritems(fail_counts)
     }
     expl_groups = sorted(self._task_expl_groups(expls), key=self._expls_key)
     body_lines = []
     for tasks, msg in expl_groups:
         body_lines.append(self._format_tasks(tasks))
         body_lines.append(msg)
     body = six.u('\n').join(filter(None, body_lines)).rstrip()
     if self._email_format == 'html':
         return six.u('<ul>\n{}\n</ul>').format(body)
     else:
         return body
Exemplo n.º 9
0
 def mock_hive_cmd(self, args, check_return=True):
     self.last_hive_cmd = args
     self.count += 1
     return six.u("statement{0}".format(self.count))
Exemplo n.º 10
0
 def _format_expl(self, expl):
     lines = expl.rstrip().split('\n')[-self._config.error_lines:]
     if self._email_format == 'html':
         return six.u('<pre>{}</pre>').format('\n'.join(lines))
     else:
         return six.u('\n{}').format(six.u('\n').join(map(six.u('      {}').format, lines)))
Exemplo n.º 11
0
 def _format_tasks(self, tasks):
     lines = map(self._format_task, sorted(tasks, key=self._expl_key))
     if self._email_format == 'html':
         return six.u('<li>{}').format(six.u('\n<br>').join(lines))
     else:
         return six.u('- {}').format(six.u('\n  ').join(lines))
Exemplo n.º 12
0
 def _format_tasks(self, tasks):
     lines = map(self._format_task, sorted(tasks, key=self._expl_key))
     if self._email_format == 'html':
         return six.u('<li>{}').format(six.u('\n<br>').join(lines))
     else:
         return six.u('- {}').format(six.u('\n  ').join(lines))
Exemplo n.º 13
0
 def mock_hive_cmd(self, args, check_return=True):
     self.last_hive_cmd = args
     self.count += 1
     return six.u("statement{0}".format(self.count))