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

Side by Side Diff: build/android/devil/android/device_blacklist.py

Issue 1334803002: Revert of [Android] Don't use a device blacklist if one isn't provided. (RELAND) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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_steps.py ('k') | build/android/devil/android/device_utils.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 import json 5 import json
6 import logging
7 import os 6 import os
8 import threading 7 import threading
9 8
10 from pylib import constants 9 from pylib import constants
11 10
12 # TODO(jbudorick): Remove this once the blacklist is optional. 11 # TODO(jbudorick): Remove this once the blacklist is optional.
13 BLACKLIST_JSON = os.path.join( 12 BLACKLIST_JSON = os.path.join(
14 constants.DIR_SOURCE_ROOT, 13 constants.DIR_SOURCE_ROOT,
15 os.environ.get('CHROMIUM_OUT_DIR', 'out'), 14 os.environ.get('CHROMIUM_OUT_DIR', 'out'),
16 'bad_devices.json') 15 'bad_devices.json')
(...skipping 26 matching lines...) Expand all
43 with self._blacklist_lock: 42 with self._blacklist_lock:
44 with open(self._path, 'w') as f: 43 with open(self._path, 'w') as f:
45 json.dump(list(set(blacklist)), f) 44 json.dump(list(set(blacklist)), f)
46 45
47 def Extend(self, devices): 46 def Extend(self, devices):
48 """Adds devices to blacklist file. 47 """Adds devices to blacklist file.
49 48
50 Args: 49 Args:
51 devices: list of bad devices to be added to the blacklist file. 50 devices: list of bad devices to be added to the blacklist file.
52 """ 51 """
53 logging.info('Adding %s to blacklist %s', ','.join(devices), self._path)
54 with self._blacklist_lock: 52 with self._blacklist_lock:
55 blacklist = self.Read() 53 blacklist = ReadBlacklist()
56 blacklist.extend(devices) 54 blacklist.extend(devices)
57 self.Write(blacklist) 55 WriteBlacklist(blacklist)
58 56
59 def Reset(self): 57 def Reset(self):
60 """Erases the blacklist file if it exists.""" 58 """Erases the blacklist file if it exists."""
61 logging.info('Resetting blacklist %s', self._path)
62 with self._blacklist_lock: 59 with self._blacklist_lock:
63 if os.path.exists(self._path): 60 if os.path.exists(self._path):
64 os.remove(self._path) 61 os.remove(self._path)
65 62
63
64 def ReadBlacklist():
65 # TODO(jbudorick): Phase out once all clients have migrated.
66 return Blacklist(BLACKLIST_JSON).Read()
67
68
69 def WriteBlacklist(blacklist):
70 # TODO(jbudorick): Phase out once all clients have migrated.
71 Blacklist(BLACKLIST_JSON).Write(blacklist)
72
73
74 def ExtendBlacklist(devices):
75 # TODO(jbudorick): Phase out once all clients have migrated.
76 Blacklist(BLACKLIST_JSON).Extend(devices)
77
78
79 def ResetBlacklist():
80 # TODO(jbudorick): Phase out once all clients have migrated.
81 Blacklist(BLACKLIST_JSON).Reset()
82
OLDNEW
« no previous file with comments | « build/android/buildbot/bb_device_steps.py ('k') | build/android/devil/android/device_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698