示例#1
0
 def __init__(self, app, no_color=False, **kwargs):
     self.app = app
     self._init_manager(app, **kwargs)
     if not isatty(self.stdout):
         no_color = True
     self.colored = colored(enabled=not no_color)
     self.init_groups()
示例#2
0
 def supports_color(self, colorize=None, logfile=None):
     colorize = self.colorize if colorize is None else colorize
     if self.app.IS_WINDOWS:
         # Windows does not support ANSI color codes.
         return False
     if colorize or colorize is None:
         # Only use color if there's no active log file
         # and stderr is an actual terminal.
         return logfile is None and isatty(sys.stderr)
     return colorize
示例#3
0
 def supports_color(self, colorize=None, logfile=None):
     colorize = self.colorize if colorize is None else colorize
     if self.app.IS_WINDOWS:
         # Windows does not support ANSI color codes.
         return False
     if colorize or colorize is None:
         # Only use color if there's no active log file
         # and stderr is an actual terminal.
         return logfile is None and isatty(sys.stderr)
     return colorize
示例#4
0
 def on_after_init(self, purge=False, no_color=None,
                   redirect_stdouts=None, redirect_stdouts_level=None,
                   **kwargs):
     self.redirect_stdouts = self.app.either(
         'worker_redirect_stdouts', redirect_stdouts)
     self.redirect_stdouts_level = self.app.either(
         'worker_redirect_stdouts_level', redirect_stdouts_level)
     super(Worker, self).setup_defaults(**kwargs)
     self.purge = purge
     self.no_color = no_color
     self._isatty = isatty(sys.stdout)
     self.colored = self.app.log.colored(
         self.logfile,
         enabled=not no_color if no_color is not None else no_color
     )
示例#5
0
 def on_after_init(self, purge=False, no_color=None,
                   redirect_stdouts=None, redirect_stdouts_level=None,
                   **kwargs):
     self.redirect_stdouts = self.app.either(
         'worker_redirect_stdouts', redirect_stdouts)
     self.redirect_stdouts_level = self.app.either(
         'worker_redirect_stdouts_level', redirect_stdouts_level)
     super(Worker, self).setup_defaults(**kwargs)
     self.purge = purge
     self.no_color = no_color
     self._isatty = isatty(sys.stdout)
     self.colored = self.app.log.colored(
         self.logfile,
         enabled=not no_color if no_color is not None else no_color
     )
示例#6
0
def test_isatty():
    fh = Mock(name='fh')
    assert isatty(fh) is fh.isatty()
    fh.isatty.side_effect = AttributeError()
    assert not isatty(fh)
示例#7
0
 def colored(self):
     if self._colored is None:
         self._colored = term.colored(
             enabled=isatty(self.stdout) and not self.no_color)
     return self._colored
示例#8
0
def test_isatty():
    fh = Mock(name='fh')
    assert isatty(fh) is fh.isatty()
    fh.isatty.side_effect = AttributeError()
    assert not isatty(fh)
示例#9
0
def supports_images():
    return isatty(sys.stdin) and ITERM_PROFILE
示例#10
0
def supports_images():
    return isatty(sys.stdin) and ITERM_PROFILE
示例#11
0
文件: base.py 项目: jdufresne/celery
 def colored(self):
     if self._colored is None:
         self._colored = term.colored(enabled=isatty(self.stdout) and not self.no_color)
     return self._colored
示例#12
0
 def _term_supports_images(self):
     return isatty(sys.stdin) and os.environ.get('ITERM_PROFILE')
示例#13
0
 def test_tty(self):
     fh = Mock(name='fh')
     self.assertIs(isatty(fh), fh.isatty())
     fh.isatty.side_effect = AttributeError()
     self.assertFalse(isatty(fh))
示例#14
0
 def test_tty(self):
     fh = Mock(name='fh')
     self.assertIs(isatty(fh), fh.isatty())
     fh.isatty.side_effect = AttributeError()
     self.assertFalse(isatty(fh))