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

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

Issue 204353007: [Android] Extract device blacklisting into its own module. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 8 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/pylib/android_commands.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
8 from pylib import constants
9 _BLACKLIST_JSON = os.path.join(
10 constants.DIR_SOURCE_ROOT,
11 os.environ.get('CHROMIUM_OUT_DIR', 'out'),
12 'bad_devices.json')
13
14 def ReadBlacklist():
15 """Reads the blacklist from the _BLACKLIST_JSON file.
16
17 Returns:
18 A list containing bad devices.
19 """
20 if not os.path.exists(_BLACKLIST_JSON):
21 return []
22
23 with open(_BLACKLIST_JSON, 'r') as f:
24 return json.load(f)
25
26
27 def WriteBlacklist(blacklist):
28 """Writes the provided blacklist to the _BLACKLIST_JSON file.
29
30 Args:
31 blacklist: list of bad devices to write to the _BLACKLIST_JSON file.
32 """
33 with open(_BLACKLIST_JSON, 'w') as f:
34 json.dump(list(set(blacklist)), f)
35
36
37 def ExtendBlacklist(devices):
38 """Adds devices to _BLACKLIST_JSON file.
39
40 Args:
41 devices: list of bad devices to be added to the _BLACKLIST_JSON file.
42 """
43 blacklist = ReadBlacklist()
44 blacklist.extend(devices)
45 WriteBlacklist(blacklist)
46
47
48 def ResetBlacklist():
49 """Erases the _BLACKLIST_JSON file if it exists."""
50 if os.path.exists(_BLACKLIST_JSON):
51 os.remove(_BLACKLIST_JSON)
52
OLDNEW
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698