liquidx / works / PyBugz

PyBugz is a python and command line interface to Bugzilla.

It was conceived as a tool to speed up the workflow for Gentoo Linux developers and contributors when dealing with bugs using Bugzilla. By avoiding the clunky web interface, the user quickly search, isolate and contribute to the project very quickly. Developers alike can easily extract attachments and close bugs all from the comfort of the command line.

PyBugz is written in Python and written in a way to be extended easily for use on other Bugzillas. I've tested the code unmodified on XenSource Bugzilla and GNOME Bugzilla.

For more information, check out the Google Code project post.


PuBugz requires ElementTree and Python 2.4.


##Example Workflow

The command line program is named bugz:

liquidx@qoo $ bugz
Usage: bugz <subcommand> [parameter(s)] [options..]

  -b, --base <bugzilla_url>    Bugzilla base URL
  -u, --user <username>        User name (if required)
  -p, --password <password>    Password (if required)
  -f, --forget                 Do not remember authentication
  --columns <columns>          Number of columns to use when
                               displaying output

  search      Search for bugs in bugzilla
  get         Get a bug from bugzilla
  attachment  Get an attachment from bugzilla
  post        Post a new bug into bugzilla
  modify      Modify a bug (eg. post a comment)
  attach      Attach file to a bug

By default, bugz uses as the Bugzilla Base URL (--base), but you can customise it to other bugzillas too:

$ bugz --base '' search google
 * Using ..
 * Searching for "google" ordered by "number"
 142505   Invite google to index bugs
 331250 rhythmbox            Add lookup on music/wikipedia/allm
 338341 Evolution            needs 'agenda view' like google calendar

To search, we can simply use the following to get a list of bugs.

$ bugz search bluetooth
 * Using ..
 * Searching for "bluetooth" ordered by "number"
  91558 liquidx              new ebuilds:bluetooth-alsa-1.6-r2.ebuild btsco-0.4
 110221 docs-team            Add section about OBEX on the command line to the
 111151 maintainer-wanted    [REQ] ebuild for the GNOME Bluetooth control remot
 124149 maintainer-wanted    kxdocker-bluetooth-1.0.0.ebuild
 137590 mobile               net-wireless/bluez-utils - /lib/udev/
 138277 kde                  kdebluetooth-1.0_beta1-r2 fails to compile with st
 142393 liquidx              [PATCH] net-wireless/bluez-libs - bluetooth.h does

If we want to read one of the bugs, we refer to it by name:

$ bugz get 142393
 * Using ..
 * Getting bug 142393 ..
Title       : [PATCH] net-wireless/bluez-libs - bluetooth.h doesn`t compile cleanly with -std=iso9899:1990 flag
Assignee    :
Reported    : 2006-08-01 02:25 PST
Updated     : 2006-08-02 04:14:59 PST

You can also get an attachment by number:

$ bugz get 71123 | grep -i attach
[Attachment] [76050] [bluez-pin-0.30.ebuild]
$ bugz attachment 76050

If we've fixed the bug, we can always close it by modifying the bug:

$ bugz modify 12344 --fixed -c "Thanks for the patch. Committed to portage."

Finally, for users, if they want to report a bug, they can do it via:

$ bugz post

If authentication is required, the interface will prompt for a username and password, or if you would like to use bugz in a script, it can be passed as command line argument.

$ bugz -u liquidx -p secretpassword get 1234

And finally, if you would like to restrict the output width, you can use --columns:

$ bugz --columns 50 get 1234

##Advanced Gentoo Workflow

Here is typically how I use bugz in my day-to-day Gentoo hacking.

First I might search for bugz that are assigned to me:

$ bugz search --assigned-to

Maybe I'm bit lazy and want to do version bumps:

$ bugz search --assigned-to --severity enhancement

So I've got a bug here for bluez-libs:

$ bugz get 143154

After reading the bug I decide that I will bump the package:

$ cd /usr/portage/net-wireless/bluez-libs 
.. bump new package ..
$ emerge bluez-libs
$ ekeyword \~all bluez-libs-3.1.ebuild
.. testing ..
$ repoman commit -m "version bump (#143154)"

Then I should close the bug and inform the reporter

$ bugz modify 143154 --status RESOLVED --resolution FIXED -c
"thanks for your report, the new version is in portage"

Or actually, we can simplify that to:

$ bugz modify 143154 --fixed -c "thanks, in portage."

Rinse. Wash. Repeat.