aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaZderMind <git@mazdermind.de>2015-11-15 14:42:47 +0100
committerMaZderMind <git@mazdermind.de>2015-11-15 14:42:47 +0100
commitd61571d7f81b867625ad0dfc62c410ba5bad06af (patch)
tree3fe659a1a841a55ff03a7d3e2a9886e63ab72380
parent478b2e0e4510796b8f4a1e145e8e5c415b24e8b2 (diff)
Allow a Command to return multiple notifications
-rw-r--r--voctocore/lib/controlserver.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/voctocore/lib/controlserver.py b/voctocore/lib/controlserver.py
index 48fff65..90d4e7c 100644
--- a/voctocore/lib/controlserver.py
+++ b/voctocore/lib/controlserver.py
@@ -87,6 +87,7 @@ class ControlServer(TCPMultiConnection):
self.log.info("processing command %r with args %s", command, args)
+ response = None
try:
command_function = self.commands.__class__.__dict__[command]
@@ -104,17 +105,19 @@ class ControlServer(TCPMultiConnection):
else:
if isinstance(responseObject, NotifyResponse):
- signal = "%s\n" % str(responseObject)
- for conn, queue in self.currentConnections.items():
- if conn == requestor:
- continue
+ responseObject = [ responseObject ]
- queue.put(signal)
+ if isinstance(responseObject, list):
+ for obj in responseObject:
+ signal = "%s\n" % str(obj)
+ for conn, queue in self.currentConnections.items():
+ queue.put(signal)
- response = "%s\n" % str(responseObject)
+ else:
+ response = "%s\n" % str(responseObject)
finally:
- if requestor in self.currentConnections:
+ if response is not None and requestor in self.currentConnections:
self.currentConnections[requestor].put(response)
return True