summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
authorIvan Alejandro <ivanalejandro0@gmail.com>2015-07-08 16:15:09 -0300
committerKali Kaneko <kali@leap.se>2015-07-20 19:14:36 -0400
commit0d9c53c4ec182c6bf3452506351258b61bb1f739 (patch)
tree3f3edeb10a65b4862fdc0fa53b787d1bc47b3654 /src/leap
parentd6abcc95e70d8c76dc4998766cbca5c444bd8915 (diff)
[bug] prevent logbook subscriber to fail
Fix: If the logbook controller is not started the stop call will fail. Trying to start it twice fails.
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/bitmask/logs/utils.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/leap/bitmask/logs/utils.py b/src/leap/bitmask/logs/utils.py
index f0e820b2..683fb542 100644
--- a/src/leap/bitmask/logs/utils.py
+++ b/src/leap/bitmask/logs/utils.py
@@ -188,15 +188,17 @@ class QtLogHandler(logbook.Handler, logbook.StringFormatterHandlerMixin):
class _LogController(object):
def __init__(self):
self._qt_handler = QtLogHandler(format_string=LOG_FORMAT)
+ self._logbook_controller = None
self.new_log = self._qt_handler.qt.new_log
def start_logbook_subscriber(self):
"""
Run in the background the log receiver.
"""
- subscriber = ZeroMQSubscriber('tcp://127.0.0.1:5000', multi=True)
- self._logbook_controller = subscriber.dispatch_in_background(
- self._qt_handler)
+ if self._logbook_controller is None:
+ subscriber = ZeroMQSubscriber('tcp://127.0.0.1:5000', multi=True)
+ self._logbook_controller = subscriber.dispatch_in_background(
+ self._qt_handler)
def stop_logbook_subscriber(self):
"""
@@ -205,8 +207,10 @@ class _LogController(object):
This allows us to re-create the subscriber when we reopen this window
without getting an error at trying to connect twice to the zmq port.
"""
- self._logbook_controller.stop()
- self._logbook_controller.subscriber.close()
+ if self._logbook_controller is not None:
+ self._logbook_controller.stop()
+ self._logbook_controller.subscriber.close()
+ self._logbook_controller = None
def get_logs(self):
return self._qt_handler.logs