Beispiel #1
0
    def handle(self, *args, **options):
        HERE = os.getcwd()
        print "Working directory is", HERE
        ZIP_SERVER = "http://developer.openblockproject.org/raw-attachment/ticket/62"
        ZIP_FILE = "bozip.zip"
        ZIP_URL = "%s/%s" % (ZIP_SERVER, ZIP_FILE)
        ZIP_FOLDER = os.path.join(HERE, 'zip_data')
        makedirs(ZIP_FOLDER) or die("couldn't create %s" % ZIP_FOLDER)

        print "Downloading zip code data..."
        wget(ZIP_URL, cwd=ZIP_FOLDER) or die("Could not download %s" % ZIP_URL)
        zip_path = os.path.join(ZIP_FOLDER, ZIP_FILE)
        unzip(zip_path, cwd=ZIP_FOLDER) or die("failed to unzip %s" % zip_path)

        print "Importing zip codes..."
        from ebpub.db.bin import import_zips
        import_zips.main([ZIP_FOLDER, '-v'])