Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: build/android/buildbot/bb_device_status_check.py

Issue 385733002: Make KillAllAdb robust to AccessDenied exceptions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698