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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/devtools/common/devtoolslib/utils.py
diff --git a/mojo/devtools/common/devtoolslib/utils.py b/mojo/devtools/common/devtoolslib/utils.py
index 7bf2e1c641221f2d89e25022c7301a10b5d8a4b8..085d2253cd3829ee4f8e22ad63b4645d1f9eb651 100644
--- a/mojo/devtools/common/devtoolslib/utils.py
+++ b/mojo/devtools/common/devtoolslib/utils.py
@@ -4,6 +4,9 @@
"""Python utils."""
+import os
+import sys
+
def overrides(parent_class):
"""Inherits the docstring from the method of the same name in the indicated
@@ -14,3 +17,11 @@ def overrides(parent_class):
method.__doc__ = getattr(parent_class, method.__name__).__doc__
return method
return overriding
+
+
+def disable_output_buffering():
+ """Disables the buffering of the stdout. Devtools command line scripts should
+ do so, so that their stdout is consistent when not directly attached to a
+ terminal (e.g. because another script runs devtools in a subprocess).
+ """
+ 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.
« 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