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 """Saves logcats from all connected devices. | 7 """Saves logcats from all connected devices. |
8 | 8 |
9 Usage: adb_logcat_monitor.py <base_dir> [<adb_binary_path>] | 9 Usage: adb_logcat_monitor.py <base_dir> [<adb_binary_path>] |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 Returns: | 76 Returns: |
77 list of devices or an empty list on timeout | 77 list of devices or an empty list on timeout |
78 """ | 78 """ |
79 signal.alarm(2) | 79 signal.alarm(2) |
80 try: | 80 try: |
81 out, err = subprocess.Popen([adb_cmd, 'devices'], | 81 out, err = subprocess.Popen([adb_cmd, 'devices'], |
82 stdout=subprocess.PIPE, | 82 stdout=subprocess.PIPE, |
83 stderr=subprocess.PIPE).communicate() | 83 stderr=subprocess.PIPE).communicate() |
84 if err: | 84 if err: |
85 logging.warning('adb device error %s', err.strip()) | 85 logging.warning('adb device error %s', err.strip()) |
86 return re.findall('^(\w+)\tdevice$', out, re.MULTILINE) | 86 return re.findall('^(\S+)\tdevice$', out, re.MULTILINE) |
87 except TimeoutException: | 87 except TimeoutException: |
88 logging.warning('"adb devices" command timed out') | 88 logging.warning('"adb devices" command timed out') |
89 return [] | 89 return [] |
90 except (IOError, OSError): | 90 except (IOError, OSError): |
91 logging.exception('Exception from "adb devices"') | 91 logging.exception('Exception from "adb devices"') |
92 return [] | 92 return [] |
93 finally: | 93 finally: |
94 signal.alarm(0) | 94 signal.alarm(0) |
95 | 95 |
96 | 96 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 pass | 147 pass |
148 os.remove(pid_file_path) | 148 os.remove(pid_file_path) |
149 | 149 |
150 | 150 |
151 if __name__ == '__main__': | 151 if __name__ == '__main__': |
152 if 2 <= len(sys.argv) <= 3: | 152 if 2 <= len(sys.argv) <= 3: |
153 print 'adb_logcat_monitor: Initializing' | 153 print 'adb_logcat_monitor: Initializing' |
154 sys.exit(main(*sys.argv[1:3])) | 154 sys.exit(main(*sys.argv[1:3])) |
155 | 155 |
156 print 'Usage: %s <base_dir> [<adb_binary_path>]' % sys.argv[0] | 156 print 'Usage: %s <base_dir> [<adb_binary_path>]' % sys.argv[0] |
OLD | NEW |