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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/device/device_blacklist.py
diff --git a/build/android/pylib/device/device_blacklist.py b/build/android/pylib/device/device_blacklist.py
new file mode 100644
index 0000000000000000000000000000000000000000..a141d62b81b828f17a243dbb70adbe8772ddba30
--- /dev/null
+++ b/build/android/pylib/device/device_blacklist.py
@@ -0,0 +1,61 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import json
+import os
+import threading
+
+from pylib import constants
+_BLACKLIST_JSON = os.path.join(
+ constants.DIR_SOURCE_ROOT,
+ os.environ.get('CHROMIUM_OUT_DIR', 'out'),
+ 'bad_devices.json')
+
+# Note that this only protects against concurrent accesses to the blacklist
+# within a process.
+_blacklist_lock = threading.RLock()
+
+def ReadBlacklist():
+ """Reads the blacklist from the _BLACKLIST_JSON file.
+
+ Returns:
+ A list containing bad devices.
+ """
+ with _blacklist_lock:
+ if not os.path.exists(_BLACKLIST_JSON):
+ return []
+
+ with open(_BLACKLIST_JSON, 'r') as f:
+ return json.load(f)
+
+
+def WriteBlacklist(blacklist):
+ """Writes the provided blacklist to the _BLACKLIST_JSON file.
+
+ Args:
+ blacklist: list of bad devices to write to the _BLACKLIST_JSON file.
+ """
+ with _blacklist_lock:
+ with open(_BLACKLIST_JSON, 'w') as f:
+ json.dump(list(set(blacklist)), f)
+
+
+def ExtendBlacklist(devices):
+ """Adds devices to _BLACKLIST_JSON file.
+
+ Args:
+ devices: list of bad devices to be added to the _BLACKLIST_JSON file.
+ """
+ with _blacklist_lock:
+ blacklist = ReadBlacklist()
+ blacklist.extend(devices)
+ WriteBlacklist(blacklist)
+
+
+def ResetBlacklist():
+ """Erases the _BLACKLIST_JSON file if it exists."""
+ with _blacklist_lock:
+ if os.path.exists(_BLACKLIST_JSON):
+ os.remove(_BLACKLIST_JSON)
+
« 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