Merge pull request #4049 from matrix-org/erikj/synctl_colour
Only colourise synctl output when attached to ttypull/4057/head
commit
e77f24d80a
|
@ -0,0 +1 @@
|
|||
Only colourise synctl output when attached to tty
|
11
synctl
11
synctl
|
@ -48,7 +48,16 @@ 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
|
||||
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:
|
||||
stream.write(message + "\n")
|
||||
else:
|
||||
stream.write(colour + message + NORMAL + "\n")
|
||||
|
|
Loading…
Reference in New Issue