I am working on the Snap! C++ project which manages many packages with a complex set of dependencies (see picture below).
So as a result I need the build of package A to be complete before I can run the build of package B. I'd like to at least semi-automate the build process and for that I would need to know, programmatically, that package A is done building. I can then verify that the build worked (that I know how to do) and if so, I can send the sources of package B and get that build started.
I found pages about the Launchpad API and I downloaded the python scripts that they offer to access the server. However, I'm not that good in python and I'm not too sure what API call I need to use. I found this huge page with what I would assume are all the calls, but I was not able to find a simple example of how to get the current build status for a specific project. Maybe getBuildQueueSizes
? But looking at the launchpadlib
Python project files, I could not find any such name in the code. So I'm not too sure how that works.
Would you have sample code you would share with us that does at least that much? Or a place where there would be an example on the Launchpad.net website?
At this point, my script connects... what do I do next?
# See API here
# https://launchpad.net/+apidoc/devel.html
from launchpadlib.launchpad import Launchpad
from os.path import expanduser
home = expanduser('~')
cachedir = home + '/.launchpadlib/cache/'
launchpad = Launchpad.login_anonymously('snapcpp', 'production', cachedir, version='devel')
If possible too, just a URI would be great. From what I can see here and there, it would be possible to simply emit an HTTP GET
to a URI and get a JSON in return with all the necessary info. What I don't see is what that URI would be. I tried several from what I've see in the docs (with super heavy examples... NOT):
https://api.launchpad.net/devel/snapcpp?ws.op=getBuildRecords&source_name=libtld
This one tells me that getBuildRecords
is not a command. In most cases, though, I get a 400 or 404. The project URL works, but all the links shown in the JSON do not help:
https://api.launchpad.net/devel/snapcpp
Testing some more, I found out I could search some builds with:
https://api.launchpad.net/devel/ubuntu/bionic?ws.op=getBuildRecords&source_name=lib
But if I try to use my project names as the source_name=...
parameter (a.k.a. "libtld" or "snapcpp"), it returns an empty list. This last URL also works with just /ubuntu?...
or with an architecture /ubuntu/bionic/amd64?...
. But that doesn't help.
I think this may be a bug so I reported on Launchpad.
launchpadlib
is a relatively thin layer over the underlying Launchpad API, and the actual operations are implemented in Launchpad. As such, you will not in general find any mention of individual API methods by looking inlaunchpadlib
's source code.Your problem here is that you're asking Launchpad questions about
/snapcpp
(a project, which is not formally related to your PPA as far as Launchpad is concerned), or about/ubuntu/bionic
(an Ubuntu series, which will only tell you about builds that are part of the official OS), rather than about your PPA. The correct URL would be:Or in
launchpadlib
-based code, something like this: