Skip to content

Commit

Permalink
Replace colorama with supervisor.colors
Browse files Browse the repository at this point in the history
  • Loading branch information
msabramo committed Jan 26, 2015
1 parent f8aada0 commit 4b4a85b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
31 changes: 31 additions & 0 deletions supervisor/colors.py
Original file line number Diff line number Diff line change
@@ -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'
15 changes: 6 additions & 9 deletions supervisor/supervisorctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -625,13 +624,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():
Expand Down Expand Up @@ -1320,8 +1319,6 @@ def help_fg(self,args=None):


def main(args=None, options=None):
colorama.init()

if options is None:
options = ClientOptions()

Expand Down

0 comments on commit 4b4a85b

Please sign in to comment.