mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Only colourise synctl output when attached to tty
This commit is contained in:
parent
d6a7797dd1
commit
df33c164de
7
synctl
7
synctl
@ -48,7 +48,12 @@ def pid_running(pid):
|
|||||||
|
|
||||||
|
|
||||||
def write(message, colour=NORMAL, stream=sys.stdout):
|
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")
|
stream.write(message + "\n")
|
||||||
else:
|
else:
|
||||||
stream.write(colour + message + NORMAL + "\n")
|
stream.write(colour + message + NORMAL + "\n")
|
||||||
|
Loading…
Reference in New Issue
Block a user