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

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

Issue 919763003: [Android] Fix logcat clearing in AdbWrapper. (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 | « no previous file | no next file » | 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 """This module wraps Android's adb tool. 5 """This module wraps Android's adb tool.
6 6
7 This is a thin wrapper around the adb interface. Any additional complexity 7 This is a thin wrapper around the adb interface. Any additional complexity
8 should be delegated to a higher level (ex. DeviceUtils). 8 should be delegated to a higher level (ex. DeviceUtils).
9 """ 9 """
10 10
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 lines = self._RunDeviceAdbCmd( 293 lines = self._RunDeviceAdbCmd(
294 cmd, timeout=timeout, retries=retries).splitlines() 294 cmd, timeout=timeout, retries=retries).splitlines()
295 if lines: 295 if lines:
296 return [ParseLine(line) for line in lines] 296 return [ParseLine(line) for line in lines]
297 else: 297 else:
298 raise device_errors.AdbCommandFailedError( 298 raise device_errors.AdbCommandFailedError(
299 cmd, 'path does not specify an accessible directory in the device', 299 cmd, 'path does not specify an accessible directory in the device',
300 device_serial=self._device_serial) 300 device_serial=self._device_serial)
301 301
302 def Logcat(self, clear=False, dump=False, filter_spec=None, 302 def Logcat(self, clear=False, dump=False, filter_spec=None,
303 logcat_format=None, timeout=None): 303 logcat_format=None, timeout=None, retries=_DEFAULT_RETRIES):
304 """Get an iterator over the logcat output. 304 """Get an iterable over the logcat output.
305 305
306 Args: 306 Args:
307 filter_spec: (optional) Spec to filter the logcat. 307 clear: If true, clear the logcat.
308 timeout: (optional) Timeout per try in seconds. 308 dump: If true, dump the current logcat contents.
309 filter_spec: If set, spec to filter the logcat.
310 logcat_format: If set, the format in which the logcat should be output.
311 Options include "brief", "process", "tag", "thread", "raw", "time",
312 "threadtime", and "long"
313 timeout: (optional) If set, timeout per try in seconds. If clear or dump
314 is set, defaults to _DEFAULT_TIMEOUT.
315 retries: (optional) If clear or dump is set, the number of retries to
316 attempt. Otherwise, does nothing.
309 317
310 Yields: 318 Yields:
311 logcat output line by line. 319 logcat output line by line.
312 """ 320 """
313 cmd = ['logcat'] 321 cmd = ['logcat']
322 use_iter = True
314 if clear: 323 if clear:
315 cmd.append('-c') 324 cmd.append('-c')
325 use_iter = False
316 if dump: 326 if dump:
317 cmd.append('-d') 327 cmd.append('-d')
328 use_iter = False
318 if logcat_format: 329 if logcat_format:
319 cmd.extend(['-v', logcat_format]) 330 cmd.extend(['-v', logcat_format])
320 if filter_spec is not None: 331 if filter_spec is not None:
321 cmd.append(filter_spec) 332 cmd.append(filter_spec)
322 return self._IterRunDeviceAdbCmd(cmd, timeout) 333
334 if use_iter:
335 return self._IterRunDeviceAdbCmd(cmd, timeout)
336 else:
337 timeout = timeout if timeout is not None else _DEFAULT_TIMEOUT
338 return self._RunDeviceAdbCmd(cmd, timeout, retries)
323 339
324 def Forward(self, local, remote, timeout=_DEFAULT_TIMEOUT, 340 def Forward(self, local, remote, timeout=_DEFAULT_TIMEOUT,
325 retries=_DEFAULT_RETRIES): 341 retries=_DEFAULT_RETRIES):
326 """Forward socket connections from the local socket to the remote socket. 342 """Forward socket connections from the local socket to the remote socket.
327 343
328 Sockets are specified by one of: 344 Sockets are specified by one of:
329 tcp:<port> 345 tcp:<port>
330 localabstract:<unix domain socket name> 346 localabstract:<unix domain socket name>
331 localreserved:<unix domain socket name> 347 localreserved:<unix domain socket name>
332 localfilesystem:<unix domain socket name> 348 localfilesystem:<unix domain socket name>
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 """Restarts the adbd daemon with root permissions, if possible. 516 """Restarts the adbd daemon with root permissions, if possible.
501 517
502 Args: 518 Args:
503 timeout: (optional) Timeout per try in seconds. 519 timeout: (optional) Timeout per try in seconds.
504 retries: (optional) Number of retries to attempt. 520 retries: (optional) Number of retries to attempt.
505 """ 521 """
506 output = self._RunDeviceAdbCmd(['root'], timeout, retries) 522 output = self._RunDeviceAdbCmd(['root'], timeout, retries)
507 if 'cannot' in output: 523 if 'cannot' in output:
508 raise device_errors.AdbCommandFailedError( 524 raise device_errors.AdbCommandFailedError(
509 ['root'], output, device_serial=self._device_serial) 525 ['root'], output, device_serial=self._device_serial)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698