Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: build/android/gyp/apk_install.py

Issue 132463007: Enable presubmit pylint in build/android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase vs tot and only disabling F0401 in specific spots Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/gyp/ant.py ('k') | build/android/gyp/create_device_library_links.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2013 The Chromium Authors. All rights reserved. 3 # Copyright 2013 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Installs an APK. 7 """Installs an APK.
8 8
9 """ 9 """
10 10
11 import optparse 11 import optparse
12 import os 12 import os
13 import re 13 import re
14 import subprocess
15 import sys 14 import sys
16 15
16 # pylint: disable=F0401
17 from util import build_device 17 from util import build_device
18 from util import build_utils 18 from util import build_utils
19 from util import md5_check 19 from util import md5_check
20 # pylint: enable=F0401
20 21
21 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..') 22 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..')
22 sys.path.append(BUILD_ANDROID_DIR) 23 sys.path.append(BUILD_ANDROID_DIR)
23 24
24 from pylib import constants 25 from pylib import constants
25 from pylib.utils import apk_helper 26 from pylib.utils import apk_helper
26 27
27 def GetNewMetadata(device, apk_package): 28 def GetNewMetadata(device, apk_package):
28 """Gets the metadata on the device for the apk_package apk.""" 29 """Gets the metadata on the device for the apk_package apk."""
29 output = device.RunShellCommand('ls -l /data/app/') 30 output = device.RunShellCommand('ls -l /data/app/')
31 # pylint: disable=C0301
30 # Matches lines like: 32 # Matches lines like:
31 # -rw-r--r-- system system 7376582 2013-04-19 16:34 org.chromium.chrome.t estshell.apk 33 # -rw-r--r-- system system 7376582 2013-04-19 16:34 org.chromium.chrome.t estshell.apk
32 # -rw-r--r-- system system 7376582 2013-04-19 16:34 org.chromium.chrome.t estshell-1.apk 34 # -rw-r--r-- system system 7376582 2013-04-19 16:34 org.chromium.chrome.t estshell-1.apk
35 # pylint: enable=C0301
33 apk_matcher = lambda s: re.match('.*%s(-[0-9]*)?.apk$' % apk_package, s) 36 apk_matcher = lambda s: re.match('.*%s(-[0-9]*)?.apk$' % apk_package, s)
34 matches = filter(apk_matcher, output) 37 matches = filter(apk_matcher, output)
35 return matches[0] if matches else None 38 return matches[0] if matches else None
36 39
37 def HasInstallMetadataChanged(device, apk_package, metadata_path): 40 def HasInstallMetadataChanged(device, apk_package, metadata_path):
38 """Checks if the metadata on the device for apk_package has changed.""" 41 """Checks if the metadata on the device for apk_package has changed."""
39 if not os.path.exists(metadata_path): 42 if not os.path.exists(metadata_path):
40 return True 43 return True
41 44
42 with open(metadata_path, 'r') as expected_file: 45 with open(metadata_path, 'r') as expected_file:
43 return expected_file.read() != device.GetInstallMetadata(apk_package) 46 return expected_file.read() != device.GetInstallMetadata(apk_package)
44 47
45 48
46 def RecordInstallMetadata(device, apk_package, metadata_path): 49 def RecordInstallMetadata(device, apk_package, metadata_path):
47 """Records the metadata from the device for apk_package.""" 50 """Records the metadata from the device for apk_package."""
48 metadata = GetNewMetadata(device, apk_package) 51 metadata = GetNewMetadata(device, apk_package)
49 if not metadata: 52 if not metadata:
50 raise Exception('APK install failed unexpectedly.') 53 raise Exception('APK install failed unexpectedly.')
51 54
52 with open(metadata_path, 'w') as outfile: 55 with open(metadata_path, 'w') as outfile:
53 outfile.write(metadata) 56 outfile.write(metadata)
54 57
55 58
56 def main(argv): 59 def main():
57 parser = optparse.OptionParser() 60 parser = optparse.OptionParser()
58 parser.add_option('--apk-path', 61 parser.add_option('--apk-path',
59 help='Path to .apk to install.') 62 help='Path to .apk to install.')
60 parser.add_option('--install-record', 63 parser.add_option('--install-record',
61 help='Path to install record (touched only when APK is installed).') 64 help='Path to install record (touched only when APK is installed).')
62 parser.add_option('--build-device-configuration', 65 parser.add_option('--build-device-configuration',
63 help='Path to build device configuration.') 66 help='Path to build device configuration.')
64 parser.add_option('--stamp', 67 parser.add_option('--stamp',
65 help='Path to touch on success.') 68 help='Path to touch on success.')
66 parser.add_option('--configuration-name', 69 parser.add_option('--configuration-name',
(...skipping 27 matching lines...) Expand all
94 Install, 97 Install,
95 record_path=record_path, 98 record_path=record_path,
96 input_paths=[options.apk_path], 99 input_paths=[options.apk_path],
97 force=force_install) 100 force=force_install)
98 101
99 if options.stamp: 102 if options.stamp:
100 build_utils.Touch(options.stamp) 103 build_utils.Touch(options.stamp)
101 104
102 105
103 if __name__ == '__main__': 106 if __name__ == '__main__':
104 sys.exit(main(sys.argv)) 107 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/gyp/ant.py ('k') | build/android/gyp/create_device_library_links.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698