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

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: Created 6 years, 9 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 import json
bulach 2014/03/21 14:38:55 nit: copyright notice
2 import os
3
4 from pylib import constants
5 _BLACKLIST_JSON = os.path.join(
6 constants.DIR_SOURCE_ROOT,
7 os.environ.get('CHROMIUM_OUT_DIR', 'out'),
8 'bad_devices.json')
9
bulach 2014/03/21 14:38:55 nit: need two \n between top-levels
10 def ReadBlacklist():
11 """Reads the blacklist from the _BLACKLIST_JSON file.
12
13 Returns:
14 A list containing bad devices.
15 """
16 blacklist = []
bulach 2014/03/21 14:38:55 nit: how about: if not os.path.exists(_BLACKLIST_
17 if os.path.exists(_BLACKLIST_JSON):
18 with open(_BLACKLIST_JSON, 'r') as f:
19 blacklist = json.load(f)
20 return blacklist
21
bulach 2014/03/21 14:38:55 nit: another \n here, 30 and 41
22 def WriteBlacklist(blacklist):
23 """Writes the provided blacklist to the _BLACKLIST_JSON file.
24
25 Args:
26 blacklist: list of bad devices to write to the _BLACKLIST_JSON file.
27 """
28 with open(_BLACKLIST_JSON, 'w') as f:
29 json.dump(list(set(blacklist)), f)
30
31 def ExtendBlacklist(devices):
32 """Adds devices to _BLACKLIST_JSON file.
33
34 Args:
35 devices: list of bad devices to be added to the _BLACKLIST_JSON file.
36 """
37 blacklist = ReadBlacklist()
38 blacklist.extend(devices)
39 WriteBlacklist(blacklist)
40
41 def ResetBlacklist():
42 """Erases the _BLACKLIST_JSON file if it exists."""
43 if os.path.exists(_BLACKLIST_JSON):
44 os.remove(_BLACKLIST_JSON)
45
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