diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2016-09-27 12:52:29 -0400 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2016-09-27 12:53:23 -0400 |
commit | be5feead1469863982560b7cf75f5bfca627e21c (patch) | |
tree | fefc12c281c9dbf158591458313c1c6d44487cd8 /src/leap/bitmask/cli/command.py | |
parent | 321dd225e40be8f3e0c2e058f831ab804ca622b0 (diff) |
[feature] try to launch backend on cli commands
Diffstat (limited to 'src/leap/bitmask/cli/command.py')
-rw-r--r-- | src/leap/bitmask/cli/command.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/leap/bitmask/cli/command.py b/src/leap/bitmask/cli/command.py index 36552c0..1694956 100644 --- a/src/leap/bitmask/cli/command.py +++ b/src/leap/bitmask/cli/command.py @@ -96,10 +96,10 @@ class Command(object): self.parser.print_help() return defer.succeed(None) - def _send(self, printer=_print_result): - d = self._conn.sendMsg(*self.data, timeout=60) + def _send(self, printer=_print_result, timeout=60, errb=None): + d = self._conn.sendMsg(*self.data, timeout=timeout) d.addCallback(self._check_err, printer) - d.addErrback(self._timeout_handler) + d.addErrback(self._timeout_handler, errb) return d def _error(self, msg): @@ -113,8 +113,10 @@ class Command(object): else: print Fore.RED + 'ERROR:' + '%s' % obj['error'] + Fore.RESET - def _timeout_handler(self, failure): - # TODO ---- could try to launch the bitmask daemon here and retry + def _timeout_handler(self, failure, errb): if failure.trap(ZmqRequestTimeoutError) == ZmqRequestTimeoutError: - print (Fore.RED + "[ERROR] Timeout contacting the bitmask daemon. " - "Is it running?" + Fore.RESET) + if callable(errb): + errb() + else: + print (Fore.RED + "[ERROR] Timeout contacting the bitmask " + "daemon. Is it running?" + Fore.RESET) |