Package: txbugzilla
Access Bugzilla’s XML-RPC API asyncronously (non-blocking) using the Twisted
framework.Simple Example: Fetching a bugfromtxbugzillaimportconnect,BugzillaExceptionfromtwisted.internetimportdeferfromtwisted.internet.taskimportreact@defer.inlineCallbacksdefexample(reactor):# connect() defaults to https://bugzilla.redhat.com/xmlrpc.cgibz=yieldconnect()# fetch a bugtry:bug=yieldbz.get_bug_simple(10000)print(bug.summary)exceptBugzillaExceptionase:print(e)if__name__=='__main__':react(example)Example: AuthenticationBy default, connections to Bugzilla are anonymous, so you cannot do fun things
like update bugs or view private bugs or private information.  If you wish to
authenticate your connection to Bugzilla, you can pass an API key toconnect(). The deferred thatconnect()returns will fire a callback
with an authenticated connection.fromtxbugzillaimportconnectfromtwisted.internetimportdefer@defer.inlineCallbacksdefexample():# Authenticate with an API keybz=yieldconnect(api_key='123456abcdef')# Do something as this logged-in user, for example:# bug = yield bz.getbugsimple(...)(Previous versions of txbugzilla supported the older username/password and
token methods for authenticating. These methods are deprecated in Bugzilla 5
and the latest version of txbugzilla no longer supports these. You must use
API keys now.)Side note: bugzillarcIf you pass no parameters toconnect(), the resulting connection will be
anonymousunlessyou have a special.config/python-bugzilla/bugzillarcfile in your home directory. This file should look something like this:$ cat ~/.config/python-bugzilla/bugzillarc
[bugzilla.redhat.com]
api_key=ABCDEFGHIJKtxbugzilla will look for this file and attempt to use the API key there if one
exists.To construct thisbugzillarcfile:Log into Bugzilla’s web UI with your browser.Go to “Preferences” -> “API Keys”.Generate a new API key.Make the.config/python-bugzilladirectory in your home directory:mkdir -p ~/.config/python-bugzillaEdit thebugzillarcfile in your text editor:cat ~/.config/python-bugzilla/bugzillarc
[buzilla.example.com]
api_key=YOUR_API_KEYExample: Assigning bugsThis will definitely earn you friends.fromtxbugzillaimportconnect,BugzillaExceptionfromtwisted.internetimportdefer@defer.inlineCallbacksdefexample():bz=yieldconnect(api_key='123456abcdef')try:result=yieldbz.assign(1234,'someone@redhat.com')ifresult:print('assigned bz #1234 to someone@redhat.com')else:print('bz #1234 is already assigned to someone@redhat.com')exceptBugzillaExceptionase:print(e)Example: Searching with an upstream bugQuickly find out “What BZ matches this external tracker ticket?”fromtxbugzillaimportconnect,BugzillaExceptionfromtwisted.internetimportdefer@defer.inlineCallbacksdefexample():bz=yieldconnect()try:result=yieldbz.find_by_external_tracker('http://tracker.ceph.com','16673')forbinresult:print(b.weburl+' '+b.summary)exceptBugzillaExceptionase:print(e)Example: Raw XML-RPC callsWant to make someAPI callnot mentioned here?
Use thecall()method to make raw XML-RPC calls. It will take care of API
key authentication for you, too.For example, to see a list of all the groups of which you are a member:fromtxbugzillaimportconnect,BugzillaExceptionfromtwisted.internetimportdeferfrompprintimportpprint@defer.inlineCallbacksdefexample():bz=yieldconnect(api_key='123456abcdef')try:result=yieldbz.call('User.get',{'names':[bz.username],'include_fields':['groups']})pprint(result['users'][0]['groups'])exceptBugzillaExceptionase:print(e)LicenseMIT (seeLICENSE)Packages that use this packagehelga-bugzilla