Skip to content

Commit

Permalink
Fixes problem with colored output
Browse files Browse the repository at this point in the history
  • Loading branch information
ask committed Oct 29, 2011
1 parent e12cb15 commit 6d98c4f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
14 changes: 7 additions & 7 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ Important Notes
* The :setting:`CELERY_TASK_ERROR_WHITELIST` setting has been replaced
by a more flexible approach (Issue #447).

The Mail sending logic is now available as ``Task.ErrorMail``.
The actual implementation is in :mod:`celery.utils.mail`.
The error mail sending logic is now available as ``Task.ErrorMail``,
with the implementation (for reference) in :mod:`celery.utils.mail`.

The error mail class can be sub-classed to gain complete control
of when error messages are sent, thus removing the need for a separate
white-list setting.
The error mail class can be sub-classed to gain complete control
of when error messages are sent, thus removing the need for a separate
white-list setting.

The :setting:`CELERY_TASK_ERROR_WHITELIST` setting has been deprecated,
and will be removed completely in version 3.0.
The :setting:`CELERY_TASK_ERROR_WHITELIST` setting has been deprecated,
and will be removed completely in version 3.0.

* Additional Deprecations

Expand Down
6 changes: 4 additions & 2 deletions celery/bin/celeryctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,15 @@ class inspect(Command):
help="Timeout in seconds (float) waiting for reply"),
Option("--destination", "-d", dest="destination",
help="Comma separated list of destination node names."))
show_body = True

def usage(self, command):
return "%%prog %s [options] %s [%s]" % (
command, self.args, "|".join(self.choices.keys()))

def run(self, *args, **kwargs):
self.quiet = kwargs.get("quiet", False)
self.show_body = kwargs.get("show_body", False)
if not args:
raise Error("Missing inspect command. See --help")
command = args[0]
Expand Down Expand Up @@ -276,7 +278,7 @@ def say(self, direction, title, body=""):
return
dirstr = not self.quiet and c.bold(c.white(direction), " ") or ""
self.out(c.reset(dirstr, title))
if body and not self.quiet:
if body and self.show_body:
self.out(body)
inspect = command(inspect)

Expand All @@ -292,7 +294,7 @@ class status(Command):
def run(self, *args, **kwargs):
replies = inspect(app=self.app,
no_color=kwargs.get("no_color", False)) \
.run("ping", **dict(kwargs, quiet=True))
.run("ping", **dict(kwargs, quiet=True, show_body=False))
if not replies:
raise Error("No nodes replied within time constraint")
nodecount = len(replies)
Expand Down
14 changes: 10 additions & 4 deletions celery/utils/term.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ def __init__(self, *s, **kwargs):
"white": self.white}

def _add(self, a, b):
return safe_str(a) + safe_str(b)
if isinstance(a, unicode):
a = safe_str(a)
if isinstance(b, unicode):
b = safe_str(b)
return str(a) + str(b)

def _fold_no_color(self, a, b):
try:
Expand All @@ -68,7 +72,9 @@ def _fold_no_color(self, a, b):
return A + B

def no_color(self):
return reduce(self._fold_no_color, self.s)
if self.s:
return reduce(self._fold_no_color, self.s)
return ""

def embed(self):
prefix = ""
Expand All @@ -80,7 +86,7 @@ def __str__(self):
suffix = ""
if self.enabled:
suffix = RESET_SEQ
return self.embed() + suffix
return safe_str(self.embed()) + suffix

def node(self, s, op):
return self.__class__(enabled=self.enabled, op=op, *s)
Expand Down Expand Up @@ -152,4 +158,4 @@ def reset(self, *s):
return self.node(s or [""], RESET_SEQ)

def __add__(self, other):
return safe_str(self) + safe_str(other)
return str(self) + str(other)

0 comments on commit 6d98c4f

Please sign in to comment.