Saturday, August 17, 2019

application development - Access the Ubuntu bug database using launchladlib



I'm trying to write a Python script using launchpadlib that can access the Ubuntu bug database, but I can't find any obvious way to restrict the search to the bugs of a particular project/distro. I know I can access bugs using



bug_one = launchpad.bugs[]


and I can access the Ubuntu distribution using




ubuntu = launchpad.distributions['ubuntu']


but I can't find a way to combine the two so that I can retrieve a list of the bugs affecting Ubuntu. The API reference documentation doesn't mention any attribute of the project or distribution entry relating to the actual bugs (just the bug supervisor), nor does the bug entry make it clear what project it affects. Given the way the functions above work, I would have expected



ubuntu_bugs = launchpad.distributions['ubuntu'].bugs[]


to return a certain bug affecting Ubuntu, but it doesn't and there's no obvious way to do it.




In launchpad there are two different entities:




  • Bugs: General information related to a problem

  • Bug task: Project/Distro specific information: status, importance, assigned to, etc.



Note that a bug is a general concept that might contain multiple tasks that are targeted against milestones for projects and distros. Hence, what you can search for a given project are the bug tasks that have been targeted for that project, not the bugs themselves (you can get the bug for each bug task though).



Hence, the way to look for the bug information would be as follows:




ubuntu = launchpad.distributions['ubuntu']
tasks = ubuntu.searchTasks()
task = tasks[0] # Get one task as an example
task.bug # Display bug for the given task


For more information, please have a look at the API documentation for the searchTasks method (in particular, the status parameter is quite useful).


No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...