summary refs log tree commit diff
path: root/synctl
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2018-10-17 17:06:49 +0100
committerErik Johnston <erik@matrix.org>2018-10-17 17:06:49 +0100
commita5aea15a6b0f4c389a243bbb3ac375c9ed128146 (patch)
tree64544102756322afbd6220d6676c8f6b607108d2 /synctl
parentNewsfile (diff)
downloadsynapse-a5aea15a6b0f4c389a243bbb3ac375c9ed128146.tar.xz
Assume isatty is always defined, and catch AttributeError. Also don't bother checking colour==Normal
Diffstat (limited to 'synctl')
-rwxr-xr-xsynctl8
1 files changed, 6 insertions, 2 deletions
diff --git a/synctl b/synctl
index 111b9c1816..4bd4c68b37 100755
--- a/synctl
+++ b/synctl
@@ -50,10 +50,14 @@ def pid_running(pid):
 def write(message, colour=NORMAL, stream=sys.stdout):
     # Lets check if we're writing to a TTY before colouring
     should_colour = False
-    if stream in (sys.stdout, sys.stderr):
+    try:
         should_colour = stream.isatty()
+    except AttributeError:
+        # Just in case `isatty` isn't defined on everything. The python
+        # docs are incredibly vague.
+        pass
 
-    if not should_colour or colour == NORMAL:
+    if not should_colour:
         stream.write(message + "\n")
     else:
         stream.write(colour + message + NORMAL + "\n")