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

Side by Side 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: Sort devices again for reboot-stability Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « build/android/buildbot/bb_device_status_check.py ('k') | build/android/pylib/perf/setup.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """A module to keep track of devices across builds.""" 5 """A module to keep track of devices across builds."""
6 6
7 import json
7 import os 8 import os
8 9
9 LAST_DEVICES_FILENAME = '.last_devices' 10 LAST_DEVICES_FILENAME = '.last_devices'
10 LAST_MISSING_DEVICES_FILENAME = '.last_missing'
11 11
12 12
13 def GetPersistentDeviceList(file_name): 13 def ReadDeviceOfflineCountMap(file_name):
14 """Returns a list of devices. 14 """Returns a dictionary of devices to the number of runs we have seen them
15 offline. So 0 indicates that they were last seen online.
15 16
16 Args: 17 Args:
17 file_name: the file name containing a list of devices. 18 file_name: the file name containing a list of devices.
18 19
19 Returns: List of device serial numbers that were on the bot. 20 Returns: Dictionary mapping device ID to integer.
20 """ 21 """
21 with open(file_name) as f: 22 with open(file_name) as f:
22 return f.read().splitlines() 23 contents = f.read()
24 try:
25 return json.loads(contents)
26 except ValueError: # This might happen in old to new format transition.
27 return []
23 28
24 29
25 def WritePersistentDeviceList(file_name, device_list): 30 def WriteDeviceOfflineCountMap(file_name, device_map):
26 path = os.path.dirname(file_name) 31 path = os.path.dirname(file_name)
27 if not os.path.exists(path): 32 if not os.path.exists(path):
28 os.makedirs(path) 33 os.makedirs(path)
29 with open(file_name, 'w') as f: 34 with open(file_name, 'w') as f:
30 f.write('\n'.join(set(device_list))) 35 f.write(json.dumps(device_map))
OLDNEW
« no previous file with comments | « build/android/buildbot/bb_device_status_check.py ('k') | build/android/pylib/perf/setup.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698