forked from iGhibli/iOS-DeviceSupport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.py
executable file
·46 lines (40 loc) · 1.24 KB
/
deploy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
import argparse
import zipfile
from os import listdir, path
SRC = path.join(path.dirname(path.abspath(__file__)), 'DeviceSupport')
DEVICE_SUPPORT_PATH='Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport'
def unzip_file(name, target):
f = path.join(SRC, name + '.zip')
zip_ref = zipfile.ZipFile(f, 'r')
zip_ref.extractall(target)
zip_ref.close()
def process(xcode, version):
target = path.join(xcode, DEVICE_SUPPORT_PATH)
exist = listdir(target)
all_files = [i.replace('.zip', '') for i in listdir(SRC) if i.endswith('.zip')]
new_files = list(set(all_files) - set(exist))
if version:
new_files = list(filter(lambda x : version in x, new_files))
for i in new_files:
print 'Unzip file "{}.zip" to {}'.format(i, target)
unzip_file(i, target)
print '\nUpdate successfully for {}'.format(xcode)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
'-t',
type=str,
dest='target',
default='/Applications/Xcode.app',
help='The path for Xcode'
)
parser.add_argument(
'-v',
type=str,
dest='version',
default=None,
help='Specific version (default is all)'
)
args = parser.parse_args()
process(args.target, args.version)