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

Side by Side Diff: build/android/pylib/android_commands.py

Issue 10912072: [android] Remove extra adb newlines from buildbot log (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed nits Created 8 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 an interface to communicate with the device via the adb command. 5 """Provides an interface to communicate with the device via the adb command.
6 6
7 Assumes adb binary is currently on system path. 7 Assumes adb binary is currently on system path.
8 """ 8 """
9 9
10 import collections 10 import collections
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 self.RunShellCommand('logcat -c') 700 self.RunShellCommand('logcat -c')
701 args = [] 701 args = []
702 if self._adb._target_arg: 702 if self._adb._target_arg:
703 args += shlex.split(self._adb._target_arg) 703 args += shlex.split(self._adb._target_arg)
704 args += ['logcat', '-v', 'threadtime'] 704 args += ['logcat', '-v', 'threadtime']
705 if filters: 705 if filters:
706 args.extend(filters) 706 args.extend(filters)
707 else: 707 else:
708 args.append('*:v') 708 args.append('*:v')
709 709
710 if logfile:
711 class NewLineNormalizer(object):
712 """A file-like object to normalize EOLs to '\n'.
713
714 Pexpect runs adb within a pseudo-tty device (see
715 http://www.noah.org/wiki/pexpect), so any '\n' printed by adb is written
716 as '\r\n' to the logfile. Since adb already uses '\r\n' to terminate
717 lines, the log ends up having '\r\r\n' at the end of each line. This
718 filter replaces the above with a single '\n' in the data stream.
719 """
720 def __init__(self, output):
721 self.output = output
722
723 def write(self, data):
724 data = data.replace('\r\r\n', '\n')
725 self.output.write(data)
726
727 def flush(self):
728 self.output.flush()
729
730 logfile = NewLineNormalizer(logfile)
731
710 # Spawn logcat and syncronize with it. 732 # Spawn logcat and syncronize with it.
711 for _ in range(4): 733 for _ in range(4):
712 self._logcat = pexpect.spawn('adb', args, timeout=timeout, 734 self._logcat = pexpect.spawn('adb', args, timeout=timeout,
713 logfile=logfile) 735 logfile=logfile)
714 self.RunShellCommand('log startup_sync') 736 self.RunShellCommand('log startup_sync')
715 if self._logcat.expect(['startup_sync', pexpect.EOF, 737 if self._logcat.expect(['startup_sync', pexpect.EOF,
716 pexpect.TIMEOUT]) == 0: 738 pexpect.TIMEOUT]) == 0:
717 break 739 break
718 self._logcat.close(force=True) 740 self._logcat.close(force=True)
719 else: 741 else:
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 ' '.join(['-c %s' % c for c in category]), 1042 ' '.join(['-c %s' % c for c in category]),
1021 '--throttle %d' % throttle, 1043 '--throttle %d' % throttle,
1022 '-s %d' % seed, 1044 '-s %d' % seed,
1023 '-v ' * verbosity, 1045 '-v ' * verbosity,
1024 '--monitor-native-crashes', 1046 '--monitor-native-crashes',
1025 '--kill-process-after-error', 1047 '--kill-process-after-error',
1026 extra_args, 1048 extra_args,
1027 '%d' % event_count] 1049 '%d' % event_count]
1028 return self.RunShellCommand(' '.join(cmd), 1050 return self.RunShellCommand(' '.join(cmd),
1029 timeout_time=event_count*throttle*1.5) 1051 timeout_time=event_count*throttle*1.5)
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