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

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

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

Questions?

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

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:

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:

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:

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)

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

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:

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!

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

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)