| 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 logging | 8 import logging |
| 9 import optparse | 9 import optparse |
| 10 import os | 10 import os |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 | 239 |
| 240 return all_restarted | 240 return all_restarted |
| 241 | 241 |
| 242 | 242 |
| 243 def KillAllAdb(): | 243 def KillAllAdb(): |
| 244 def GetAllAdb(): | 244 def GetAllAdb(): |
| 245 for p in psutil.process_iter(): | 245 for p in psutil.process_iter(): |
| 246 try: | 246 try: |
| 247 if 'adb' in p.name: | 247 if 'adb' in p.name: |
| 248 yield p | 248 yield p |
| 249 except psutil.error.NoSuchProcess: | 249 except (psutil.error.NoSuchProcess, psutil.error.AccessDenied): |
| 250 pass | 250 pass |
| 251 | 251 |
| 252 for sig in [signal.SIGTERM, signal.SIGQUIT, signal.SIGKILL]: | 252 for sig in [signal.SIGTERM, signal.SIGQUIT, signal.SIGKILL]: |
| 253 for p in GetAllAdb(): | 253 for p in GetAllAdb(): |
| 254 try: | 254 try: |
| 255 print 'kill %d %d (%s [%s])' % (sig, p.pid, p.name, | 255 print 'kill %d %d (%s [%s])' % (sig, p.pid, p.name, |
| 256 ' '.join(p.cmdline)) | 256 ' '.join(p.cmdline)) |
| 257 p.send_signal(sig) | 257 p.send_signal(sig) |
| 258 except psutil.error.NoSuchProcess: | 258 except (psutil.error.NoSuchProcess, psutil.error.AccessDenied): |
| 259 pass | 259 pass |
| 260 for p in GetAllAdb(): | 260 for p in GetAllAdb(): |
| 261 try: | 261 try: |
| 262 print 'Unable to kill %d (%s [%s])' % (p.pid, p.name, ' '.join(p.cmdline)) | 262 print 'Unable to kill %d (%s [%s])' % (p.pid, p.name, ' '.join(p.cmdline)) |
| 263 except psutil.error.NoSuchProcess: | 263 except (psutil.error.NoSuchProcess, psutil.error.AccessDenied): |
| 264 pass | 264 pass |
| 265 | 265 |
| 266 | 266 |
| 267 def main(): | 267 def main(): |
| 268 parser = optparse.OptionParser() | 268 parser = optparse.OptionParser() |
| 269 parser.add_option('', '--out-dir', | 269 parser.add_option('', '--out-dir', |
| 270 help='Directory where the device path is stored', | 270 help='Directory where the device path is stored', |
| 271 default=os.path.join(constants.DIR_SOURCE_ROOT, 'out')) | 271 default=os.path.join(constants.DIR_SOURCE_ROOT, 'out')) |
| 272 parser.add_option('--no-provisioning-check', action='store_true', | 272 parser.add_option('--no-provisioning-check', action='store_true', |
| 273 help='Will not check if devices are provisioned properly.') | 273 help='Will not check if devices are provisioned properly.') |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 # devices with critically low battery. Remove those devices from testing, | 364 # devices with critically low battery. Remove those devices from testing, |
| 365 # allowing build to continue with good devices. | 365 # allowing build to continue with good devices. |
| 366 return 2 | 366 return 2 |
| 367 | 367 |
| 368 if not devices: | 368 if not devices: |
| 369 return 1 | 369 return 1 |
| 370 | 370 |
| 371 | 371 |
| 372 if __name__ == '__main__': | 372 if __name__ == '__main__': |
| 373 sys.exit(main()) | 373 sys.exit(main()) |
| OLD | NEW |