BugHelperPLBClass

Differences between revisions 3 and 4
Revision 3 as of 2008-02-21 09:39:17
Size: 5465
Editor: a89-182-26-76
Comment:
Revision 4 as of 2008-02-21 11:50:40
Size: 9196
Editor: a89-182-26-76
Comment:
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:
   deb http://ppa.launchpad.net/bughelper-dev/ubuntu hardy main   deb http://ppa.launchpad.net/bughelper-dev/ubuntu hardy main
Line 10: Line 10:
   sudo apt-get update
   sudo apt-get install bughelper python-launchpad-bugs
  sudo apt-get update
  sudo apt-get install bughelper python-launchpad-bugs
Line 55: Line 55:
 * ~/.bughelper/packages is created by bughelper automatically after its first run
 * let's have a 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 different 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'
    * ~/.bughelper/packages is created by bughelper automatically after its first run
    * let's have a 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 different 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'
Line 62: Line 62:
python-launchpad-bugs bit
    * features accessible via python-launchpad-bugs
        * tags, status, importance ...
== 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
    >>> BugList = Connector.ConnectBugList()
    >>> bl = BugList("https://bugs.launchpad.net/bughelper/+bugs")
Each member of this list has attributes like 'bugnumber', 'url', 'status' and 'importance'.

Getting filtered lists is also very easy:
    >>> bug_filter = URLBugListFilter()
    >>> bug_filter.add_option("status", ("New","Confirmed"))
    >>> bug_filter.add_option("importance", ("Medium",))
    >>> bl = BugList(bug_filter("https://bugs.launchpad.net/bughelper/+bugs"))
It's also possible to use arbitrary 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 = 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:
    >>> b.url
    'https://bugs.launchpad.net/ubuntu/+source/xine-lib/+bug/123456'
    >>> print b.subscriptions
    set([<user ken-paulsen (Valyander)>, [...], <user kubuntu-sujee (LinuxLover)>])
    >>> print b.comments
    [<Comment #1 by kubuntu-sujee on 2007-07-03 07:17:39 UTC>,[...],<Comment #6 by bersace on 2007-09-30 22:04:49 UTC>]
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>"}

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.

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!
Line 67: Line 125:
    * bughelper has a separate mailing list
    * code available at ...
    * bughelper has a separate mailing list, bughelper@l.u.c
    * browse https://launchpad.net/python-launchpad-bugs and https://launchpad.net/bughelper to file bugreports or get the code
    * for more information check out our wiki pages at https://wiki.ubuntu.com/BugHelper
    * and last but not least ping us in #ubuntu-bugs

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's really kind of boring but there you have it

bugnumbers is designed for reporting and querying lists of bugs

  • starting points for a query are
    • -p a package
    • -D a Distro
    • -P a project in Launchpad
    • -l or a url of a search 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 than 2 attachments using 'bugnumbers -p xorg --na "=2"' 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 control 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

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 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 different 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'

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 arbitrary 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:

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

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.

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!

How you can participate

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