diff --git a/setup.py b/setup.py index d937cfb14..ccd069ad4 100644 --- a/setup.py +++ b/setup.py @@ -22,8 +22,7 @@ elif (3, 0) < py_version < (3, 2): raise RuntimeError('On Python 3, Supervisor requires Python 3.2 or later') -requires = ['meld3 >= 1.0.0', - 'colorama'] +requires = ['meld3 >= 1.0.0'] tests_require = [] if py_version < (3, 3): tests_require.append('mock') diff --git a/supervisor/colors.py b/supervisor/colors.py new file mode 100644 index 000000000..a0bba337f --- /dev/null +++ b/supervisor/colors.py @@ -0,0 +1,31 @@ +ESC = '\033[' + + +class ansicolors: + class fg: + black = ESC + '30m' + red = ESC + '31m' + green = ESC + '32m' + yellow = ESC + '33m' + blue = ESC + '34m' + magenta = ESC + '35m' + cyan = ESC + '36m' + white = ESC + '37m' + reset = ESC + '39m' + + class bg: + black = ESC + '40m' + red = ESC + '41m' + green = ESC + '42m' + yellow = ESC + '43m' + blue = ESC + '44m' + magenta = ESC + '45m' + cyan = ESC + '46m' + white = ESC + '47m' + reset = ESC + '49m' + + class style: + bright = ESC + '1m' + dim = ESC + '2m' + normal = ESC + '22m' + reset_all = ESC + '0m' diff --git a/supervisor/supervisorctl.py b/supervisor/supervisorctl.py index 3512903a7..47b6923e8 100755 --- a/supervisor/supervisorctl.py +++ b/supervisor/supervisorctl.py @@ -30,8 +30,7 @@ import errno import threading -import colorama - +from supervisor.colors import ansicolors from supervisor.compat import xmlrpclib from supervisor.compat import urlparse from supervisor.compat import unicode @@ -626,13 +625,13 @@ def _get_status_template(self, colorize_output, maxlen): def _colorize_state(self, statename): colors = { - 'RUNNING': colorama.Style.BRIGHT + colorama.Fore.GREEN, - 'STOPPED': colorama.Style.BRIGHT + colorama.Fore.YELLOW, - 'BACKOFF': colorama.Style.BRIGHT + colorama.Fore.RED, - 'FATAL': colorama.Style.BRIGHT + colorama.Fore.RED, + 'RUNNING': ansicolors.style.bright + ansicolors.fg.green, + 'STOPPED': ansicolors.style.bright + ansicolors.fg.yellow, + 'BACKOFF': ansicolors.style.bright + ansicolors.fg.red, + 'FATAL': ansicolors.style.bright + ansicolors.fg.red, } color = colors.get(statename, '') - return '%s%s%s' % (color, statename, colorama.Fore.RESET) + return '%s%s%s' % (color, statename, ansicolors.fg.reset) def do_status(self, arg): if not self.ctl.upcheck(): @@ -1321,8 +1320,6 @@ def help_fg(self,args=None): def main(args=None, options=None): - colorama.init() - if options is None: options = ClientOptions()