From ecafdd273b6baec2e3c6f6548b743f23fc9b7c44 Mon Sep 17 00:00:00 2001 From: Jon Nordby Date: Mon, 13 Nov 2017 17:39:05 +0100 Subject: [PATCH] Make Haigha optional Since not Py3 compatible References #4 --- msgflo/msgflo.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/msgflo/msgflo.py b/msgflo/msgflo.py index 17d01ed..a6f9c40 100755 --- a/msgflo/msgflo.py +++ b/msgflo/msgflo.py @@ -22,8 +22,13 @@ import gevent.event # AMQP -from haigha.connection import Connection as haigha_Connection -from haigha.message import Message as haigha_Message +haigha = None +try: + import haigha + from haigha.connection import Connection as haigha_Connection + from haigha.message import Message as haigha_Message +except ImportError as e: + haigha = e # MQTT import paho.mqtt.client as mqtt @@ -111,6 +116,9 @@ class AmqpEngine(Engine): def __init__(self, broker, discovery_period=None): Engine.__init__(self, broker, discovery_period=discovery_period) + if isinstance(haigha, Exception): + raise haigha + # Prepare connection to AMQP broker vhost = '/' if self.broker_info.path: