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

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

Issue 896503002: [Android] Add LogcatMonitor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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/pylib/device/adb_wrapper.py ('k') | build/android/pylib/device/logcat_monitor.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=unused-argument
10 10
11 import logging 11 import logging
12 import multiprocessing 12 import multiprocessing
13 import os 13 import os
14 import re 14 import re
15 import sys 15 import sys
16 import tempfile 16 import tempfile
17 import time 17 import time
18 import zipfile 18 import zipfile
19 19
20 import pylib.android_commands 20 import pylib.android_commands
21 from pylib import cmd_helper 21 from pylib import cmd_helper
22 from pylib import constants 22 from pylib import constants
23 from pylib.device import adb_wrapper 23 from pylib.device import adb_wrapper
24 from pylib.device import decorators 24 from pylib.device import decorators
25 from pylib.device import device_errors 25 from pylib.device import device_errors
26 from pylib.device import intent 26 from pylib.device import intent
27 from pylib.device import logcat_monitor
27 from pylib.device.commands import install_commands 28 from pylib.device.commands import install_commands
28 from pylib.utils import apk_helper 29 from pylib.utils import apk_helper
29 from pylib.utils import device_temp_file 30 from pylib.utils import device_temp_file
30 from pylib.utils import host_utils 31 from pylib.utils import host_utils
31 from pylib.utils import md5sum 32 from pylib.utils import md5sum
32 from pylib.utils import parallelizer 33 from pylib.utils import parallelizer
33 from pylib.utils import timeout_retry 34 from pylib.utils import timeout_retry
34 from pylib.utils import zip_utils 35 from pylib.utils import zip_utils
35 36
36 _DEFAULT_TIMEOUT = 30 37 _DEFAULT_TIMEOUT = 30
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 Returns: 1282 Returns:
1282 A 2-tuple containing: 1283 A 2-tuple containing:
1283 - A dict containing the overall memory usage statistics for the PID. 1284 - A dict containing the overall memory usage statistics for the PID.
1284 - A dict containing memory usage statistics broken down by mapping. 1285 - A dict containing memory usage statistics broken down by mapping.
1285 1286
1286 Raises: 1287 Raises:
1287 CommandTimeoutError on timeout. 1288 CommandTimeoutError on timeout.
1288 """ 1289 """
1289 return self.old_interface.GetMemoryUsageForPid(pid) 1290 return self.old_interface.GetMemoryUsageForPid(pid)
1290 1291
1292 @decorators.WithTimeoutAndRetriesFromInstance()
1293 def GetLogcatMonitor(self, timeout=None, retries=None, *args, **kwargs):
1294 """Returns a new LogcatMonitor associated with this device.
1295
1296 Parameters passed to this function are passed directly to
1297 |logcat_monitor.LogcatMonitor| and are documented there.
1298
1299 Args:
1300 timeout: timeout in seconds
1301 retries: number of retries
1302 """
1303 return logcat_monitor.LogcatMonitor(self.adb, *args, **kwargs)
1304
1291 def __str__(self): 1305 def __str__(self):
1292 """Returns the device serial.""" 1306 """Returns the device serial."""
1293 return self.adb.GetDeviceSerial() 1307 return self.adb.GetDeviceSerial()
1294 1308
1295 @classmethod 1309 @classmethod
1296 def parallel(cls, devices=None, async=False): 1310 def parallel(cls, devices=None, async=False):
1297 """Creates a Parallelizer to operate over the provided list of devices. 1311 """Creates a Parallelizer to operate over the provided list of devices.
1298 1312
1299 If |devices| is either |None| or an empty list, the Parallelizer will 1313 If |devices| is either |None| or an empty list, the Parallelizer will
1300 operate over all attached devices. 1314 operate over all attached devices.
1301 1315
1302 Args: 1316 Args:
1303 devices: A list of either DeviceUtils instances or objects from 1317 devices: A list of either DeviceUtils instances or objects from
1304 from which DeviceUtils instances can be constructed. If None, 1318 from which DeviceUtils instances can be constructed. If None,
1305 all attached devices will be used. 1319 all attached devices will be used.
1306 async: If true, returns a Parallelizer that runs operations 1320 async: If true, returns a Parallelizer that runs operations
1307 asynchronously. 1321 asynchronously.
1308 1322
1309 Returns: 1323 Returns:
1310 A Parallelizer operating over |devices|. 1324 A Parallelizer operating over |devices|.
1311 """ 1325 """
1312 if not devices: 1326 if not devices:
1313 devices = adb_wrapper.AdbWrapper.GetDevices() 1327 devices = adb_wrapper.AdbWrapper.GetDevices()
1314 devices = [d if isinstance(d, cls) else cls(d) for d in devices] 1328 devices = [d if isinstance(d, cls) else cls(d) for d in devices]
1315 if async: 1329 if async:
1316 return parallelizer.Parallelizer(devices) 1330 return parallelizer.Parallelizer(devices)
1317 else: 1331 else:
1318 return parallelizer.SyncParallelizer(devices) 1332 return parallelizer.SyncParallelizer(devices)
OLDNEW
« no previous file with comments | « build/android/pylib/device/adb_wrapper.py ('k') | build/android/pylib/device/logcat_monitor.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698