# create-customization-key.py # Chris Ball # # Usage: Run inside a customization key directory, populate the bundles/ # dir for the key; see http://wiki.laptop.org/go/Customization_key import urllib import re import sys from os.path import isdir def usage(): print "Usage: create-customization-key (g1g1|all|mexico|peru)" sys.exit(0) # Constants. REPO_URL = "http://mock.laptop.org/repos/local.update1/XOS/" G1G1 = ["AcousticMeasure", "Analyze", "Calculate", "Chat", "Etoys", "Log", "Measure", "Memorize", "NewsReader", "Paint", "Pippy", "Read", "Record", "TamTamEdit", "TamTamJam", "TamTamMini", "TamTamSynthLab", "Terminal", "TurtleArt", "Web", "Write"] MEXICO = G1G1 + ["BlockParty", "ClockActivity", "Connect", "Implode", "Maze", "Ruler", "Scratch", "Speak", "StopWatchActivity", "TurtleArtwithSensors"] MEXICO.remove("TurtleArt") PERU = MEXICO + ["JigsawPuzzle", "SliderPuzzle", "XaoS"] PERU.remove("BlockParty") if len(sys.argv) != 2: usage() # Create a list of available activities. response = urllib.urlopen(REPO_URL + "index.html") index = response.read() link = re.compile('.* int(bundles[activity]): bundles[activity] = ver else: bundles[activity] = ver if sys.argv[1].lower() == 'peru': contents = PERU elif sys.argv[1].lower() == 'mexico': contents = MEXICO elif sys.argv[1].lower() == 'g1g1': contents = G1G1 elif sys.argv[1].lower() == 'all': contents = [k for k in bundles.iterkeys()] else: usage() # Are we in a customization key root? if not isdir("bundles"): print "No bundles/ directory -- are we in the root of a customization key?" sys.exit(0) # Does the repo contain all the activities asked for? for act in contents: if not act in bundles: print act + " is not in the repository!" sys.exit(0) # Perform the downloads. for activity in sorted(contents): filename = activity + "-" + bundles[activity] + ".xo" try: urllib.urlretrieve(REPO_URL + filename, "bundles/" + filename) except IOError, msg: print "Download failed: " + msg sys.exit(0) print "Downloaded %s-%s" % (activity, bundles[activity]) print "Done."