Access Bugzilla’s XML-RPC API asyncronously (non-blocking) using the Twisted framework.
Simple Example: Fetching a bug
from txbugzilla import connect, BugzillaException
from twisted.internet import defer
from twisted.internet.task import react
@defer.inlineCallbacks
def example(reactor):
# connect() defaults to https://bugzilla.redhat.com/xmlrpc.cgi
bz = yield connect()
# fetch a bug
try:
bug = yield bz.get_bug_simple(10000)
print(bug.summary)
except BugzillaException as e:
print(e)
if __name__ == '__main__':
react(example)
Example: Authentication
By 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 to connect(). The deferred that connect() returns will fire a callback with an authenticated connection.
from txbugzilla import connect
from twisted.internet import defer
@defer.inlineCallbacks
def example():
# Authenticate with an API key
bz = yield connect(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: bugzillarc
If you pass no parameters to connect(), the resulting connection will be anonymous unless you have a special .config/python-bugzilla/bugzillarc file in your home directory. This file should look something like this:
$ cat ~/.config/python-bugzilla/bugzillarc [bugzilla.redhat.com] api_key=ABCDEFGHIJK
txbugzilla will look for this file and attempt to use the API key there if one exists.
To construct this bugzillarc file:
Log into Bugzilla’s web UI with your browser.
Go to “Preferences” -> “API Keys”.
Generate a new API key.
Make the .config/python-bugzilla directory in your home directory:
mkdir -p ~/.config/python-bugzilla
Edit the bugzillarc file in your text editor:
cat ~/.config/python-bugzilla/bugzillarc [buzilla.example.com] api_key=YOUR_API_KEY
Example: Assigning bugs
This will definitely earn you friends.
from txbugzilla import connect, BugzillaException
from twisted.internet import defer
@defer.inlineCallbacks
def example():
bz = yield connect(api_key='123456abcdef')
try:
result = yield bz.assign(1234, 'someone@redhat.com')
if result:
print('assigned bz #1234 to someone@redhat.com')
else:
print('bz #1234 is already assigned to someone@redhat.com')
except BugzillaException as e:
print(e)
Example: Searching with an upstream bug
Quickly find out “What BZ matches this external tracker ticket?”
from txbugzilla import connect, BugzillaException
from twisted.internet import defer
@defer.inlineCallbacks
def example():
bz = yield connect()
try:
result = yield bz.find_by_external_tracker(
'http://tracker.ceph.com', '16673')
for b in result:
print(b.weburl + ' ' + b.summary)
except BugzillaException as e:
print(e)
Example: Raw XML-RPC calls
Want to make some API call not mentioned here? Use the call() 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:
from txbugzilla import connect, BugzillaException
from twisted.internet import defer
from pprint import pprint
@defer.inlineCallbacks
def example():
bz = yield connect(api_key='123456abcdef')
try:
result = yield bz.call('User.get', {'names': [bz.username],
'include_fields': ['groups']})
pprint(result['users'][0]['groups'])
except BugzillaException as e:
print(e)
License
MIT (see LICENSE)
Packages that use this package
Metadata
Release files for txbugzilla 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| txbugzilla-2.1.0.tar.gz | 10.4 kB | Without provenance | Details |
Release files / txbugzilla-2.1.0.tar.gz
| Download URL | txbugzilla-2.1.0.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b9b83459986a47066f5b9b1cd0645828f12fc6b899f380553352ad656db63075
|
|
BLAKE2b-256 checksum How to use checksums |
7c9b686abcaa9f8df4a92a8abd38e2142ff93dc1fa9028bc0a926a90de493e09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.10
|
Security for txbugzilla 2.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.