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 import logging | 8 import logging |
9 import optparse | 9 import optparse |
10 import os | 10 import os |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 if not os.path.exists(out_dir): | 100 if not os.path.exists(out_dir): |
101 os.makedirs(out_dir) | 101 os.makedirs(out_dir) |
102 with open(path, 'w') as f: | 102 with open(path, 'w') as f: |
103 # Write devices currently visible plus devices previously seen. | 103 # Write devices currently visible plus devices previously seen. |
104 f.write('\n'.join(set(device_list))) | 104 f.write('\n'.join(set(device_list))) |
105 | 105 |
106 last_devices_path = os.path.join(out_dir, '.last_devices') | 106 last_devices_path = os.path.join(out_dir, '.last_devices') |
107 last_devices = ReadDeviceList('.last_devices') | 107 last_devices = ReadDeviceList('.last_devices') |
108 missing_devs = list(set(last_devices) - set(adb_online_devs)) | 108 missing_devs = list(set(last_devices) - set(adb_online_devs)) |
109 | 109 |
110 WriteDeviceList('.last_devices', (adb_online_devs + last_devices)) | 110 WriteDeviceList('.last_devices', (adb_online_devs + last_devices)) |
Isaac (away)
2013/05/07 07:57:50
make a variable:
all_known_devices = adb_online_d
| |
111 WriteDeviceList('.last_missing', missing_devs) | 111 WriteDeviceList('.last_missing', missing_devs) |
112 | 112 |
113 if not adb_online_devs and not last_devices: | |
Isaac (away)
2013/05/07 01:57:08
Not sure this is needed. Can you move the devices
Siva Chandra
2013/05/07 06:42:55
Wouldn't it be useful to report last devices (if .
Isaac (away)
2013/05/07 07:20:13
But this bypasses all the other logic. Why not in
Siva Chandra
2013/05/07 07:43:10
The 'if' at line 117 is executed if there were mis
Isaac (away)
2013/05/07 07:57:50
Good point.
| |
114 # This can happen if for some reason the .last_devices file is not | |
115 # present or if it was empty. | |
116 return ['No online devices. Have any devices been plugged in?'] | |
113 if missing_devs: | 117 if missing_devs: |
114 devices_missing_msg = '%d devices not detected.' % len(missing_devs) | 118 devices_missing_msg = '%d devices not detected.' % len(missing_devs) |
115 buildbot_report.PrintSummaryText(devices_missing_msg) | 119 buildbot_report.PrintSummaryText(devices_missing_msg) |
116 | 120 |
117 # TODO(navabi): Debug by printing both output from GetCmdOutput and | 121 # TODO(navabi): Debug by printing both output from GetCmdOutput and |
118 # GetAttachedDevices to compare results. | 122 # GetAttachedDevices to compare results. |
119 return ['Current online devices: %s' % adb_online_devs, | 123 return ['Current online devices: %s' % adb_online_devs, |
120 '%s are no longer visible. Were they removed?\n' % missing_devs, | 124 '%s are no longer visible. Were they removed?\n' % missing_devs, |
121 'SHERIFF: See go/chrome_device_monitor', | 125 'SHERIFF: See go/chrome_device_monitor', |
122 'Cache file: %s\n\n' % last_devices_path, | 126 'Cache file: %s\n\n' % last_devices_path, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 msg = '\n'.join(err_msg) | 187 msg = '\n'.join(err_msg) |
184 print msg | 188 print msg |
185 SendDeviceStatusAlert(msg) | 189 SendDeviceStatusAlert(msg) |
186 | 190 |
187 if not devices: | 191 if not devices: |
188 return 1 | 192 return 1 |
189 | 193 |
190 | 194 |
191 if __name__ == '__main__': | 195 if __name__ == '__main__': |
192 sys.exit(main()) | 196 sys.exit(main()) |
OLD | NEW |