Exemple #1
0
def mail_send(apiurl,
              project,
              to,
              subject,
              body,
              from_key='maintainer',
              followup_to_key='release-list',
              dry=False):

    config = Config.get(apiurl, project)
    if from_key is None:
        sender = entity_email(apiurl,
                              conf.get_apiurl_usr(apiurl),
                              include_name=True)
    else:
        sender = config['mail-{}'.format(from_key)]

    if '@' not in to:
        to = config['mail-{}'.format(to)]

    followup_to = config.get('mail-{}'.format(followup_to_key))
    relay = config.get('mail-relay', 'relay.suse.de')

    mail_send_with_details(text=body,
                           subject=subject,
                           relay=relay,
                           sender=sender,
                           followup_to=followup_to,
                           to=to,
                           dry=dry)
Exemple #2
0
def mail_send(apiurl, project, to, subject, body, from_key='maintainer',
              followup_to_key='release-list', dry=False):
    from email.mime.text import MIMEText
    import email.utils
    import smtplib

    config = Config.get(apiurl, project)
    msg = MIMEText(body)
    msg['Message-ID'] = email.utils.make_msgid()
    msg['Date'] = email.utils.formatdate(localtime=1)
    if from_key is None:
        msg['From'] = entity_email(apiurl, conf.get_apiurl_usr(apiurl), include_name=True)
    else:
        msg['From'] = config['mail-{}'.format(from_key)]
    if '@' not in to:
        to = config['mail-{}'.format(to)]
    msg['To'] = to
    followup_to = config.get('mail-{}'.format(followup_to_key))
    if followup_to:
        msg['Mail-Followup-To'] = followup_to
    msg['Subject'] = subject

    if dry:
        print(msg.as_string())
        return

    s = smtplib.SMTP(config.get('mail-relay', 'relay.suse.de'))
    s.sendmail(msg['From'], [msg['To']], msg.as_string())
    s.quit()
def notify(args):
    apiurl = osc.conf.config['apiurl']

    # devel_projects_get() only works for Factory as such
    # devel_project_fallback() must be used on a per package basis.
    packages = meta_get_packagelist(apiurl, args.project)
    maintainer_map = {}
    for package in packages:
        devel_project, devel_package = devel_project_fallback(apiurl, args.project, package)
        if devel_project and devel_package:
            devel_package_identifier = '/'.join([devel_project, devel_package])
            userids = maintainers_get(apiurl, devel_project, devel_package)
            for userid in userids:
                maintainer_map.setdefault(userid, set())
                maintainer_map[userid].add(devel_package_identifier)

    Config(args.project) # Ensure mail-* options are loaded for mail_send().
    subject = 'Packages you maintain are present in {}'.format(args.project)
    for userid, package_identifiers in maintainer_map.items():
        email = entity_email(apiurl, userid)
        message = 'The following packages you maintain are in {}:\n\n- {}'.format(
            args.project, '\n- '.join(sorted(package_identifiers)))

        mail_send(args.project, email, subject, message, dry=args.dry)
        print('notified {} of {} packages'.format(userid, len(package_identifiers)))
Exemple #4
0
def bug_owner(apiurl, package, entity='person'):
    query = {
        'binary': package,
    }
    url = osc.core.makeurl(apiurl, ('search', 'owner'), query=query)
    root = ET.parse(osc.core.http_GET(url)).getroot()

    bugowner = root.find('.//{}[@role="bugowner"]'.format(entity))
    if bugowner is not None:
        return entity_email(apiurl, bugowner.get('name'), entity)
    maintainer = root.find('.//{}[@role="maintainer"]'.format(entity))
    if maintainer is not None:
        return entity_email(apiurl, maintainer.get('name'), entity)
    if entity == 'person':
        return bug_owner(apiurl, package, 'group')

    return None
Exemple #5
0
def bug_owner(apiurl, package, entity='person'):
    query = {
        'binary': package,
    }
    url = osc.core.makeurl(apiurl, ('search', 'owner'), query=query)
    root = ET.parse(osc.core.http_GET(url)).getroot()

    bugowner = root.find('.//{}[@role="bugowner"]'.format(entity))
    if bugowner is not None:
        return entity_email(apiurl, bugowner.get('name'), entity)
    maintainer = root.find('.//{}[@role="maintainer"]'.format(entity))
    if maintainer is not None:
        return entity_email(apiurl, maintainer.get('name'), entity)
    if entity == 'person':
        return bug_owner(apiurl, package, 'group')

    return None
