Commit 88bb473f authored by Christof Schulze's avatar Christof Schulze 😎
Browse files

better modularisation (preparation for python package)

parent 51cd8724
Loading
Loading
Loading
Loading
+15 −13
Original line number Original line Diff line number Diff line
@@ -18,6 +18,8 @@


import sys
import sys
import re
import re
from ammsml.config import constants as C



IS_COLOR: bool = True
IS_COLOR: bool = True


@@ -40,16 +42,16 @@ else:
#     IS_COLOR = True
#     IS_COLOR = True




class BColors:
# class BColors:
    HEADER = '\033[95m'
#     HEADER = '\033[95m'
    OKBLUE = '\033[94m'
#     OKBLUE = '\033[94m'
    CHANGED = '\033[94m'
#     CHANGED = '\033[94m'
    OKGREEN = '\033[92m'
#     OKGREEN = '\033[92m'
    WARNING = '\033[93m'
#     WARNING = '\033[93m'
    ERROR = '\033[91m'
#     ERROR = '\033[91m'
    ENDC = '\033[0m'
#     ENDC = '\033[0m'
    BOLD = '\033[1m'
#     BOLD = '\033[1m'
    UNDERLINE = '\033[4m'
#     UNDERLINE = '\033[4m'


# --- begin "pretty"
# --- begin "pretty"
#
#
@@ -115,9 +117,9 @@ def colorize(lead, num, color):
def hostcolor(host: str, stats: list, color: bool = True) -> str:
def hostcolor(host: str, stats: list, color: bool = True) -> str:
    if IS_COLOR and color:
    if IS_COLOR and color:
        if stats['failures'] != 0 or stats['unreachable'] != 0:
        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:
        elif stats['changed'] != 0:
            return "%-37s" % stringc(host, BColors.CHANGED)
            return "%-37s" % stringc(host, C.COLOR_CHANGED)
        else:
        else:
            return "%-37s" % stringc(host, BColors.OKGREEN)
            return "%-37s" % stringc(host, C.COLOR_OKGREEN)
    return "%-26s" % host
    return "%-26s" % host
+7 −7
Original line number Original line Diff line number Diff line
@@ -28,13 +28,13 @@ import subprocess
from struct import unpack, pack
from struct import unpack, pack
from termios import TIOCGWINSZ
from termios import TIOCGWINSZ


from utils.color import stringc
from ammsml.utils.color import stringc
from utils.parsing import to_text
from ammsml.utils.parsing import to_text
from utils.errors import AMMSMLError
from ammsml.utils.errors import AMMSMLError
from utils.singleton import Singleton
from ammsml.utils.singleton import Singleton
from config import constants as C
from ammsml.config import constants as C
from utils.six import with_metaclass
from ammsml.utils.six import with_metaclass
from utils.wrap import wrap_var
from ammsml.utils.wrap import wrap_var




b_COW_PATHS = (
b_COW_PATHS = (
+1 −1
Original line number Original line Diff line number Diff line
@@ -18,7 +18,7 @@


import yaml
import yaml


from utils.parsing import to_text
# from ammsml.utils.parsing import to_text




class AMMSMLBaseYAMLObject(object):
class AMMSMLBaseYAMLObject(object):
+3 −3
Original line number Original line Diff line number Diff line
@@ -20,8 +20,8 @@ import os
import shutil
import shutil
from errno import EEXIST
from errno import EEXIST


from utils.parsing import to_text
from ammsml.utils.parsing import to_text
from utils.errors import AMMSMLError
from ammsml.utils.errors import AMMSMLError


__all__ = ['unfrackpath', 'makedirs_safe', 'resolve_path', 'cleanup_tmp_file']
__all__ = ['unfrackpath', 'makedirs_safe', 'resolve_path', 'cleanup_tmp_file']


@@ -129,7 +129,7 @@ def cleanup_tmp_file(path, warn=False):
            except Exception as e:
            except Exception as e:
                if warn:
                if warn:
                    # Importing here to avoid circular import
                    # Importing here to avoid circular import
                    from utils.display import Display
                    from ammsml.utils.display import Display
                    display = Display()
                    display = Display()
                    display.display(u'Unable to remove temporary file {0}'.format(to_text(e)))
                    display.display(u'Unable to remove temporary file {0}'.format(to_text(e)))
    except Exception:
    except Exception: