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

Side by Side Diff: build/android/pylib/remote/device/appurify_sanitized.py

Issue 1571803002: [Android] Prepare build/android/ for catapult+devil. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@create-device-library-links
Patch Set: rebase Created 4 years, 11 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
1 # Copyright 2014 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import contextlib 5 import contextlib
6 import logging 6 import logging
7 import os 7 import os
8 import sys
9 8
10 from pylib import constants 9 from pylib.constants import host_paths
11 10
12 sys.path.append(os.path.join( 11 _REQUESTS_PATH = os.path.join(
13 constants.DIR_SOURCE_ROOT, 'third_party', 'requests', 'src')) 12 host_paths.DIR_SOURCE_ROOT, 'third_party', 'requests', 'src')
14 sys.path.append(os.path.join( 13 _APPURIFY_PYTHON_PATH = os.path.join(
15 constants.DIR_SOURCE_ROOT, 'third_party', 'appurify-python', 'src')) 14 host_paths.DIR_SOURCE_ROOT, 'third_party', 'appurify-python', 'src')
16 handlers_before = list(logging.getLogger().handlers)
17 15
18 import appurify.api # pylint: disable=import-error 16 with host_paths.SysPath(_REQUESTS_PATH), (
19 import appurify.utils # pylint: disable=import-error 17 host_paths.SysPath(_APPURIFY_PYTHON_PATH)):
20 18
21 handlers_after = list(logging.getLogger().handlers) 19 handlers_before = list(logging.getLogger().handlers)
22 new_handler = list(set(handlers_after) - set(handlers_before))
23 while new_handler:
24 logging.info("Removing logging handler.")
25 logging.getLogger().removeHandler(new_handler.pop())
26 20
27 api = appurify.api 21 import appurify.api # pylint: disable=import-error
28 utils = appurify.utils 22 import appurify.utils # pylint: disable=import-error
23
24 handlers_after = list(logging.getLogger().handlers)
25 new_handler = list(set(handlers_after) - set(handlers_before))
26 while new_handler:
27 logging.info("Removing logging handler.")
28 logging.getLogger().removeHandler(new_handler.pop())
29
30 api = appurify.api
31 utils = appurify.utils
29 32
30 # This is not thread safe. If multiple threads are ever supported with appurify 33 # This is not thread safe. If multiple threads are ever supported with appurify
31 # this may cause logging messages to go missing. 34 # this may cause logging messages to go missing.
32 @contextlib.contextmanager 35 @contextlib.contextmanager
33 def SanitizeLogging(verbose_count, level): 36 def SanitizeLogging(verbose_count, level):
34 if verbose_count < 2: 37 if verbose_count < 2:
35 logging.disable(level) 38 logging.disable(level)
36 yield True 39 yield True
37 logging.disable(logging.NOTSET) 40 logging.disable(logging.NOTSET)
38 else: 41 else:
39 yield False 42 yield False
40 43
OLDNEW
« no previous file with comments | « build/android/pylib/perf/test_runner.py ('k') | build/android/pylib/results/flakiness_dashboard/results_uploader.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698