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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 print 'adb_logcat_monitor: %s already exists? Cleaning' % base_dir | 101 print 'adb_logcat_monitor: %s already exists? Cleaning' % base_dir |
102 shutil.rmtree(base_dir, ignore_errors=True) | 102 shutil.rmtree(base_dir, ignore_errors=True) |
103 | 103 |
104 os.makedirs(base_dir) | 104 os.makedirs(base_dir) |
105 logging.basicConfig(filename=os.path.join(base_dir, 'eventlog'), | 105 logging.basicConfig(filename=os.path.join(base_dir, 'eventlog'), |
106 level=logging.INFO, | 106 level=logging.INFO, |
107 format='%(asctime)-2s %(levelname)-8s %(message)s') | 107 format='%(asctime)-2s %(levelname)-8s %(message)s') |
108 | 108 |
109 # Set up the alarm for calling 'adb devices'. This is to ensure | 109 # Set up the alarm for calling 'adb devices'. This is to ensure |
110 # our script doesn't get stuck waiting for a process response | 110 # our script doesn't get stuck waiting for a process response |
| 111 # pylint: disable=unused-argument |
111 def TimeoutHandler(_signum, _unused_frame): | 112 def TimeoutHandler(_signum, _unused_frame): |
112 raise TimeoutException() | 113 raise TimeoutException() |
113 signal.signal(signal.SIGALRM, TimeoutHandler) | 114 signal.signal(signal.SIGALRM, TimeoutHandler) |
114 | 115 |
115 # Handle SIGTERMs to ensure clean shutdown | 116 # Handle SIGTERMs to ensure clean shutdown |
| 117 # pylint: disable=unused-argument |
116 def SigtermHandler(_signum, _unused_frame): | 118 def SigtermHandler(_signum, _unused_frame): |
117 raise SigtermError() | 119 raise SigtermError() |
118 signal.signal(signal.SIGTERM, SigtermHandler) | 120 signal.signal(signal.SIGTERM, SigtermHandler) |
119 | 121 |
120 logging.info('Started with pid %d', os.getpid()) | 122 logging.info('Started with pid %d', os.getpid()) |
121 pid_file_path = os.path.join(base_dir, 'LOGCAT_MONITOR_PID') | 123 pid_file_path = os.path.join(base_dir, 'LOGCAT_MONITOR_PID') |
122 | 124 |
123 try: | 125 try: |
124 with open(pid_file_path, 'w') as f: | 126 with open(pid_file_path, 'w') as f: |
125 f.write(str(os.getpid())) | 127 f.write(str(os.getpid())) |
(...skipping 21 matching lines...) Expand all Loading... |
147 pass | 149 pass |
148 os.remove(pid_file_path) | 150 os.remove(pid_file_path) |
149 | 151 |
150 | 152 |
151 if __name__ == '__main__': | 153 if __name__ == '__main__': |
152 if 2 <= len(sys.argv) <= 3: | 154 if 2 <= len(sys.argv) <= 3: |
153 print 'adb_logcat_monitor: Initializing' | 155 print 'adb_logcat_monitor: Initializing' |
154 sys.exit(main(*sys.argv[1:3])) | 156 sys.exit(main(*sys.argv[1:3])) |
155 | 157 |
156 print 'Usage: %s <base_dir> [<adb_binary_path>]' % sys.argv[0] | 158 print 'Usage: %s <base_dir> [<adb_binary_path>]' % sys.argv[0] |
OLD | NEW |