Skip to content

Instantly share code, notes, and snippets.

@gerito1
Created February 4, 2015 02:52
Show Gist options
  • Save gerito1/66e42f37126112489f0b to your computer and use it in GitHub Desktop.
Save gerito1/66e42f37126112489f0b to your computer and use it in GitHub Desktop.
download.py
def get_latest_os_info():
debugger("Downloading latest OS information")
# we put everything in a try block as urlopen raises URLError
try:
# get latest.json from download.kano.me
response = urllib2.urlopen(LATEST_OS_INFO_URL)
latest_json = json.load(response)
print latest_json
# give the server some time to breathe between requests
debugger('Latest Kano OS image is {}'.format(latest_json['filename']))
time.sleep(1)
image_url = '{base_url}{filename}'.format(
base_url=latest_json['base_url'],
filename=latest_json['filename'])
gz_url = '{image_url}.gz'.format(image_url=image_url)
# use the url for the latest os version to get info about the image
image_info_json = '{image_url}.json'.format(image_url=image_url)
print image_info_json
#Fails here
response = urllib2.urlopen(image_info_json)
os_json = json.load(response)
print os_json
# give the server some time to breathe between requests
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment