These days I often use launchpadlib in my projects for scripting access/modifications in Launchpad. While launchpadlib has quite a good API documentation, this only covers the method calls, not the attributes or collections. So it often takes some poking and trying until you figure out how to access/change things.
I found myself typing the same things over and over, so I finally wrote a little script called lpshell:
#!/usr/bin/python -i
import code, os, sys
from launchpadlib.launchpad import Launchpad, STAGING_SERVICE_ROOT, EDGE_SERVICE_ROOT
lp = Launchpad.login_with('test', STAGING_SERVICE_ROOT)
This logs into Launchpad and gives you an interactive Python shell with an “lp” object:
$ lpshell >>> lp.bugs[439482].duplicate_of
Update: I committed this to ubuntu-dev-tools now, renamed to lp-shell for consistency with the other lp-* commands.
#1 by sil on 2010/01/13 - 03:01
Zitieren
blimey, #!/usr/bin/python -i. I didn’t know about that. That’s a really nice technique
#2 by Markus Korn on 2010/01/13 - 10:00
Zitieren
Some time ago I started a project called ilaunchpad-shell [0], which is a customized ipython shell for exactly the same purpose, making access to launchpad via launchpadlib easier. Maybe this is useful for you too. It has some shortcuts for frequently used things, basic integration of the apidoc, a debug mode which prints httplib2 debug messages and exceptionhook for launchpadlib’s HTTPErrors to print all useful information.
[0] https://edge.launchpad.net/ilaunchpad-shell
#3 by Matt Zimmerman on 2010/01/13 - 13:04
Zitieren
Nice one! It would be great to see this little gem in a Launchpad tools package in Ubuntu.
#4 by pitti on 2010/01/13 - 15:36
Zitieren
Indeed, I committed/uploaded to ubuntu-dev-tools now.
#5 by Andrea Corbellini on 2010/01/14 - 18:56
Zitieren
Just a tip: you can also put that code in a RC file for the Python console, so you can access your “lp” object in every Python console, without needing to run “lpshell”.
#6 by Michael Bienia on 2010/01/15 - 18:00
Zitieren
There is also “Interactive Launchpad Shell” (https://edge.launchpad.net/ilaunchpad-shell).
#7 by Markus Korn on 2010/01/17 - 18:25
Zitieren
hmm, I thought I commented on this post last week, but maybe something went wrong.
All I wanted to say is: some time ago I started ilaunchpad-shell [0], which is a customized ipython shell with similar purpose than lpshell. It has a few shortcuts for frequently used code, basic apidoc integration and an exception hook for launchpadlib’s HTTPErrors which prints all relevant information in a nice way.
[0] https://launchpad.net/ilaunchpad-shell