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

Side by Side Diff: build/android/device_status_check.py

Issue 10665012: Minor fixes to android device_status script (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | build/android/pylib/buildbot_report.py » ('j') | 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 (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 """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 8
9 import optparse 9 import optparse
10 import os 10 import os
11 import sys 11 import sys
12 12
13 from pylib import buildbot_report
13 from pylib.android_commands import GetAttachedDevices 14 from pylib.android_commands import GetAttachedDevices
14 from pylib.cmd_helper import GetCmdOutput 15 from pylib.cmd_helper import GetCmdOutput
15 16
16 17
17 def DeviceInfo(serial): 18 def DeviceInfo(serial):
18 """Gathers info on a device via various adb calls. 19 """Gathers info on a device via various adb calls.
19 20
20 Args: 21 Args:
21 serial: The serial of the attached device to construct info about. 22 serial: The serial of the attached device to construct info about.
22 23
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 last_devices = [] 64 last_devices = []
64 try: 65 try:
65 with open(last_devices_path) as f: 66 with open(last_devices_path) as f:
66 last_devices = f.read().splitlines() 67 last_devices = f.read().splitlines()
67 except IOError: 68 except IOError:
68 # Ignore error, file might not exist 69 # Ignore error, file might not exist
69 pass 70 pass
70 71
71 missing_devs = list(set(last_devices) - set(adb_online_devs)) 72 missing_devs = list(set(last_devices) - set(adb_online_devs))
72 if missing_devs: 73 if missing_devs:
73 print '@@@STEP_WARNINGS@@@' 74 buildbot_report.PrintWarning()
74 print '@@@STEP_SUMMARY_TEXT@%s not detected.@@@' % missing_devs 75 buildbot_report.PrintSummaryText(
76 '%d devices not detected.' % len(missing_devs))
75 print 'Current online devices: %s' % adb_online_devs 77 print 'Current online devices: %s' % adb_online_devs
76 print '%s are no longer visible. Were they removed?\n' % missing_devs 78 print '%s are no longer visible. Were they removed?\n' % missing_devs
77 print 'SHERIFF: See go/chrome_device_monitor' 79 print 'SHERIFF: See go/chrome_device_monitor'
78 print 'Cache file: %s\n\n' % last_devices_path 80 print 'Cache file: %s\n\n' % last_devices_path
79 print 'adb devices' 81 print 'adb devices'
80 print GetCmdOutput(['adb', 'devices']) 82 print GetCmdOutput(['adb', 'devices'])
81 else: 83 else:
82 new_devs = set(adb_online_devs) - set(last_devices) 84 new_devs = set(adb_online_devs) - set(last_devices)
83 if new_devs: 85 if new_devs and os.path.exists(last_devices_path):
84 print '@@@STEP_WARNINGS@@@' 86 buildbot_report.PrintWarning()
85 print '@@@STEP_SUMMARY_TEXT@New devices detected :-)@@@' 87 buildbot_report.PrintSummaryText(
88 '%d new devices detected' % len(new_devs))
86 print ('New devices detected %s. And now back to your ' 89 print ('New devices detected %s. And now back to your '
87 'regularly scheduled program.' % list(new_devs)) 90 'regularly scheduled program.' % list(new_devs))
88 91
89 # Write devices currently visible plus devices previously seen. 92 # Write devices currently visible plus devices previously seen.
90 with open(last_devices_path, 'w') as f: 93 with open(last_devices_path, 'w') as f:
91 f.write('\n'.join(set(adb_online_devs + last_devices))) 94 f.write('\n'.join(set(adb_online_devs + last_devices)))
92 95
93 96
94 def main(): 97 def main():
95 parser = optparse.OptionParser() 98 parser = optparse.OptionParser()
96 parser.add_option('', '--out-dir', 99 parser.add_option('', '--out-dir',
97 help='Directory where the device path is stored', 100 help='Directory where the device path is stored',
98 default=os.path.join(os.path.dirname(__file__), '..', 101 default=os.path.join(os.path.dirname(__file__), '..',
99 '..', 'out')) 102 '..', 'out'))
100 103
101 options, args = parser.parse_args() 104 options, args = parser.parse_args()
102 if args: 105 if args:
103 parser.error('Unknown options %s' % args) 106 parser.error('Unknown options %s' % args)
107 buildbot_report.PrintNamedStep('Device Status Check')
104 devices = GetAttachedDevices() 108 devices = GetAttachedDevices()
105
106 types, builds, reports = [], [], [] 109 types, builds, reports = [], [], []
107 if devices: 110 if devices:
108 types, builds, reports = zip(*[DeviceInfo(dev) for dev in devices]) 111 types, builds, reports = zip(*[DeviceInfo(dev) for dev in devices])
109 112
110 unique_types = list(set(types)) 113 unique_types = list(set(types))
111 unique_builds = list(set(builds)) 114 unique_builds = list(set(builds))
112 115
113 print ('@@@BUILD_STEP Device Status Check - ' 116 buildbot_report.PrintMsg('Online devices: %d. Device types %s, builds %s'
114 '%d online devices, types %s, builds %s@@@' 117 % (len(devices), unique_types, unique_builds))
115 % (len(devices), unique_types, unique_builds))
116 print '\n'.join(reports) 118 print '\n'.join(reports)
117 CheckForMissingDevices(options, devices) 119 CheckForMissingDevices(options, devices)
118 120
119 if __name__ == '__main__': 121 if __name__ == '__main__':
120 sys.exit(main()) 122 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/buildbot_report.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698