summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2018-10-17 13:46:08 +0100
committerErik Johnston <erik@matrix.org>2018-10-17 13:47:53 +0100
commitdf33c164de7d73323814ac439a394173d662e366 (patch)
treeeef273251593835860acd1bbcfee6c0acb95a257
parentFix roomlist since tokens on Python 3 (#4046) (diff)
downloadsynapse-df33c164de7d73323814ac439a394173d662e366.tar.xz
Only colourise synctl output when attached to tty
-rwxr-xr-xsynctl7
1 files changed, 6 insertions, 1 deletions
diff --git a/synctl b/synctl
index 09b64459b1..111b9c1816 100755
--- a/synctl
+++ b/synctl
@@ -48,7 +48,12 @@ def pid_running(pid):
 
 
 def write(message, colour=NORMAL, stream=sys.stdout):
-    if colour == NORMAL:
+    # Lets check if we're writing to a TTY before colouring
+    should_colour = False
+    if stream in (sys.stdout, sys.stderr):
+        should_colour = stream.isatty()
+
+    if not should_colour or colour == NORMAL:
         stream.write(message + "\n")
     else:
         stream.write(colour + message + NORMAL + "\n")