diff options
author | Kali Kaneko <kali@leap.se> | 2015-09-10 16:22:03 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2015-09-10 17:17:37 -0400 |
commit | b3e960608ef2d26b8f7c9edaedd5655f8804d19e (patch) | |
tree | 4798e2f19b7a82e3130cd07bf377437a2b2ee519 /src/leap/bitmask/logs/safezmqhandler.py | |
parent | f075e0a646c36b267a50cd68919cb2fbef2af2fc (diff) |
[bug] add compatibility for logbook versions < 0.7.0
for the version in ubuntu trusty, the call for the zeromq handler
initialization gets one less argument
Diffstat (limited to 'src/leap/bitmask/logs/safezmqhandler.py')
-rw-r--r-- | src/leap/bitmask/logs/safezmqhandler.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/leap/bitmask/logs/safezmqhandler.py b/src/leap/bitmask/logs/safezmqhandler.py index 4f7aca9b..4b3d26c7 100644 --- a/src/leap/bitmask/logs/safezmqhandler.py +++ b/src/leap/bitmask/logs/safezmqhandler.py @@ -19,9 +19,11 @@ A thread-safe zmq handler for LogBook. """ import json import threading +from distutils import LooseVersion from logbook.queues import ZeroMQHandler from logbook import NOTSET +from logbook import __version__ as LOGBOOK_VERSION import zmq @@ -53,8 +55,13 @@ class SafeZMQHandler(ZeroMQHandler): # instead of calling the ZeroMQHandler's one. # The best approach may be to inherit directly from `logbook.Handler`. - ZeroMQHandler.__init__(self, uri, level, filter, bubble, context, - multi) + args = (self, uri, level, filter, bubble, context) + + # Workaround for an API change: version 0.6.0 in trusty doesn't accepts + # the multi parameter. + if LooseVersion(LOGBOOK_VERSION) >= LooseVersion('0.7.0'): + args += (multi,) + ZeroMQHandler.__init__(*args) current_id = self._get_caller_id() # we store the socket created on the parent |