Exemplo n.º 1
0
    def get_command_info(self,
                         command,
                         indent=0,
                         prefix='',
                         color=None,
                         help=False):
        if help:
            help = '|' + text.indent(self.choices[command][1], indent + 4)
        else:
            help = None
        try:
            # see if it uses args.
            meth = getattr(self, command)
            return text.join([
                '|' + text.indent(
                    '{0}{1} {2}'.format(prefix, color(command), meth.__doc__),
                    indent),
                help,
            ])

        except AttributeError:
            return text.join([
                '|' + text.indent(prefix + str(color(command)), indent),
                help,
            ])
Exemplo n.º 2
0
 def pretty_dict_ok_error(self, n):
     c = self.colored
     try:
         return (c.green("OK"), text.indent(self.pretty(n["ok"])[1], 4))
     except KeyError:
         pass
     return (c.red("ERROR"), text.indent(self.pretty(n["error"])[1], 4))
Exemplo n.º 3
0
 def pretty_dict_ok_error(self, n):
     c = self.colored
     try:
         return (c.green('OK'), text.indent(self.pretty(n['ok'])[1], 4))
     except KeyError:
         pass
     return (c.red('ERROR'), text.indent(self.pretty(n['error'])[1], 4))
Exemplo n.º 4
0
 def pretty_dict_ok_error(self, n):
     c = self.colored
     try:
         return (c.green("OK"), text.indent(self.pretty(n["ok"])[1], 4))
     except KeyError:
         pass
     return (c.red("ERROR"), text.indent(self.pretty(n["error"])[1], 4))
Exemplo n.º 5
0
 def get_command_info(
     cls,
     command,
     indent=0,
     prefix="",
     color=None,
     help=False,
     app=None,
     choices=None,
 ):
     if choices is None:
         choices = cls._choices_by_group(app)
     meta = choices[command]
     if help:
         help = "|" + text.indent(meta.help, indent + 4)
     else:
         help = None
     return text.join([
         "|" + text.indent(
             "{0}{1} {2}".format(prefix, color(command), meta.signature
                                 or ""),
             indent,
         ),
         help,
     ])
Exemplo n.º 6
0
 def pretty_dict_ok_error(self, n):
     try:
         return (self.OK,
                 text.indent(self.pretty(n['ok'])[1], 4))
     except KeyError:
         pass
     return (self.ERROR,
             text.indent(self.pretty(n['error'])[1], 4))
Exemplo n.º 7
0
 def pretty_dict_ok_error(self, n):
     c = self.colored
     try:
         return (c.green('OK'),
                 text.indent(self.pretty(n['ok'])[1], 4))
     except KeyError:
         pass
     return (c.red('ERROR'),
             text.indent(self.pretty(n['error'])[1], 4))
Exemplo n.º 8
0
 def get_command_info(self, command, indent=0, color=None):
     colored = term.colored().names[color] if color else lambda x: x
     obj = self.commands[command]
     if obj.leaf:
         return '|' + text.indent('celery %s' % colored(command), indent)
     return text.join([
         ' ',
         '|' + text.indent('celery %s --help' % colored(command), indent),
         obj.list_commands(indent, 'celery %s' % command, colored),
     ])
Exemplo n.º 9
0
 def get_command_info(self, command, indent=0, color=None):
     colored = term.colored().names[color] if color else lambda x: x
     obj = self.commands[command]
     if obj.leaf:
         return '|' + text.indent("celery %s" % colored(command), indent)
     return text.join([
         " ",
         '|' + text.indent("celery %s --help" % colored(command), indent),
         obj.list_commands(indent, "celery %s" % command, colored),
     ])
Exemplo n.º 10
0
 def get_command_info(self, command, indent=0, color=None):
     colored = term.colored().names[color] if color else lambda x: x
     obj = self.commands[command]
     cmd = 'celery {0}'.format(colored(command))
     if obj.leaf:
         return '|' + text.indent(cmd, indent)
     return text.join([
         ' ',
         '|' + text.indent('{0} --help'.format(cmd), indent),
         obj.list_commands(indent, 'celery {0}'.format(command), colored),
     ])
