From d4705502fc6a8592e7b8ca1b690c080b5a06363e Mon Sep 17 00:00:00 2001 From: Joshua Lock Date: Fri, 16 Oct 2020 17:06:07 +0100 Subject: [PATCH] repo: make colorama a soft dependency Instead of using colorama directly for terminal colours, use the constants in securesystemslib.interface which map to colorama colours IFF colorama is installed. This change results in a red password prompt when colorama is installed and a standard terminal output coloured prompt when colorama is not installed. Signed-off-by: Joshua Lock --- tuf/scripts/repo.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tuf/scripts/repo.py b/tuf/scripts/repo.py index 3f75e582..93fb9352 100755 --- a/tuf/scripts/repo.py +++ b/tuf/scripts/repo.py @@ -24,7 +24,7 @@ Note: 'pip install securesystemslib[crypto,pynacl]' is required by the CLI, - which installs the 3rd-party dependencies: cryptography, pynacl, and colorama. + which installs the 3rd-party dependencies: cryptography and pynacl. Note: arguments within brackets are optional. @@ -153,9 +153,9 @@ import tuf.repository_tool as repo_tool # 'pip install securesystemslib[crypto,pynacl]' is required for the CLI, -# which installs the cryptography, pynacl, and colorama dependencies. +# which installs the cryptography and pynacl. import securesystemslib -from colorama import Fore +from securesystemslib import interface import six @@ -428,7 +428,7 @@ def import_privatekey_from_file(keypath, password=None): # However, care should be taken when including the full path in exceptions # and log files. password = securesystemslib.interface.get_password('Enter a password for' - ' the encrypted key (' + Fore.RED + repr(keypath) + Fore.RESET + '): ', + ' the encrypted key (' + interface.TERM_RED + repr(keypath) + interface.TERM_RED + '): ', confirm=False) # Does 'password' have the correct format?