Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] tools/zmqshell: port to python3
@ 2023-03-26 21:34 Stefano Sabatini
  2023-03-28 22:08 ` Stefano Sabatini
  2023-03-29  4:06 ` Leo Izen
  0 siblings, 2 replies; 5+ messages in thread
From: Stefano Sabatini @ 2023-03-26 21:34 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Stefano Sabatini

Also extend docs, use argparse and logging.
---
 tools/zmqshell.py | 63 ++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 52 insertions(+), 11 deletions(-)

diff --git a/tools/zmqshell.py b/tools/zmqshell.py
index a7d1126006..8d941636e1 100755
--- a/tools/zmqshell.py
+++ b/tools/zmqshell.py
@@ -1,6 +1,32 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
+
+import argparse
+import cmd
+import logging
+import sys
+import zmq
+
+HELP = '''
+Provide a shell used to send interactive commands to a zmq filter.
+
+The command assumes there is a running zmq or azmq filter acting as a
+ZMQ server.
+
+You can send a command to it, follwing the syntax:
+TARGET COMMAND [COMMAND_ARGS]
+
+* TARGET is the target filter identifier to send the command to
+* COMMAND is the name of the command sent to the filter
+* COMMAND_ARGS is the optional specification of command arguments
+
+See the zmq/azmq filters documentation for more details, and the
+zeromq documentation at:
+https://zeromq.org/
+'''
+
+logging.basicConfig(format='zmqshell|%(levelname)s> %(message)s', level=logging.INFO)
+log = logging.getLogger()
 
-import sys, zmq, cmd
 
 class LavfiCmd(cmd.Cmd):
     prompt = 'lavfi> '
@@ -14,13 +40,28 @@ class LavfiCmd(cmd.Cmd):
     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:
+        log.info(f"Sending command: {cmd}")
+        self.requester.send_string(cmd)
+        response = self.requester.recv_string()
+        log.info(f"Received response: {response}")
+
+
+class Formatter(
+    argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter
+):
     pass
+
+
+def main():
+    parser = argparse.ArgumentParser(description=HELP, formatter_class=Formatter)
+    parser.add_argument('--bind-address', '-b', default='tcp://localhost:5555', help='specify bind address used to communicate with ZMQ')
+
+    args = parser.parse_args()
+    try:
+        LavfiCmd(args.bind_address).cmdloop('FFmpeg libavfilter interactive shell')
+    except KeyboardInterrupt:
+        pass
+
+
+if __name__ == '__main__':
+    main()
-- 
2.25.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH] tools/zmqshell: port to python3
  2023-03-26 21:34 [FFmpeg-devel] [PATCH] tools/zmqshell: port to python3 Stefano Sabatini
@ 2023-03-28 22:08 ` Stefano Sabatini
  2023-03-29  4:06 ` Leo Izen
  1 sibling, 0 replies; 5+ messages in thread
From: Stefano Sabatini @ 2023-03-28 22:08 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On date Sunday 2023-03-26 23:34:59 +0200, Stefano Sabatini wrote:
> Also extend docs, use argparse and logging.
> ---
>  tools/zmqshell.py | 63 ++++++++++++++++++++++++++++++++++++++---------
>  1 file changed, 52 insertions(+), 11 deletions(-)

Will apply in a few days if I see no comments.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH] tools/zmqshell: port to python3
  2023-03-26 21:34 [FFmpeg-devel] [PATCH] tools/zmqshell: port to python3 Stefano Sabatini
  2023-03-28 22:08 ` Stefano Sabatini
@ 2023-03-29  4:06 ` Leo Izen
  2023-04-01 23:21   ` Stefano Sabatini
  1 sibling, 1 reply; 5+ messages in thread
From: Leo Izen @ 2023-03-29  4:06 UTC (permalink / raw)
  To: ffmpeg-devel

On 3/26/23 17:34, Stefano Sabatini wrote:
> Also extend docs, use argparse and logging.
> ---
>   tools/zmqshell.py | 63 ++++++++++++++++++++++++++++++++++++++---------
>   1 file changed, 52 insertions(+), 11 deletions(-)
> 
> diff --git a/tools/zmqshell.py b/tools/zmqshell.py
> index a7d1126006..8d941636e1 100755
> --- a/tools/zmqshell.py
> +++ b/tools/zmqshell.py
> @@ -1,6 +1,32 @@
> -#!/usr/bin/env python2
> +#!/usr/bin/env python3
> +
> +import argparse
> +import cmd
> +import logging
> +import sys
> +import zmq
> +
> +HELP = '''
> +Provide a shell used to send interactive commands to a zmq filter.
> +
> +The command assumes there is a running zmq or azmq filter acting as a
> +ZMQ server.
> +
> +You can send a command to it, follwing the syntax:
> +TARGET COMMAND [COMMAND_ARGS]
> +
> +* TARGET is the target filter identifier to send the command to
> +* COMMAND is the name of the command sent to the filter
> +* COMMAND_ARGS is the optional specification of command arguments
> +
> +See the zmq/azmq filters documentation for more details, and the
> +zeromq documentation at:
> +https://zeromq.org/
> +'''
> +
> +logging.basicConfig(format='zmqshell|%(levelname)s> %(message)s', level=logging.INFO)
> +log = logging.getLogger()
>   
> -import sys, zmq, cmd
>   
>   class LavfiCmd(cmd.Cmd):
>       prompt = 'lavfi> '
> @@ -14,13 +40,28 @@ class LavfiCmd(cmd.Cmd):
>       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:
> +        log.info(f"Sending command: {cmd}")
> +        self.requester.send_string(cmd)
> +        response = self.requester.recv_string()
> +        log.info(f"Received response: {response}")
> +
> +
> +class Formatter(
> +    argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter
> +):
>       pass
> +
> +
> +def main():
> +    parser = argparse.ArgumentParser(description=HELP, formatter_class=Formatter)
> +    parser.add_argument('--bind-address', '-b', default='tcp://localhost:5555', help='specify bind address used to communicate with ZMQ')
> +

This changes the interface to use `--bind-address` instead of just 
passing the address directly as argv[1]. Does this have the potential to 
break anything downstream? Or do we make no promises about this interface?


- Leo Izen (thebombzen)

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH] tools/zmqshell: port to python3
  2023-03-29  4:06 ` Leo Izen
@ 2023-04-01 23:21   ` Stefano Sabatini
  2023-04-02 15:14     ` Stefano Sabatini
  0 siblings, 1 reply; 5+ messages in thread
From: Stefano Sabatini @ 2023-04-01 23:21 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On date Wednesday 2023-03-29 00:06:40 -0400, Leo Izen wrote:
> On 3/26/23 17:34, Stefano Sabatini wrote:
> > Also extend docs, use argparse and logging.
> > ---
> >   tools/zmqshell.py | 63 ++++++++++++++++++++++++++++++++++++++---------
> >   1 file changed, 52 insertions(+), 11 deletions(-)
[...]
> > +def main():
> > +    parser = argparse.ArgumentParser(description=HELP, formatter_class=Formatter)
> > +    parser.add_argument('--bind-address', '-b', default='tcp://localhost:5555', help='specify bind address used to communicate with ZMQ')
> > +

> This changes the interface to use `--bind-address` instead of just passing
> the address directly as argv[1]. Does this have the potential to break
> anything downstream? Or do we make no promises about this interface?

This is mostly meant for interactive use, so I'd rather keep things
simple and drop the old syntax.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH] tools/zmqshell: port to python3
  2023-04-01 23:21   ` Stefano Sabatini
@ 2023-04-02 15:14     ` Stefano Sabatini
  0 siblings, 0 replies; 5+ messages in thread
From: Stefano Sabatini @ 2023-04-02 15:14 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On date Sunday 2023-04-02 01:21:12 +0200, Stefano Sabatini wrote:
> On date Wednesday 2023-03-29 00:06:40 -0400, Leo Izen wrote:
> > On 3/26/23 17:34, Stefano Sabatini wrote:
> > > Also extend docs, use argparse and logging.
> > > ---
> > >   tools/zmqshell.py | 63 ++++++++++++++++++++++++++++++++++++++---------
> > >   1 file changed, 52 insertions(+), 11 deletions(-)
> [...]
> > > +def main():
> > > +    parser = argparse.ArgumentParser(description=HELP, formatter_class=Formatter)
> > > +    parser.add_argument('--bind-address', '-b', default='tcp://localhost:5555', help='specify bind address used to communicate with ZMQ')
> > > +
> 
> > This changes the interface to use `--bind-address` instead of just passing
> > the address directly as argv[1]. Does this have the potential to break
> > anything downstream? Or do we make no promises about this interface?
> 
> This is mostly meant for interactive use, so I'd rather keep things
> simple and drop the old syntax.

Pushed.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-04-02 15:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-26 21:34 [FFmpeg-devel] [PATCH] tools/zmqshell: port to python3 Stefano Sabatini
2023-03-28 22:08 ` Stefano Sabatini
2023-03-29  4:06 ` Leo Izen
2023-04-01 23:21   ` Stefano Sabatini
2023-04-02 15:14     ` Stefano Sabatini

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git