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

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

Issue 521823003: Added mailing list for device alerts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CC Mailing List so GUTS can CC. Created 6 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
« 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 json 8 import json
9 import logging 9 import logging
10 import optparse 10 import optparse
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 missing_devs = list(set(last_devices) - set(adb_online_devs)) 143 missing_devs = list(set(last_devices) - set(adb_online_devs))
144 new_missing_devs = list(set(missing_devs) - set(last_missing_devices)) 144 new_missing_devs = list(set(missing_devs) - set(last_missing_devices))
145 145
146 if new_missing_devs and os.environ.get('BUILDBOT_SLAVENAME'): 146 if new_missing_devs and os.environ.get('BUILDBOT_SLAVENAME'):
147 logging.info('new_missing_devs %s' % new_missing_devs) 147 logging.info('new_missing_devs %s' % new_missing_devs)
148 devices_missing_msg = '%d devices not detected.' % len(missing_devs) 148 devices_missing_msg = '%d devices not detected.' % len(missing_devs)
149 bb_annotations.PrintSummaryText(devices_missing_msg) 149 bb_annotations.PrintSummaryText(devices_missing_msg)
150 150
151 from_address = 'chrome-bot@chromium.org' 151 from_address = 'chrome-bot@chromium.org'
152 to_addresses = ['chrome-labs-tech-ticket@google.com'] 152 to_addresses = ['chrome-labs-tech-ticket@google.com',
153 'chrome-android-device-alert@google.com']
friedman 2014/09/03 21:42:24 Do you have to have it in the To address as well a
154 cc_addresses = ['chrome-android-device-alert@google.com']
153 subject = 'Devices offline on %s, %s, %s' % ( 155 subject = 'Devices offline on %s, %s, %s' % (
154 os.environ.get('BUILDBOT_SLAVENAME'), 156 os.environ.get('BUILDBOT_SLAVENAME'),
155 os.environ.get('BUILDBOT_BUILDERNAME'), 157 os.environ.get('BUILDBOT_BUILDERNAME'),
156 os.environ.get('BUILDBOT_BUILDNUMBER')) 158 os.environ.get('BUILDBOT_BUILDNUMBER'))
157 msg = ('Please reboot the following devices:\n%s' % 159 msg = ('Please reboot the following devices:\n%s' %
158 '\n'.join(map(str,new_missing_devs))) 160 '\n'.join(map(str,new_missing_devs)))
159 SendEmail(from_address, to_addresses, subject, msg) 161 SendEmail(from_address, to_addresses, cc_addresses, subject, msg)
160 162
161 all_known_devices = list(set(adb_online_devs) | set(last_devices)) 163 all_known_devices = list(set(adb_online_devs) | set(last_devices))
162 device_list.WritePersistentDeviceList(last_devices_path, all_known_devices) 164 device_list.WritePersistentDeviceList(last_devices_path, all_known_devices)
163 device_list.WritePersistentDeviceList(last_missing_devices_path, missing_devs) 165 device_list.WritePersistentDeviceList(last_missing_devices_path, missing_devs)
164 166
165 if not all_known_devices: 167 if not all_known_devices:
166 # This can happen if for some reason the .last_devices file is not 168 # This can happen if for some reason the .last_devices file is not
167 # present or if it was empty. 169 # present or if it was empty.
168 return ['No online devices. Have any devices been plugged in?'] 170 return ['No online devices. Have any devices been plugged in?']
169 if missing_devs: 171 if missing_devs:
(...skipping 21 matching lines...) Expand all
191 else: 193 else:
192 new_devs = set(adb_online_devs) - set(last_devices) 194 new_devs = set(adb_online_devs) - set(last_devices)
193 if new_devs and os.path.exists(last_devices_path): 195 if new_devs and os.path.exists(last_devices_path):
194 bb_annotations.PrintWarning() 196 bb_annotations.PrintWarning()
195 bb_annotations.PrintSummaryText( 197 bb_annotations.PrintSummaryText(
196 '%d new devices detected' % len(new_devs)) 198 '%d new devices detected' % len(new_devs))
197 print ('New devices detected %s. And now back to your ' 199 print ('New devices detected %s. And now back to your '
198 'regularly scheduled program.' % list(new_devs)) 200 'regularly scheduled program.' % list(new_devs))
199 201
200 202
201 def SendEmail(from_address, to_addresses, subject, msg): 203 def SendEmail(from_address, to_addresses, cc_addresses, subject, msg):
202 msg_body = '\r\n'.join(['From: %s' % from_address, 204 msg_body = '\r\n'.join(['From: %s' % from_address,
203 'To: %s' % ', '.join(to_addresses), 205 'To: %s' % ', '.join(to_addresses),
206 'CC: %s' % ', '.join(cc_addresses),
204 'Subject: %s' % subject, '', msg]) 207 'Subject: %s' % subject, '', msg])
205 try: 208 try:
206 server = smtplib.SMTP('localhost') 209 server = smtplib.SMTP('localhost')
207 server.sendmail(from_address, to_addresses, msg_body) 210 server.sendmail(from_address, to_addresses, msg_body)
208 server.quit() 211 server.quit()
209 except Exception as e: 212 except Exception as e:
210 print 'Failed to send alert email. Error: %s' % e 213 print 'Failed to send alert email. Error: %s' % e
211 214
212 215
213 def RestartUsb(): 216 def RestartUsb():
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 347
345 if err_msg: 348 if err_msg:
346 bb_annotations.PrintWarning() 349 bb_annotations.PrintWarning()
347 msg = '\n'.join(err_msg) 350 msg = '\n'.join(err_msg)
348 print msg 351 print msg
349 from_address = 'buildbot@chromium.org' 352 from_address = 'buildbot@chromium.org'
350 to_addresses = ['chromium-android-device-alerts@google.com'] 353 to_addresses = ['chromium-android-device-alerts@google.com']
351 bot_name = os.environ.get('BUILDBOT_BUILDERNAME') 354 bot_name = os.environ.get('BUILDBOT_BUILDERNAME')
352 slave_name = os.environ.get('BUILDBOT_SLAVENAME') 355 slave_name = os.environ.get('BUILDBOT_SLAVENAME')
353 subject = 'Device status check errors on %s, %s.' % (slave_name, bot_name) 356 subject = 'Device status check errors on %s, %s.' % (slave_name, bot_name)
354 SendEmail(from_address, to_addresses, subject, msg) 357 SendEmail(from_address, to_addresses, [], subject, msg)
355 358
356 if options.device_status_dashboard: 359 if options.device_status_dashboard:
357 perf_tests_results_helper.PrintPerfResult('BotDevices', 'OnlineDevices', 360 perf_tests_results_helper.PrintPerfResult('BotDevices', 'OnlineDevices',
358 [len(devices)], 'devices') 361 [len(devices)], 'devices')
359 perf_tests_results_helper.PrintPerfResult('BotDevices', 'OfflineDevices', 362 perf_tests_results_helper.PrintPerfResult('BotDevices', 'OfflineDevices',
360 [len(offline_devices)], 'devices', 363 [len(offline_devices)], 'devices',
361 'unimportant') 364 'unimportant')
362 for serial, battery in zip(devices, batteries): 365 for serial, battery in zip(devices, batteries):
363 perf_tests_results_helper.PrintPerfResult('DeviceBattery', serial, 366 perf_tests_results_helper.PrintPerfResult('DeviceBattery', serial,
364 [battery], '%', 367 [battery], '%',
(...skipping 14 matching lines...) Expand all
379 # devices with critically low battery. Remove those devices from testing, 382 # devices with critically low battery. Remove those devices from testing,
380 # allowing build to continue with good devices. 383 # allowing build to continue with good devices.
381 return 2 384 return 2
382 385
383 if not devices: 386 if not devices:
384 return 1 387 return 1
385 388
386 389
387 if __name__ == '__main__': 390 if __name__ == '__main__':
388 sys.exit(main()) 391 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