Loading color.py +15 −13 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ import sys import re from ammsml.config import constants as C IS_COLOR: bool = True Loading @@ -40,16 +42,16 @@ else: # IS_COLOR = True class BColors: HEADER = '\033[95m' OKBLUE = '\033[94m' CHANGED = '\033[94m' OKGREEN = '\033[92m' WARNING = '\033[93m' ERROR = '\033[91m' ENDC = '\033[0m' BOLD = '\033[1m' UNDERLINE = '\033[4m' # class BColors: # HEADER = '\033[95m' # OKBLUE = '\033[94m' # CHANGED = '\033[94m' # OKGREEN = '\033[92m' # WARNING = '\033[93m' # ERROR = '\033[91m' # ENDC = '\033[0m' # BOLD = '\033[1m' # UNDERLINE = '\033[4m' # --- begin "pretty" # Loading Loading @@ -115,9 +117,9 @@ def colorize(lead, num, color): def hostcolor(host: str, stats: list, color: bool = True) -> str: if IS_COLOR and color: if stats['failures'] != 0 or stats['unreachable'] != 0: return "%-37s" % stringc(host, BColors.ERROR) return "%-37s" % stringc(host, C.COLOR_ERROR) elif stats['changed'] != 0: return "%-37s" % stringc(host, BColors.CHANGED) return "%-37s" % stringc(host, C.COLOR_CHANGED) else: return "%-37s" % stringc(host, BColors.OKGREEN) return "%-37s" % stringc(host, C.COLOR_OKGREEN) return "%-26s" % host display.py +7 −7 Original line number Diff line number Diff line Loading @@ -28,13 +28,13 @@ import subprocess from struct import unpack, pack from termios import TIOCGWINSZ from utils.color import stringc from utils.parsing import to_text from utils.errors import AMMSMLError from utils.singleton import Singleton from config import constants as C from utils.six import with_metaclass from utils.wrap import wrap_var from ammsml.utils.color import stringc from ammsml.utils.parsing import to_text from ammsml.utils.errors import AMMSMLError from ammsml.utils.singleton import Singleton from ammsml.config import constants as C from ammsml.utils.six import with_metaclass from ammsml.utils.wrap import wrap_var b_COW_PATHS = ( Loading parseing_yaml.py +1 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ import yaml from utils.parsing import to_text # from ammsml.utils.parsing import to_text class AMMSMLBaseYAMLObject(object): Loading path.py +3 −3 Original line number Diff line number Diff line Loading @@ -20,8 +20,8 @@ import os import shutil from errno import EEXIST from utils.parsing import to_text from utils.errors import AMMSMLError from ammsml.utils.parsing import to_text from ammsml.utils.errors import AMMSMLError __all__ = ['unfrackpath', 'makedirs_safe', 'resolve_path', 'cleanup_tmp_file'] Loading Loading @@ -129,7 +129,7 @@ def cleanup_tmp_file(path, warn=False): except Exception as e: if warn: # Importing here to avoid circular import from utils.display import Display from ammsml.utils.display import Display display = Display() display.display(u'Unable to remove temporary file {0}'.format(to_text(e))) except Exception: Loading Loading
color.py +15 −13 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ import sys import re from ammsml.config import constants as C IS_COLOR: bool = True Loading @@ -40,16 +42,16 @@ else: # IS_COLOR = True class BColors: HEADER = '\033[95m' OKBLUE = '\033[94m' CHANGED = '\033[94m' OKGREEN = '\033[92m' WARNING = '\033[93m' ERROR = '\033[91m' ENDC = '\033[0m' BOLD = '\033[1m' UNDERLINE = '\033[4m' # class BColors: # HEADER = '\033[95m' # OKBLUE = '\033[94m' # CHANGED = '\033[94m' # OKGREEN = '\033[92m' # WARNING = '\033[93m' # ERROR = '\033[91m' # ENDC = '\033[0m' # BOLD = '\033[1m' # UNDERLINE = '\033[4m' # --- begin "pretty" # Loading Loading @@ -115,9 +117,9 @@ def colorize(lead, num, color): def hostcolor(host: str, stats: list, color: bool = True) -> str: if IS_COLOR and color: if stats['failures'] != 0 or stats['unreachable'] != 0: return "%-37s" % stringc(host, BColors.ERROR) return "%-37s" % stringc(host, C.COLOR_ERROR) elif stats['changed'] != 0: return "%-37s" % stringc(host, BColors.CHANGED) return "%-37s" % stringc(host, C.COLOR_CHANGED) else: return "%-37s" % stringc(host, BColors.OKGREEN) return "%-37s" % stringc(host, C.COLOR_OKGREEN) return "%-26s" % host
display.py +7 −7 Original line number Diff line number Diff line Loading @@ -28,13 +28,13 @@ import subprocess from struct import unpack, pack from termios import TIOCGWINSZ from utils.color import stringc from utils.parsing import to_text from utils.errors import AMMSMLError from utils.singleton import Singleton from config import constants as C from utils.six import with_metaclass from utils.wrap import wrap_var from ammsml.utils.color import stringc from ammsml.utils.parsing import to_text from ammsml.utils.errors import AMMSMLError from ammsml.utils.singleton import Singleton from ammsml.config import constants as C from ammsml.utils.six import with_metaclass from ammsml.utils.wrap import wrap_var b_COW_PATHS = ( Loading
parseing_yaml.py +1 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ import yaml from utils.parsing import to_text # from ammsml.utils.parsing import to_text class AMMSMLBaseYAMLObject(object): Loading
path.py +3 −3 Original line number Diff line number Diff line Loading @@ -20,8 +20,8 @@ import os import shutil from errno import EEXIST from utils.parsing import to_text from utils.errors import AMMSMLError from ammsml.utils.parsing import to_text from ammsml.utils.errors import AMMSMLError __all__ = ['unfrackpath', 'makedirs_safe', 'resolve_path', 'cleanup_tmp_file'] Loading Loading @@ -129,7 +129,7 @@ def cleanup_tmp_file(path, warn=False): except Exception as e: if warn: # Importing here to avoid circular import from utils.display import Display from ammsml.utils.display import Display display = Display() display.display(u'Unable to remove temporary file {0}'.format(to_text(e))) except Exception: Loading