Exemplo n.º 11
0
 def format(self, indent=0, indent_first=True):
     """Format routing table into string for log dumps."""
     active = self.consume_from
     if not active:
         return ""
     info = [QUEUE_FORMAT.strip() % dict(
                 name=(name + ":").ljust(12), **config)
                     for name, config in sorted(active.iteritems())]
     if indent_first:
         return text.indent("\n".join(info), indent)
     return info[0] + "\n" + text.indent("\n".join(info[1:]), indent)
Exemplo n.º 12
0
 def get_command_info(self, command, indent=0, color=None):
     colored = term.colored().names[color] if color else lambda x: x
     obj = self.commands[command]
     cmd = 'celery {0}'.format(colored(command))
     if obj.leaf:
         return '|' + text.indent(cmd, indent)
     return text.join([
         ' ',
         '|' + text.indent('{0} --help'.format(cmd), indent),
         obj.list_commands(indent, 'celery {0}'.format(command), colored),
     ])
Exemplo n.º 13
0
    def get_command_info(self, command, indent=0, prefix="", color=None, help=False):
        if help:
            help = "|" + text.indent(self.choices[command][1], indent + 4)
        else:
            help = None
        try:
            # see if it uses args.
            meth = getattr(self, command)
            return text.join(["|" + text.indent("%s%s %s" % (prefix, color(command), meth.__doc__), indent), help])

        except AttributeError:
            return text.join(["|" + text.indent(prefix + str(color(command)), indent), help])
Exemplo n.º 14
0
 def get_command_info(self, command, indent=0, color=None):
     colored = term.colored().names[color] if color else lambda x: x
     obj = self.commands[command]
     cmd = "celery {0}".format(colored(command))
     if obj.leaf:
         return "|" + text.indent(cmd, indent)
     return text.join(
         [
             " ",
             "|" + text.indent("{0} --help".format(cmd), indent),
             obj.list_commands(indent, "celery {0}".format(command), colored),
         ]
     )
Exemplo n.º 15
0
 def get_command_info(cls, command, indent=0,
                      color=None, colored=None, app=None):
     colored = term.colored() if colored is None else colored
     colored = colored.names[color] if color else lambda x: x
     obj = cls.commands[command]
     cmd = 'celery {0}'.format(colored(command))
     if obj.leaf:
         return '|' + text.indent(cmd, indent)
     return text.join([
         ' ',
         '|' + text.indent('{0} --help'.format(cmd), indent),
         obj.list_commands(indent, 'celery {0}'.format(command), colored,
                           app=app),
     ])
Exemplo n.º 16
0
 def get_command_info(cls, command,
                      indent=0, prefix='', color=None,
                      help=False, app=None, choices=None):
     if choices is None:
         choices = cls._choices_by_group(app)
     meta = choices[command]
     if help:
         help = '|' + text.indent(meta.help, indent + 4)
     else:
         help = None
     return text.join([
         '|' + text.indent('{0}{1} {2}'.format(
             prefix, color(command), meta.signature or ''), indent),
         help,
     ])
Exemplo n.º 17
0
 def get_command_info(self, command,
                      indent=0, prefix='', color=None,
                      help=False, app=None, choices=None):
     if choices is None:
         choices = self._choices_by_group(app)
     meta = choices[command]
     if help:
         help = '|' + text.indent(meta.help, indent + 4)
     else:
         help = None
     return text.join([
         '|' + text.indent('{0}{1} {2}'.format(
             prefix, color(command), meta.signature or ''), indent),
         help,
     ])
Exemplo n.º 18
0
 def say_remote_command_reply(self, replies):
     c = self.colored
     node = replies.keys()[0]
     reply = replies[node]
     status, preply = self.prettify(reply)
     self.say_chat("->", c.cyan(node, ": ") + status,
                   text.indent(preply, 4))
Exemplo n.º 19
0
 def say_remote_command_reply(self, replies):
     c = self.colored
     node = next(iter(replies))  # <-- take first.
     reply = replies[node]
     status, preply = self.pretty(reply)
     self.say_chat('->', c.cyan(node, ': ') + status,
                   text.indent(preply, 4) if self.show_reply else '')
Exemplo n.º 20
0
 def say_remote_command_reply(self, replies):
     c = self.colored
     node = next(iter(replies))  # <-- take first.
     reply = replies[node]
     status, preply = self.pretty(reply)
     self.say_chat('->', c.cyan(node, ': ') + status,
                   text.indent(preply, 4) if self.show_reply else '')
Exemplo n.º 21
0
 def say_remote_command_reply(self, replies):
     c = self.colored
     node = replies.keys()[0]
     reply = replies[node]
     status, preply = self.prettify(reply)
     self.say_chat('->', c.cyan(node, ': ') + status,
                   text.indent(preply, 4) if self.show_reply else '')
Exemplo n.º 22
0
def _say_remote_command_reply(ctx, replies, show_reply=False):
    node = next(iter(replies))  # <-- take first.
    reply = replies[node]
    node = ctx.obj.style(f'{node}: ', fg='cyan', bold=True)
    status, preply = ctx.obj.pretty(reply)
    ctx.obj.say_chat('->', f'{node}{status}',
                     text.indent(preply, 4) if show_reply else '',
                     show_body=show_reply)
Exemplo n.º 23
0
    def get_command_info(self, command, indent=0, prefix='', color=None,
            help=False):
        if help:
            help = '|' + text.indent(self.choices[command][1], indent + 4)
        else:
            help = None
        try:
            # see if it uses args.
            meth = getattr(self, command)
            return text.join([
                '|' + text.indent('{0}{1} {2}'.format(prefix, color(command),
                                                meth.__doc__), indent), help,
            ])

        except AttributeError:
            return text.join([
                '|' + text.indent(prefix + str(color(command)), indent), help,
            ])
Exemplo n.º 24
0
 def list_commands(self, indent=0):
     white = term.colored().white
     ret = []
     for cls, commands, color in command_classes:
         ret.extend([
             text.indent('+ {0}: '.format(white(cls)), indent), '\n'.join(
                 self.get_command_info(command, indent + 4, color)
                 for command in commands), ''
         ])
     return '\n'.join(ret).strip()
Exemplo n.º 25
0
 def list_commands(self, indent=0):
     white = term.colored().white
     ret = []
     for cls, commands, color in command_classes:
         ret.extend([
             text.indent('+ {0}: '.format(white(cls)), indent),
             '\n'.join(self.get_command_info(command, indent + 4, color)
                       for command in commands),
             ''
         ])
     return '\n'.join(ret).strip()
Exemplo n.º 26
0
 def list_commands(self, indent=0, colored=None):
     colored = term.colored() if colored is None else colored
     white = colored.white
     ret = []
     for cls, commands, color in command_classes:
         ret.extend([
             text.indent('+ {0}: '.format(white(cls)), indent), '\n'.join(
                 self.get_command_info(command, indent + 4, color, colored)
                 for command in commands), ''
         ])
     return '\n'.join(ret).strip()
Exemplo n.º 27
0
 def list_commands(self, indent=0):
     white = term.colored().white
     ret = []
     for cls, commands, color in command_classes:
         ret.extend([
             text.indent("+ %s: " % white(cls), indent),
             "\n".join(self.get_command_info(command, indent + 4, color)
                         for command in commands),
             ""
         ])
     return "\n".join(ret).strip()
Exemplo n.º 28
0
 def list_commands(self, indent=0, colored=None):
     colored = term.colored() if colored is None else colored
     white = colored.white
     ret = []
     for cls, commands, color in command_classes:
         ret.extend([
             text.indent('+ {0}: '.format(white(cls)), indent),
             '\n'.join(
                 self.get_command_info(command, indent + 4, color, colored)
                 for command in commands),
             ''
         ])
     return '\n'.join(ret).strip()
Exemplo n.º 29
0
 def test_textindent(self):
     assert indent(RANDTEXT, 4) == RANDTEXT_RES
Exemplo n.º 30
0
 def say_remote_command_reply(self, replies):
     c = self.colored
     node = iter(replies).next()  # <-- take first.
     reply = replies[node]
     status, preply = self.prettify(reply)
     self.say_chat("->", c.cyan(node, ": ") + status, text.indent(preply, 4) if self.show_reply else "")
Exemplo n.º 31
0
 def test_textindent(self):
     assert indent(RANDTEXT, 4) == RANDTEXT_RES
Exemplo n.º 32
0
 def test_textindent(self):
     self.assertEqual(indent(RANDTEXT, 4), RANDTEXT_RES)
Exemplo n.º 33
0
 def test_textindent(self):
     self.assertEqual(indent(RANDTEXT, 4), RANDTEXT_RES)