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

Side by Side Diff: build/android/pylib/device/device_blacklist.py

Issue 2101243005: Add a snapshot of flutter/engine/src/build to our sdk (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add README.dart Created 4 years, 5 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
OLDNEW
(Empty)
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.
4
5 import json
6 import os
7 import threading
8
9 from pylib import constants
10 _BLACKLIST_JSON = os.path.join(
11 constants.DIR_SOURCE_ROOT,
12 os.environ.get('CHROMIUM_OUT_DIR', 'out'),
13 'bad_devices.json')
14
15 # Note that this only protects against concurrent accesses to the blacklist
16 # within a process.
17 _blacklist_lock = threading.RLock()
18
19 def ReadBlacklist():
20 """Reads the blacklist from the _BLACKLIST_JSON file.
21
22 Returns:
23 A list containing bad devices.
24 """
25 with _blacklist_lock:
26 if not os.path.exists(_BLACKLIST_JSON):
27 return []
28
29 with open(_BLACKLIST_JSON, 'r') as f:
30 return json.load(f)
31
32
33 def WriteBlacklist(blacklist):
34 """Writes the provided blacklist to the _BLACKLIST_JSON file.
35
36 Args:
37 blacklist: list of bad devices to write to the _BLACKLIST_JSON file.
38 """
39 with _blacklist_lock:
40 with open(_BLACKLIST_JSON, 'w') as f:
41 json.dump(list(set(blacklist)), f)
42
43
44 def ExtendBlacklist(devices):
45 """Adds devices to _BLACKLIST_JSON file.
46
47 Args:
48 devices: list of bad devices to be added to the _BLACKLIST_JSON file.
49 """
50 with _blacklist_lock:
51 blacklist = ReadBlacklist()
52 blacklist.extend(devices)
53 WriteBlacklist(blacklist)
54
55
56 def ResetBlacklist():
57 """Erases the _BLACKLIST_JSON file if it exists."""
58 with _blacklist_lock:
59 if os.path.exists(_BLACKLIST_JSON):
60 os.remove(_BLACKLIST_JSON)
61
OLDNEW
« no previous file with comments | « build/android/pylib/device/decorators_test.py ('k') | build/android/pylib/device/device_errors.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698