Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Unified Diff: build/android/pylib/device/device_list.py

Issue 1148873007: Fix last_devices to be quieter, and improve device affinity. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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))

Powered by Google App Engine
This is Rietveld 408576698