#!/usr/bin/python """ Mozilla Automatic Update Service Configurator This script knows about a list of releases and update paths in a database, and can generate a tree of static update.xml files or AUS2-format "snippet" configration files. """ import getopt, sys from database import DatabaseHandler from input.files import Aus2Snippet from output.files import Xml def usage(): print "Usage: aus [OPTION]... ..." print "Import to, export from and configure AUS database." print "Example: aus --import ../incoming" print print "-h, --help for help" print "-i, --import AUS2 snippet incoming directory to import from" print "-e, --export Export to tree of XML files" def main(argv): aus2_incoming = None try: opts, args = getopt.getopt(argv, "hie", ["help", "import", "export"]) for opt, arg in opts: if opt in ("-h", "--help"): usage() sys.exit() elif opt in ("-i", "--import"): if len(args) != 1: print "Argument required." usage sys.exit(2) aus2_incoming = args[0] elif opt in ("-e", "--export"): dbToXml() except getopt.GetoptError: usage() sys.exit(2) if aus2_incoming != None: ausToDb(incoming_dir=aus2_incoming) def ausToDb(incoming_dir): db = DatabaseHandler("aus") imp = Aus2Snippet() for release in imp.run(incoming_dir = incoming_dir): complete_patch_id = None partial_patch_id = None update_id = None update = release.getUpdate() complete_patch = update.getCompletePatch() partial_patch = update.getPartialPatch() if complete_patch != None and partial_patch != None: complete_patch_id = db.setPatch(complete_patch) partial_patch_id = db.setPatch(partial_patch) update_id = db.setUpdate(update, complete_patch_id, partial_patch_id) db.setRelease(release, update_id) def dbToXml(): xml = Xml() xml.run() if __name__ == "__main__": main(sys.argv[1:])