Last active
June 1, 2017 11:40
-
-
Save ceyusa/42803c987a1f31e5e98c4c0971255634 to your computer and use it in GitHub Desktop.
get gstreamer-vaapi pending bugs
This file contains hidden or 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/env python3 | |
| # -*- coding: utf-8 -*- | |
| import csv | |
| import io | |
| import pprint | |
| import urllib.parse | |
| import urllib.request | |
| from datetime import datetime | |
| from textwrap import wrap | |
| from time import strptime | |
| status = [ 'UNCONFIRMED', 'NEW', 'ASSIGNED', 'REOPENED', 'NEEDINFO' ] | |
| columns = [ 'bug_status', 'short_desc' ,'changeddate', 'priority', | |
| 'bug_severity', 'status_whiteboard' ] | |
| params = urllib.parse.urlencode({ 'product' : 'GStreamer', | |
| 'component' : 'gstreamer-vaapi', | |
| 'query_format': 'advanced', | |
| 'ctype' : 'csv', | |
| 'bug_status' : status, | |
| 'columnlist' : ",".join(columns) }, | |
| doseq = True) | |
| url = "https://bugzilla.gnome.org/buglist.cgi?%s" % params | |
| def sorting(bug): | |
| whiteboard = bug['status_whiteboard'] | |
| prio = 0 | |
| if whiteboard is not '': | |
| prio = int(whiteboard[-1]) | |
| prio = abs(prio - 3) | |
| return prio, strptime(bug['changeddate'], "%Y-%m-%d %H:%M:%S"), int(bug['bug_id']) | |
| def get_bug_list(url): | |
| try: | |
| with urllib.request.urlopen(url) as csvfile: | |
| bugreader = csv.DictReader(io.TextIOWrapper(csvfile)) | |
| return sorted(bugreader, key=sorting, reverse=True) | |
| except urllib.error.URLError as e: | |
| print('urlib error: {}'.format(e.reason)) | |
| return None | |
| except csv.Error as e: | |
| print('csv error: {}'.format(e)) | |
| return None | |
| def print_bug(bug): | |
| whiteboard = bug['status_whiteboard'] | |
| if whiteboard is not '': | |
| whiteboard = "[{}] ".format(whiteboard) | |
| title = "{}{}".format(whiteboard, bug['short_desc']) | |
| bug_url = "https://bugzilla.gnome.org/show_bug.cgi?id=%s" % bug['bug_id'] | |
| print("{0}\n{1}\n{2}/{3}/{4} - {5} UTC".format("\n".join(wrap(title)), | |
| bug_url, | |
| bug['bug_status'], | |
| bug['priority'], | |
| bug['bug_severity'], | |
| bug['changeddate'])) | |
| print("-" * 10) | |
| def main(): | |
| print("Report generated at %s" % datetime.utcnow().strftime("%a %b %d %Y %H:%M:%S UTC")) | |
| print("=" * 80) | |
| print("") | |
| num = 0 | |
| bugs = get_bug_list(url) | |
| for bug in bugs: | |
| num += 1 | |
| print_bug(bug) | |
| print("Total: %d" % num) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment