Check TCP handler before sending notifications
authorThierry Florac <tflorac@ulthar.net>
Wed, 07 Feb 2018 12:38:16 +0100
changeset 31 3be93cea8f89
parent 30 cb1fc976d8ec
child 32 7573397d632b
Check TCP handler before sending notifications
src/pyams_notify/event.py
--- a/src/pyams_notify/event.py	Fri Jan 26 17:36:18 2018 +0100
+++ b/src/pyams_notify/event.py	Wed Feb 07 12:38:16 2018 +0100
@@ -111,7 +111,10 @@
         request = query_request()
     if request is None:
         return
-    ws = WebSocketClient('ws://{0}/notify'.format(request.registry.settings.get('pyams_notify.tcp_handler')))
+    handler = request.registry.settings.get('pyams_notify.tcp_handler')
+    if not handler:
+        return
+    ws = WebSocketClient('ws://{0}/notify'.format(handler))
     ws.connect()
     try:
         json_data = json.dumps(event, cls=NotificationEncoder)