blob: b68fd5bfcff3b44ed1301b4ea04640bbea1d049a [file] [log] [blame]
Koushik Dutta3a5397d2010-06-27 20:10:23 -07001#!/usr/bin/env python
2import sys, random, urllib2, zipfile, StringIO, os
3from optparse import OptionParser
4
5FILENAME="gapps-passion-FRF83-signed.zip"
6MIRRORS=["http://www.kanged.net/up/files/1/",]
7
8def device():
9 print "usage: extract-google-files -m [method]"
10 print "Note: Device method is currently not implemented, please use download"
11 sys.exit(1)
12
13def download():
14 try:
15 os.makedirs("proprietary")
16 except:
17 pass
18 os.chdir("proprietary")
19 if len(MIRRORS) > 1:
20 i = random.randrange(0, len(MIRRORS)-1)
21 else:
22 i = 0
23 url = MIRRORS[i] + FILENAME
24 print "Fetching from %s" % url
25
26 data = urllib2.urlopen(url).read()
27 zip = zipfile.ZipFile(StringIO.StringIO(data),'r')
28
29 for filename in zip.namelist():
30 if filename.split("/")[0] == "system":
31 print "Extracting %s" % filename
32 zip.extract(filename)
33
34def main():
35 parser = OptionParser(usage="usage: %prog [options]")
36 parser.add_option("-m", "--method", dest='method', default="device", help="Extraction Method: device, download [default: device]")
37 (options, args) = parser.parse_args()
38
39 if options.method == "device":
40 return device()
41
42 if options.method == "download":
43 return download()
44
45if __name__ == '__main__':
46 main()