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

Side by Side Diff: build/android/pylib/device/device_utils.py

Issue 796663002: Update from https://crrev.com/307758 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Updates for SkCanvas::NewRaster deprecation Created 6 years 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 | « base/tuple.h ('k') | build/android/pylib/device/device_utils_test.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 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 """Provides a variety of device interactions based on adb. 5 """Provides a variety of device interactions based on adb.
6 6
7 Eventually, this will be based on adb_wrapper. 7 Eventually, this will be based on adb_wrapper.
8 """ 8 """
9 # pylint: disable=W0613 9 # pylint: disable=W0613
10 10
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 """ 911 """
912 if len(contents) < 512 and not force_push: 912 if len(contents) < 512 and not force_push:
913 cmd = 'echo -n %s > %s' % (cmd_helper.SingleQuote(contents), 913 cmd = 'echo -n %s > %s' % (cmd_helper.SingleQuote(contents),
914 cmd_helper.SingleQuote(device_path)) 914 cmd_helper.SingleQuote(device_path))
915 self.RunShellCommand(cmd, as_root=as_root, check_return=True) 915 self.RunShellCommand(cmd, as_root=as_root, check_return=True)
916 else: 916 else:
917 with tempfile.NamedTemporaryFile() as host_temp: 917 with tempfile.NamedTemporaryFile() as host_temp:
918 host_temp.write(contents) 918 host_temp.write(contents)
919 host_temp.flush() 919 host_temp.flush()
920 if as_root and self.NeedsSU(): 920 if as_root and self.NeedsSU():
921 with device_temp_file.DeviceTempFile(self) as device_temp: 921 with device_temp_file.DeviceTempFile(self.adb) as device_temp:
922 self.adb.Push(host_temp.name, device_temp.name) 922 self.adb.Push(host_temp.name, device_temp.name)
923 # Here we need 'cp' rather than 'mv' because the temp and 923 # Here we need 'cp' rather than 'mv' because the temp and
924 # destination files might be on different file systems (e.g. 924 # destination files might be on different file systems (e.g.
925 # on internal storage and an external sd card) 925 # on internal storage and an external sd card)
926 self.RunShellCommand(['cp', device_temp.name, device_path], 926 self.RunShellCommand(['cp', device_temp.name, device_path],
927 as_root=True, check_return=True) 927 as_root=True, check_return=True)
928 else: 928 else:
929 self.adb.Push(host_temp.name, device_path) 929 self.adb.Push(host_temp.name, device_path)
930 930
931 @decorators.WithTimeoutAndRetriesFromInstance() 931 @decorators.WithTimeoutAndRetriesFromInstance()
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 1166
1167 Raises: 1167 Raises:
1168 CommandTimeoutError on timeout. 1168 CommandTimeoutError on timeout.
1169 """ 1169 """
1170 return self.old_interface.GetMemoryUsageForPid(pid) 1170 return self.old_interface.GetMemoryUsageForPid(pid)
1171 1171
1172 def __str__(self): 1172 def __str__(self):
1173 """Returns the device serial.""" 1173 """Returns the device serial."""
1174 return self.adb.GetDeviceSerial() 1174 return self.adb.GetDeviceSerial()
1175 1175
1176 @staticmethod 1176 @classmethod
1177 def parallel(devices=None, async=False): 1177 def parallel(cls, devices=None, async=False):
1178 """Creates a Parallelizer to operate over the provided list of devices. 1178 """Creates a Parallelizer to operate over the provided list of devices.
1179 1179
1180 If |devices| is either |None| or an empty list, the Parallelizer will 1180 If |devices| is either |None| or an empty list, the Parallelizer will
1181 operate over all attached devices. 1181 operate over all attached devices.
1182 1182
1183 Args: 1183 Args:
1184 devices: A list of either DeviceUtils instances or objects from 1184 devices: A list of either DeviceUtils instances or objects from
1185 from which DeviceUtils instances can be constructed. If None, 1185 from which DeviceUtils instances can be constructed. If None,
1186 all attached devices will be used. 1186 all attached devices will be used.
1187 async: If true, returns a Parallelizer that runs operations 1187 async: If true, returns a Parallelizer that runs operations
1188 asynchronously. 1188 asynchronously.
1189 1189
1190 Returns: 1190 Returns:
1191 A Parallelizer operating over |devices|. 1191 A Parallelizer operating over |devices|.
1192 """ 1192 """
1193 if not devices or len(devices) == 0: 1193 if not devices:
1194 devices = pylib.android_commands.GetAttachedDevices() 1194 devices = adb_wrapper.AdbWrapper.GetDevices()
1195 parallelizer_type = (parallelizer.Parallelizer if async 1195 devices = [d if isinstance(d, cls) else cls(d) for d in devices]
1196 else parallelizer.SyncParallelizer) 1196 if async:
1197 return parallelizer_type([ 1197 return parallelizer.Parallelizer(devices)
1198 d if isinstance(d, DeviceUtils) else DeviceUtils(d) 1198 else:
1199 for d in devices]) 1199 return parallelizer.SyncParallelizer(devices)
OLDNEW
« no previous file with comments | « base/tuple.h ('k') | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698