diff options
author | Ruben Pollan <meskio@sindominio.net> | 2017-08-28 17:04:14 +0200 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2017-08-31 11:04:38 +0200 |
commit | f19bfeb73fc19747bd02cbbd5c024de4dc86b5a8 (patch) | |
tree | 2dc001b06043887c22fd40c966cb6af3f92de187 /src/leap/bitmask/cli | |
parent | f476bdd9a769364bec7c342b5b6399530d4d454a (diff) |
[refactor] make the VPN location formating in the cli
Diffstat (limited to 'src/leap/bitmask/cli')
-rw-r--r-- | src/leap/bitmask/cli/vpn.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/leap/bitmask/cli/vpn.py b/src/leap/bitmask/cli/vpn.py index 44556ac2..5a9cce9e 100644 --- a/src/leap/bitmask/cli/vpn.py +++ b/src/leap/bitmask/cli/vpn.py @@ -20,6 +20,8 @@ Bitmask Command Line interface: vpn module import argparse import sys +from colorama import Fore + from leap.bitmask.cli import command @@ -97,7 +99,7 @@ SUBCOMMANDS: def list(self, raw_args): self.data += ['list'] - return self._send(command.default_dict_printer) + return self._send(location_printer) def get_cert(self, raw_args): parser = argparse.ArgumentParser( @@ -115,3 +117,18 @@ SUBCOMMANDS: self.data += ['get_cert', uid] return self._send(command.default_dict_printer) + + +def location_printer(result): + def pprint(key, value): + print(Fore.RESET + key.ljust(20) + Fore.GREEN + + value + Fore.RESET) + + for provider, locations in result.items(): + for loc in locations.values(): + location_str = ("[%(country_code)s] %(name)s " + "(UTC%(timezone)s %(hemisphere)s)" % loc) + pprint(provider, location_str) + + if not locations.values(): + pprint(provider, "---") |