Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 smtplib | |
| 12 import string | |
| 11 import sys | 13 import sys |
| 12 | 14 |
| 13 from pylib import buildbot_report | 15 from pylib import buildbot_report |
| 14 from pylib.android_commands import GetAttachedDevices | 16 from pylib.android_commands import GetAttachedDevices |
| 15 from pylib.cmd_helper import GetCmdOutput | 17 from pylib.cmd_helper import GetCmdOutput |
| 16 | 18 |
| 17 | 19 |
| 18 def DeviceInfo(serial): | 20 def DeviceInfo(serial): |
| 19 """Gathers info on a device via various adb calls. | 21 """Gathers info on a device via various adb calls. |
| 20 | 22 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 last_devices = [] | 65 last_devices = [] |
| 64 try: | 66 try: |
| 65 with open(last_devices_path) as f: | 67 with open(last_devices_path) as f: |
| 66 last_devices = f.read().splitlines() | 68 last_devices = f.read().splitlines() |
| 67 except IOError: | 69 except IOError: |
| 68 # Ignore error, file might not exist | 70 # Ignore error, file might not exist |
| 69 pass | 71 pass |
| 70 | 72 |
| 71 missing_devs = list(set(last_devices) - set(adb_online_devs)) | 73 missing_devs = list(set(last_devices) - set(adb_online_devs)) |
| 72 if missing_devs: | 74 if missing_devs: |
| 75 from_address = 'buildbot@chromium.org' | |
| 76 to_address = 'clank-infrastructure-team@google.com' | |
|
Isaac (away)
2012/09/29 03:17:04
Suggest we add a keyword to this to make it easier
Isaac (away)
2012/09/29 03:33:08
You can ignore this earlier comment. But we can't
navabi1
2012/10/01 21:52:15
Done.
| |
| 77 script_path_list = os.getcwd().split('/') | |
| 78 # Assumes name of bot is after .../build/slave/<BOT NAME>/... | |
|
Isaac (away)
2012/09/29 03:17:04
I think cleaner to either use environment variable
navabi1
2012/10/01 21:52:15
Done.
| |
| 79 slave_index = script_path_list.index('slave') | |
| 80 bot_name = script_path_list[slave_index + 1] | |
| 81 subject = 'Device not detected on %s' % bot_name | |
|
Isaac (away)
2012/09/29 03:17:04
Several of the testers have the same name (they're
navabi1
2012/10/01 21:52:15
Rather than pass FACTORY_PROPERTIES, I'll use the
Isaac (away)
2012/10/01 22:35:45
sg
| |
| 82 | |
| 73 buildbot_report.PrintWarning() | 83 buildbot_report.PrintWarning() |
| 74 buildbot_report.PrintSummaryText( | 84 devices_missing_msg = '%d devices not detected.' % len(missing_devs) |
| 75 '%d devices not detected.' % len(missing_devs)) | 85 buildbot_report.PrintSummaryText(devices_missing_msg) |
| 76 print 'Current online devices: %s' % adb_online_devs | 86 |
| 77 print '%s are no longer visible. Were they removed?\n' % missing_devs | 87 body = string.join(( |
|
Isaac (away)
2012/09/29 03:17:04
nit: python will implicitly join strings that are
navabi1
2012/10/01 21:52:15
I prefer to leave it like this. While it is clean
Isaac (away)
2012/10/01 22:35:45
sg, was confused by the string.join
| |
| 78 print 'SHERIFF: See go/chrome_device_monitor' | 88 'Current online devices: %s' % adb_online_devs, |
| 79 print 'Cache file: %s\n\n' % last_devices_path | 89 '%s are no longer visible. Were they removed?\n' % missing_devs, |
| 80 print 'adb devices' | 90 'SHERIFF: See go/clank/engineering/buildbots/troubleshooting', |
| 81 print GetCmdOutput(['adb', 'devices']) | 91 'Cache file: %s\n\n' % last_devices_path, |
| 92 'adb devices', GetCmdOutput(['adb', 'devices'])), "\r\n") | |
| 93 | |
| 94 msg_body = string.join(( | |
| 95 "From: %s" % from_address, | |
| 96 "To: %s" % to_address, | |
| 97 "Subject: %s" % subject, | |
| 98 "", | |
| 99 body), "\r\n") | |
| 100 | |
| 101 print body | |
| 102 | |
| 103 # Send email from to clank infra | |
| 104 server = smtplib.SMTP('localhost') | |
| 105 server.sendmail(from_address, [to_address], msg_body) | |
| 106 server.quit() | |
| 82 else: | 107 else: |
| 83 new_devs = set(adb_online_devs) - set(last_devices) | 108 new_devs = set(adb_online_devs) - set(last_devices) |
| 84 if new_devs and os.path.exists(last_devices_path): | 109 if new_devs and os.path.exists(last_devices_path): |
| 85 buildbot_report.PrintWarning() | 110 buildbot_report.PrintWarning() |
| 86 buildbot_report.PrintSummaryText( | 111 buildbot_report.PrintSummaryText( |
| 87 '%d new devices detected' % len(new_devs)) | 112 '%d new devices detected' % len(new_devs)) |
| 88 print ('New devices detected %s. And now back to your ' | 113 print ('New devices detected %s. And now back to your ' |
| 89 'regularly scheduled program.' % list(new_devs)) | 114 'regularly scheduled program.' % list(new_devs)) |
| 90 | 115 |
| 91 if not os.path.exists(out_dir): | 116 if not os.path.exists(out_dir): |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 114 unique_types = list(set(types)) | 139 unique_types = list(set(types)) |
| 115 unique_builds = list(set(builds)) | 140 unique_builds = list(set(builds)) |
| 116 | 141 |
| 117 buildbot_report.PrintMsg('Online devices: %d. Device types %s, builds %s' | 142 buildbot_report.PrintMsg('Online devices: %d. Device types %s, builds %s' |
| 118 % (len(devices), unique_types, unique_builds)) | 143 % (len(devices), unique_types, unique_builds)) |
| 119 print '\n'.join(reports) | 144 print '\n'.join(reports) |
| 120 CheckForMissingDevices(options, devices) | 145 CheckForMissingDevices(options, devices) |
| 121 | 146 |
| 122 if __name__ == '__main__': | 147 if __name__ == '__main__': |
| 123 sys.exit(main()) | 148 sys.exit(main()) |
| OLD | NEW |