summaryrefslogtreecommitdiff
path: root/gr-utils/python/utils
diff options
context:
space:
mode:
Diffstat (limited to 'gr-utils/python/utils')
-rw-r--r--gr-utils/python/utils/CMakeLists.txt3
-rwxr-xr-xgr-utils/python/utils/gr_modtool34
-rwxr-xr-xgr-utils/python/utils/gr_plot_char39
-rwxr-xr-xgr-utils/python/utils/gr_plot_const49
-rw-r--r--gr-utils/python/utils/gr_plot_fft8
-rwxr-xr-xgr-utils/python/utils/gr_plot_fft_c11
-rwxr-xr-xgr-utils/python/utils/gr_plot_fft_f12
-rwxr-xr-xgr-utils/python/utils/gr_plot_float33
-rwxr-xr-xgr-utils/python/utils/gr_plot_int31
-rwxr-xr-xgr-utils/python/utils/gr_plot_iq46
-rw-r--r--gr-utils/python/utils/gr_plot_psd8
-rwxr-xr-xgr-utils/python/utils/gr_plot_psd_c13
-rwxr-xr-xgr-utils/python/utils/gr_plot_psd_f13
-rwxr-xr-xgr-utils/python/utils/gr_plot_qt26
-rwxr-xr-xgr-utils/python/utils/gr_plot_short33
-rw-r--r--gr-utils/python/utils/gr_read_file_metadata28
-rwxr-xr-xgr-utils/python/utils/grcc92
-rw-r--r--gr-utils/python/utils/plot_data.py23
-rw-r--r--[-rwxr-xr-x]gr-utils/python/utils/plot_fft_base.py68
-rw-r--r--[-rwxr-xr-x]gr-utils/python/utils/plot_psd_base.py83
-rw-r--r--gr-utils/python/utils/pyqt_filter.py1
-rw-r--r--gr-utils/python/utils/pyqt_plot.py1
22 files changed, 268 insertions, 387 deletions
diff --git a/gr-utils/python/utils/CMakeLists.txt b/gr-utils/python/utils/CMakeLists.txt
index 54eba51170..3ce335c4ed 100644
--- a/gr-utils/python/utils/CMakeLists.txt
+++ b/gr-utils/python/utils/CMakeLists.txt
@@ -30,7 +30,6 @@ GR_PYTHON_INSTALL(
pyqt_plot.py
pyqt_filter.py
DESTINATION ${GR_PYTHON_DIR}/gnuradio
- COMPONENT "utils"
)
GR_PYTHON_INSTALL(
@@ -50,7 +49,5 @@ GR_PYTHON_INSTALL(
gr_plot_short
gr_plot_qt
gr_read_file_metadata
- grcc
DESTINATION ${GR_RUNTIME_DIR}
- COMPONENT "utils"
)
diff --git a/gr-utils/python/utils/gr_modtool b/gr-utils/python/utils/gr_modtool
index 1690be207f..f959c91f66 100755
--- a/gr-utils/python/utils/gr_modtool
+++ b/gr-utils/python/utils/gr_modtool
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2012, 2017 Free Software Foundation, Inc.
+# Copyright 2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -21,24 +21,34 @@
#
""" A tool for editing GNU Radio out-of-tree modules. """
+from __future__ import print_function
+
from gnuradio.modtool import *
+def setup_parser():
+ modules = get_modtool_modules(ModTool.__subclasses__())
+ parser = ModTool.get_parser()
+ subparsers = parser.add_subparsers(title="Commands")
+ epilog = []
+ for module in modules:
+ subparser = subparsers.add_parser(module.name,
+ description=module.description)
+ module.setup_parser(subparser)
+ subparser.set_defaults(module=module)
+ epilog.append(" {:<22}{}".format(module.name, module.description))
+ parser.epilog = '\n'.join(epilog)
+ return parser
+
def main():
""" Here we go. Parse command, choose class and run. """
- cmd_dict = get_class_dict(ModTool.__subclasses__())
- command = get_command_from_argv(cmd_dict.keys())
- if command is None:
- print 'Usage:' + Templates['usage']
- exit(2)
- modtool = cmd_dict[command]()
- try:
- (options, args) = modtool.parser.parse_args()
- modtool.setup(options, args)
- modtool.run()
+ parser = setup_parser()
+ args = parser.parse_args()
+ try:
+ args.module().run(args)
except ModToolException as err:
- print >> sys.stderr, err
+ print(err, file=sys.stderr)
exit(1)
if __name__ == '__main__':
diff --git a/gr-utils/python/utils/gr_plot_char b/gr-utils/python/utils/gr_plot_char
index a2b93a63c6..3199919fa9 100755
--- a/gr-utils/python/utils/gr_plot_char
+++ b/gr-utils/python/utils/gr_plot_char
@@ -20,35 +20,34 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
try:
import scipy
except ImportError:
- print "Please install SciPy to run this script (http://www.scipy.org/)"
- raise SystemExit, 1
+ print("Please install SciPy to run this script (http://www.scipy.org/)")
+ raise SystemExit(1)
-from optparse import OptionParser
+from argparse import ArgumentParser
from gnuradio.plot_data import plot_data
def main():
- usage="%prog: [options] input_filenames"
description = "Takes a GNU Radio byte/char binary file and displays the samples versus time. You can set the block size to specify how many points to read in at a time and the start position in the file. By default, the system assumes a sample rate of 1, so in time, each sample is plotted versus the sample number. To set a true time axis, set the sample rate (-R or --sample-rate) to the sample rate used when capturing the samples."
- parser = OptionParser(conflict_handler="resolve", usage=usage, description=description)
- parser.add_option("-B", "--block", type="int", default=1000,
- help="Specify the block size [default=%default]")
- parser.add_option("-s", "--start", type="int", default=0,
- help="Specify where to start in the file [default=%default]")
- parser.add_option("-R", "--sample-rate", type="float", default=1.0,
- help="Set the sampler rate of the data [default=%default]")
-
- (options, args) = parser.parse_args ()
- if len(args) < 1:
- parser.print_help()
- raise SystemExit, 1
- filenames = args
-
- datatype=scipy.int8
- dc = plot_data(datatype, filenames, options)
+ parser = ArgumentParser(conflict_handler="resolve", description=description)
+ parser.add_argument("-B", "--block", type=int, default=1000,
+ help="Specify the block size [default=%(default)r]")
+ parser.add_argument("-s", "--start", type=int, default=0,
+ help="Specify where to start in the file [default=%(default)r]")
+ parser.add_argument("-R", "--sample-rate", type=float, default=1.0,
+ help="Set the sampler rate of the data [default=%(default)r]")
+ parser.add_argument("files", metavar="FILE", nargs="+",
+ help="Input file with complex samples")
+
+ args = parser.parse_args()
+
+ datatype = scipy.int8
+ dc = plot_data(datatype, args.files, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/gr_plot_const b/gr-utils/python/utils/gr_plot_const
index e2580dd58f..2ec54c3585 100755
--- a/gr-utils/python/utils/gr_plot_const
+++ b/gr-utils/python/utils/gr_plot_const
@@ -20,20 +20,22 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
try:
import scipy
except ImportError:
- print "Please install SciPy to run this script (http://www.scipy.org/)"
- raise SystemExit, 1
+ print("Please install SciPy to run this script (http://www.scipy.org/)")
+ raise SystemExit(1)
try:
from pylab import *
from matplotlib.font_manager import fontManager, FontProperties
except ImportError:
- print "Please install Matplotlib to run this script (http://matplotlib.sourceforge.net/)"
- raise SystemExit, 1
+ print("Please install Matplotlib to run this script (http://matplotlib.sourceforge.net/)")
+ raise SystemExit(1)
-from optparse import OptionParser
+from argparse import ArgumentParser
class draw_constellation:
def __init__(self, filename, options):
@@ -83,7 +85,7 @@ class draw_constellation:
try:
iq = scipy.fromfile(self.hfile, dtype=self.datatype, count=self.block_length)
except MemoryError:
- print "End of File"
+ print("End of File")
else:
# retesting length here as newer version of scipy does not throw a MemoryError, just
# returns a zero-length array
@@ -94,7 +96,7 @@ class draw_constellation:
self.time = scipy.array([i*(1/self.sample_rate) for i in range(len(self.reals))])
return True
else:
- print "End of File"
+ print("End of File")
return False
def make_plots(self):
@@ -215,36 +217,29 @@ class draw_constellation:
def find(item_in, list_search):
try:
- return list_search.index(item_in) != None
+ return list_search.index(item_in) != None
except ValueError:
- return False
+ return False
def main():
- usage="%prog: [options] input_filename"
description = "Takes a GNU Radio complex binary file and displays the I&Q data versus time and the constellation plot (I vs. Q). You can set the block size to specify how many points to read in at a time and the start position in the file. By default, the system assumes a sample rate of 1, so in time, each sample is plotted versus the sample number. To set a true time axis, set the sample rate (-R or --sample-rate) to the sample rate used when capturing the samples."
- parser = OptionParser(conflict_handler="resolve", usage=usage, description=description)
- parser.add_option("-B", "--block", type="int", default=1000,
- help="Specify the block size [default=%default]")
- parser.add_option("-s", "--start", type="int", default=0,
- help="Specify where to start in the file [default=%default]")
- parser.add_option("-R", "--sample-rate", type="float", default=1.0,
- help="Set the sampler rate of the data [default=%default]")
-
- (options, args) = parser.parse_args ()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
- filename = args[0]
+ parser = ArgumentParser(conflict_handler="resolve", description=description)
+ parser.add_argument("-B", "--block", type=int, default=1000,
+ help="Specify the block size [default=%(default)r]")
+ parser.add_argument("-s", "--start", type=int, default=0,
+ help="Specify where to start in the file [default=%(default)r]")
+ parser.add_argument("-R", "--sample-rate", type=float, default=1.0,
+ help="Set the sampler rate of the data [default=%(default)r]")
+ parser.add_argument("file", metavar="FILE",
+ help="Input file with complex samples")
+ args = parser.parse_args()
- dc = draw_constellation(filename, options)
+ dc = draw_constellation(args.file, args)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
pass
-
-
-
diff --git a/gr-utils/python/utils/gr_plot_fft b/gr-utils/python/utils/gr_plot_fft
index 4343481645..59fc88b994 100644
--- a/gr-utils/python/utils/gr_plot_fft
+++ b/gr-utils/python/utils/gr_plot_fft
@@ -27,13 +27,9 @@ from gnuradio.plot_fft_base import plot_fft_base
def main():
parser = plot_fft_base.setup_options()
- (options, args) = parser.parse_args ()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
- filename = args[0]
+ args = parser.parse_args()
- dc = plot_fft_base(options.data_type, filename, options)
+ dc = plot_fft_base(args.data_type, args.file, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/gr_plot_fft_c b/gr-utils/python/utils/gr_plot_fft_c
index 43e808d95a..48d3218586 100755
--- a/gr-utils/python/utils/gr_plot_fft_c
+++ b/gr-utils/python/utils/gr_plot_fft_c
@@ -26,15 +26,12 @@ from gnuradio.plot_fft_base import plot_fft_base
def main():
parser = plot_fft_base.setup_options()
- parser.remove_option("--data-type")
+ parser.add_argument("-d", "--data-type", default="complex64",
+ choices=("complex64", ))
- (options, args) = parser.parse_args ()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
- filename = args[0]
+ args = parser.parse_args()
- dc = plot_fft_base("complex64", filename, options)
+ dc = plot_fft_base("complex64", args.file, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/gr_plot_fft_f b/gr-utils/python/utils/gr_plot_fft_f
index dee9b17dea..d1791419bb 100755
--- a/gr-utils/python/utils/gr_plot_fft_f
+++ b/gr-utils/python/utils/gr_plot_fft_f
@@ -26,15 +26,11 @@ from gnuradio.plot_fft_base import plot_fft_base
def main():
parser = plot_fft_base.setup_options()
- parser.remove_option("--data-type")
+ parser.add_argument("-d", "--data-type", default="float32",
+ choices=("float32", ))
+ args = parser.parse_args()
- (options, args) = parser.parse_args ()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
- filename = args[0]
-
- dc = plot_fft_base("float32", filename, options)
+ dc = plot_fft_base("float32", args.file, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/gr_plot_float b/gr-utils/python/utils/gr_plot_float
index 22806e48ae..4fd86549e2 100755
--- a/gr-utils/python/utils/gr_plot_float
+++ b/gr-utils/python/utils/gr_plot_float
@@ -20,35 +20,34 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
try:
import scipy
except ImportError:
- print "Please install SciPy to run this script (http://www.scipy.org/)"
- raise SystemExit, 1
+ print("Please install SciPy to run this script (http://www.scipy.org/)")
+ raise SystemExit(1)
-from optparse import OptionParser
+from argparse import ArgumentParser
from gnuradio.plot_data import plot_data
def main():
- usage="%prog: [options] input_filenames"
description = "Takes a GNU Radio floating point binary file and displays the samples versus time. You can set the block size to specify how many points to read in at a time and the start position in the file. By default, the system assumes a sample rate of 1, so in time, each sample is plotted versus the sample number. To set a true time axis, set the sample rate (-R or --sample-rate) to the sample rate used when capturing the samples."
- parser = OptionParser(conflict_handler="resolve", usage=usage, description=description)
- parser.add_option("-B", "--block", type="int", default=1000,
- help="Specify the block size [default=%default]")
- parser.add_option("-s", "--start", type="int", default=0,
- help="Specify where to start in the file [default=%default]")
- parser.add_option("-R", "--sample-rate", type="float", default=1.0,
- help="Set the sampler rate of the data [default=%default]")
+ parser = ArgumentParser(conflict_handler="resolve", description=description)
+ parser.add_argument("-B", "--block", type=int, default=1000,
+ help="Specify the block size [default=%(default)r]")
+ parser.add_argument("-s", "--start", type=int, default=0,
+ help="Specify where to start in the file [default=%(default)r]")
+ parser.add_argument("-R", "--sample-rate", type=float, default=1.0,
+ help="Set the sampler rate of the data [default=%(default)r]")
+ parser.add_argument("file", metavar="FILE", nargs='+',
+ help="Input file with samples")
- (options, args) = parser.parse_args ()
- if len(args) < 1:
- parser.print_help()
- raise SystemExit, 1
- filenames = args
+ args = parser.parse_args()
datatype=scipy.float32
- dc = plot_data(datatype, filenames, options)
+ dc = plot_data(datatype, args.file, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/gr_plot_int b/gr-utils/python/utils/gr_plot_int
index 355ddf0189..b4051fa15f 100755
--- a/gr-utils/python/utils/gr_plot_int
+++ b/gr-utils/python/utils/gr_plot_int
@@ -23,32 +23,29 @@
try:
import scipy
except ImportError:
- print "Please install SciPy to run this script (http://www.scipy.org/)"
- raise SystemExit, 1
+ print("Please install SciPy to run this script (http://www.scipy.org/)")
+ raise SystemExit(1)
-from optparse import OptionParser
+from argparse import ArgumentParser
from gnuradio.plot_data import plot_data
def main():
- usage="%prog: [options] input_filenames"
description = "Takes a GNU Radio integer binary file and displays the samples versus time. You can set the block size to specify how many points to read in at a time and the start position in the file. By default, the system assumes a sample rate of 1, so in time, each sample is plotted versus the sample number. To set a true time axis, set the sample rate (-R or --sample-rate) to the sample rate used when capturing the samples."
- parser = OptionParser(conflict_handler="resolve", usage=usage, description=description)
- parser.add_option("-B", "--block", type="int", default=1000,
- help="Specify the block size [default=%default]")
- parser.add_option("-s", "--start", type="int", default=0,
- help="Specify where to start in the file [default=%default]")
- parser.add_option("-R", "--sample-rate", type="float", default=1.0,
- help="Set the sampler rate of the data [default=%default]")
+ parser = ArgumentParser(conflict_handler="resolve", description=description)
+ parser.add_argument("-B", "--block", type=int, default=1000,
+ help="Specify the block size [default=%(default)r]")
+ parser.add_argument("-s", "--start", type=int, default=0,
+ help="Specify where to start in the file [default=%(default)r]")
+ parser.add_argument("-R", "--sample-rate", type=float, default=1.0,
+ help="Set the sampler rate of the data [default=%(default)r]")
+ parser.add_argument("file", metavar="FILE", nargs='+',
+ help="Input file");
- (options, args) = parser.parse_args ()
- if len(args) < 1:
- parser.print_help()
- raise SystemExit, 1
- filenames = args
+ args = parser.parse_args()
datatype=scipy.int32
- dc = plot_data(datatype, filenames, options)
+ dc = plot_data(datatype, args.file, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/gr_plot_iq b/gr-utils/python/utils/gr_plot_iq
index bf8077b6b4..f27f75d412 100755
--- a/gr-utils/python/utils/gr_plot_iq
+++ b/gr-utils/python/utils/gr_plot_iq
@@ -20,19 +20,21 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
try:
import scipy
except ImportError:
- print "Please install SciPy to run this script (http://www.scipy.org/)"
- raise SystemExit, 1
+ print("Please install SciPy to run this script (http://www.scipy.org/)")
+ raise SystemExit(1)
try:
from pylab import *
except ImportError:
- print "Please install Matplotlib to run this script (http://matplotlib.sourceforge.net/)"
- raise SystemExit, 1
+ print("Please install Matplotlib to run this script (http://matplotlib.sourceforge.net/)")
+ raise SystemExit(1)
-from optparse import OptionParser
+from argparse import ArgumentParser
class draw_iq:
def __init__(self, filename, options):
@@ -81,7 +83,7 @@ class draw_iq:
try:
self.iq = scipy.fromfile(self.hfile, dtype=self.datatype, count=self.block_length)
except MemoryError:
- print "End of File"
+ print("End of File")
else:
self.reals = scipy.array([r.real for r in self.iq])
self.imags = scipy.array([i.imag for i in self.iq])
@@ -144,35 +146,29 @@ class draw_iq:
def find(item_in, list_search):
try:
- return list_search.index(item_in) != None
+ return list_search.index(item_in) != None
except ValueError:
- return False
+ return False
def main():
- usage="%prog: [options] input_filename"
description = "Takes a GNU Radio complex binary file and displays the I&Q data versus time. You can set the block size to specify how many points to read in at a time and the start position in the file. By default, the system assumes a sample rate of 1, so in time, each sample is plotted versus the sample number. To set a true time axis, set the sample rate (-R or --sample-rate) to the sample rate used when capturing the samples."
- parser = OptionParser(conflict_handler="resolve", usage=usage, description=description)
- parser.add_option("-B", "--block", type="int", default=1000,
- help="Specify the block size [default=%default]")
- parser.add_option("-s", "--start", type="int", default=0,
- help="Specify where to start in the file [default=%default]")
- parser.add_option("-R", "--sample-rate", type="float", default=1.0,
- help="Set the sampler rate of the data [default=%default]")
+ parser = ArgumentParser(conflict_handler="resolve", description=description)
+ parser.add_argument("-B", "--block", type=int, default=1000,
+ help="Specify the block size [default=%(default)r]")
+ parser.add_argument("-s", "--start", type=int, default=0,
+ help="Specify where to start in the file [default=%(default)r]")
+ parser.add_argument("-R", "--sample-rate", type=float, default=1.0,
+ help="Set the sampler rate of the data [default=%(default)r]")
+ parser.add_argument("file", metavar="FILE",
+ help="Input file with complex samples")
- (options, args) = parser.parse_args ()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
- filename = args[0]
+ args = parser.parse_args()
- dc = draw_iq(filename, options)
+ dc = draw_iq(args.file, args)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
pass
-
-
-
diff --git a/gr-utils/python/utils/gr_plot_psd b/gr-utils/python/utils/gr_plot_psd
index 059ca6b645..b052cbfdd7 100644
--- a/gr-utils/python/utils/gr_plot_psd
+++ b/gr-utils/python/utils/gr_plot_psd
@@ -27,13 +27,9 @@ from gnuradio.plot_psd_base import plot_psd_base
def main():
parser = plot_psd_base.setup_options()
- (options, args) = parser.parse_args ()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
- filename = args[0]
+ args = parser.parse_args()
- dc = plot_psd_base(options.data_type, filename, options)
+ dc = plot_psd_base(args.data_type, args.file, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/gr_plot_psd_c b/gr-utils/python/utils/gr_plot_psd_c
index fff2bff0f2..352a838138 100755
--- a/gr-utils/python/utils/gr_plot_psd_c
+++ b/gr-utils/python/utils/gr_plot_psd_c
@@ -20,22 +20,19 @@
# Boston, MA 02110-1301, USA.
#
-from optparse import OptionParser
+from argparse import ArgumentParser
from gnuradio.plot_psd_base import plot_psd_base
# This is a wrapper program for plot_psd_base specifically for complex data
def main():
parser = plot_psd_base.setup_options()
- parser.remove_option("--data-type")
+ parser.add_argument("-d", "--data-type", default="complex64",
+ choices=("complex64", ))
- (options, args) = parser.parse_args ()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
- filename = args[0]
+ args = parser.parse_args()
- dc = plot_psd_base("complex64", filename, options)
+ dc = plot_psd_base("complex64", args.file, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/gr_plot_psd_f b/gr-utils/python/utils/gr_plot_psd_f
index ec67994797..ab860e3fb8 100755
--- a/gr-utils/python/utils/gr_plot_psd_f
+++ b/gr-utils/python/utils/gr_plot_psd_f
@@ -20,22 +20,19 @@
# Boston, MA 02110-1301, USA.
#
-from optparse import OptionParser
+from argparse import ArgumentParser
from gnuradio.plot_psd_base import plot_psd_base
# This is a wrapper program for gr_plot_psd specifically for floating point data
def main():
parser = plot_psd_base.setup_options()
- parser.remove_option("--data-type")
+ parser.add_argument("-d", "--data-type", default="complex64",
+ choices=("float32", ))
- (options, args) = parser.parse_args ()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
- filename = args[0]
+ args = parser.parse_args()
- dc = plot_psd_base("float32", filename, options)
+ dc = plot_psd_base("float32", args.file, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/gr_plot_qt b/gr-utils/python/utils/gr_plot_qt
index 9205d23a7e..854ecc53b8 100755
--- a/gr-utils/python/utils/gr_plot_qt
+++ b/gr-utils/python/utils/gr_plot_qt
@@ -4,34 +4,34 @@ try:
import scipy
from scipy import fftpack
except ImportError:
- print "Please install SciPy to run this script (http://www.scipy.org/)"
- raise SystemExit, 1
+ print("Please install SciPy to run this script (http://www.scipy.org/)")
+ raise SystemExit(1)
try:
from matplotlib import mlab
except ImportError:
- print "Please install Matplotlib to run this script (http://matplotlib.sourceforge.net)"
- raise SystemExit, 1
+ print("Please install Matplotlib to run this script (http://matplotlib.sourceforge.net)")
+ raise SystemExit(1)
try:
from PyQt4 import Qt, QtCore, QtGui
except ImportError:
- print "Please install PyQt4 to run this script (http://www.riverbankcomputing.co.uk/software/pyqt/download)"
- raise SystemExit, 1
+ print("Please install PyQt4 to run this script (http://www.riverbankcomputing.co.uk/software/pyqt/download)")
+ raise SystemExit(1)
try:
import PyQt4.Qwt5 as Qwt
except ImportError:
- print "Please install PyQwt5 to run this script (http://pyqwt.sourceforge.net/)"
- raise SystemExit, 1
+ print("Please install PyQwt5 to run this script (http://pyqwt.sourceforge.net/)")
+ raise SystemExit(1)
try:
# FIXME: re-enable this before committing
#from gnuradio.pyqt_plot import Ui_MainWindow
from gnuradio.pyqt_plot import Ui_MainWindow
except ImportError:
- print "Could not import from pyqt_plot. Please build with \"pyuic4 pyqt_plot.ui -o pyqt_plot.py\""
- raise SystemExit, 1
+ print("Could not import from pyqt_plot. Please build with \"pyuic4 pyqt_plot.ui -o pyqt_plot.py\"")
+ raise SystemExit(1)
import sys, os
from optparse import OptionParser
@@ -284,7 +284,7 @@ class gr_plot_qt(QtGui.QMainWindow):
def open_file(self):
filename = Qt.QFileDialog.getOpenFileName(self, "Open", ".")
if(filename != ""):
- #print filename
+ #print(filename)
self.initialize(filename)
def reload_file(self):
@@ -320,7 +320,7 @@ class gr_plot_qt(QtGui.QMainWindow):
def init_data_input(self):
self.hfile.seek(0, os.SEEK_END)
self.signal_size = self.hfile.tell()/self.sizeof_data
- #print "Sizeof File: ", self.signal_size
+ #print("Sizeof File: ", self.signal_size)
self.hfile.seek(0, os.SEEK_SET)
def get_data(self, start, end):
@@ -338,7 +338,7 @@ class gr_plot_qt(QtGui.QMainWindow):
tstep = 1.0 / self.sample_rate
self.iq = iq
- self.time = [tstep*(self.position + i) for i in xrange(len(self.iq))]
+ self.time = [tstep*(self.position + i) for i in range(len(self.iq))]
self.set_file_pos_box(start, end)
except MemoryError:
diff --git a/gr-utils/python/utils/gr_plot_short b/gr-utils/python/utils/gr_plot_short
index 702a2a94a6..d367ea381f 100755
--- a/gr-utils/python/utils/gr_plot_short
+++ b/gr-utils/python/utils/gr_plot_short
@@ -20,35 +20,34 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
try:
import scipy
except ImportError:
- print "Please install SciPy to run this script (http://www.scipy.org/)"
- raise SystemExit, 1
+ print("Please install SciPy to run this script (http://www.scipy.org/)")
+ raise SystemExit(1)
-from optparse import OptionParser
+from argparse import ArgumentParser
from gnuradio.plot_data import plot_data
def main():
- usage="%prog: [options] input_filenames"
description = "Takes a GNU Radio short integer binary file and displays the samples versus time. You can set the block size to specify how many points to read in at a time and the start position in the file. By default, the system assumes a sample rate of 1, so in time, each sample is plotted versus the sample number. To set a true time axis, set the sample rate (-R or --sample-rate) to the sample rate used when capturing the samples."
- parser = OptionParser(conflict_handler="resolve", usage=usage, description=description)
- parser.add_option("-B", "--block", type="int", default=1000,
- help="Specify the block size [default=%default]")
- parser.add_option("-s", "--start", type="int", default=0,
- help="Specify where to start in the file [default=%default]")
- parser.add_option("-R", "--sample-rate", type="float", default=1.0,
- help="Set the sampler rate of the data [default=%default]")
+ parser = ArgumentParser(conflict_handler="resolve", description=description)
+ parser.add_argument("-B", "--block", type=int, default=1000,
+ help="Specify the block size [default=%(default)r]")
+ parser.add_argument("-s", "--start", type=int, default=0,
+ help="Specify where to start in the file [default=%(default)r]")
+ parser.add_argument("-R", "--sample-rate", type=float, default=1.0,
+ help="Set the sampler rate of the data [default=%(default)r]")
+ parser.add_argument("files", metavar="FILE", nargs="+",
+ help="Input file with data (int16_t)")
- (options, args) = parser.parse_args ()
- if len(args) < 1:
- parser.print_help()
- raise SystemExit, 1
- filenames = args
+ args = parser.parse_args()
datatype=scipy.int16
- dc = plot_data(datatype, filenames, options)
+ dc = plot_data(datatype, args.files, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/gr_read_file_metadata b/gr-utils/python/utils/gr_read_file_metadata
index 429b38310f..1a94560ad2 100644
--- a/gr-utils/python/utils/gr_read_file_metadata
+++ b/gr-utils/python/utils/gr_read_file_metadata
@@ -20,8 +20,10 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
import sys
-from optparse import OptionParser
+from argparse import ArgumentParser
import pmt
from gnuradio.blocks import parse_file_metadata
@@ -45,7 +47,7 @@ def main(filename, detached=False):
sys.stderr.write("Could not deserialize header: invalid or corrupt data file.\n")
sys.exit(1)
- print "HEADER {0}".format(nheaders)
+ print("HEADER {0}".format(nheaders))
info = parse_file_metadata.parse_header(header, True)
if(info["extra_len"] > 0):
@@ -59,7 +61,7 @@ def main(filename, detached=False):
sys.stderr.write("Could not deserialize extras: invalid or corrupt data file.\n")
sys.exit(1)
- print "\nExtra Header:"
+ print("\nExtra Header:")
extra_info = parse_file_metadata.parse_extra_dict(extra, info, True)
nheaders += 1
@@ -67,21 +69,17 @@ def main(filename, detached=False):
if(not detached):
nread += info['nbytes']
handle.seek(nread, 0)
- print "\n\n"
+ print("\n\n")
+
if __name__ == "__main__":
- usage="%prog: [options] filename"
description = "Read in a GNU Radio file with meta data, extracts the header and prints it."
- parser = OptionParser(conflict_handler="resolve",
- usage=usage, description=description)
- parser.add_option("-D", "--detached", action="store_true", default=False,
+ parser = ArgumentParser(conflict_handler="resolve", description=description)
+ parser.add_argument("-D", "--detached", action="store_true",
help="Used if header is detached.")
- (options, args) = parser.parse_args ()
-
- if(len(args) < 1):
- sys.stderr.write("No filename given\n")
- sys.exit(1)
+ parser.add_argument("file", metavar="FILE",
+ help="Input file");
+ args = parser.parse_args()
- filename = args[0]
- main(filename, options.detached)
+ main(args.file, args.detached)
diff --git a/gr-utils/python/utils/grcc b/gr-utils/python/utils/grcc
deleted file mode 100755
index b9bd1551b9..0000000000
--- a/gr-utils/python/utils/grcc
+++ /dev/null
@@ -1,92 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2012 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-import os
-import sys
-from optparse import OptionParser
-import warnings
-warnings.simplefilter('ignore')
-
-from gnuradio import gr
-
-try:
- from grc.core.Platform import Platform
-except ImportError:
- from gnuradio.grc.core.Platform import Platform
-
-
-class GRCC:
- def __init__(self, grcfile, out_dir):
- self.out_dir = out_dir
- self.platform = Platform(
- prefs_file=gr.prefs(),
- version=gr.version(),
- version_parts=(gr.major_version(), gr.api_version(), gr.minor_version())
- )
- data = self.platform.parse_flow_graph(grcfile)
-
- self.fg = self.platform.get_new_flow_graph()
- self.fg.import_data(data)
- self.fg.grc_file_path = os.path.abspath(grcfile)
- self.fg.validate()
-
- if not self.fg.is_valid():
- raise StandardError("\n\n".join(
- ["Validation failed:"] + self.fg.get_error_messages()
- ))
-
- self.gen = self.platform.Generator(self.fg, out_dir)
- self.gen.write()
-
- def exec_program(self):
- progname = self.fg.get_option('id')
- os.system("{0}/{1}.py".format(self.out_dir, progname))
-
-
-def main():
- usage="%prog: [options] filename"
- description = "Compiles a GRC file (.grc) into a GNU Radio Python program. The program is stored in ~/.grc_gnuradio by default, but this location can be changed with the -d option."
-
- parser = OptionParser(conflict_handler="resolve", usage=usage, description=description)
- parser.add_option("-d", "--directory", type="string", default='{0}/.grc_gnuradio/'.format(os.environ["HOME"]),
- help="Specify the directory to output the compile program [default=%default]")
- parser.add_option("-e", "--execute", action="store_true", default=False,
- help="Run the program after compiling [default=%default]")
- (options, args) = parser.parse_args ()
-
- if len(args) != 1:
- sys.stderr.write("Please specify a GRC file name to compile.\n")
- sys.exit(1)
-
- try:
- g = GRCC(args[0], options.directory + "/")
- except Exception as e:
- sys.stderr.write(str(e) + "\n")
- sys.stderr.write("Error during file compilation.\n")
- sys.exit(1)
-
- if options.execute:
- g.exec_program()
-
-
-if __name__ == "__main__":
- main()
diff --git a/gr-utils/python/utils/plot_data.py b/gr-utils/python/utils/plot_data.py
index 2ae3b1d5b3..a054147114 100644
--- a/gr-utils/python/utils/plot_data.py
+++ b/gr-utils/python/utils/plot_data.py
@@ -22,21 +22,24 @@
Utility to help plotting data from files.
"""
+from __future__ import print_function
+from __future__ import division
+from __future__ import unicode_literals
+
try:
import scipy
except ImportError:
- print "Please install SciPy to run this script (http://www.scipy.org/)"
- raise SystemExit, 1
+ print("Please install SciPy to run this script (http://www.scipy.org/)")
+ raise SystemExit(1)
try:
from pylab import *
except ImportError:
- print "Please install Matplotlib to run this script (http://matplotlib.sourceforge.net/)"
- raise SystemExit, 1
+ print("Please install Matplotlib to run this script (http://matplotlib.sourceforge.net/)")
+ raise SystemExit(1)
-from optparse import OptionParser
-class plot_data:
+class plot_data(object):
def __init__(self, datatype, filenames, options):
self.hfile = list()
self.legend_text = list()
@@ -87,10 +90,10 @@ class plot_data:
try:
f = scipy.fromfile(hfile, dtype=self.datatype, count=self.block_length)
except MemoryError:
- print "End of File"
+ print("End of File")
else:
self.f = scipy.array(f)
- self.time = scipy.array([i*(1/self.sample_rate) for i in range(len(self.f))])
+ self.time = scipy.array([i*(1 / self.sample_rate) for i in range(len(self.f))])
def make_plots(self):
self.sp_f = self.fig.add_subplot(2,1,1, position=[0.075, 0.2, 0.875, 0.6])
@@ -163,6 +166,6 @@ class plot_data:
def find(item_in, list_search):
try:
- return list_search.index(item_in) != None
+ return list_search.index(item_in) != None
except ValueError:
- return False
+ return False
diff --git a/gr-utils/python/utils/plot_fft_base.py b/gr-utils/python/utils/plot_fft_base.py
index c4bc484d97..5040aefa87 100755..100644
--- a/gr-utils/python/utils/plot_fft_base.py
+++ b/gr-utils/python/utils/plot_fft_base.py
@@ -20,22 +20,26 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import division
+from __future__ import unicode_literals
+
try:
import scipy
from scipy import fftpack
except ImportError:
- print "Please install SciPy to run this script (http://www.scipy.org/)"
- raise SystemExit, 1
+ print("Please install SciPy to run this script (http://www.scipy.org/)")
+ raise SystemExit(1)
try:
from pylab import *
except ImportError:
- print "Please install Python Matplotlib (http://matplotlib.sourceforge.net/) and Python TkInter https://wiki.python.org/moin/TkInter to run this script"
- raise SystemExit, 1
+ print("Please install Python Matplotlib (http://matplotlib.sourceforge.net/) and Python TkInter https://wiki.python.org/moin/TkInter to run this script")
+ raise SystemExit(1)
-from optparse import OptionParser
+from argparse import ArgumentParser
-class plot_fft_base:
+class plot_fft_base(object):
def __init__(self, datatype, filename, options):
self.hfile = open(filename, "r")
self.block_length = options.block
@@ -79,33 +83,33 @@ class plot_fft_base:
show()
def get_data(self):
- self.position = self.hfile.tell()/self.sizeof_data
+ self.position = self.hfile.tell() / self.sizeof_data
self.text_file_pos.set_text("File Position: %d" % (self.position))
try:
self.iq = scipy.fromfile(self.hfile, dtype=self.datatype, count=self.block_length)
except MemoryError:
- print "End of File"
+ print("End of File")
else:
self.iq_fft = self.dofft(self.iq)
tstep = 1.0 / self.sample_rate
- #self.time = scipy.array([tstep*(self.position + i) for i in xrange(len(self.iq))])
- self.time = scipy.array([tstep*(i) for i in xrange(len(self.iq))])
+ #self.time = scipy.array([tstep*(self.position + i) for i in range(len(self.iq))])
+ self.time = scipy.array([tstep*(i) for i in range(len(self.iq))])
self.freq = self.calc_freq(self.time, self.sample_rate)
def dofft(self, iq):
N = len(iq)
iq_fft = scipy.fftpack.fftshift(scipy.fft(iq)) # fft and shift axis
- iq_fft = 20*scipy.log10(abs((iq_fft+1e-15)/N)) # convert to decibels, adjust power
+ iq_fft = 20*scipy.log10(abs((iq_fft+1e-15) / N)) # convert to decibels, adjust power
# adding 1e-15 (-300 dB) to protect against value errors if an item in iq_fft is 0
return iq_fft
def calc_freq(self, time, sample_rate):
N = len(time)
- Fs = 1.0 / (time.max() - time.min())
+ Fs = 1.0 / (time.max( - time.min()))
Fn = 0.5 * sample_rate
- freq = scipy.array([-Fn + i*Fs for i in xrange(N)])
+ freq = scipy.array([-Fn + i*Fs for i in range(N)])
return freq
def make_plots(self):
@@ -209,41 +213,37 @@ class plot_fft_base:
@staticmethod
def setup_options():
- usage="%prog: [options] input_filename"
description = "Takes a GNU Radio complex binary file and displays the I&Q data versus time as well as the frequency domain (FFT) plot. The y-axis values are plotted assuming volts as the amplitude of the I&Q streams and converted into dBm in the frequency domain (the 1/N power adjustment out of the FFT is performed internally). The script plots a certain block of data at a time, specified on the command line as -B or --block. This value defaults to 1000. The start position in the file can be set by specifying -s or --start and defaults to 0 (the start of the file). By default, the system assumes a sample rate of 1, so in time, each sample is plotted versus the sample number. To set a true time and frequency axis, set the sample rate (-R or --sample-rate) to the sample rate used when capturing the samples."
- parser = OptionParser(conflict_handler="resolve", usage=usage, description=description)
- parser.add_option("-d", "--data-type", type="string", default="complex64",
- help="Specify the data type (complex64, float32, (u)int32, (u)int16, (u)int8) [default=%default]")
- parser.add_option("-B", "--block", type="int", default=1000,
- help="Specify the block size [default=%default]")
- parser.add_option("-s", "--start", type="int", default=0,
- help="Specify where to start in the file [default=%default]")
- parser.add_option("-R", "--sample-rate", type="float", default=1.0,
- help="Set the sampler rate of the data [default=%default]")
+ parser = ArgumentParser(conflict_handler="resolve", description=description)
+ parser.add_argument("-d", "--data-type", default="complex64",
+ choices=("complex64", "float32", "uint32", "int32", "uint16",
+ "int16", "uint8", "int8"),
+ help="Specify the data type [default=%(default)r]")
+ parser.add_argument("-B", "--block", type=int, default=1000,
+ help="Specify the block size [default=%(default)r]")
+ parser.add_argument("-s", "--start", type=int, default=0,
+ help="Specify where to start in the file [default=%(default)r]")
+ parser.add_argument("-R", "--sample-rate", type=float, default=1.0,
+ help="Set the sampler rate of the data [default=%(default)r]")
+ parser.add_argument("file", metavar="FILE",
+ help="Input file with samples")
return parser
def find(item_in, list_search):
try:
- return list_search.index(item_in) != None
+ return list_search.index(item_in) != None
except ValueError:
- return False
+ return False
def main():
parser = plot_fft_base.setup_options()
- (options, args) = parser.parse_args ()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
- filename = args[0]
+ args = parser.parse_args()
- dc = plot_fft_base(options.data_type, filename, options)
+ dc = plot_fft_base(args.data_type, args.file, args)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
pass
-
-
-
diff --git a/gr-utils/python/utils/plot_psd_base.py b/gr-utils/python/utils/plot_psd_base.py
index fe3c9e12b7..0a0f3cab34 100755..100644
--- a/gr-utils/python/utils/plot_psd_base.py
+++ b/gr-utils/python/utils/plot_psd_base.py
@@ -20,24 +20,28 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import division
+from __future__ import unicode_literals
+
try:
import scipy
from scipy import fftpack
except ImportError:
- print "Please install SciPy to run this script (http://www.scipy.org/)"
- raise SystemExit, 1
+ print("Please install SciPy to run this script (http://www.scipy.org/)")
+ raise SystemExit(1)
try:
from pylab import *
except ImportError:
- print "Please install Matplotlib to run this script (http://matplotlib.sourceforge.net/)"
- raise SystemExit, 1
+ print("Please install Matplotlib to run this script (http://matplotlib.sourceforge.net/)")
+ raise SystemExit(1)
-from optparse import OptionParser
+from argparse import ArgumentParser
from scipy import log10
-from gnuradio.eng_option import eng_option
+from gnuradio.eng_arg import eng_float, intx
-class plot_psd_base:
+class plot_psd_base(object):
def __init__(self, datatype, filename, options):
self.hfile = open(filename, "r")
self.block_length = options.block
@@ -87,30 +91,30 @@ class plot_psd_base:
show()
def get_data(self):
- self.position = self.hfile.tell()/self.sizeof_data
+ self.position = self.hfile.tell() / self.sizeof_data
self.text_file_pos.set_text("File Position: %d" % self.position)
try:
self.iq = scipy.fromfile(self.hfile, dtype=self.datatype, count=self.block_length)
except MemoryError:
- print "End of File"
+ print("End of File")
return False
else:
# retesting length here as newer version of scipy does not throw a MemoryError, just
# returns a zero-length array
if(len(self.iq) > 0):
tstep = 1.0 / self.sample_rate
- #self.time = scipy.array([tstep*(self.position + i) for i in xrange(len(self.iq))])
- self.time = scipy.array([tstep*(i) for i in xrange(len(self.iq))])
+ #self.time = scipy.array([tstep*(self.position + i) for i in range(len(self.iq))])
+ self.time = scipy.array([tstep*(i) for i in range(len(self.iq))])
self.iq_psd, self.freq = self.dopsd(self.iq)
return True
else:
- print "End of File"
+ print("End of File")
return False
def dopsd(self, iq):
''' Need to do this here and plot later so we can do the fftshift '''
- overlap = self.psdfftsize/4
+ overlap = self.psdfftsize / 4
winfunc = scipy.blackman
psd,freq = mlab.psd(iq, self.psdfftsize, self.sample_rate,
window = lambda d: d*winfunc(self.psdfftsize),
@@ -174,7 +178,7 @@ class plot_psd_base:
self.sp_psd.set_xlim([f.min(), f.max()])
def draw_spec(self, t, s):
- overlap = self.specfftsize/4
+ overlap = self.specfftsize / 4
winfunc = scipy.blackman
self.sp_spec.clear()
self.sp_spec.specgram(s, self.specfftsize, self.sample_rate,
@@ -244,49 +248,44 @@ class plot_psd_base:
@staticmethod
def setup_options():
- usage="%prog: [options] input_filename"
description = "Takes a GNU Radio binary file (with specified data type using --data-type) and displays the I&Q data versus time as well as the power spectral density (PSD) plot. The y-axis values are plotted assuming volts as the amplitude of the I&Q streams and converted into dBm in the frequency domain (the 1/N power adjustment out of the FFT is performed internally). The script plots a certain block of data at a time, specified on the command line as -B or --block. The start position in the file can be set by specifying -s or --start and defaults to 0 (the start of the file). By default, the system assumes a sample rate of 1, so in time, each sample is plotted versus the sample number. To set a true time and frequency axis, set the sample rate (-R or --sample-rate) to the sample rate used when capturing the samples. Finally, the size of the FFT to use for the PSD and spectrogram plots can be set independently with --psd-size and --spec-size, respectively. The spectrogram plot does not display by default and is turned on with -S or --enable-spec."
- parser = OptionParser(option_class=eng_option, conflict_handler="resolve",
- usage=usage, description=description)
- parser.add_option("-d", "--data-type", type="string", default="complex64",
- help="Specify the data type (complex64, float32, (u)int32, (u)int16, (u)int8) [default=%default]")
- parser.add_option("-B", "--block", type="int", default=8192,
- help="Specify the block size [default=%default]")
- parser.add_option("-s", "--start", type="int", default=0,
- help="Specify where to start in the file [default=%default]")
- parser.add_option("-R", "--sample-rate", type="eng_float", default=1.0,
- help="Set the sampler rate of the data [default=%default]")
- parser.add_option("", "--psd-size", type="int", default=1024,
- help="Set the size of the PSD FFT [default=%default]")
- parser.add_option("", "--spec-size", type="int", default=256,
- help="Set the size of the spectrogram FFT [default=%default]")
- parser.add_option("-S", "--enable-spec", action="store_true", default=False,
- help="Turn on plotting the spectrogram [default=%default]")
+ parser = ArgumentParser(conflict_handler="resolve", description=description)
+ parser.add_argument("-d", "--data-type", default="complex64",
+ choices=("complex64", "float32", "int32", "uint32", "int16",
+ "uint16", "int8", "uint8" ),
+ help="Specify the data type [default=%(default)r]")
+ parser.add_argument("-B", "--block", type=int, default=8192,
+ help="Specify the block size [default=%(default)r]")
+ parser.add_argument("-s", "--start", type=int, default=0,
+ help="Specify where to start in the file [default=%(default)r]")
+ parser.add_argument("-R", "--sample-rate", type=eng_float, default=1.0,
+ help="Set the sampler rate of the data [default=%(default)r]")
+ parser.add_argument("--psd-size", type=int, default=1024,
+ help="Set the size of the PSD FFT [default=%(default)r]")
+ parser.add_argument("--spec-size", type=int, default=256,
+ help="Set the size of the spectrogram FFT [default=%(default)r]")
+ parser.add_argument("-S", "--enable-spec", action="store_true",
+ help="Turn on plotting the spectrogram [default=%(default)r]")
+ parser.add_argument("file", metavar="FILE",
+ help="Input file with samples")
return parser
def find(item_in, list_search):
try:
- return list_search.index(item_in) != None
+ return list_search.index(item_in) != None
except ValueError:
- return False
+ return False
def main():
parser = plot_psd_base.setup_options()
- (options, args) = parser.parse_args ()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
- filename = args[0]
+ args = parser.parse_args()
- dc = plot_psd_base(options.data_type, filename, options)
+ dc = plot_psd_base(args.data_type, args.file, args)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
pass
-
-
-
diff --git a/gr-utils/python/utils/pyqt_filter.py b/gr-utils/python/utils/pyqt_filter.py
index 0c781f2347..fac17644d3 100644
--- a/gr-utils/python/utils/pyqt_filter.py
+++ b/gr-utils/python/utils/pyqt_filter.py
@@ -7,6 +7,7 @@
#
# WARNING! All changes made in this file will be lost!
+from __future__ import unicode_literals
from PyQt4 import QtCore, QtGui
class Ui_MainWindow(object):
diff --git a/gr-utils/python/utils/pyqt_plot.py b/gr-utils/python/utils/pyqt_plot.py
index 5650135abf..80711b4e88 100644
--- a/gr-utils/python/utils/pyqt_plot.py
+++ b/gr-utils/python/utils/pyqt_plot.py
@@ -7,6 +7,7 @@
#
# WARNING! All changes made in this file will be lost!
+from __future__ import unicode_literals
from PyQt4 import QtCore, QtGui
class Ui_MainWindow(object):