Hi,
There are many scripts in use that parse the web interface for snapshots and releases.linaro.org. This is far from ideal because changes to the web interface can result in the scripts breaking. To alleviate this problem an API has been introduced. The API is very simple, just two new URLs and a new header when downloading files.
<server>/api/ls/<path to file> returns a JSON document containing all the data shown by a file listing on the web interface. It can target either a directory of a file.
<server>/api/license/<path to file> returns a JSON document containing the licence information for the file pointed to. Both the license text and the digest used to accept the license are returned. Including the digest means that the choice of digest used internally can change without re-writing clients - to the client this is just a magic string and they don't need to care how it is generated.
When downloading a file you simply include the header LICENSE_ACCEPTED, its value being a space separated list of license digests representing the licenses that you have accepted.
e.g. (license text and digest removed for brevity)
http://snapshots.linaro.org/api/ls/quantal/hwpacks/snowball/latest { "files": [ { "mtime": "15-Mar-2013 08:29", "name": "hwpack_linaro-snowball_20130315-269_armhf_supported.manifest.txt", "size": "762", "type": "text", "url": "/quantal/hwpacks/snowball/latest/hwpack_linaro-snowball_20130315-269_armhf_supported.manifest.txt" }, { "mtime": "15-Mar-2013 08:31", "name": "hwpack_linaro-snowball_20130315-269_armhf_supported.tar.gz", "size": "18.1M", "type": "other", "url": "/quantal/hwpacks/snowball/latest/hwpack_linaro-snowball_20130315-269_armhf_supported.tar.gz" } ] }
http://snapshots.linaro.org/api/license/quantal/hwpacks/snowball/latest/hwpa... { "licenses": [ { "text": "license text...", "digest": "license digest..." } ] }
wget --header="LICENSE_ACCEPTED: license digest..." http://snapshots.linaro.org/quantal/hwpacks/snowball/latest/hwpack_linaro-sn...
There is a example client script that illustrates how to use the API here: http://bazaar.launchpad.net/~linaro-automation/linaro-license-protection/tru...
Usage: download.py <URL>
If URL points to a directory all files are downloaded. If URL points to a file, just that file is downloaded.
It prints the license(s) for each file and waits for the user to accept each one. It also stores which licenses the user has accepted so they don't need to be re-accepted if the text hasn't changed.
W dniu 26.03.2013 15:18, James Tunnicliffe pisze:
There are many scripts in use that parse the web interface for snapshots and releases.linaro.org. This is far from ideal because changes to the web interface can result in the scripts breaking. To alleviate this problem an API has been introduced. The API is very simple, just two new URLs and a new header when downloading files.
Thanks for API - it will make live easier.
I tried it today and have few suggestions:
http://snapshots.linaro.org/api/ls/quantal/hwpacks/snowball/latest { "files": [ { "mtime": "15-Mar-2013 08:29", "name": "hwpack_linaro-snowball_20130315-269_armhf_supported.manifest.txt", "size": "762", "type": "text", "url": "/quantal/hwpacks/snowball/latest/hwpack_linaro-snowball_20130315-269_armhf_supported.manifest.txt" },
1. Please return 'mtime' as timestamp so we do not have to parse date. 2. Similar with 'size' which should be in bytes. 3. Can 'type' entry be MIME data? text/plain, text/html, application/x-tgz etc. Now it is 'text' or 'other'.
On 2 April 2013 10:02, Marcin Juszkiewicz marcin.juszkiewicz@linaro.org wrote:
W dniu 26.03.2013 15:18, James Tunnicliffe pisze:
There are many scripts in use that parse the web interface for snapshots and releases.linaro.org. This is far from ideal because changes to the web interface can result in the scripts breaking. To alleviate this problem an API has been introduced. The API is very simple, just two new URLs and a new header when downloading files.
Thanks for API - it will make live easier.
I tried it today and have few suggestions:
http://snapshots.linaro.org/api/ls/quantal/hwpacks/snowball/latest { "files": [ { "mtime": "15-Mar-2013 08:29", "name": "hwpack_linaro-snowball_20130315-269_armhf_supported.manifest.txt", "size": "762", "type": "text", "url": "/quantal/hwpacks/snowball/latest/hwpack_linaro-snowball_20130315-269_armhf_supported.manifest.txt" },
- Please return 'mtime' as timestamp so we do not have to parse date.
- Similar with 'size' which should be in bytes.
- Can 'type' entry be MIME data? text/plain, text/html,
application/x-tgz etc. Now it is 'text' or 'other'.
Thanks for the suggestions. Should have something out later today.