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

Side by Side Diff: build/android/gyp/util/build_device.py

Issue 153743008: Revert of Enable presubmit pylint in build/android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merging with changes to pylib/linker/test_case.py. 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/strip_library_for_device.py ('k') | build/android/gyp/util/build_utils.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 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """ A simple device interface for build steps. 5 """ A simple device interface for build steps.
6 6
7 """ 7 """
8 8
9 import logging 9 import logging
10 import os 10 import os
11 import re 11 import re
12 import sys 12 import sys
13 13
14 import build_utils # pylint: disable=F0401 14 import build_utils
15 15
16 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..', '..') 16 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..', '..')
17 sys.path.append(BUILD_ANDROID_DIR) 17 sys.path.append(BUILD_ANDROID_DIR)
18 18
19 from pylib import android_commands 19 from pylib import android_commands
20 20
21 from pylib.android_commands import GetAttachedDevices
22
21 23
22 class BuildDevice(object): 24 class BuildDevice(object):
23 def __init__(self, configuration): 25 def __init__(self, configuration):
24 self.id = configuration['id'] 26 self.id = configuration['id']
25 self.description = configuration['description'] 27 self.description = configuration['description']
26 self.install_metadata = configuration['install_metadata'] 28 self.install_metadata = configuration['install_metadata']
27 self.adb = android_commands.AndroidCommands(self.id) 29 self.adb = android_commands.AndroidCommands(self.id)
28 30
29 def RunShellCommand(self, *args, **kwargs): 31 def RunShellCommand(self, *args, **kwargs):
30 return self.adb.RunShellCommand(*args, **kwargs) 32 return self.adb.RunShellCommand(*args, **kwargs)
(...skipping 12 matching lines...) Expand all
43 # Matches lines like: 45 # Matches lines like:
44 # -rw-r--r-- system system 7376582 2013-04-19 16:34 \ 46 # -rw-r--r-- system system 7376582 2013-04-19 16:34 \
45 # org.chromium.chrome.testshell.apk 47 # org.chromium.chrome.testshell.apk
46 # -rw-r--r-- system system 7376582 2013-04-19 16:34 \ 48 # -rw-r--r-- system system 7376582 2013-04-19 16:34 \
47 # org.chromium.chrome.testshell-1.apk 49 # org.chromium.chrome.testshell-1.apk
48 apk_matcher = lambda s: re.match('.*%s(-[0-9]*)?.apk$' % apk_package, s) 50 apk_matcher = lambda s: re.match('.*%s(-[0-9]*)?.apk$' % apk_package, s)
49 matches = filter(apk_matcher, self.install_metadata) 51 matches = filter(apk_matcher, self.install_metadata)
50 return matches[0] if matches else None 52 return matches[0] if matches else None
51 53
52 54
53 def GetConfigurationForDevice(device_id): 55 def GetConfigurationForDevice(id):
54 adb = android_commands.AndroidCommands(device_id) 56 adb = android_commands.AndroidCommands(id)
55 configuration = None 57 configuration = None
56 has_root = False 58 has_root = False
57 is_online = adb.IsOnline() 59 is_online = adb.IsOnline()
58 if is_online: 60 if is_online:
59 cmd = 'ls -l /data/app; getprop ro.build.description' 61 cmd = 'ls -l /data/app; getprop ro.build.description'
60 cmd_output = adb.RunShellCommand(cmd) 62 cmd_output = adb.RunShellCommand(cmd)
61 has_root = not 'Permission denied' in cmd_output[0] 63 has_root = not 'Permission denied' in cmd_output[0]
62 if not has_root: 64 if not has_root:
63 # Disable warning log messages from EnableAdbRoot() 65 # Disable warning log messages from EnableAdbRoot()
64 logging.getLogger().disabled = True 66 logging.getLogger().disabled = True
65 has_root = adb.EnableAdbRoot() 67 has_root = adb.EnableAdbRoot()
66 logging.getLogger().disabled = False 68 logging.getLogger().disabled = False
67 cmd_output = adb.RunShellCommand(cmd) 69 cmd_output = adb.RunShellCommand(cmd)
68 70
69 configuration = { 71 configuration = {
70 'id': device_id, 72 'id': id,
71 'description': cmd_output[-1], 73 'description': cmd_output[-1],
72 'install_metadata': cmd_output[:-1], 74 'install_metadata': cmd_output[:-1],
73 } 75 }
74 return configuration, is_online, has_root 76 return configuration, is_online, has_root
75 77
76 78
77 def WriteConfigurations(configurations, path): 79 def WriteConfigurations(configurations, path):
78 # Currently we only support installing to the first device. 80 # Currently we only support installing to the first device.
79 build_utils.WriteJson(configurations[:1], path, only_if_changed=True) 81 build_utils.WriteJson(configurations[:1], path, only_if_changed=True)
80 82
81 83
82 def ReadConfigurations(path): 84 def ReadConfigurations(path):
83 return build_utils.ReadJson(path) 85 return build_utils.ReadJson(path)
84 86
85 87
86 def GetBuildDevice(configurations): 88 def GetBuildDevice(configurations):
87 assert len(configurations) == 1 89 assert len(configurations) == 1
88 return BuildDevice(configurations[0]) 90 return BuildDevice(configurations[0])
89 91
90 92
91 def GetBuildDeviceFromPath(path): 93 def GetBuildDeviceFromPath(path):
92 configurations = ReadConfigurations(path) 94 configurations = ReadConfigurations(path)
93 if len(configurations) > 0: 95 if len(configurations) > 0:
94 return GetBuildDevice(ReadConfigurations(path)) 96 return GetBuildDevice(ReadConfigurations(path))
95 return None 97 return None
96 98
OLDNEW
« no previous file with comments | « build/android/gyp/strip_library_for_device.py ('k') | build/android/gyp/util/build_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698