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:
Nils Philippsen 2019-11-18 11:28:18 +01:00
parent 0ec554a1c6
commit 214dedae86

View file

@ -1,7 +1,7 @@
#!/usr/bin/python -tt
# -*- 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,
# 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
env = 'staging'
cache = dogpile.cache.make_region().configure(
'dogpile.cache.memory',
expiration_time=3600,
@ -81,11 +83,10 @@ def retry_session():
return session
{% if env == 'staging' %}
BZSERVER = 'https://partner-bugzilla.redhat.com'
{% else %}
BZSERVER = 'https://bugzilla.redhat.com'
{% endif %}
if env == 'staging':
BZSERVER = 'https://partner-bugzilla.redhat.com'
else:
BZSERVER = 'https://bugzilla.redhat.com'
BZUSER = '{{ bugzilla_user }}'
BZPASS = '{{ bugzilla_password }}'
@ -100,21 +101,20 @@ NOTIFYEMAIL = [
VERBOSE = False
DRYRUN = False
{% if env == 'staging' %}
FASURL = 'https://admin.stg.fedoraproject.org/accounts'
FASINSECURE = True
PAGUREURL = 'https://stg.pagure.io'
PAGURE_DIST_GIT_URL = 'https://src.stg.fedoraproject.org'
PDCURL = 'https://pdc.stg.fedoraproject.org/rest_api/v1/'
MDAPIURL = 'https://apps.stg.fedoraproject.org/mdapi/'
{% else %}
FASURL = 'https://admin.fedoraproject.org/accounts'
FASINSECURE = False
PAGUREURL = 'https://pagure.io'
PAGURE_DIST_GIT_URL = 'https://src.fedoraproject.org'
PDCURL = 'https://pdc.fedoraproject.org/rest_api/v1/'
MDAPIURL = 'https://apps.fedoraproject.org/mdapi/'
{% endif %}
if env == 'staging':
FASURL = 'https://admin.stg.fedoraproject.org/accounts'
FASINSECURE = True
PAGUREURL = 'https://stg.pagure.io'
PAGURE_DIST_GIT_URL = 'https://src.stg.fedoraproject.org'
PDCURL = 'https://pdc.stg.fedoraproject.org/rest_api/v1/'
MDAPIURL = 'https://apps.stg.fedoraproject.org/mdapi/'
else:
FASURL = 'https://admin.fedoraproject.org/accounts'
FASINSECURE = False
PAGUREURL = 'https://pagure.io'
PAGURE_DIST_GIT_URL = 'https://src.fedoraproject.org'
PDCURL = 'https://pdc.fedoraproject.org/rest_api/v1/'
MDAPIURL = 'https://apps.fedoraproject.org/mdapi/'
EMAIL_FROM = 'accounts@fedoraproject.org'
@ -452,10 +452,10 @@ def send_email(fromAddress, toAddress, subject, message, ccAddress=None):
This will be replaced by sending messages to a log later.
'''
{% if env == 'staging' %}
if env == 'staging':
# Send no email in staging...
pass
{% else %}
else:
msg = Message()
msg.add_header('To', ','.join(toAddress))
msg.add_header('From', fromAddress)
@ -467,7 +467,6 @@ def send_email(fromAddress, toAddress, subject, message, ccAddress=None):
smtp = smtplib.SMTP('bastion')
smtp.sendmail(fromAddress, toAddress, msg.as_string())
smtp.quit()
{% endif %}
def notify_users(errors):
@ -723,13 +722,12 @@ if __name__ == '__main__':
poc=poc,
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
# components in the "Fedora Modules" project yet
pagure_projects = [
p for p in pagure_projects if p['namespace'] != 'modules'
]
{% endif %}
branches_url = PDCURL.split('rest_api')[0] + 'extras/active_branches.json'
if VERBOSE: