 Chromium Code Reviews
 Chromium Code Reviews Issue 336713002:
  Alert chrome-labs-tech-ticket when new offline device detected.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 336713002:
  Alert chrome-labs-tech-ticket when new offline device detected.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: build/android/buildbot/bb_device_status_check.py | 
| diff --git a/build/android/buildbot/bb_device_status_check.py b/build/android/buildbot/bb_device_status_check.py | 
| index a3b83415b3c21b90a1c90898818cd95517540125..9290456fa4cec08df61cf978224637c6dc9790fd 100755 | 
| --- a/build/android/buildbot/bb_device_status_check.py | 
| +++ b/build/android/buildbot/bb_device_status_check.py | 
| @@ -125,19 +125,40 @@ def CheckForMissingDevices(options, adb_online_devs): | 
| out_dir = os.path.abspath(options.out_dir) | 
| + # last_devices denotes all known devices prior to this run | 
| last_devices_path = os.path.join(out_dir, device_list.LAST_DEVICES_FILENAME) | 
| + last_missing_devices_path = os.path.join(out_dir, | 
| + device_list.LAST_MISSING_DEVICES_FILENAME) | 
| try: | 
| last_devices = device_list.GetPersistentDeviceList(last_devices_path) | 
| except IOError: | 
| # Ignore error, file might not exist | 
| last_devices = [] | 
| + | 
| + try: | 
| + last_missing_devices = device_list.GetPersistentDeviceList( | 
| + last_missing_devices_path) | 
| + except IOError: | 
| + last_missing_devices = [] | 
| + | 
| missing_devs = list(set(last_devices) - set(adb_online_devs)) | 
| 
friedman1
2014/06/13 00:31:55
If you keep these as a set you can use better oper
 | 
| + new_missing_devs = list(set(missing_devs) - set(last_missing_devices)) | 
| + | 
| + if new_missing_devs: | 
| + logging.info('new_missing_devs %s' % new_missing_devs) | 
| + devices_missing_msg = '%d devices not detected.' % len(missing_devs) | 
| + bb_annotations.PrintSummaryText(devices_missing_msg) | 
| + | 
| + from_address = 'chrome-bot@google.com' | 
| + to_address = 'chrome-labs-tech-ticket@google.com' | 
| + subject = 'Devices offline on %s' % os.environ.get('BUILDBOT_SLAVENAME') | 
| + msg = ('Please reboot the following devices:\n%s' % | 
| + '\n'.join(map(str,new_missing_devs))) | 
| + SendEmail(from_address, to_address, subject, msg) | 
| all_known_devices = list(set(adb_online_devs) | set(last_devices)) | 
| device_list.WritePersistentDeviceList(last_devices_path, all_known_devices) | 
| - device_list.WritePersistentDeviceList( | 
| - os.path.join(out_dir, device_list.LAST_MISSING_DEVICES_FILENAME), | 
| - missing_devs) | 
| + device_list.WritePersistentDeviceList(last_missing_devices_path, missing_devs) | 
| if not all_known_devices: | 
| # This can happen if for some reason the .last_devices file is not | 
| @@ -176,12 +197,7 @@ def CheckForMissingDevices(options, adb_online_devs): | 
| 'regularly scheduled program.' % list(new_devs)) | 
| -def SendDeviceStatusAlert(msg): | 
| - from_address = 'buildbot@chromium.org' | 
| - to_address = 'chromium-android-device-alerts@google.com' | 
| - bot_name = os.environ.get('BUILDBOT_BUILDERNAME') | 
| - slave_name = os.environ.get('BUILDBOT_SLAVENAME') | 
| - subject = 'Device status check errors on %s, %s.' % (slave_name, bot_name) | 
| +def SendEmail(from_address, to_address, subject, msg): | 
| msg_body = '\r\n'.join(['From: %s' % from_address, 'To: %s' % to_address, | 
| 'Subject: %s' % subject, '', msg]) | 
| try: | 
| @@ -324,7 +340,12 @@ def main(): | 
| bb_annotations.PrintWarning() | 
| msg = '\n'.join(err_msg) | 
| print msg | 
| - SendDeviceStatusAlert(msg) | 
| + from_address = 'buildbot@chromium.org' | 
| + to_address = 'chromium-android-device-alerts@google.com' | 
| + bot_name = os.environ.get('BUILDBOT_BUILDERNAME') | 
| + slave_name = os.environ.get('BUILDBOT_SLAVENAME') | 
| + subject = 'Device status check errors on %s, %s.' % (slave_name, bot_name) | 
| + SendEmail(from_address, to_address, subject, msg) | 
| if options.device_status_dashboard: | 
| perf_tests_results_helper.PrintPerfResult('BotDevices', 'OnlineDevices', |