Index: build/android/pylib/device/device_list.py |
diff --git a/build/android/pylib/device/device_list.py b/build/android/pylib/device/device_list.py |
index 0eb6acba2b28b66c0c473f6ecd615f70f39f73b9..6dad115b832a9229fb43ac6fdc63b93e76037a39 100644 |
--- a/build/android/pylib/device/device_list.py |
+++ b/build/android/pylib/device/device_list.py |
@@ -4,27 +4,32 @@ |
"""A module to keep track of devices across builds.""" |
+import json |
import os |
LAST_DEVICES_FILENAME = '.last_devices' |
-LAST_MISSING_DEVICES_FILENAME = '.last_missing' |
-def GetPersistentDeviceList(file_name): |
- """Returns a list of devices. |
+def GetOfflineDeviceMap(file_name): |
jbudorick
2015/05/23 01:06:49
This is poorly named; it sounds like the map conta
luqui
2015/05/27 20:01:12
Done.
|
+ """Returns a dictionary of devices to the number of runs we have seen them |
+ offline. So 0 indicates that they were last seen online. |
Args: |
file_name: the file name containing a list of devices. |
- Returns: List of device serial numbers that were on the bot. |
+ Returns: Dictionary mapping device ID to integer. |
""" |
with open(file_name) as f: |
- return f.read().splitlines() |
+ contents = f.read() |
+ try: |
+ return json.loads(contents) |
+ except ValueError: # This might happen in old to new format transition. |
+ return [] |
-def WritePersistentDeviceList(file_name, device_list): |
+def WriteOfflineDeviceMap(file_name, device_map): |
path = os.path.dirname(file_name) |
if not os.path.exists(path): |
os.makedirs(path) |
with open(file_name, 'w') as f: |
- f.write('\n'.join(set(device_list))) |
+ f.write(json.dumps(device_map)) |