]> git.llucax.com Git - software/pymin.git/commitdiff
Add a simple response to all commands.
authorLeandro Lucarella <llucarella@integratech.com.ar>
Mon, 24 Sep 2007 17:11:33 +0000 (14:11 -0300)
committerLeandro Lucarella <llucarella@integratech.com.ar>
Mon, 24 Sep 2007 17:11:33 +0000 (14:11 -0300)
The response consist of a success indicator ("OK") followed by the response
body lenght. The response body is command-dependant.

dispatcher.py
pymindaemon.py

index addd45f716a3446b5fa0078875328eb2cdf37d5c..29cff6e88d7909738644b3a6fd4c991349f34878 100644 (file)
@@ -108,7 +108,7 @@ class Dispatcher:
                 raise CommandNotFoundError(command)
             handler = getattr(handler, route[0])
             route = route[1:]
-        handler(*route)
+        return handler(*route)
 
 
 if __name__ == '__main__':
index 76a31d75eae0bdc54bb5417102cabf156758d5c1..1e9589aa242478b49e1e06990e2fefbe51142298 100644 (file)
@@ -58,7 +58,12 @@ class PyminDaemon(EventLoop):
     def handle(self):
         r"handle() -> None :: Handle incoming events using the dispatcher."
         (msg, addr) = self.file.recvfrom(65535)
-        self.dispatcher.dispatch(msg)
+        result = self.dispatcher.dispatch(msg)
+        if result is None:
+            msg = 'OK 0'
+        else:
+            msg = 'OK %d\n%s' % (len(str(result)), result)
+        self.file.sendto(msg, addr)
         #try:
         #    d.dispatch(msg)
         #except dis.BadRouteError, inst: