diff options
Diffstat (limited to 'src/leap/bitmask/cli')
-rw-r--r-- | src/leap/bitmask/cli/command.py | 23 | ||||
-rw-r--r-- | src/leap/bitmask/cli/mail.py | 20 | ||||
-rw-r--r-- | src/leap/bitmask/cli/vpn.py | 6 |
3 files changed, 29 insertions, 20 deletions
diff --git a/src/leap/bitmask/cli/command.py b/src/leap/bitmask/cli/command.py index 068f19b5..4bee325d 100644 --- a/src/leap/bitmask/cli/command.py +++ b/src/leap/bitmask/cli/command.py @@ -51,6 +51,29 @@ def default_dict_printer(result): print(Fore.RESET + key.ljust(10) + color + value + Fore.RESET) +def print_status(status, depth=0): + for name, v in [(' status', status)] + status['childrenStatus'].items(): + line = Fore.RESET + name.ljust(12) + if v['status'] in ('on', 'starting'): + line += Fore.GREEN + elif v['status'] == 'failure': + line += Fore.RED + line += v['status'] + if v['error']: + line += Fore.RED + " (" + v['error'] + ")" + line += Fore.RESET + print(line) + + for k, v in status.items(): + if k in ('status', 'childrenStatus', 'error'): + continue + if k == 'up': + k = '↑↑↑ ' + elif k == 'down': + k = '↓↓↓ ' + print(Fore.RESET + k.ljust(12) + Fore.CYAN + str(v) + Fore.RESET) + + class Command(object): """A generic command dispatcher. Any command in the class attribute `commands` will be dispached and diff --git a/src/leap/bitmask/cli/mail.py b/src/leap/bitmask/cli/mail.py index fd44383b..1624606a 100644 --- a/src/leap/bitmask/cli/mail.py +++ b/src/leap/bitmask/cli/mail.py @@ -57,22 +57,4 @@ SUBCOMMANDS: uid = self.cfg.get('bonafide', 'active', default=None) self.data += ['status', uid] - return self._send(self._print_status) - - def _print_status(self, status, depth=0): - for name, v in [('mail', status)] + status['childrenStatus'].items(): - line = Fore.RESET + name.ljust(10) - if v['status'] in ('on', 'starting'): - line += Fore.GREEN - elif v['status'] == 'failure': - line += Fore.RED - line += v['status'] - if v['error']: - line += Fore.RED + " (" + v['error'] + ")" - line += Fore.RESET - print(line) - - for k, v in status.items(): - if k in ('status', 'childrenStatus', 'error'): - continue - print(Fore.RESET + k.ljust(10) + Fore.CYAN + str(v) + Fore.RESET) + return self._send(command.print_status) diff --git a/src/leap/bitmask/cli/vpn.py b/src/leap/bitmask/cli/vpn.py index 69825159..e413e89d 100644 --- a/src/leap/bitmask/cli/vpn.py +++ b/src/leap/bitmask/cli/vpn.py @@ -43,7 +43,7 @@ SUBCOMMANDS: '''.format(name=command.appname) - commands = ['stop', 'status', 'install', 'uninstall', + commands = ['stop', 'install', 'uninstall', 'enable', 'disable'] def start(self, raw_args): @@ -68,6 +68,10 @@ SUBCOMMANDS: return self._send(command.default_dict_printer) + def status(self, raw_args): + self.data += ['status'] + return self._send(command.print_status) + def check(self, raw_args): parser = argparse.ArgumentParser( description='Bitmask VPN check', |