| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Shutdown adb_logcat_monitor and print accumulated logs. | 7 """Shutdown adb_logcat_monitor and print accumulated logs. |
| 8 | 8 |
| 9 To test, call './adb_logcat_printer.py <base_dir>' where | 9 To test, call './adb_logcat_printer.py <base_dir>' where |
| 10 <base_dir> contains 'adb logcat -v threadtime' files named as | 10 <base_dir> contains 'adb logcat -v threadtime' files named as |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 def FindLogFiles(base_dir): | 72 def FindLogFiles(base_dir): |
| 73 """Search a directory for logcat files. | 73 """Search a directory for logcat files. |
| 74 | 74 |
| 75 Args: | 75 Args: |
| 76 base_dir: directory to search | 76 base_dir: directory to search |
| 77 | 77 |
| 78 Returns: | 78 Returns: |
| 79 Mapping of device_id to a sorted list of file paths for a given device | 79 Mapping of device_id to a sorted list of file paths for a given device |
| 80 """ | 80 """ |
| 81 logcat_filter = re.compile(r'^logcat_(\w+)_(\d+)$') | 81 logcat_filter = re.compile(r'^logcat_(\S+)_(\d+)$') |
| 82 # list of tuples (<device_id>, <seq num>, <full file path>) | 82 # list of tuples (<device_id>, <seq num>, <full file path>) |
| 83 filtered_list = [] | 83 filtered_list = [] |
| 84 for cur_file in os.listdir(base_dir): | 84 for cur_file in os.listdir(base_dir): |
| 85 matcher = logcat_filter.match(cur_file) | 85 matcher = logcat_filter.match(cur_file) |
| 86 if matcher: | 86 if matcher: |
| 87 filtered_list += [(matcher.group(1), int(matcher.group(2)), | 87 filtered_list += [(matcher.group(1), int(matcher.group(2)), |
| 88 os.path.join(base_dir, cur_file))] | 88 os.path.join(base_dir, cur_file))] |
| 89 filtered_list.sort() | 89 filtered_list.sort() |
| 90 file_map = {} | 90 file_map = {} |
| 91 for device_id, _, cur_file in filtered_list: | 91 for device_id, _, cur_file in filtered_list: |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 except: | 204 except: |
| 205 logger.exception('Unexpected exception') | 205 logger.exception('Unexpected exception') |
| 206 | 206 |
| 207 logger.info('Done.') | 207 logger.info('Done.') |
| 208 sh.flush() | 208 sh.flush() |
| 209 output_file.write('\nLogcat Printer Event Log\n') | 209 output_file.write('\nLogcat Printer Event Log\n') |
| 210 output_file.write(log_stringio.getvalue()) | 210 output_file.write(log_stringio.getvalue()) |
| 211 | 211 |
| 212 if __name__ == '__main__': | 212 if __name__ == '__main__': |
| 213 sys.exit(main(sys.argv[1:])) | 213 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |