From be5feead1469863982560b7cf75f5bfca627e21c Mon Sep 17 00:00:00 2001 From: "Kali Kaneko (leap communications)" Date: Tue, 27 Sep 2016 12:52:29 -0400 Subject: [feature] try to launch backend on cli commands --- src/leap/bitmask/cli/command.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/leap/bitmask/cli/command.py') diff --git a/src/leap/bitmask/cli/command.py b/src/leap/bitmask/cli/command.py index 36552c03..1694956e 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) -- cgit v1.2.3