| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 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 """A class to keep track of devices across builds and report state.""" | 7 """A class to keep track of devices across builds and report state.""" |
| 8 import json | 8 import json |
| 9 import logging | 9 import logging |
| 10 import optparse | 10 import optparse |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 | 242 |
| 243 return all_restarted | 243 return all_restarted |
| 244 | 244 |
| 245 | 245 |
| 246 def KillAllAdb(): | 246 def KillAllAdb(): |
| 247 def GetAllAdb(): | 247 def GetAllAdb(): |
| 248 for p in psutil.process_iter(): | 248 for p in psutil.process_iter(): |
| 249 try: | 249 try: |
| 250 if 'adb' in p.name: | 250 if 'adb' in p.name: |
| 251 yield p | 251 yield p |
| 252 except (psutil.error.NoSuchProcess, psutil.error.AccessDenied): | 252 except (psutil.NoSuchProcess, psutil.AccessDenied): |
| 253 pass | 253 pass |
| 254 | 254 |
| 255 for sig in [signal.SIGTERM, signal.SIGQUIT, signal.SIGKILL]: | 255 for sig in [signal.SIGTERM, signal.SIGQUIT, signal.SIGKILL]: |
| 256 for p in GetAllAdb(): | 256 for p in GetAllAdb(): |
| 257 try: | 257 try: |
| 258 print 'kill %d %d (%s [%s])' % (sig, p.pid, p.name, | 258 print 'kill %d %d (%s [%s])' % (sig, p.pid, p.name, |
| 259 ' '.join(p.cmdline)) | 259 ' '.join(p.cmdline)) |
| 260 p.send_signal(sig) | 260 p.send_signal(sig) |
| 261 except (psutil.error.NoSuchProcess, psutil.error.AccessDenied): | 261 except (psutil.NoSuchProcess, psutil.AccessDenied): |
| 262 pass | 262 pass |
| 263 for p in GetAllAdb(): | 263 for p in GetAllAdb(): |
| 264 try: | 264 try: |
| 265 print 'Unable to kill %d (%s [%s])' % (p.pid, p.name, ' '.join(p.cmdline)) | 265 print 'Unable to kill %d (%s [%s])' % (p.pid, p.name, ' '.join(p.cmdline)) |
| 266 except (psutil.error.NoSuchProcess, psutil.error.AccessDenied): | 266 except (psutil.NoSuchProcess, psutil.AccessDenied): |
| 267 pass | 267 pass |
| 268 | 268 |
| 269 | 269 |
| 270 def main(): | 270 def main(): |
| 271 parser = optparse.OptionParser() | 271 parser = optparse.OptionParser() |
| 272 parser.add_option('', '--out-dir', | 272 parser.add_option('', '--out-dir', |
| 273 help='Directory where the device path is stored', | 273 help='Directory where the device path is stored', |
| 274 default=os.path.join(constants.DIR_SOURCE_ROOT, 'out')) | 274 default=os.path.join(constants.DIR_SOURCE_ROOT, 'out')) |
| 275 parser.add_option('--no-provisioning-check', action='store_true', | 275 parser.add_option('--no-provisioning-check', action='store_true', |
| 276 help='Will not check if devices are provisioned properly.') | 276 help='Will not check if devices are provisioned properly.') |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 # devices with critically low battery. Remove those devices from testing, | 379 # devices with critically low battery. Remove those devices from testing, |
| 380 # allowing build to continue with good devices. | 380 # allowing build to continue with good devices. |
| 381 return 2 | 381 return 2 |
| 382 | 382 |
| 383 if not devices: | 383 if not devices: |
| 384 return 1 | 384 return 1 |
| 385 | 385 |
| 386 | 386 |
| 387 if __name__ == '__main__': | 387 if __name__ == '__main__': |
| 388 sys.exit(main()) | 388 sys.exit(main()) |
| OLD | NEW |