Skip to content

Instantly share code, notes, and snippets.

@omaciel
Created May 11, 2017 18:19
Show Gist options
  • Save omaciel/10dafa4cb6fcaf4d0f6792ad2014ac4a to your computer and use it in GitHub Desktop.
Save omaciel/10dafa4cb6fcaf4d0f6792ad2014ac4a to your computer and use it in GitHub Desktop.
Script that updates a Bugzilla flag for issues that have been closed.
$ python update_flags.py
Updating Bugzilla: 1192486
Updating Bugzilla: 1253941
Updating Bugzilla: 1296242
Updating Bugzilla: 1437719
Updating Bugzilla: 1440955
Updating Bugzilla: 1358176
Updating Bugzilla: 1277063
Updating Bugzilla: 1192245
Updating Bugzilla: 1240472
Updating Bugzilla: 1262598
from __future__ import print_function
import bugzilla # Make sure to get latest version
import os
# Source your Bugzilla credentials to your ENV
# (i.e. add them to your .<shell>rc file)
user = os.environ.get('BUGZILLA_USER_NAME', '')
password = os.environ.get('BUGZILLA_USER_PASSWORD', '')
bugzilla = bugzilla.Bugzilla(
url="https://bugzilla.redhat.com/xmlrpc.cgi",
user=user,
password=password,
)
# Search Bugzilla for the following items:
# Product: Red Hat Satellite 6
# Classification: Red Hat
# Status: CLOSED
# Resolution: NOTABUG, WONTFIX, DUPLICATE, CANTFIX, INSUFFICIENT_DATA
# Flags: qe_test_coverage?
query = bugzilla.url_to_query(
'https://bugzilla.redhat.com/buglist.cgi?'
'bug_status=CLOSED'
'&classification=Red%20Hat'
'&f1=flagtypes.name'
'&o1=equals'
'&v1=qe_test_coverage%3F'
'&product=Red%20Hat%20Satellite%206'
'&query_format=advanced'
'&resolution=NOTABUG'
'&resolution=WONTFIX'
'&resolution=DUPLICATE'
'&resolution=CANTFIX'
'&resolution=INSUFFICIENT_DATA'
)
# Explicitly fetch these fields
query["include_fields"] = ["id", "summary", "flags"]
# Execute the query
bugs = bugzilla.query(query)
# Update the flag 'qe_test_coverage' for all found issues
for bug in bugs:
print('Updating Bugzilla: {}'.format(bug.id))
bug.updateflags({'qe_test_coverage': '-'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment