Created
October 12, 2019 10:52
-
-
Save hroncok/5a5be8bd9b7be5df8bbc7bd1d353d536 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import bugzilla | |
import sys | |
import logging | |
assert sys.version_info[0] > 2, 'Needs Python 3' | |
PKG = sys.argv[1] | |
LOGGER = logging.getLogger() | |
LOGGER.setLevel(logging.DEBUG) | |
fh = logging.FileHandler('bugzilla.log') | |
fh.setLevel(logging.DEBUG) | |
LOGGER.addHandler(fh) | |
URL = 'https://bugzilla.redhat.com' | |
TEMPLATE = f"""Automation has figured out the package is retired in rawhide. | |
If you like it to be unretired, please open a ticket at https://pagure.io/releng/new_issue?template=package_unretirement | |
""" # noqa | |
bzapi = bugzilla.Bugzilla(URL) | |
if not bzapi.logged_in: | |
print(f'Log in to Bugzilla ta {URL}') | |
bzapi.interactive_login() | |
def open_bugz(version=None): | |
version = version or 'rawhide' | |
query = bzapi.build_query(product='Fedora', version=version, component=PKG) | |
query['status'] = [ | |
'NEW', | |
'ASSIGNED', | |
'POST', | |
'MODIFIED', | |
'ON_QA', | |
'VERIFIED', | |
'RELEASE_PENDING', | |
] | |
return bzapi.query(query) | |
def close_bugzillas(bug_ids, comment=None): | |
update = bzapi.build_update(comment=comment or TEMPLATE, | |
status='CLOSED', resolution='WONTFIX') | |
try: | |
bzapi.update_bugs(bug_ids, update) | |
except Exception: | |
LOGGER.exception() | |
print(f'Gathering {PKG} bugz, this can take a while...') | |
bugz = open_bugz() | |
bug_ids = [b.id for b in bugz] | |
for bug_id in bug_ids: | |
print(f'{URL}/show_bug.cgi?id={bug_id}') | |
if bug_ids: | |
print(f'Closing {PKG} bugz, this can take a while...') | |
close_bugzillas(bug_ids) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment