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

Unified Diff: build/android/adb_logcat_printer.py

Issue 59903026: Fix android presubmit errors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix_typo Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/buildbot/bb_device_steps.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/adb_logcat_printer.py
diff --git a/build/android/adb_logcat_printer.py b/build/android/adb_logcat_printer.py
index 5194668ec6e80dcf800758b1b9670c3fe9167f62..8e69a2c417936d20094e0b6bc228168d467ee73a 100755
--- a/build/android/adb_logcat_printer.py
+++ b/build/android/adb_logcat_printer.py
@@ -20,6 +20,7 @@ monitoring for the deletion of the aforementioned file.
import cStringIO
import logging
+import optparse
import os
import re
import signal
@@ -52,7 +53,7 @@ def CombineLogFiles(list_of_lists, logger):
try:
line = cur_device_log[-1]
# Used to make sure we only splice on a timestamped line
- if re.match('^\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3} ', line):
+ if re.match(r'^\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3} ', line):
common_index = cur_file_lines.index(line)
else:
logger.warning('splice error - no timestamp in "%s"?', line.strip())
@@ -76,7 +77,7 @@ def FindLogFiles(base_dir):
Returns:
Mapping of device_id to a sorted list of file paths for a given device
"""
- logcat_filter = re.compile('^logcat_(\w+)_(\d+)$')
+ logcat_filter = re.compile(r'^logcat_(\w+)_(\d+)$')
# list of tuples (<device_id>, <seq num>, <full file path>)
filtered_list = []
for cur_file in os.listdir(base_dir):
@@ -87,7 +88,7 @@ def FindLogFiles(base_dir):
filtered_list.sort()
file_map = {}
for device_id, _, cur_file in filtered_list:
- if not device_id in file_map:
+ if device_id not in file_map:
file_map[device_id] = []
file_map[device_id] += [cur_file]
@@ -149,7 +150,19 @@ def ShutdownLogcatMonitor(base_dir, logger):
logger.exception('Error signaling logcat monitor - continuing')
-def main(base_dir, output_file):
+def main(argv):
+ parser = optparse.OptionParser(usage='Usage: %prog [options] <log dir>')
bulach 2013/11/14 19:50:04 nit: while at it, it seems a bit confusing to have
Isaac (away) 2013/11/21 11:11:34 --output-path is optional, while the extra arg is
+ parser.add_option('--output-path',
+ help='Output file path (if unspecified, prints to stdout)')
+ options, args = parser.parse_args(argv)
+ if len(args) != 1:
+ parser.error('Wrong number of unparsed args')
+ base_dir = args[0]
+ if options.output_path:
+ output_file = open(options.output_path, 'w')
+ else:
+ output_file = sys.stdout
+
log_stringio = cStringIO.StringIO()
logger = logging.getLogger('LogcatPrinter')
logger.setLevel(LOG_LEVEL)
@@ -196,7 +209,4 @@ def main(base_dir, output_file):
output_file.write(log_stringio.getvalue())
if __name__ == '__main__':
- if len(sys.argv) == 1:
- print 'Usage: %s <base_dir>' % sys.argv[0]
- sys.exit(1)
- sys.exit(main(sys.argv[1], sys.stdout))
+ sys.exit(main(sys.argv[1:]))
« no previous file with comments | « no previous file | build/android/buildbot/bb_device_steps.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698