0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-13 14:33:14 +01:00

Merge pull request #4049 from matrix-org/erikj/synctl_colour

Only colourise synctl output when attached to tty
This commit is contained in:
Erik Johnston 2018-10-18 10:51:14 +01:00 committed by GitHub
commit e77f24d80a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

1
changelog.d/4049.misc Normal file
View file

@ -0,0 +1 @@
Only colourise synctl output when attached to tty

11
synctl
View file

@ -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")