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.
8 from pylib import constants
9 _BLACKLIST_JSON = os.path.join(
10 constants.DIR_SOURCE_ROOT,
11 os.environ.get('CHROMIUM_OUT_DIR', 'out'),
15 """Reads the blacklist from the _BLACKLIST_JSON file.
18 A list containing bad devices.
20 if not os.path.exists(_BLACKLIST_JSON):
23 with open(_BLACKLIST_JSON, 'r') as f:
27 def WriteBlacklist(blacklist):
28 """Writes the provided blacklist to the _BLACKLIST_JSON file.
31 blacklist: list of bad devices to write to the _BLACKLIST_JSON file.
33 with open(_BLACKLIST_JSON, 'w') as f:
34 json.dump(list(set(blacklist)), f)
37 def ExtendBlacklist(devices):
38 """Adds devices to _BLACKLIST_JSON file.
41 devices: list of bad devices to be added to the _BLACKLIST_JSON file.
43 blacklist = ReadBlacklist()
44 blacklist.extend(devices)
45 WriteBlacklist(blacklist)
49 """Erases the _BLACKLIST_JSON file if it exists."""
50 if os.path.exists(_BLACKLIST_JSON):
51 os.remove(_BLACKLIST_JSON)