Created
February 4, 2015 02:52
-
-
Save gerito1/66e42f37126112489f0b to your computer and use it in GitHub Desktop.
download.py
This file contains hidden or 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
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