| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 249 |
| 250 if failed_restart: | 250 if failed_restart: |
| 251 return 1 | 251 return 1 |
| 252 | 252 |
| 253 return 0 | 253 return 0 |
| 254 | 254 |
| 255 | 255 |
| 256 def KillAllAdb(): | 256 def KillAllAdb(): |
| 257 def GetAllAdb(): | 257 def GetAllAdb(): |
| 258 for p in psutil.process_iter(): | 258 for p in psutil.process_iter(): |
| 259 if 'adb' in p.name: | 259 try: |
| 260 yield p | 260 if 'adb' in p.name: |
| 261 yield p |
| 262 except psutil.error.NoSuchProcess: |
| 263 pass |
| 261 | 264 |
| 262 for sig in [signal.SIGTERM, signal.SIGQUIT, signal.SIGKILL]: | 265 for sig in [signal.SIGTERM, signal.SIGQUIT, signal.SIGKILL]: |
| 263 for p in GetAllAdb(): | 266 for p in GetAllAdb(): |
| 264 try: | 267 try: |
| 265 print 'kill %d %d (%s [%s])' % (sig, p.pid, p.name, | 268 print 'kill %d %d (%s [%s])' % (sig, p.pid, p.name, |
| 266 ' '.join(p.cmdline)) | 269 ' '.join(p.cmdline)) |
| 267 p.send_signal(sig) | 270 p.send_signal(sig) |
| 268 except psutil.error.NoSuchProcess: | 271 except psutil.error.NoSuchProcess: |
| 269 pass | 272 pass |
| 270 for p in GetAllAdb(): | 273 for p in GetAllAdb(): |
| 271 print 'Unable to kill %d (%s [%s])' % (p.pid, p.name, ' '.join(p.cmdline)) | 274 try: |
| 275 print 'Unable to kill %d (%s [%s])' % (p.pid, p.name, ' '.join(p.cmdline)) |
| 276 except psutil.error.NoSuchProcess: |
| 277 pass |
| 272 | 278 |
| 273 | 279 |
| 274 def main(): | 280 def main(): |
| 275 parser = optparse.OptionParser() | 281 parser = optparse.OptionParser() |
| 276 parser.add_option('', '--out-dir', | 282 parser.add_option('', '--out-dir', |
| 277 help='Directory where the device path is stored', | 283 help='Directory where the device path is stored', |
| 278 default=os.path.join(constants.DIR_SOURCE_ROOT, 'out')) | 284 default=os.path.join(constants.DIR_SOURCE_ROOT, 'out')) |
| 279 parser.add_option('--no-provisioning-check', action='store_true', | 285 parser.add_option('--no-provisioning-check', action='store_true', |
| 280 help='Will not check if devices are provisioned properly.') | 286 help='Will not check if devices are provisioned properly.') |
| 281 parser.add_option('--device-status-dashboard', action='store_true', | 287 parser.add_option('--device-status-dashboard', action='store_true', |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 # devices with critically low battery or install speed. Remove those devices | 356 # devices with critically low battery or install speed. Remove those devices |
| 351 # from testing, allowing build to continue with good devices. | 357 # from testing, allowing build to continue with good devices. |
| 352 return 1 | 358 return 1 |
| 353 | 359 |
| 354 if not devices: | 360 if not devices: |
| 355 return 1 | 361 return 1 |
| 356 | 362 |
| 357 | 363 |
| 358 if __name__ == '__main__': | 364 if __name__ == '__main__': |
| 359 sys.exit(main()) | 365 sys.exit(main()) |
| OLD | NEW |