예제 #1
0
 def __call__(self, **filters):
     if self.cli_mode:
         print(title("Roles:"))
     roles = [r.name for r in Role.filter(**filters)]
     if self.cli_mode:
         for r in roles:
             print(" - {0}".format(r))
     return roles
예제 #2
0
 def __call__(self, **filters):
     if self.cli_mode:
         print(title("Roles:"))
     roles = [r.name for r in Role.filter(**filters)]
     if self.cli_mode:
         for r in roles:
             print(" - {0}".format(r))
     return roles
예제 #3
0
 def __call__(self, **filters):
     if self.cli_mode:
         print(title("Hosts:"))
     hosts = [h.name for h in Host.filter(**filters)]
     if self.cli_mode:
         for h in hosts:
             print(" - {0}".format(h))
     return hosts
예제 #4
0
파일: host.py 프로젝트: ponkt/pepperstack
 def __call__(self, **filters):
     if self.cli_mode:
         print(title("Hosts:"))
     hosts = [h.name for h in Host.filter(**filters)]
     if self.cli_mode:
         for h in hosts:
             print(" - {0}".format(h))
     return hosts
예제 #5
0
 def __call__(self, name):
     r = Role.find(name)
     if not r:
         raise DoesNotExistsException(
             "Role {0} does not exists in database".format(name))
     ret = r.as_dict()
     if self.cli_mode:
         print(title(r.name + ':'))
         pretty_print(ret)
     return ret
예제 #6
0
 def __call__(self, name):
     h = Host.find(name)
     if not h:
         raise DoesNotExistsException("Host {0} does not exists in database"
                                      .format(name))
     ret = h.as_dict()
     if self.cli_mode:
         print(title(h.name + ':'))
         pretty_print(ret)
     return ret
예제 #7
0
 def __call__(self, name, key, default=None):
     h = Host.find(name)
     if not h:
         raise DoesNotExistsException("Host {0} does not exists in database"
                                      .format(name))
     ret = h.get(key, default)
     if self.cli_mode:
         print(title(h.name + ':'))
         print("{0}: {1}".format(key, ret))
     return ret
예제 #8
0
 def __call__(self, name):
     r = Role.find(name)
     if not r:
         raise DoesNotExistsException("Role {0} does not exists in database"
                                      .format(name))
     ret = r.as_dict()
     if self.cli_mode:
         print(title(r.name + ':'))
         pretty_print(ret)
     return ret
예제 #9
0
파일: host.py 프로젝트: ponkt/pepperstack
 def __call__(self, name):
     h = Host.find(name)
     if not h:
         raise DoesNotExistsException(
             "Host {0} does not exists in database".format(name))
     ret = h.as_dict()
     if self.cli_mode:
         print(title(h.name + ':'))
         pretty_print(ret)
     return ret
예제 #10
0
파일: host.py 프로젝트: ponkt/pepperstack
 def __call__(self, name, key, default=None):
     h = Host.find(name)
     if not h:
         raise DoesNotExistsException(
             "Host {0} does not exists in database".format(name))
     ret = h.get(key, default)
     if self.cli_mode:
         print(title(h.name + ':'))
         print("{0}: {1}".format(key, ret))
     return ret
예제 #11
0
    def __call__(self, cmd=None):
        from . import get_command

        if not self.cli_mode:
            return None
        if not cmd:
            print(command_list_help(in_help_text=False))
        else:
            c = get_command(cmd)
            t = "Command '{0}' help:".format(cmd)
            print(title(t))
            print(c.get_help_text().format(command=cmd))
예제 #12
0
    def __call__(self, cmd=None):
        from . import get_command

        if not self.cli_mode:
            return None
        if not cmd:
            print(command_list_help(in_help_text=False))
        else:
            c = get_command(cmd)
            t = "Command '{0}' help:".format(cmd)
            print(title(t))
            print(c.get_help_text().format(command=cmd))
예제 #13
0
def command_list_help(in_help_text=True):
    """
    Returns a string describing each command and his short help

    """
    from . import get_command_dict

    if in_help_text:
        help_text = "available commands:"
    else:
        help_text = title("Available commands:") + '\n'
    for k, v in list(get_command_dict().items()):
        for c, d in _build_cmd_list_r(v, k):
            help_text += '  {0: <12}{1}\n'.format(c, d)
        help_text += '\n'
    return help_text
예제 #14
0
def command_list_help(in_help_text=True):
    """
    Returns a string describing each command and his short help

    """
    from . import get_command_dict

    if in_help_text:
        help_text = "available commands:"
    else:
        help_text = title("Available commands:") + '\n'
    for k, v in list(get_command_dict().items()):
        for c, d in _build_cmd_list_r(v, k):
            help_text += '  {0: <12}{1}\n'.format(c, d)
        help_text += '\n'
    return help_text