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

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
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 return logcat_monitor.LogcatMonitor(self.adb, *args, **kwargs)
1296
1291 def __str__(self): 1297 def __str__(self):
1292 """Returns the device serial.""" 1298 """Returns the device serial."""
1293 return self.adb.GetDeviceSerial() 1299 return self.adb.GetDeviceSerial()
1294 1300
1295 @classmethod 1301 @classmethod
1296 def parallel(cls, devices=None, async=False): 1302 def parallel(cls, devices=None, async=False):
1297 """Creates a Parallelizer to operate over the provided list of devices. 1303 """Creates a Parallelizer to operate over the provided list of devices.
1298 1304
1299 If |devices| is either |None| or an empty list, the Parallelizer will 1305 If |devices| is either |None| or an empty list, the Parallelizer will
1300 operate over all attached devices. 1306 operate over all attached devices.
1301 1307
1302 Args: 1308 Args:
1303 devices: A list of either DeviceUtils instances or objects from 1309 devices: A list of either DeviceUtils instances or objects from
1304 from which DeviceUtils instances can be constructed. If None, 1310 from which DeviceUtils instances can be constructed. If None,
1305 all attached devices will be used. 1311 all attached devices will be used.
1306 async: If true, returns a Parallelizer that runs operations 1312 async: If true, returns a Parallelizer that runs operations
1307 asynchronously. 1313 asynchronously.
1308 1314
1309 Returns: 1315 Returns:
1310 A Parallelizer operating over |devices|. 1316 A Parallelizer operating over |devices|.
1311 """ 1317 """
1312 if not devices: 1318 if not devices:
1313 devices = adb_wrapper.AdbWrapper.GetDevices() 1319 devices = adb_wrapper.AdbWrapper.GetDevices()
1314 devices = [d if isinstance(d, cls) else cls(d) for d in devices] 1320 devices = [d if isinstance(d, cls) else cls(d) for d in devices]
1315 if async: 1321 if async:
1316 return parallelizer.Parallelizer(devices) 1322 return parallelizer.Parallelizer(devices)
1317 else: 1323 else:
1318 return parallelizer.SyncParallelizer(devices) 1324 return parallelizer.SyncParallelizer(devices)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698