foxfirefey: A fox colored like flame over an ornately framed globe (Default)
foxfirefey ([personal profile] foxfirefey) wrote in [site community profile] dw_dev2009-08-01 12:27 pm
Entry tags:

Using PyBugz to access our Bugzilla from the command line

Okay, so, I admit it, I'm kind of a command line lover. I've found this Python program that allows Bugzilla access from the command line, and so far have been liking it. I think [personal profile] sophie is considering installing it on the Dreamhack machine, too. A bit of a walkthrough is available after the cut.

You can download it at GitHub: http://github.com/ColdWind/pybugz/tree/master

Before installing, you'll want to edit bugz/cli.py so that Dreamwidth's Bugzilla is the base:

'base': make_option('-b', '--base', type='string',
    default = 'http://bugs.dwscoalition.org/',
    help = 'Base URL of Bugzilla'),


To install, you can run this command:

sudo python setup.py install

Now it should be up and running; you can see a list of commands by just typing bugz:

Usage: bugz  [parameter(s)] [options..]

Subcommands:
  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
  namedcmd    Run a stored search,

Examples:
  bugz get 12345
  bugz search python --assigned-to liquidx@gentoo.org
  bugz attachment 5000 --view
  bugz attach 140574 python-2.4.3.ebuild
  bugz modify 140574 -c "Me too"
  bugz namedcmd "Amd64 stable"

For more information on subcommands, run:
  bugz  --help


If you use authentication once with -u YOUREMAIL, it'll ask for your password and you don't have to enter it in again.

It can be quite flexible. For instance, here is a search that finds everything open that is assigned to me:

bugz search -a skittisheclipse@gmail.com


The output is:

 * Using http://bugs.dwscoalition.org/ 
 * Searching for bugs with the following options:
 *    assigned_to          = skittisheclipse@gmail.com
 * Already logged in.
28 skittisheclipse      Download CSV of poll results
31 skittisheclipse      Expand all comments on page
168 skittisheclipse      New implementation to overriding other users style choices.
476 skittisheclipse      Make site scheme menus available to S2
489 skittisheclipse      Turn User section of /stats.bml into a matrix
823 skittisheclipse      Update viewer_is for access/subscribe instead (S2.pm)
852 skittisheclipse      Atom Publishing Protocol Implementation Out of Date
991 skittisheclipse      OpenID 2.0 is not supported.
1369 skittisheclipse      add an inbox area for "Unread items"
1474 skittisheclipse      Add view=flat to comment pages
1475 skittisheclipse      Make a search module for S2
 * 11 bug(s) found.


I have that as a named search though, so I could also search for it by search name:

bugz namedcmd "To Do"


Then, if I want more information on a particular bug, I can do:

$ bugz get 31
 * Using http://bugs.dwscoalition.org/ 
 * Getting bug 31 ..
 * Already logged in.
Title       : Expand all comments on page
Assignee    : skittisheclipse@gmail.com
Reported    : 2008-07-25 16:22
Updated     : 2009-03-05 16:14:28
Status      : ASSIGNED
Severity    : trivial
Priority    : P4
Reporter    : denise@dreamwidth.org
Product     : Dreamwidth Development
Component   : Misc UI/Frontend
Keywords    : effort-minor, paiduser-enhancement, why-usability
CC          : denise@dreamwidth.org
CC          : skittisheclipse@gmail.com
Comments    : 1
Attachments : 0
URL         : http://bugs.dwscoalition.org/show_bug.cgi?id=31


[Comment #0] denise@dreamwidth.org : 2008-07-25 16:22:59
----------------------------------------------------------------
For users who are permitted (by account type) to use the "expand comment thread" AJAX,
there should also be an "expand all comments on page" option.


I can use it to search all new, effort minor bugs, too:

bugz search -k effort-minor -s NEW


Another spiffy thing is I can use it to fetch attachments to bugs:

$ bugz attachment 1833
 * Using http://bugs.dwscoalition.org/ 
 * Getting attachment 1833
 * Already logged in.
 * Saving attachment: "bug1475.patch"


Unfortunately, I haven't been able to get it to set the status of a bug to assigned when assigning it to myself using bugz, and I don't really have the time to fiddle with it now to figure out why. I also want to be able to have it pick a random bug from a search and make it so that I can submit an attachment with all the options we need for an attachment submission, like our ispatch and review and commit flags. It'd probably be a good idea to remove the specific Gentoo repository things, too. So, if you like Python and would like to make bugz even better for us, feel free to tinker! If you get things to work, maybe we could set up a fork repository for the changes and have a DW version of it.
pne: A picture of a plush toy, halfway between a duck and a platypus, with a green body and a yellow bill and feet. (Default)

[personal profile] pne 2009-08-03 10:58 am (UTC)(link)
You might want to replace <code> with </code> after sudo python setup.py install.

Edit: how annoying; <ins> appears to have been overridden so you can't see any difference.
Edited 2009-08-03 10:59 (UTC)