#!/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()