def notify(args):
    import smtplib
    apiurl = osc.conf.config['apiurl']

    # devel_projects_get() only works for Factory as such
    # devel_project_fallback() must be used on a per package basis.
    packages = args.packages
    if not packages:
        packages = package_list_kind_filtered(apiurl, args.project)
    maintainer_map = {}
    for package in packages:
        devel_project, devel_package = devel_project_fallback(
            apiurl, args.project, package)
        if devel_project and devel_package:
            devel_package_identifier = '/'.join([devel_project, devel_package])
            userids = maintainers_get(apiurl, devel_project, devel_package)
            for userid in userids:
                maintainer_map.setdefault(userid, set())
                maintainer_map[userid].add(devel_package_identifier)

    subject = 'Packages you maintain are present in {}'.format(args.project)
    for userid, package_identifiers in maintainer_map.items():
        email = entity_email(apiurl, userid)
        message = """This is a friendly reminder about your packages in {}.

Please verify that the included packages are working as intended and
have versions appropriate for a stable release. Changes may be submitted until
April 26th [at the latest].

Keep in mind that some packages may be shared with SUSE Linux
Enterprise. Concerns with those should be raised via Bugzilla.

Please contact [email protected] if your package
needs special attention by the release team.

According to the information in OBS ("osc maintainer") you are
in charge of the following packages:

- {}""".format(args.project, '\n- '.join(sorted(package_identifiers)))

        log = 'notified {} of {} packages'.format(userid,
                                                  len(package_identifiers))
        try:
            mail_send(apiurl,
                      args.project,
                      email,
                      subject,
                      message,
                      dry=args.dry)
            print(log)
        except smtplib.SMTPRecipientsRefused:
            print('[FAILED ADDRESS] {} ({})'.format(log, email))
        except smtplib.SMTPException as e:
            print('[FAILED SMTP] {} ({})'.format(log, e))
Exemple #7
0
def notify(args):
    import smtplib
    apiurl = osc.conf.config['apiurl']

    # devel_projects_get() only works for Factory as such
    # devel_project_fallback() must be used on a per package basis.
    packages = args.packages
    if not packages:
        packages = package_list_without_links(apiurl, args.project)
    maintainer_map = {}
    for package in packages:
        devel_project, devel_package = devel_project_fallback(apiurl, args.project, package)
        if devel_project and devel_package:
            devel_package_identifier = '/'.join([devel_project, devel_package])
            userids = maintainers_get(apiurl, devel_project, devel_package)
            for userid in userids:
                maintainer_map.setdefault(userid, set())
                maintainer_map[userid].add(devel_package_identifier)

    subject = 'Packages you maintain are present in {}'.format(args.project)
    for userid, package_identifiers in maintainer_map.items():
        email = entity_email(apiurl, userid)
        message = """This is a friendly reminder about your packages in {}.

Please verify that the included packages are working as intended and
have versions appropriate for a stable release. Changes may be submitted until
April 26th [at the latest].

Keep in mind that some packages may be shared with SUSE Linux
Enterprise. Concerns with those should be raised via Bugzilla.

Please contact [email protected] if your package
needs special attention by the release team.

According to the information in OBS ("osc maintainer") you are
in charge of the following packages:

- {}""".format(
            args.project, '\n- '.join(sorted(package_identifiers)))

        log = 'notified {} of {} packages'.format(userid, len(package_identifiers))
        try:
            mail_send(apiurl, args.project, email, subject, message, dry=args.dry)
            print(log)
        except smtplib.SMTPRecipientsRefused as e:
            print('[FAILED ADDRESS] {} ({})'.format(log, email))
        except smtplib.SMTPException as e:
            print('[FAILED SMTP] {} ({})'.format(log, e))
def mail_send(apiurl,
              project,
              to,
              subject,
              body,
              from_key='maintainer',
              followup_to_key='release-list',
              dry=False):
    from email.mime.text import MIMEText
    import email.utils
    import smtplib

    config = Config.get(apiurl, project)
    msg = MIMEText(body)
    msg['Message-ID'] = email.utils.make_msgid()
    msg['Date'] = email.utils.formatdate(localtime=1)
    if from_key is None:
        msg['From'] = entity_email(apiurl,
                                   conf.get_apiurl_usr(apiurl),
                                   include_name=True)
    else:
        msg['From'] = config['mail-{}'.format(from_key)]
    if '@' not in to:
        to = config['mail-{}'.format(to)]
    msg['To'] = to
    followup_to = config.get('mail-{}'.format(followup_to_key))
    if followup_to:
        msg['Mail-Followup-To'] = followup_to
    msg['Subject'] = subject

    if dry:
        print(msg.as_string())
        return

    s = smtplib.SMTP(config.get('mail-relay', 'relay.suse.de'))
    s.sendmail(msg['From'], [msg['To']], msg.as_string())
    s.quit()