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.
9 from pylib
import constants
10 _BLACKLIST_JSON
= os
.path
.join(
11 constants
.DIR_SOURCE_ROOT
,
12 os
.environ
.get('CHROMIUM_OUT_DIR', 'out'),
15 # Note that this only protects against concurrent accesses to the blacklist
17 _blacklist_lock
= threading
.RLock()
20 """Reads the blacklist from the _BLACKLIST_JSON file.
23 A list containing bad devices.
26 if not os
.path
.exists(_BLACKLIST_JSON
):
29 with
open(_BLACKLIST_JSON
, 'r') as f
:
33 def WriteBlacklist(blacklist
):
34 """Writes the provided blacklist to the _BLACKLIST_JSON file.
37 blacklist: list of bad devices to write to the _BLACKLIST_JSON file.
40 with
open(_BLACKLIST_JSON
, 'w') as f
:
41 json
.dump(list(set(blacklist
)), f
)
44 def ExtendBlacklist(devices
):
45 """Adds devices to _BLACKLIST_JSON file.
48 devices: list of bad devices to be added to the _BLACKLIST_JSON file.
51 blacklist
= ReadBlacklist()
52 blacklist
.extend(devices
)
53 WriteBlacklist(blacklist
)
57 """Erases the _BLACKLIST_JSON file if it exists."""
59 if os
.path
.exists(_BLACKLIST_JSON
):
60 os
.remove(_BLACKLIST_JSON
)