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

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

Issue 814653003: Clean up logging and add device randomization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: get rid of import Created 5 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
« no previous file with comments | « no previous file | build/android/pylib/remote/device/remote_device_environment.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 logging 6 import logging
6 import os 7 import os
7 import sys 8 import sys
8 9
9 from pylib import constants 10 from pylib import constants
10 11
11 sys.path.append(os.path.join( 12 sys.path.append(os.path.join(
12 constants.DIR_SOURCE_ROOT, 'third_party', 'requests', 'src')) 13 constants.DIR_SOURCE_ROOT, 'third_party', 'requests', 'src'))
13 sys.path.append(os.path.join( 14 sys.path.append(os.path.join(
14 constants.DIR_SOURCE_ROOT, 'third_party', 'appurify-python', 'src')) 15 constants.DIR_SOURCE_ROOT, 'third_party', 'appurify-python', 'src'))
15 handlers_before = list(logging.getLogger().handlers) 16 handlers_before = list(logging.getLogger().handlers)
16 17
17 import appurify.api 18 import appurify.api
18 import appurify.utils 19 import appurify.utils
19 20
20 handlers_after = list(logging.getLogger().handlers) 21 handlers_after = list(logging.getLogger().handlers)
21 new_handler = list(set(handlers_after) - set(handlers_before)) 22 new_handler = list(set(handlers_after) - set(handlers_before))
22 while new_handler: 23 while new_handler:
23 logging.info("Removing logging handler.") 24 logging.info("Removing logging handler.")
24 logging.getLogger().removeHandler(new_handler.pop()) 25 logging.getLogger().removeHandler(new_handler.pop())
25 26
26 api = appurify.api 27 api = appurify.api
27 utils = appurify.utils 28 utils = appurify.utils
29
30 # This is not thread safe. If multiple threads are ever supported with appurify
31 # this may cause logging messages to go missing.
32 @contextlib.contextmanager
33 def SanitizeLogging(verbose_count, level):
34 if verbose_count < 2:
35 logging.disable(level)
36 yield True
37 logging.disable(logging.NOTSET)
38 else:
39 yield False
40
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/remote/device/remote_device_environment.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698