BugHelperPLBClass

Notes for Ubuntu Developer Week class on 2008-02-21

I'm going to make an educated guess as to why you all are here. It's because you want to know how the bughelper suite and python launchpad bugs can help you! Well, Markus and I intend to tell you how it can.

If you want to tryout the examples we provide in our session, please install bughelper and python-launchpad-bugs. Some of the examples will only work with the latest versions of this tools. To get these versions please add

to your /etc/apt/sources.list, and replace 'hardy' with the version of ubuntu you use. Then run

  • sudo apt-get update sudo apt-get install bughelper python-launchpad-bugs

That's all preparation we need, let's start the session!

Python-launchpad-bugs is a python interface to work with bugs, and blueprints, in Launchpad. While bughelper is a suite of utilities that uses python-launchpad-bugs to help you find specific bugs in Launchpad. We'll start off talking about the bughelper suite and then move on to python-launchpad-bugs.

The bughelper suite is comprised of buginfo, bugnumbers and bughelper.

buginfo is designed for reporting information about one specific bug

  • buginfo --title 38442 will just return the bug's title
  • it provides an easy interface for accessing information about a single bug

bugnumbers is designed for returning a list of bugs based off a query of a list of bugs

  • starting points for a query are
    • the initial starting point of a query was -p <package> in Ubuntu or -l for a url (of a search in Launchpad) this has been expanded to include

    • -D a Distro
    • -P a project in Launchpad
  • you can then filter based on features in Launchpad and some not in Launchpad
    • some features not in Launchpad are querying on the number of duplicates, subscribers, comments, attachments, the date or author of the last comment and the reporter
    • For example lets say I'm the gdm maintainer and I know Brian Murray reports some useful bug reports I could find all the bugs he's reported using 'bugnumbers -p gdm --reporter=brian-murray' or if I wanted just the new ones I could add that as a filter too so 'bugnumbers -p gdm --reporter=brian-murray --status New'
    • Another example is xorg bug reports which should always contain 2 attachments /etc/X11/xorg.conf and /var/log/Xorg.0.log. We could look for New bug reports with more than 1 attachment using 'bugnumbers -p xorg --na ">1"' to find "more complete" bug reports that might be worth triaging first.

    • I run reports on busy packages for bugs with more than 2 duplicates, more than 5 subscribers and more than 5 comments at http://people.ubuntu.com/~brian/reports/

  • you can also modify the output of bugnumbers - formats available are
    • plain - ex 120269 (Confirmed, Low) - Gnome hides utility windows in fullscreen mode
    • numbers - just the bug numbers
    • url - urls linking to the bug numbers
    • wiki - formatted in moinmoin markup for wiki.ubuntu.com
    • bugday - (bzr only) formatted for the Ubuntu bug days
    • html - same info as in plain but marked up for html
    • it is also quite easy to add a new format if you want they are located in bugHelper/format/
  • additionally bugnumbers can report on stats about your package / project
    • bugnumbers -p gnome-power-manager --stats -C
    • the -C also includes the Closed bug reports - this is what I use to generate the data for the bug graphs

Questions?

bughelper searches bug reports for a specific string and provides you with a clue about that bug report

  • as an example lets use update-manager it has a few bug reports so we'll reduce the set to New bugs only
    • bughelper -p update-manager --status New
    • bughelper will search all New update-manager bug reports for the information defined in the update-manager.info and then return a "clue" as to what the bug may be about
    • the update-manager query I mentioned returned:

    http://launchpad.net/bugs/191834 [update-manager (Ubuntu): New/Undecided] - This is expected when someone is running a development release of Ubuntu

    • Looking at the clue file the string that matched was "Could not calculate the upgrade" which appears in bug 191834 and we are reminded that this is normal behavior if someone is running the development release of Ubuntu
      • unfortunately this person isn't and this is a terrible example
    • bughelper also can search attachments of bug reports which is quite useful for crash reports
  • clue files use a separate bzr branch bughelper-data and are stored on your local disk in ~/.bughelper/packages
  • ~/.bughelper/packages is created by bughelper automatically after its first run
  • let's have a look at '~/.bughelper/packages/bughelper.info' as an example.
    • this file is also online at http://tinyurl.com/2zwm7a

    • as you can see clue-file are in a xml format and can contain multiple clues
    • you can combine operations by using logical operators like 'and' or 'or'
    • Regular Expressions are also supported as you can see in the first clue, this clue matches all bugs with 'importance' set to 'Undecided' and which are tagged with 'xpath' or 'commandline'
    • clue files can also inherit clues from another package and can be used to manage bug workflow
    • the kernel team wants bugs that are confirmed or triaged assigned to one of their team and we can see a clue file for this at http://tinyurl.com/2wc2r

