Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix terminal colors not displaying properly on Windows #424

Merged
merged 2 commits into from Nov 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions bandit/formatters/screen.py
Expand Up @@ -48,6 +48,17 @@
from bandit.core import docs_utils
from bandit.core import test_properties

# This fixes terminal colors not displaying properly on Windows systems.
# Colorama will intercept any ANSI escape codes and convert them to the
# proper Windows console API calls to change text color.
if sys.platform.startswith('win32'):
try:
import colorama
except ImportError:
pass
else:
colorama.init()

LOG = logging.getLogger(__name__)

COLOR = {
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Expand Up @@ -5,3 +5,4 @@ GitPython>=1.0.1 # BSD License (3 clause)
PyYAML>=3.12 # MIT
six>=1.10.0 # MIT
stevedore>=1.20.0 # Apache-2.0
colorama>=0.3.9;platform_system=="Windows" # BSD License (3 clause)