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

Unified Diff: build/android/devil/android/device_blacklist.py

Issue 1770943003: [Android] Remove chromium version of devil. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/devil/android/decorators_test.py ('k') | build/android/devil/android/device_errors.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/devil/android/device_blacklist.py
diff --git a/build/android/devil/android/device_blacklist.py b/build/android/devil/android/device_blacklist.py
deleted file mode 100644
index 94f9cbeccc4ef5664c6630165d13d56959d31b0b..0000000000000000000000000000000000000000
--- a/build/android/devil/android/device_blacklist.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# 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 logging
-import os
-import threading
-import time
-
-
-class Blacklist(object):
-
- def __init__(self, path):
- self._blacklist_lock = threading.RLock()
- self._path = path
-
- def Read(self):
- """Reads the blacklist from the blacklist file.
-
- Returns:
- A dict containing bad devices.
- """
- with self._blacklist_lock:
- if not os.path.exists(self._path):
- return dict()
-
- with open(self._path, 'r') as f:
- blacklist = json.load(f)
- if not isinstance(blacklist, dict):
- logging.warning('Ignoring %s: %s (a dict was expected instead)',
- self._path, blacklist)
- blacklist = dict()
- return blacklist
-
- def Write(self, blacklist):
- """Writes the provided blacklist to the blacklist file.
-
- Args:
- blacklist: list of bad devices to write to the blacklist file.
- """
- with self._blacklist_lock:
- with open(self._path, 'w') as f:
- json.dump(blacklist, f)
-
- def Extend(self, devices, reason='unknown'):
- """Adds devices to blacklist file.
-
- Args:
- devices: list of bad devices to be added to the blacklist file.
- reason: string specifying the reason for blacklist (eg: 'unauthorized')
- """
- timestamp = time.time()
- event_info = {
- 'timestamp': timestamp,
- 'reason': reason,
- }
- device_dicts = {device: event_info for device in devices}
- logging.info('Adding %s to blacklist %s for reason: %s',
- ','.join(devices), self._path, reason)
- with self._blacklist_lock:
- blacklist = self.Read()
- blacklist.update(device_dicts)
- self.Write(blacklist)
-
- def Reset(self):
- """Erases the blacklist file if it exists."""
- logging.info('Resetting blacklist %s', self._path)
- with self._blacklist_lock:
- if os.path.exists(self._path):
- os.remove(self._path)
« no previous file with comments | « build/android/devil/android/decorators_test.py ('k') | build/android/devil/android/device_errors.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698