Scripting around your Launchpad project

Slashdot it! Delicious Share on Facebook Tweet! Digg!

The Launchpad Shell

Sometimes a convenient way to access the Launchpad API without having to write a complete script is needed. Think of it this way: You want to quickly gather data about several packages in a PPA. Doing it manually through the web browser would be tedious, whereas writing a separate script would be pointless if you only plan on doing that once. The good news is that a convenient tool lets you perform LP API calls from a Python interpreter: the lp-shell . Ubuntu users can easily get this tool through the lptools package available in universe.

sudo apt-get install lptools

The lp-shell script is easy to use – just run it from a terminal and a Python interpreter ready for LP API usage is now available for work. Just use the predefined lp variable, which has the Launchpad object initialized (Figure 3).

Figure 3: Interactive Launchpad shell.

By default lp-shell uses login_with() , so whenever you use the LP object, a login request will be initialized in your browser. If you want to use anonymous access instead, just run lp-shell with the -a command-line argument.

The interactive shell also supports some additional parameters. By default, the 1.0 LP API is used, so to get the latest API changes, you need to specify the API version in the command line instead.

lp-shell production devel

The first argument is always the Launchpad service to be used – it can be either production or staging. The second one is the API level to use. In most cases, devel is preferred because, as mentioned previously, the stable APIs are currently outdated, missing out on many of the interesting features and fixes.

Final Words

The LP API is vast and very useful for any advanced Launchpad user with basic Python knowledge. All this was made possible by the great Launchpad team working tirelessly on bug fixes and feature improvements. Big thanks to them for all their awesome work! Because Launchpad now supports both Bazaar and Git for code hosting, why not give it a try for your own project?

Infos

  1. Launchpadlib setup and basic tutorial: https://help.launchpad.net/API/launchpadlib
  2. Launchpad API documentation for the devel API version: https://api.launchpad.net/devel

Buy this article as PDF

Express-Checkout as PDF

Pages: 3

Price $0.99
(incl. VAT)

Buy Ubuntu User

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content