Created
January 23, 2017 19:47
-
-
Save bgruening/17321f69e35143ffa202d344875a7343 to your computer and use it in GitHub Desktop.
get all biocontainers via Quay.io API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import argparse | |
import json | |
import sys | |
import tempfile | |
try: | |
import requests | |
except ImportError: | |
requests = None | |
QUAY_API_URL = 'https://quay.io/api/v1/repository' | |
parameters = {'public': 'true', 'namespace': 'biocontainers'} | |
r = requests.get(QUAY_API_URL, headers={'Accept-encoding': 'gzip'}, params=parameters, | |
timeout=12) | |
json_decoder = json.JSONDecoder() | |
decoded_request = json_decoder.decode(r.text) | |
for repository in decoded_request['repositories']: | |
rep_name = repository['name'] | |
url = "%s/%s/%s" % (QUAY_API_URL, 'biocontainers', rep_name) | |
r = requests.get(url, headers={'Accept-encoding': 'gzip'}, timeout=12) | |
json_decoder = json.JSONDecoder() | |
decoded_request = json_decoder.decode(r.text) | |
for tag, infos in decoded_request['tags'].items(): | |
print('quay.io/biocontainers/%s:%s\t%s' % (rep_name, tag, infos['size'])) | |
# docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v /share/:/output --privileged -t --rm dk2sin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment