Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Script for downloading all available AirPort device firmwares
#!/usr/bin/env python
import errno
import os
import plistlib
import sys
import urllib
def makedirs_if_absent(path):
except OSError as exception:
if exception.errno != errno.EEXIST:
#XXX: not really doing much to check the invocation yet
if len(sys.argv) != 2:
print "Usage: [destination path]"
# start out with the version plist
#TODO: should also grab version.xml.signature and verify our copy of the plist
(version_file, junk) = urllib.urlretrieve("")
version_plist = plistlib.readPlist(version_file)
# available keys are "AirPortUtility", "AirPortUtilityWin", and "firmwareUpdates"
# we only care about the last one right now
for fw_dict in version_plist["firmwareUpdates"]:
fw_productid = fw_dict["productID"]
fw_url = fw_dict["location"]
fw_filename = fw_url.rsplit("/", 1)[1]
fw_dir = os.path.join(sys.argv[1], fw_productid)
fw_path = os.path.join(fw_dir, fw_filename)
print "Downloading {0}".format(fw_url)
urllib.urlretrieve(fw_url, fw_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment