Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: third_party/libadblockplus/download_ndk.py

Issue 29670555: Issue 6264 - Can't prepare libadblockplus dependencies (Closed)
Left Patch Set: Deleting NDK directory before extracting. Formatted with respect to eyeo python code style Created Jan. 18, 2018, 8:23 a.m.
Right Patch Set: Renamed variable Created Jan. 18, 2018, 12:19 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « third_party/libadblockplus/delete_dir.py ('k') | third_party/libadblockplus_android/BUILD.gn » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 import os 1 import os
2 import urllib 2 import urllib
3 import zipfile 3 import zipfile
4 import sys 4 import sys
5 import shutil 5 import shutil
6 6
7 7
8 def main(argv): 8 def main(argv):
9 # Download 9 # Download
10 ndk_src = 'https://dl.google.com/android/repository/android-ndk-r12b-linux-x 86_64.zip' 10 ndk_src = 'https://dl.google.com/android/repository/android-ndk-r12b-linux-x 86_64.zip'
11 11
12 cwd = os.getcwd() 12 cwd = os.getcwd()
13 libadblockplus_root = os.path.join(cwd, 13 libadblockplus_third_party = os.path.join(cwd,
sergei 2018/01/18 09:16:51 I think it's rather libadblockplus_third_party_dir
anton 2018/01/18 12:20:26 Done. See patch set #6
14 'src', 'third_party', 14 'src', 'third_party',
15 'libadblockplus', 'third_party') 15 'libadblockplus', 'third_party')
sergei 2018/01/18 09:16:50 Why not to put it into cwd/src/third_party?
anton 2018/01/18 09:49:12 it's required for libadblockplus (and libadblockpl
16 ndk_dst = os.path.join(libadblockplus_root, 16 ndk_dst = os.path.join(libadblockplus_third_party,
17 'android-ndk-r12b-linux-x86_64.zip') 17 'android-ndk-r12b-linux-x86_64.zip')
18 18
19 if os.path.exists(ndk_dst): 19 if os.path.exists(ndk_dst):
20 os.remove(ndk_dst) 20 os.remove(ndk_dst)
21 21
22 print('Downloading {} to {}'.format(ndk_src, ndk_dst)) 22 print('Downloading {} to {}'.format(ndk_src, ndk_dst))
23 urllib.urlretrieve(ndk_src, ndk_dst) 23 urllib.urlretrieve(ndk_src, ndk_dst)
24 24
25 # Delete existing NDK directory 25 # Delete existing NDK directory
26 ndk_dir = os.path.join(libadblockplus_root, 'android-ndk-r12b') 26 ndk_dir = os.path.join(libadblockplus_third_party, 'android-ndk-r12b')
anton 2018/01/18 08:25:45 Previously we deleted whole 'third_party' includin
27 if os.path.exists(ndk_dir): 27 if os.path.exists(ndk_dir):
28 print('Deleting {}'.format(ndk_dir)) 28 print('Deleting {}'.format(ndk_dir))
29 shutil.rmtree(ndk_dir) 29 shutil.rmtree(ndk_dir)
30 30
31 # Extract zip (preserving file permissions) 31 # Extract zip (preserving file permissions)
32 print('Extracting {} to {}'.format(ndk_dst, libadblockplus_root)) 32 print('Extracting {} to {}'.format(ndk_dst, libadblockplus_third_party))
33 with zipfile.ZipFile(ndk_dst, 'r') as zf: 33 with zipfile.ZipFile(ndk_dst, 'r') as zf:
sergei 2018/01/18 09:16:50 Taking into account the number of files I would pr
anton 2018/01/18 09:49:12 zip python library does not keep permissions ("exe
34 for info in zf.infolist(): 34 for info in zf.infolist():
35 zf.extract(info.filename, path=libadblockplus_root) 35 zf.extract(info.filename, path=libadblockplus_third_party)
36 out_path = os.path.join(libadblockplus_root, info.filename) 36 out_path = os.path.join(libadblockplus_third_party, info.filename)
37 37
38 perm = info.external_attr >> 16L 38 perm = info.external_attr >> 16L
39 os.chmod(out_path, perm) 39 os.chmod(out_path, perm)
40 40
41 # Delete zip 41 # Delete zip
42 os.remove(ndk_dst) 42 os.remove(ndk_dst)
43 43
44 return 0 44 return 0
45 45
46 46
47 if '__main__' == __name__: 47 if '__main__' == __name__:
48 try: 48 try:
49 sys.exit(main(sys.argv[1:])) 49 sys.exit(main(sys.argv[1:]))
50 except KeyboardInterrupt: 50 except KeyboardInterrupt:
51 sys.stderr.write('interrupted\n') 51 sys.stderr.write('interrupted\n')
52 sys.exit(1) 52 sys.exit(1)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld