Some tools had an artificial dependency on python2: zmqshell.py and normalize.py
This patch changes the requested environment to a generic "python", and add parenthesis to the "print" calls. 2to3 shows no other modifications are needed, so I expect this to be okay. Please note that this was untested. --- tools/normalize.py | 13 +++++++------ tools/zmqshell.py | 7 ++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tools/normalize.py b/tools/normalize.py index 7d87c5e154..a550d06906 100755 --- a/tools/normalize.py +++ b/tools/normalize.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python +# This script is compatible both with python 2 and 3; please keep it so import sys, subprocess @@ -7,7 +8,7 @@ if len(sys.argv) > 2: encopt = sys.argv[2:-1] ofile = sys.argv[-1] else: - print 'usage: %s <input> [encode_options] <output>' % sys.argv[0] + print('usage: %s <input> [encode_options] <output>' % sys.argv[0]) sys.exit(1) analysis_cmd = 'ffprobe -v error -of compact=p=0:nk=1 ' @@ -15,7 +16,7 @@ analysis_cmd += '-show_entries frame_tags=lavfi.r128.I -f lavfi ' analysis_cmd += "amovie='%s',ebur128=metadata=1" % ifile try: probe_out = subprocess.check_output(analysis_cmd, shell=True) -except subprocess.CalledProcessError, e: +except subprocess.CalledProcessError as e: sys.exit(e.returncode) loudness = ref = -23 for line in probe_out.splitlines(): @@ -24,10 +25,10 @@ for line in probe_out.splitlines(): loudness = sline adjust = ref - float(loudness) if abs(adjust) < 0.0001: - print 'No normalization needed for ' + ifile + print('No normalization needed for ' + ifile) else: - print "Adjust %s by %.1fdB" % (ifile, adjust) + print("Adjust %s by %.1fdB" % (ifile, adjust)) norm_cmd = ['ffmpeg', '-i', ifile, '-af', 'volume=%fdB' % adjust] norm_cmd += encopt + [ofile] - print ' => %s' % ' '.join(norm_cmd) + print(' => %s' % ' '.join(norm_cmd)) subprocess.call(norm_cmd) diff --git a/tools/zmqshell.py b/tools/zmqshell.py index a7d1126006..ff229b29c9 100755 --- a/tools/zmqshell.py +++ b/tools/zmqshell.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python +# This script is compatible both with python 2 and 3; please keep it so import sys, zmq, cmd @@ -14,10 +15,10 @@ class LavfiCmd(cmd.Cmd): def onecmd(self, cmd): if cmd == 'EOF': sys.exit(0) - print 'Sending command:[%s]' % cmd + print('Sending command:[%s]' % cmd) self.requester.send(cmd) message = self.requester.recv() - print 'Received reply:[%s]' % message + print('Received reply:[%s]' % message) try: bind_address = sys.argv[1] if len(sys.argv) > 1 else "tcp://localhost:5555" -- 2.18.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel