tools: add zmqshell.py.
authorClément Bœsch <ubitux@gmail.com>
Sun, 19 May 2013 15:55:19 +0000 (17:55 +0200)
committerClément Bœsch <ubitux@gmail.com>
Sun, 19 May 2013 15:59:21 +0000 (17:59 +0200)
tools/zmqshell.py [new file with mode: 0755]

diff --git a/tools/zmqshell.py b/tools/zmqshell.py
new file mode 100755 (executable)
index 0000000..a7d1126
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/env python2
+
+import sys, zmq, cmd
+
+class LavfiCmd(cmd.Cmd):
+    prompt = 'lavfi> '
+
+    def __init__(self, bind_address):
+        context = zmq.Context()
+        self.requester = context.socket(zmq.REQ)
+        self.requester.connect(bind_address)
+        cmd.Cmd.__init__(self)
+
+    def onecmd(self, cmd):
+        if cmd == 'EOF':
+            sys.exit(0)
+        print 'Sending command:[%s]' % cmd
+        self.requester.send(cmd)
+        message = self.requester.recv()
+        print 'Received reply:[%s]' % message
+
+try:
+    bind_address = sys.argv[1] if len(sys.argv) > 1 else "tcp://localhost:5555"
+    LavfiCmd(bind_address).cmdloop('FFmpeg libavfilter interactive shell')
+except KeyboardInterrupt:
+    pass