Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 """A module to keep track of devices across builds.""" | |
|
jbudorick
2014/06/03 13:52:52
I'm not sure that this module goes far enough - it
| |
| 6 | |
| 7 import os | |
| 8 | |
| 9 LAST_DEVICES_FILENAME = '.last_devices' | |
| 10 LAST_MISSING_DEVICES_FILENAME = '.last_missing' | |
| 11 | |
| 12 | |
| 13 def GetDeviceList(file_name): | |
|
jbudorick
2014/06/03 13:52:52
This should be renamed to avoid confusion with Adb
bulach
2014/06/03 14:25:52
good point! Get|WritePersistentDeviceList.
| |
| 14 """Returns a list of devices. | |
| 15 | |
| 16 Args: | |
| 17 file_name: the file name containing a list of devices. | |
| 18 | |
| 19 Returns: List of device serial numbers that were on the bot. | |
| 20 """ | |
| 21 devices = [] | |
| 22 try: | |
| 23 with open(file_name) as f: | |
| 24 devices = f.read().splitlines() | |
| 25 except IOError: | |
| 26 # Ignore error, file might not exist | |
| 27 pass | |
|
jbudorick
2014/06/03 13:52:52
This should log something. Not an error, obviously
bulach
2014/06/03 14:25:52
good catch.. the exception shouldn't be handled he
| |
| 28 return devices | |
| 29 | |
| 30 | |
| 31 def WriteDeviceList(file_name, device_list): | |
| 32 path = os.path.dirname(file_name) | |
| 33 if not os.path.exists(path): | |
| 34 os.makedirs(path) | |
| 35 with open(file_name, 'w') as f: | |
| 36 f.write('\n'.join(set(device_list))) | |
| OLD | NEW |