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

Side by Side Diff: mojo/devtools/common/devtoolslib/utils.py

Issue 1964903002: Disable output buffering in devtools scripts. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 7 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 | « mojo/devtools/common/devtoolslib/android_shell.py ('k') | mojo/devtools/common/mojo_benchmark » ('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 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 """Python utils.""" 5 """Python utils."""
6 6
7 import os
8 import sys
9
7 10
8 def overrides(parent_class): 11 def overrides(parent_class):
9 """Inherits the docstring from the method of the same name in the indicated 12 """Inherits the docstring from the method of the same name in the indicated
10 parent class. 13 parent class.
11 """ 14 """
12 def overriding(method): 15 def overriding(method):
13 assert(method.__name__ in dir(parent_class)) 16 assert(method.__name__ in dir(parent_class))
14 method.__doc__ = getattr(parent_class, method.__name__).__doc__ 17 method.__doc__ = getattr(parent_class, method.__name__).__doc__
15 return method 18 return method
16 return overriding 19 return overriding
20
21
22 def disable_output_buffering():
23 """Disables the buffering of the stdout. Devtools command line scripts should
24 do so, so that their stdout is consistent when not directly attached to a
25 terminal (e.g. because another script runs devtools in a subprocess).
26 """
27 sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
qsr 2016/05/10 16:15:21 How portable is this? Does this work on every plat
ppi 2016/05/10 16:17:08 Good question - I will check that it works on Mac
ppi 2016/05/11 11:21:29 Mac seems to be happy w/ this.
OLDNEW
« no previous file with comments | « mojo/devtools/common/devtoolslib/android_shell.py ('k') | mojo/devtools/common/mojo_benchmark » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698