aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2022-02-01 12:36:28 +0100
committerMartin Ridgers <[email protected]>2022-02-01 12:36:28 +0100
commit267322450df4f0d702a8baa4f9c7be083e4a9661 (patch)
tree5d3478597e3b4c87129b85075a13ab017ea5b1f5 /scripts
parentScript for building a branch over SSH (diff)
downloadzen-267322450df4f0d702a8baa4f9c7be083e4a9661.tar.xz
zen-267322450df4f0d702a8baa4f9c7be083e4a9661.zip
Disable remote_build.py's ANSI codes if the terminal doesn't support them
Diffstat (limited to 'scripts')
-rw-r--r--scripts/remote_build.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/scripts/remote_build.py b/scripts/remote_build.py
index e83f95d8d..756748853 100644
--- a/scripts/remote_build.py
+++ b/scripts/remote_build.py
@@ -6,10 +6,23 @@ from pathlib import Path
# {{{1 misc --------------------------------------------------------------------
+# Disables output of ANSI codes if the terminal doesn't support them
+if os.name == "nt":
+ from ctypes import windll, c_int, byref
+ stdout_handle = windll.kernel32.GetStdHandle(c_int(-11))
+ mode = c_int(0)
+ windll.kernel32.GetConsoleMode(c_int(stdout_handle), byref(mode))
+ ansi_on = (mode.value & 4) != 0
+else:
+ ansi_on = True
+
#-------------------------------------------------------------------------------
def _header(*args, ansi=96):
- print(f"\x1b[{ansi}m##", *args, end="")
- print("\x1b[0m")
+ if ansi_on:
+ print(f"\x1b[{ansi}m##", *args, end="")
+ print("\x1b[0m")
+ else:
+ print("\n##", *args)
#-------------------------------------------------------------------------------
def _run_checked(cmd, *args, **kwargs):