make the script a plain python file
Replace template variables by normal Python ones, which we want to be able to set in a configuration file in the future. Signed-off-by: Nils Philippsen <nils@redhat.com>
This commit is contained in:
parent
0ec554a1c6
commit
214dedae86
1 changed files with 42 additions and 44 deletions
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/python -tt
|
#!/usr/bin/python -tt
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright © 2013-2017 Red Hat, Inc.
|
# Copyright © 2013-2019 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This copyrighted material is made available to anyone wishing to use, modify,
|
# This copyrighted material is made available to anyone wishing to use, modify,
|
||||||
# copy, or redistribute it subject to the terms and conditions of the GNU
|
# copy, or redistribute it subject to the terms and conditions of the GNU
|
||||||
|
@ -60,6 +60,8 @@ from requests.adapters import HTTPAdapter
|
||||||
from requests.packages.urllib3.util.retry import Retry
|
from requests.packages.urllib3.util.retry import Retry
|
||||||
|
|
||||||
|
|
||||||
|
env = 'staging'
|
||||||
|
|
||||||
cache = dogpile.cache.make_region().configure(
|
cache = dogpile.cache.make_region().configure(
|
||||||
'dogpile.cache.memory',
|
'dogpile.cache.memory',
|
||||||
expiration_time=3600,
|
expiration_time=3600,
|
||||||
|
@ -81,11 +83,10 @@ def retry_session():
|
||||||
return session
|
return session
|
||||||
|
|
||||||
|
|
||||||
{% if env == 'staging' %}
|
if env == 'staging':
|
||||||
BZSERVER = 'https://partner-bugzilla.redhat.com'
|
BZSERVER = 'https://partner-bugzilla.redhat.com'
|
||||||
{% else %}
|
else:
|
||||||
BZSERVER = 'https://bugzilla.redhat.com'
|
BZSERVER = 'https://bugzilla.redhat.com'
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
BZUSER = '{{ bugzilla_user }}'
|
BZUSER = '{{ bugzilla_user }}'
|
||||||
BZPASS = '{{ bugzilla_password }}'
|
BZPASS = '{{ bugzilla_password }}'
|
||||||
|
@ -100,21 +101,20 @@ NOTIFYEMAIL = [
|
||||||
VERBOSE = False
|
VERBOSE = False
|
||||||
DRYRUN = False
|
DRYRUN = False
|
||||||
|
|
||||||
{% if env == 'staging' %}
|
if env == 'staging':
|
||||||
FASURL = 'https://admin.stg.fedoraproject.org/accounts'
|
FASURL = 'https://admin.stg.fedoraproject.org/accounts'
|
||||||
FASINSECURE = True
|
FASINSECURE = True
|
||||||
PAGUREURL = 'https://stg.pagure.io'
|
PAGUREURL = 'https://stg.pagure.io'
|
||||||
PAGURE_DIST_GIT_URL = 'https://src.stg.fedoraproject.org'
|
PAGURE_DIST_GIT_URL = 'https://src.stg.fedoraproject.org'
|
||||||
PDCURL = 'https://pdc.stg.fedoraproject.org/rest_api/v1/'
|
PDCURL = 'https://pdc.stg.fedoraproject.org/rest_api/v1/'
|
||||||
MDAPIURL = 'https://apps.stg.fedoraproject.org/mdapi/'
|
MDAPIURL = 'https://apps.stg.fedoraproject.org/mdapi/'
|
||||||
{% else %}
|
else:
|
||||||
FASURL = 'https://admin.fedoraproject.org/accounts'
|
FASURL = 'https://admin.fedoraproject.org/accounts'
|
||||||
FASINSECURE = False
|
FASINSECURE = False
|
||||||
PAGUREURL = 'https://pagure.io'
|
PAGUREURL = 'https://pagure.io'
|
||||||
PAGURE_DIST_GIT_URL = 'https://src.fedoraproject.org'
|
PAGURE_DIST_GIT_URL = 'https://src.fedoraproject.org'
|
||||||
PDCURL = 'https://pdc.fedoraproject.org/rest_api/v1/'
|
PDCURL = 'https://pdc.fedoraproject.org/rest_api/v1/'
|
||||||
MDAPIURL = 'https://apps.fedoraproject.org/mdapi/'
|
MDAPIURL = 'https://apps.fedoraproject.org/mdapi/'
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
|
|
||||||
EMAIL_FROM = 'accounts@fedoraproject.org'
|
EMAIL_FROM = 'accounts@fedoraproject.org'
|
||||||
|
@ -452,22 +452,21 @@ def send_email(fromAddress, toAddress, subject, message, ccAddress=None):
|
||||||
|
|
||||||
This will be replaced by sending messages to a log later.
|
This will be replaced by sending messages to a log later.
|
||||||
'''
|
'''
|
||||||
{% if env == 'staging' %}
|
if env == 'staging':
|
||||||
# Send no email in staging...
|
# Send no email in staging...
|
||||||
pass
|
pass
|
||||||
{% else %}
|
else:
|
||||||
msg = Message()
|
msg = Message()
|
||||||
msg.add_header('To', ','.join(toAddress))
|
msg.add_header('To', ','.join(toAddress))
|
||||||
msg.add_header('From', fromAddress)
|
msg.add_header('From', fromAddress)
|
||||||
msg.add_header('Subject', subject)
|
msg.add_header('Subject', subject)
|
||||||
if ccAddress is not None:
|
if ccAddress is not None:
|
||||||
msg.add_header('Cc', ','.join(ccAddress))
|
msg.add_header('Cc', ','.join(ccAddress))
|
||||||
toAddress = toAddress + ccAddress
|
toAddress = toAddress + ccAddress
|
||||||
msg.set_payload(message)
|
msg.set_payload(message)
|
||||||
smtp = smtplib.SMTP('bastion')
|
smtp = smtplib.SMTP('bastion')
|
||||||
smtp.sendmail(fromAddress, toAddress, msg.as_string())
|
smtp.sendmail(fromAddress, toAddress, msg.as_string())
|
||||||
smtp.quit()
|
smtp.quit()
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
|
|
||||||
def notify_users(errors):
|
def notify_users(errors):
|
||||||
|
@ -723,13 +722,12 @@ if __name__ == '__main__':
|
||||||
poc=poc,
|
poc=poc,
|
||||||
watchers=pagure_namespace_to_cc[namespace][name],
|
watchers=pagure_namespace_to_cc[namespace][name],
|
||||||
))
|
))
|
||||||
{% if env == 'staging' %}
|
if env == 'staging':
|
||||||
# Filter out any modules, since we don't have rights to create new
|
# Filter out any modules, since we don't have rights to create new
|
||||||
# components in the "Fedora Modules" project yet
|
# components in the "Fedora Modules" project yet
|
||||||
pagure_projects = [
|
pagure_projects = [
|
||||||
p for p in pagure_projects if p['namespace'] != 'modules'
|
p for p in pagure_projects if p['namespace'] != 'modules'
|
||||||
]
|
]
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
branches_url = PDCURL.split('rest_api')[0] + 'extras/active_branches.json'
|
branches_url = PDCURL.split('rest_api')[0] + 'extras/active_branches.json'
|
||||||
if VERBOSE:
|
if VERBOSE:
|
Loading…
Add table
Add a link
Reference in a new issue