Skip to content

Commit

Permalink
Disable color output on Windows 8 and Windows Server 2012.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtesta committed Feb 6, 2021
1 parent 3c0fc8e commit 1b7cfbe
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ssh_audit/ssh_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,12 @@ def main() -> int:
if (sys.platform == 'win32') and ('colorama' not in sys.modules):
out.v("WARNING: colorama module not found. Colorized output will be ddisabled.", write_now=True)

# Disable color output on Windiows 8 and Windows Server 2012, as they are still supported by Microsoft (until Jan. 2023 and Oct. 2023, respectively); they do not support ANSI color codes. According to https://docs.microsoft.com/en-us/windows/win32/sysinfo/operating-system-version, the major versions of Server 2016, Server 2019, and Windows 10 are all 10.
if (sys.platform == 'win32') and (sys.getwindowsversion().major < 10): # pylint: disable=no-member
aconf.colors = False
out.use_colors = False
out.v("Disabling color output on this platform since it is not supported (Windows major version: %d)." % sys.getwindowsversion().major) # pylint: disable=no-member

# If we're outputting JSON, turn off colors and ensure 'info' level messages go through.
if aconf.json:
out.json = True
Expand Down

0 comments on commit 1b7cfbe

Please sign in to comment.