~lool/launchpad-work-items-tracker/backlog-timestamp-in-2099

« back to all changes in this revision

Viewing changes to collect

  • Committer: Mattias Backman
  • Date: 2012-02-01 18:15:21 UTC
  • mto: (330.2.1 linaro-staging)
  • mto: This revision was merged to the branch mainline in revision 331.
  • Revision ID: mattias.backman@linaro.org-20120201181521-pn8ldtw4o9y1afxw
Use project names as keys for error emails, instead of blueprint regexps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
667
667
def send_error_mails(cfg):
668
668
    '''Send data_errors to contacts.
669
669
 
670
 
    Data error contacts are defined in the configuration in the "error_contact"
671
 
    map (which assigns a regexp over spec names to a list of email addresses).
672
 
    If no match is found, the error goes to stderr.
 
670
    Data error contacts are defined in the configuration in the 
 
671
    "project_notification_addresses" map (which assigns project names to a list
 
672
    of email addresses). If no address list for a project is found, the error
 
673
    goes to stderr.
673
674
    '''
674
675
    global error_collector
675
676
 
678
679
 
679
680
    dbg('mailing %i data errors' % len(error_collector.errors))
680
681
    for error in error_collector.errors:
681
 
        for pattern, addresses in cfg['error_contact'].iteritems():
682
 
            if (error.get_blueprint_name() is not None
683
 
                and re.search(pattern, error.get_blueprint_name())):
684
 
                dbg('spec %s matches error_contact pattern "%s", mailing to %s' % (error.get_blueprint_name(),
685
 
                    pattern, ', '.join(addresses)))
686
 
                for a in addresses:
687
 
                    emails.setdefault(a, '')
688
 
                    emails[a] += error.format_for_display() + '\n'
689
 
                break
 
682
        project_name = error.get_project_name()
 
683
        if project_name is not None:
 
684
            addresses = cfg['project_notification_addresses'][project_name]
 
685
            dbg('spec %s is targetted to "%s", mailing to %s' % (error.get_blueprint_name(),
 
686
                                                                 project_name, ', '.join(addresses)))
 
687
            for a in addresses:
 
688
                emails.setdefault(a, '')
 
689
                emails[a] += error.format_for_display() + '\n'
690
690
        else:
691
691
            print >> sys.stderr, error.format_for_display(), '(no error_contact pattern)'
692
692