-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy pathgetbug.py
More file actions
40 lines (31 loc) · 1.33 KB
/
getbug.py
File metadata and controls
40 lines (31 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
#
# This work is licensed under the GNU GPLv2 or later.
# See the COPYING file in the top-level directory.
# getbug.py: Simple demonstration of connecting to bugzilla, fetching
# a bug, and printing some details.
import pprint
import bugzilla
# public test instance of bugzilla.redhat.com. It's okay to make changes
URL = "bugzilla.stage.redhat.com"
bzapi = bugzilla.Bugzilla(URL)
# getbug() is just a simple wrapper around getbugs(), which takes a list
# IDs, if you need to fetch multiple
#
# Example bug: https://bugzilla.stage.redhat.com/show_bug.cgi?id=427301
bug = bzapi.getbug(427301)
print("Fetched bug #%s:" % bug.id)
print(" Product = %s" % bug.product)
print(" Component = %s" % bug.component)
print(" Status = %s" % bug.status)
print(" Resolution= %s" % bug.resolution)
print(" Summary = %s" % bug.summary)
# Just check dir(bug) for other attributes, or check upstream bugzilla
# Bug.get docs for field names:
# https://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#get-bug
# comments must be fetched separately on stock bugzilla. this just returns
# a raw dict with all the info.
comments = bug.get_comments()
print("\nLast comment data:\n%s" % pprint.pformat(comments[-1]))
# get_comments is just a wrapper around bzapi.get_comments(), which can be
# used for bulk comments fetching