From 40a64b041ea03797a66834c6a251bd4374292548 Mon Sep 17 00:00:00 2001 From: ctso Date: Fri, 25 Jun 2010 03:10:02 +0000 Subject: [PATCH] Added an extract-google-files script (python) --- extract-google-files | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 extract-google-files diff --git a/extract-google-files b/extract-google-files new file mode 100755 index 00000000..b68fd5bf --- /dev/null +++ b/extract-google-files @@ -0,0 +1,46 @@ +#!/usr/bin/env python +import sys, random, urllib2, zipfile, StringIO, os +from optparse import OptionParser + +FILENAME="gapps-passion-FRF83-signed.zip" +MIRRORS=["http://www.kanged.net/up/files/1/",] + +def device(): + print "usage: extract-google-files -m [method]" + print "Note: Device method is currently not implemented, please use download" + sys.exit(1) + +def download(): + try: + os.makedirs("proprietary") + except: + pass + os.chdir("proprietary") + if len(MIRRORS) > 1: + i = random.randrange(0, len(MIRRORS)-1) + else: + i = 0 + url = MIRRORS[i] + FILENAME + print "Fetching from %s" % url + + data = urllib2.urlopen(url).read() + zip = zipfile.ZipFile(StringIO.StringIO(data),'r') + + for filename in zip.namelist(): + if filename.split("/")[0] == "system": + print "Extracting %s" % filename + zip.extract(filename) + +def main(): + parser = OptionParser(usage="usage: %prog [options]") + parser.add_option("-m", "--method", dest='method', default="device", help="Extraction Method: device, download [default: device]") + (options, args) = parser.parse_args() + + if options.method == "device": + return device() + + if options.method == "download": + return download() + +if __name__ == '__main__': + main()