Questions?

python-launchpad-bugs

python-launchpad-bugs allows you to access bugs.launchpad.net via python. This python module is used by many tools like apport, ubuntu-dev-tools and of course bughelper and bugnumbers.

Let me give you a short "Howto" on using python-launchpad-bugs. This requires some basic understanding of python.

Let's start a python session and do some general preparation:

  • >>> import launchpadbugs.connector as Connector >>> from launchpadbugs.basebuglistfilter import URLBugListFilter

Ok, so far so good, let's get a list of all open bugs in the bughelper project

Each member of this list has attributes like 'bugnumber', 'url', 'status' and 'importance'.

Getting filtered lists is also very easy:

It's also possible to use any python functions as a filter, but this would go too far right now.

Okay, that's all about bug lists for now, for more information please visit http://tinyurl.com/yrmze9

Now, let's have a look on how to handle bugreports with python-launchpad-bugs:

  • >>> Bug = Connector.ConnectBug() >>> b = Bug(123456)

The argument of Bug() can either be a bug number, an url of a bugreport or an element of a BugList-object

There is a huge amount of attributes of a bug-object. You can access almost all information of a bugreport. Let's have a look at some examples:

For a list of all attributes of a Bug-object and some examples on using these attributes have a look at http://tinyurl.com/2mboze

So far, we have only read bugs, but with python-launchpad-bugs you can also change bugreports in a very easy way! First of all, only registered user can change bugreports in launchpad, so let's authenticate with our account data:

  • >>> Bug.authentication = {"password":"<your-password>","email":"<your-login-email>"}

There is also another possibility of authentication: you can use a mozilla cookie-file (this for example works for cookies created by epiphany or firefox < 3.0)

  • >>> Bug.authentication = "/path/to/the/cookiefile/cookie.txt"

Now I want to show you, as an example, how to change the status of a bug:

  • >>> demo = Bug(193948) >>> demo.status 'New' >>> demo.status = "Invalid" >>> demo.commit()

Until you call the 'commit()'-method all changes are local, with 'commit()' you try to commit all changes you did locally to launchpad. Like this you can for example change the description, add comments or attachments, subscribe to a bug or change the tags.

Let's have a look at two more complex examples. You can get this scripts here: https://wiki.ubuntu.com/BugHelper/Dev/python-launchpad-bugs/Examples These two scripts show you how to use python-launchpad-bugs to do things you can't do in launchpad itself.

Let's say you are a developer of an upstream project in launchpad. When you create a package of your tool and build it for ubuntu, bugs in ubuntu are closed by the (LP: #123456) syntax, but upstream bugs are not. The first example also closes this upstream bugs in your project and adds a comment containing the changelog-entry.

I wrote the second example few days ago when we had all these python-central bugreports. This example returns you a list of bugs created in ubuntu after 2008-02-18 and filters this list by the following criteria:

  • 'pycentral' or 'python-central' in the content of the bugreport
  • an attachment called 'DpkgTerminalLog.gz' which contains 'pycentral' or 'python-central'

As a last example I want to show you how to create a bugreport with python-launchpad-bugs, it's only one line of code!

  • >>> b = Bug.New(

  • .. product = {"name":"buglog-data"},
  • .. summary = "this class is almost over",
  • .. description = "UDW rocks! - but we need more time to show all features of bughelper and py-lp-bugs")

This creates a new bugreport in the 'buglog-data'-project, if you would like to file a bugreport in ubuntu use

  • 'product = {"target": "ubuntu", "name": "my-package"}'

Ok, that's all about python-launchpad-bugs for now, time for some questions!

If you would like to use bughelper and/or python-launchpadbugs and have any questions, or even better if you want to help us improving this two packages, this are ways to get in with us:

QATeam/BugHelperPLBClass (last edited 2008-08-06 16:39:58 by localhost)