commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 14/20: python3: update gr-utils for python3


From: git
Subject: [Commit-gnuradio] [gnuradio] 14/20: python3: update gr-utils for python3 support
Date: Sun, 25 Dec 2016 03:59:59 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch python3
in repository gnuradio.

commit 6eac86523f2055cdee199c183eb2be945e7b1349
Author: Douglas Anderson <address@hidden>
Date:   Thu Dec 22 12:55:41 2016 -0700

    python3: update gr-utils for python3 support
---
 gr-utils/python/modtool/cmakefile_editor.py        |  6 ++--
 .../modtool/gr-newmod/cmake/Modules/GrPython.cmake | 11 ++++---
 .../gr-newmod/docs/doxygen/doxyxml/__init__.py     |  2 +-
 .../modtool/gr-newmod/docs/doxygen/doxyxml/base.py | 14 ++++-----
 .../gr-newmod/docs/doxygen/doxyxml/doxyindex.py    |  2 +-
 .../docs/doxygen/doxyxml/generated/compound.py     |  4 +--
 .../doxygen/doxyxml/generated/compoundsuper.py     |  2 +-
 .../docs/doxygen/doxyxml/generated/index.py        |  2 +-
 .../docs/doxygen/doxyxml/generated/indexsuper.py   |  2 +-
 .../modtool/gr-newmod/docs/doxygen/doxyxml/text.py |  2 +-
 .../modtool/gr-newmod/docs/doxygen/swig_doc.py     |  2 +-
 gr-utils/python/modtool/modtool_add.py             | 36 ++++++++++++----------
 gr-utils/python/modtool/modtool_base.py            |  8 +++--
 gr-utils/python/modtool/modtool_disable.py         | 14 +++++----
 gr-utils/python/modtool/modtool_info.py            | 13 ++++----
 gr-utils/python/modtool/modtool_makexml.py         | 14 +++++----
 gr-utils/python/modtool/modtool_newmod.py          | 10 +++---
 gr-utils/python/modtool/modtool_rename.py          | 28 +++++++++--------
 gr-utils/python/modtool/modtool_rm.py              | 10 +++---
 gr-utils/python/modtool/parser_cc_block.py         | 15 +++++----
 gr-utils/python/modtool/scm.py                     |  4 ++-
 gr-utils/python/utils/gr_modtool                   |  4 ++-
 gr-utils/python/utils/gr_plot_char                 |  6 ++--
 gr-utils/python/utils/gr_plot_const                | 21 ++++++-------
 gr-utils/python/utils/gr_plot_float                |  6 ++--
 gr-utils/python/utils/gr_plot_int                  |  4 +--
 gr-utils/python/utils/gr_plot_iq                   | 19 ++++++------
 gr-utils/python/utils/gr_plot_qt                   | 24 +++++++--------
 gr-utils/python/utils/gr_plot_short                |  6 ++--
 gr-utils/python/utils/gr_read_file_metadata        |  8 +++--
 gr-utils/python/utils/plot_data.py                 | 16 +++++-----
 gr-utils/python/utils/plot_fft_base.py             | 19 ++++++------
 gr-utils/python/utils/plot_psd_base.py             | 21 ++++++-------
 33 files changed, 193 insertions(+), 162 deletions(-)

diff --git a/gr-utils/python/modtool/cmakefile_editor.py 
b/gr-utils/python/modtool/cmakefile_editor.py
index d57c650..e82fade 100644
--- a/gr-utils/python/modtool/cmakefile_editor.py
+++ b/gr-utils/python/modtool/cmakefile_editor.py
@@ -20,6 +20,8 @@
 #
 """ Edit CMakeLists.txt files """
 
+from __future__ import print_function
+
 import re
 
 class CMakeFileEditor(object):
@@ -126,9 +128,9 @@ class CMakeFileEditor(object):
             comment_out_re = r'\n' + self.indent + comment_out_re
         (self.cfile, nsubs) = re.subn(r'(\b'+fname+r'\b)\s*', comment_out_re, 
self.cfile)
         if nsubs == 0:
-            print "Warning: A replacement failed when commenting out %s. Check 
the CMakeFile.txt manually." % fname
+            print("Warning: A replacement failed when commenting out %s. Check 
the CMakeFile.txt manually." % fname)
         elif nsubs > 1:
-            print "Warning: Replaced %s %d times (instead of once). Check the 
CMakeFile.txt manually." % (fname, nsubs)
+            print("Warning: Replaced %s %d times (instead of once). Check the 
CMakeFile.txt manually." % (fname, nsubs))
 
     def comment_out_lines(self, pattern, comment_str='#'):
         """ Comments out all lines that match with pattern """
diff --git a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPython.cmake 
b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPython.cmake
index 0bfa92d..6b997c0 100644
--- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPython.cmake
+++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPython.cmake
@@ -36,11 +36,12 @@ if(PYTHON_EXECUTABLE)
 else(PYTHON_EXECUTABLE)
 
     #use the built-in find script
+    set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6)
     find_package(PythonInterp 2)
 
     #and if that fails use the find program routine
     if(NOT PYTHONINTERP_FOUND)
-        find_program(PYTHON_EXECUTABLE NAMES python python2 python2.7 
python2.6 python2.5)
+        find_program(PYTHON_EXECUTABLE NAMES python python2 python2.7)
         if(PYTHON_EXECUTABLE)
             set(PYTHONINTERP_FOUND TRUE)
         endif(PYTHON_EXECUTABLE)
@@ -86,7 +87,7 @@ macro(GR_PYTHON_CHECK_MODULE desc mod cmd have)
 try:
     import ${mod}
     assert ${cmd}
-except ImportError, AssertionError: exit(-1)
+except (ImportError, AssertionError): exit(-1)
 except: pass
 #########################################"
         RESULT_VARIABLE ${have}
@@ -106,7 +107,7 @@ endmacro(GR_PYTHON_CHECK_MODULE)
 if(NOT DEFINED GR_PYTHON_DIR)
 execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "
 from distutils import sysconfig
-print sysconfig.get_python_lib(plat_specific=True, prefix='')
+print(sysconfig.get_python_lib(plat_specific=True, prefix=''))
 " OUTPUT_VARIABLE GR_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE
 )
 endif()
@@ -119,7 +120,7 @@ file(TO_CMAKE_PATH ${GR_PYTHON_DIR} GR_PYTHON_DIR)
 function(GR_UNIQUE_TARGET desc)
     file(RELATIVE_PATH reldir ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
     execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import re, hashlib
-unique = hashlib.md5('${reldir}${ARGN}').hexdigest()[:5]
+unique = hashlib.md5(b'${reldir}${ARGN}').hexdigest()[:5]
 print(re.sub('\\W', '_', '${desc} ${reldir} ' + unique))"
     OUTPUT_VARIABLE _target OUTPUT_STRIP_TRAILING_WHITESPACE)
     add_custom_target(${_target} ALL DEPENDS ${ARGN})
@@ -233,7 +234,7 @@ endfunction(GR_PYTHON_INSTALL)
 file(WRITE ${CMAKE_BINARY_DIR}/python_compile_helper.py "
 import sys, py_compile
 files = sys.argv[1:]
-srcs, gens = files[:len(files)/2], files[len(files)/2:]
+srcs, gens = files[:len(files)//2], files[len(files)//2:]
 for src, gen in zip(srcs, gens):
     py_compile.compile(file=src, cfile=gen, doraise=True)
 ")
diff --git a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/__init__.py 
b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/__init__.py
index 5cd0b3c..cf842c9 100644
--- a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/__init__.py
+++ b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/__init__.py
@@ -64,7 +64,7 @@ u'Outputs the vital aadvark statistics.'
 
 """
 
-from doxyindex import DoxyIndex, DoxyFunction, DoxyParam, DoxyClass, DoxyFile, 
DoxyNamespace, DoxyGroup, DoxyFriend, DoxyOther
+from .doxyindex import DoxyIndex, DoxyFunction, DoxyParam, DoxyClass, 
DoxyFile, DoxyNamespace, DoxyGroup, DoxyFriend, DoxyOther
 
 def _test():
     import os
diff --git a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/base.py 
b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/base.py
index e8f026a..89e0191 100644
--- a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/base.py
+++ b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/base.py
@@ -30,18 +30,18 @@ import pdb
 
 from xml.parsers.expat import ExpatError
 
-from generated import compound
+from generated from . import compound
 
 
 class Base(object):
 
-    class Duplicate(StandardError):
+    class Duplicate(Exception):
         pass
 
-    class NoSuchMember(StandardError):
+    class NoSuchMember(Exception):
         pass
 
-    class ParsingError(StandardError):
+    class ParsingError(Exception):
         pass
 
     def __init__(self, parse_data, top=None):
@@ -94,7 +94,7 @@ class Base(object):
         for cls in self.mem_classes:
             if cls.can_parse(mem):
                 return cls
-        raise StandardError(("Did not find a class for object '%s'." \
+        raise Exception(("Did not find a class for object '%s'." \
                                  % (mem.get_name())))
 
     def convert_mem(self, mem):
@@ -102,10 +102,10 @@ class Base(object):
             cls = self.get_cls(mem)
             converted = cls.from_parse_data(mem, self.top)
             if converted is None:
-                raise StandardError('No class matched this object.')
+                raise Exception('No class matched this object.')
             self.add_ref(converted)
             return converted
-        except StandardError, e:
+        except Exception, e:
             print e
 
     @classmethod
diff --git 
a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/doxyindex.py 
b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/doxyindex.py
index 78e8153..2dc4124 100644
--- a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/doxyindex.py
+++ b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/doxyindex.py
@@ -25,7 +25,7 @@ docs than the generated classes provide.
 
 import os
 
-from generated import index
+from .generated import index
 from base import Base
 from text import description
 
diff --git 
a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/compound.py 
b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/compound.py
index 1522ac2..c8f4b72 100644
--- 
a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/compound.py
+++ 
b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/compound.py
@@ -4,13 +4,13 @@
 Generated Mon Feb  9 19:08:05 2009 by generateDS.py.
 """
 
-from string import lower as str_lower
+
 from xml.dom import minidom
 from xml.dom import Node
 
 import sys
 
-import compoundsuper as supermod
+from . import compoundsuper as supermod
 from compoundsuper import MixedContainer
 
 
diff --git 
a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/compoundsuper.py
 
b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/compoundsuper.py
index 6255dda..f1996f9 100644
--- 
a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/compoundsuper.py
+++ 
b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/compoundsuper.py
@@ -6,7 +6,7 @@
 
 import sys
 import getopt
-from string import lower as str_lower
+
 from xml.dom import minidom
 from xml.dom import Node
 
diff --git 
a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/index.py 
b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/index.py
index 7a70e14..91c0927 100644
--- a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/index.py
+++ b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/index.py
@@ -8,7 +8,7 @@ from xml.dom import minidom
 
 import os
 import sys
-import compound
+from . import compound
 
 import indexsuper as supermod
 
diff --git 
a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/indexsuper.py
 
b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/indexsuper.py
index a991530..2fc4cd3 100644
--- 
a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/indexsuper.py
+++ 
b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/indexsuper.py
@@ -6,7 +6,7 @@
 
 import sys
 import getopt
-from string import lower as str_lower
+
 from xml.dom import minidom
 from xml.dom import Node
 
diff --git a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/text.py 
b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/text.py
index 629edd1..12f9d17 100644
--- a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/text.py
+++ b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/text.py
@@ -49,7 +49,7 @@ def description_bit(obj):
     elif is_string(obj):
         return obj
     else:
-        raise StandardError('Expecting a string or something with content, 
content_ or value attribute')
+        raise Exception('Expecting a string or something with content, 
content_ or value attribute')
     # If this bit is a paragraph then add one some line breaks.
     if hasattr(obj, 'name') and obj.name == 'para':
         result += "\n\n"
diff --git a/gr-utils/python/modtool/gr-newmod/docs/doxygen/swig_doc.py 
b/gr-utils/python/modtool/gr-newmod/docs/doxygen/swig_doc.py
index d3536db..cd871ad 100644
--- a/gr-utils/python/modtool/gr-newmod/docs/doxygen/swig_doc.py
+++ b/gr-utils/python/modtool/gr-newmod/docs/doxygen/swig_doc.py
@@ -309,7 +309,7 @@ if __name__ == "__main__":
     # Parse command line options and set up doxyxml.
     err_msg = "Execute using: python swig_doc.py xml_path outputfilename"
     if len(sys.argv) != 3:
-        raise StandardError(err_msg)
+        raise Exception(err_msg)
     xml_path = sys.argv[1]
     swigdocfilename = sys.argv[2]
     di = DoxyIndex(xml_path)
diff --git a/gr-utils/python/modtool/modtool_add.py 
b/gr-utils/python/modtool/modtool_add.py
index b7d33c6..825be0f 100644
--- a/gr-utils/python/modtool/modtool_add.py
+++ b/gr-utils/python/modtool/modtool_add.py
@@ -20,6 +20,8 @@
 #
 """ Module to add new blocks """
 
+from __future__ import print_function
+
 import os
 import re
 
@@ -69,12 +71,12 @@ class ModToolAdd(ModTool):
 
         self._info['blocktype'] = options.block_type
         if self._info['blocktype'] is None:
-            # Print list out of blocktypes to user for reference
-            print str(self._block_types)
+            # Print(list out of blocktypes to user for reference)
+            print(str(self._block_types))
             while self._info['blocktype'] not in self._block_types:
                 self._info['blocktype'] = raw_input("Enter block type: ")
                 if self._info['blocktype'] not in self._block_types:
-                    print 'Must be one of ' + str(self._block_types)
+                    print('Must be one of ' + str(self._block_types))
         # Allow user to specify language interactively if not set
         self._info['lang'] = options.lang
         if self._info['lang'] is None:
@@ -83,7 +85,7 @@ class ModToolAdd(ModTool):
         if self._info['lang'] == 'c++':
             self._info['lang'] = 'cpp'
 
-        print "Language: %s" % {'cpp': 'C++', 'python': 
'Python'}[self._info['lang']]
+        print("Language: %s" % {'cpp': 'C++', 'python': 
'Python'}[self._info['lang']])
 
         if ((self._skip_subdirs['lib'] and self._info['lang'] == 'cpp')
              or (self._skip_subdirs['python'] and self._info['lang'] == 
'python')):
@@ -93,14 +95,14 @@ class ModToolAdd(ModTool):
             self._info['blockname'] = raw_input("Enter name of block/code 
(without module name prefix): ")
         if not re.match('[a-zA-Z0-9_]+', self._info['blockname']):
             raise ModToolException('Invalid block name.')
-        print "Block/code identifier: " + self._info['blockname']
+        print("Block/code identifier: " + self._info['blockname'])
         self._info['fullblockname'] = self._info['modname'] + '_' + 
self._info['blockname']
         if not options.license_file:
             self._info['copyrightholder'] = options.copyright
             if self._info['copyrightholder'] is None:
                 self._info['copyrightholder'] = '<+YOU OR YOUR COMPANY+>'
             elif self._info['is_component']:
-                print "For GNU Radio components the FSF is added as copyright 
holder"
+                print("For GNU Radio components the FSF is added as copyright 
holder")
         self._license_file = options.license_file
         self._info['license'] = self.setup_choose_license()
         if options.argument_list is not None:
@@ -118,8 +120,8 @@ class ModToolAdd(ModTool):
                 self._add_cc_qa = ask_yes_no('Add C++ QA code?', not 
self._add_py_qa)
         self._skip_cmakefiles = options.skip_cmakefiles
         if self._info['version'] == 'autofoo' and not self._skip_cmakefiles:
-            print "Warning: Autotools modules are not supported. ",
-            print "Files will be created, but Makefiles will not be edited."
+            print("Warning: Autotools modules are not supported. ",
+                  "Files will be created, but Makefiles will not be edited.")
             self._skip_cmakefiles = True
 
     def setup_choose_license(self):
@@ -143,7 +145,7 @@ class ModToolAdd(ModTool):
     def _write_tpl(self, tpl, path, fname):
         """ Shorthand for writing a substituted template to a file"""
         path_to_file = os.path.join(path, fname)
-        print "Adding file '%s'..." % path_to_file
+        print("Adding file '%s'..." % path_to_file)
         open(path_to_file, 'w').write(render_template(tpl, **self._info))
         self.scm.add_files((path_to_file,))
 
@@ -197,7 +199,7 @@ class ModToolAdd(ModTool):
                                             )
                     self.scm.mark_files_updated((self._file['qalib'],))
                 except IOError:
-                    print "Can't add C++ QA files."
+                    print("Can't add C++ QA files.")
         fname_cc = None
         fname_h  = None
         if self._info['version']  == '37':
@@ -218,9 +220,9 @@ class ModToolAdd(ModTool):
             if self._info['version'] == '37':
                 _add_qa()
             elif self._info['version'] == '36':
-                print "Warning: C++ QA files not supported for 3.6-style OOTs."
+                print("Warning: C++ QA files not supported for 3.6-style 
OOTs.")
             elif self._info['version'] == 'autofoo':
-                print "Warning: C++ QA files not supported for autotools."
+                print("Warning: C++ QA files not supported for autotools.")
         if not self._skip_cmakefiles:
             ed = CMakeFileEditor(self._file['cmlib'])
             cmake_list_var = '[a-z]*_?' + self._info['modname'] + '_sources'
@@ -237,9 +239,9 @@ class ModToolAdd(ModTool):
         - Edit main *.i file
         """
         if self._get_mainswigfile() is None:
-            print 'Warning: No main swig file found.'
+            print('Warning: No main swig file found.')
             return
-        print "Editing %s..." % self._file['swig']
+        print("Editing %s..." % self._file['swig'])
         mod_block_sep = '/'
         if self._info['version'] == '36':
             mod_block_sep = '_'
@@ -266,11 +268,11 @@ class ModToolAdd(ModTool):
         """
         fname_py_qa = 'qa_' + self._info['blockname'] + '.py'
         self._write_tpl('qa_python', self._info['pydir'], fname_py_qa)
-        os.chmod(os.path.join(self._info['pydir'], fname_py_qa), 0755)
+        os.chmod(os.path.join(self._info['pydir'], fname_py_qa), 0o755)
         self.scm.mark_files_updated((os.path.join(self._info['pydir'], 
fname_py_qa),))
         if self._skip_cmakefiles or 
CMakeFileEditor(self._file['cmpython']).check_for_glob('qa_*.py'):
             return
-        print "Editing %s/CMakeLists.txt..." % self._info['pydir']
+        print("Editing %s/CMakeLists.txt..." % self._info['pydir'])
         open(self._file['cmpython'], 'a').write(
                 'GR_ADD_TEST(qa_%s ${PYTHON_EXECUTABLE} 
${CMAKE_CURRENT_SOURCE_DIR}/%s)\n' % \
                   (self._info['blockname'], fname_py_qa))
@@ -307,7 +309,7 @@ class ModToolAdd(ModTool):
         ed = CMakeFileEditor(self._file['cmgrc'], '\n    ')
         if self._skip_cmakefiles or ed.check_for_glob('*.xml'):
             return
-        print "Editing grc/CMakeLists.txt..."
+        print("Editing grc/CMakeLists.txt...")
         ed.append_value('install', fname_grc, 
to_ignore_end='DESTINATION[^()]+')
         ed.write()
         self.scm.mark_files_updated((self._file['cmgrc'],))
diff --git a/gr-utils/python/modtool/modtool_base.py 
b/gr-utils/python/modtool/modtool_base.py
index 990e63a..8585111 100644
--- a/gr-utils/python/modtool/modtool_base.py
+++ b/gr-utils/python/modtool/modtool_base.py
@@ -20,6 +20,8 @@
 #
 """ Base class for the modules """
 
+from __future__ import print_function
+
 import os
 import re
 from argparse import ArgumentParser, RawDescriptionHelpFormatter
@@ -94,7 +96,7 @@ class ModTool(object):
             self._info['modname'] = get_modname()
         if self._info['modname'] is None:
             raise ModToolException('No GNU Radio module found in the given 
directory.')
-        print "GNU Radio module name identified: " + self._info['modname']
+        print("GNU Radio module name identified: " + self._info['modname'])
         if self._info['version'] == '36' and (
                 os.path.isdir(os.path.join('include', self._info['modname'])) 
or
                 os.path.isdir(os.path.join('include', 'gnuradio', 
self._info['modname']))
@@ -144,7 +146,7 @@ class ModTool(object):
         else:
             self.scm = SCMRepoFactory(self.options, 
'.').make_empty_scm_manager()
         if self.scm is None:
-            print "Error: Can't set up SCM."
+            print("Error: Can't set up SCM.")
             exit(1)
 
     def _check_directory(self, directory):
@@ -156,7 +158,7 @@ class ModTool(object):
             files = os.listdir(directory)
             os.chdir(directory)
         except OSError:
-            print "Can't read or chdir to directory %s." % directory
+            print("Can't read or chdir to directory %s." % directory)
             return False
         self._info['is_component'] = False
         for f in files:
diff --git a/gr-utils/python/modtool/modtool_disable.py 
b/gr-utils/python/modtool/modtool_disable.py
index 1772a74..2c75ca5 100644
--- a/gr-utils/python/modtool/modtool_disable.py
+++ b/gr-utils/python/modtool/modtool_disable.py
@@ -20,6 +20,8 @@
 #
 """ Disable blocks module """
 
+from __future__ import print_function
+
 import os
 import re
 import sys
@@ -62,7 +64,7 @@ class ModToolDisable(ModTool):
             try:
                 initfile = open(self._file['pyinit']).read()
             except IOError:
-                print "Could not edit __init__.py, that might be a problem."
+                print("Could not edit __init__.py, that might be a problem.")
                 return False
             pymodname = os.path.splitext(fname)[0]
             initfile = re.sub(r'((from|import)\s+\b'+pymodname+r'\b)', r'#\1', 
initfile)
@@ -93,14 +95,14 @@ class ModToolDisable(ModTool):
                                         self._info['modname'], fname),
                                         r'//\1', swigfile)
             if nsubs > 0:
-                print "Changing %s..." % self._file['swig']
+                print("Changing %s..." % self._file['swig'])
             if nsubs > 1: # Need to find a single BLOCK_MAGIC
                 blockname = 
os.path.splitext(fname[len(self._info['modname'])+1:])[0]
                 if self._info['version'] == '37':
                     blockname = os.path.splitext(fname)[0]
                 (swigfile, nsubs) = re.subn('(GR_SWIG_BLOCK_MAGIC2?.+%s.+;)' % 
blockname, r'//\1', swigfile)
                 if nsubs > 1:
-                    print "Hm, changed more then expected while editing %s." % 
self._file['swig']
+                    print("Hm, changed more then expected while editing %s." % 
self._file['swig'])
             open(self._file['swig'], 'w').write(swigfile)
             self.scm.mark_file_updated(self._file['swig'])
             return False
@@ -112,7 +114,7 @@ class ModToolDisable(ModTool):
             if self._info['version'] == '37':
                 blockname = os.path.splitext(fname)[0]
             swigfile = re.sub('(%include\s+"'+fname+'")', r'//\1', swigfile)
-            print "Changing %s..." % self._file['swig']
+            print("Changing %s..." % self._file['swig'])
             swigfile = re.sub('(GR_SWIG_BLOCK_MAGIC2?.+'+blockname+'.+;)', 
r'//\1', swigfile)
             open(self._file['swig'], 'w').write(swigfile)
             self.scm.mark_file_updated(self._file['swig'])
@@ -135,7 +137,7 @@ class ModToolDisable(ModTool):
                 cmake = CMakeFileEditor(os.path.join(subdir, 'CMakeLists.txt'))
             except IOError:
                 continue
-            print "Traversing %s..." % subdir
+            print("Traversing %s..." % subdir)
             filenames = cmake.find_filenames_match(self._info['pattern'])
             yes = self._info['yes']
             for fname in filenames:
@@ -155,5 +157,5 @@ class ModToolDisable(ModTool):
                     cmake.disable_file(fname)
             cmake.write()
             self.scm.mark_files_updated((os.path.join(subdir, 
'CMakeLists.txt'),))
-        print "Careful: 'gr_modtool disable' does not resolve dependencies."
+        print("Careful: 'gr_modtool disable' does not resolve dependencies.")
 
diff --git a/gr-utils/python/modtool/modtool_info.py 
b/gr-utils/python/modtool/modtool_info.py
index 3179482..0a0b90f 100644
--- a/gr-utils/python/modtool/modtool_info.py
+++ b/gr-utils/python/modtool/modtool_info.py
@@ -1,4 +1,3 @@
-#
 # Copyright 2013 Free Software Foundation, Inc.
 #
 # This file is part of GNU Radio
@@ -20,6 +19,8 @@
 #
 """ Returns information about a module """
 
+from __future__ import print_function
+
 import os
 
 from modtool_base import ModTool, ModToolException
@@ -83,7 +84,7 @@ class ModToolInfo(ModTool):
             mod_info['build_dir'] = build_dir
             mod_info['incdirs'] += self._get_include_dirs(mod_info)
         if self._python_readable:
-            print str(mod_info)
+            print(str(mod_info))
         else:
             self._pretty_print(mod_info)
 
@@ -135,7 +136,7 @@ class ModToolInfo(ModTool):
             inc_dirs = [os.path.normpath(path) for path in 
self._suggested_dirs.split(':') if os.path.isdir(path)]
         return inc_dirs
 
-    def _pretty_print(self, mod_info):
+    def _pretty_print(elf, mod_info):
         """ Output the module info in human-readable format """
         index_names = {'base_dir': 'Base directory',
                        'modname':  'Module name',
@@ -144,10 +145,10 @@ class ModToolInfo(ModTool):
                        'incdirs': 'Include directories'}
         for key in mod_info.keys():
             if key == 'version':
-                print "        API version: %s" % {
+                print("        API version: %s" % {
                         '36': 'pre-3.7',
                         '37': 'post-3.7',
                         'autofoo': 'Autotools (pre-3.5)'
-                        }[mod_info['version']]
+                        }[mod_info['version']])
             else:
-                print '%19s: %s' % (index_names[key], mod_info[key])
+                print('%19s: %s' % (index_names[key], mod_info[key]))
diff --git a/gr-utils/python/modtool/modtool_makexml.py 
b/gr-utils/python/modtool/modtool_makexml.py
index 5f53749..4ebfaf7 100644
--- a/gr-utils/python/modtool/modtool_makexml.py
+++ b/gr-utils/python/modtool/modtool_makexml.py
@@ -20,6 +20,8 @@
 #
 """ Automatically create XML bindings for GRC from block code """
 
+from __future__ import print_function
+
 import os
 import re
 import glob
@@ -60,7 +62,7 @@ class ModToolMakeXML(ModTool):
 
     def run(self, options):
         """ Go, go, go! """
-        print "Warning: This is an experimental feature. Don't expect any 
magic."
+        print("Warning: This is an experimental feature. Don't expect any 
magic.")
         self.setup(options)
         # 1) Go through lib/
         if not self._skip_subdirs['lib']:
@@ -80,12 +82,12 @@ class ModToolMakeXML(ModTool):
         """ Search for files matching pattern in the given path. """
         files = glob.glob("%s/%s"% (path, path_glob))
         files_filt = []
-        print "Searching for matching files in %s/:" % path
+        print("Searching for matching files in %s/:" % path)
         for f in files:
             if re.search(self._info['pattern'], os.path.basename(f)) is not 
None:
                 files_filt.append(f)
         if len(files_filt) == 0:
-            print "None found."
+            print("None found.")
         return files_filt
 
     def _make_grc_xml_from_block_data(self, params, iosig, blockname):
@@ -110,7 +112,7 @@ class ModToolMakeXML(ModTool):
                     return
             else:
                 file_exists = True
-                print "Warning: Overwriting existing GRC file."
+                print("Warning: Overwriting existing GRC file.")
         grc_generator = GRCXMLGenerator(
                 modname=self._info['modname'],
                 blockname=blockname,
@@ -125,7 +127,7 @@ class ModToolMakeXML(ModTool):
         if not self._skip_subdirs['grc']:
             ed = CMakeFileEditor(self._file['cmgrc'])
             if re.search(fname_xml, ed.cfile) is None and not 
ed.check_for_glob('*.xml'):
-                print "Adding GRC bindings to grc/CMakeLists.txt..."
+                print("Adding GRC bindings to grc/CMakeLists.txt...")
                 ed.append_value('install', fname_xml, 
to_ignore_end='DESTINATION[^()]+')
                 ed.write()
                 self.scm.mark_files_updated(self._file['cmgrc'])
@@ -158,7 +160,7 @@ class ModToolMakeXML(ModTool):
             blockname = blockname.replace(self._info['modname']+'_', '', 1)
             return (blockname, fname_h)
         # Go, go, go
-        print "Making GRC bindings for %s..." % fname_cc
+        print("Making GRC bindings for %s..." % fname_cc)
         (blockname, fname_h) = _get_blockdata(fname_cc)
         try:
             parser = ParserCCBlock(fname_cc,
diff --git a/gr-utils/python/modtool/modtool_newmod.py 
b/gr-utils/python/modtool/modtool_newmod.py
index 4382d9b..c470cb1 100644
--- a/gr-utils/python/modtool/modtool_newmod.py
+++ b/gr-utils/python/modtool/modtool_newmod.py
@@ -20,6 +20,8 @@
 #
 """ Create a whole new out-of-tree module """
 
+from __future__ import print_function
+
 import shutil
 import os
 import re
@@ -76,7 +78,7 @@ class ModToolNewModule(ModTool):
         * Rename files and directories that contain the word howto
         """
         self.setup(options)
-        print "Creating out-of-tree module in %s..." % self._dir,
+        print("Creating out-of-tree module in %s..." % (self._dir,))
         try:
             shutil.copytree(self._srcdir, self._dir)
             os.chdir(self._dir)
@@ -93,8 +95,8 @@ class ModToolNewModule(ModTool):
                     os.rename(f, os.path.join(root, filename.replace('howto', 
self._info['modname'])))
             if os.path.basename(root) == 'howto':
                 os.rename(root, os.path.join(os.path.dirname(root), 
self._info['modname']))
-        print "Done."
+        print("Done.")
         if self.scm.init_repo(path_to_repo="."):
-            print "Created repository... you might want to commit before 
continuing."
-        print "Use 'gr_modtool add' to add a new block to this currently empty 
module."
+            print("Created repository... you might want to commit before 
continuing.")
+        print("Use 'gr_modtool add' to add a new block to this currently empty 
module.")
 
diff --git a/gr-utils/python/modtool/modtool_rename.py 
b/gr-utils/python/modtool/modtool_rename.py
index f0ff412..8586b4f 100644
--- a/gr-utils/python/modtool/modtool_rename.py
+++ b/gr-utils/python/modtool/modtool_rename.py
@@ -20,6 +20,8 @@
 #
 """ Module to rename blocks """
 
+from __future__ import print_function
+
 import os
 import re
 
@@ -61,7 +63,7 @@ class ModToolRename(ModTool):
             self._info['oldname'] = raw_input("Enter name of block/code to 
rename (without module name prefix): ")
         if not re.match('[a-zA-Z0-9_]+', self._info['oldname']):
             raise ModToolException('Invalid block name.')
-        print "Block/code to rename identifier: " + self._info['oldname']
+        print("Block/code to rename identifier: " + self._info['oldname'])
         self._info['fulloldname'] = self._info['modname'] + '_' + 
self._info['oldname']
 
         # now get the new block name
@@ -71,7 +73,7 @@ class ModToolRename(ModTool):
             self._info['newname'] = options.new_name[0]
         if not re.match('[a-zA-Z0-9_]+', self._info['newname']):
             raise ModToolException('Invalid block name.')
-        print "Block/code identifier: " + self._info['newname']
+        print("Block/code identifier: " + self._info['newname'])
         self._info['fullnewname'] = self._info['modname'] + '_' + 
self._info['newname']
 
     def run(self, options):
@@ -80,7 +82,7 @@ class ModToolRename(ModTool):
         module = self._info['modname']
         oldname = self._info['oldname']
         newname = self._info['newname']
-        print "In module '%s' rename block '%s' to '%s'" % (module, oldname, 
newname)
+        print("In module '%s' rename block '%s' to '%s'" % (module, oldname, 
newname))
         self._run_swig_rename(self._file['swig'], oldname, newname)
         self._run_grc_rename(self._info['modname'], oldname, newname)
         self._run_python_qa(self._info['modname'], oldname, newname)
@@ -93,11 +95,11 @@ class ModToolRename(ModTool):
         """ Rename SWIG includes and block_magic """
         nsubs = self._run_file_replace(swigfilename, old, new)
         if nsubs < 1:
-            print "Couldn't find '%s' in file '%s'." % (old, swigfilename)
+            print("Couldn't find '%s' in file '%s'." % (old, swigfilename))
         if nsubs == 2:
-            print "Changing 'noblock' type file"
+            print("Changing 'noblock' type file")
         if nsubs > 3:
-            print "Hm, changed more then expected while editing %s." % 
swigfilename
+            print("Hm, changed more then expected while editing %s." % 
swigfilename)
         return False
 
     def _run_lib(self, module, old, new):
@@ -117,7 +119,7 @@ class ModToolRename(ModTool):
         filename = 'qa_' + module + '.cc'
         nsubs = self._run_file_replace(path + filename, old, new)
         if nsubs > 0:
-            print "C++ QA code detected, renaming..."
+            print("C++ QA code detected, renaming...")
             filename = 'qa_' + old + '.cc'
             self._run_file_replace(path + filename, old, new)
             filename = 'qa_' + old + '.h'
@@ -125,7 +127,7 @@ class ModToolRename(ModTool):
             self._run_file_replace(path + filename, old.upper(), new.upper())
             self._run_file_rename(path, 'qa_' + old, 'qa_' + new)
         else:
-            print "No C++ QA code detected, skipping..."
+            print("No C++ QA code detected, skipping...")
 
     def _run_include(self, module, old, new):
         path = './include/' + module + '/'
@@ -140,13 +142,13 @@ class ModToolRename(ModTool):
         filename = '__init__.py'
         nsubs = self._run_file_replace(path + filename, old, new)
         if nsubs > 0:
-            print "Python block detected, renaming..."
+            print("Python block detected, renaming...")
             filename = old + '.py'
             self._run_file_replace(path + filename, old, new)
             self._run_cmakelists(path, old, new)
             self._run_file_rename(path, old, new)
         else:
-            print "Not a Python block, nothing to do here..."
+            print("Not a Python block, nothing to do here...")
 
     def _run_python_qa(self, module, old, new):
         new = 'qa_' + new
@@ -166,7 +168,7 @@ class ModToolRename(ModTool):
         filename = path + 'CMakeLists.txt'
         nsubs = self._run_file_replace(filename, first, second)
         if nsubs < 1:
-            print "'%s' wasn't in '%s'." % (first, filename)
+            print("'%s' wasn't in '%s'." % (first, filename))
 
     def _run_file_rename(self, path, old, new):
         files = os.listdir(path)
@@ -175,14 +177,14 @@ class ModToolRename(ModTool):
                 nl = file.replace(old, new)
                 src = path + file
                 dst = path + nl
-                print "Renaming file '%s' to '%s'." % (src, dst)
+                print("Renaming file '%s' to '%s'." % (src, dst))
                 os.rename(src, dst)
 
     def _run_file_replace(self, filename, old, new):
         if not os.path.isfile(filename):
             return False
         else:
-            print "In '%s' renaming occurences of '%s' to '%s'" % (filename, 
old, new)
+            print("In '%s' renaming occurences of '%s' to '%s'" % (filename, 
old, new))
 
         cfile = open(filename).read()
         (cfile, nsubs) = re.subn(old, new, cfile)
diff --git a/gr-utils/python/modtool/modtool_rm.py 
b/gr-utils/python/modtool/modtool_rm.py
index eef743d..8d5a07a 100644
--- a/gr-utils/python/modtool/modtool_rm.py
+++ b/gr-utils/python/modtool/modtool_rm.py
@@ -20,6 +20,8 @@
 #
 """ Remove blocks module """
 
+from __future__ import print_function
+
 import os
 import re
 import sys
@@ -132,12 +134,12 @@ class ModToolRemove(ModTool):
         for g in globs:
             files = files + glob.glob("%s/%s"% (path, g))
         files_filt = []
-        print "Searching for matching files in %s/:" % path
+        print("Searching for matching files in %s/:" % path)
         for f in files:
             if re.search(self._info['pattern'], os.path.basename(f)) is not 
None:
                 files_filt.append(f)
         if len(files_filt) == 0:
-            print "None found."
+            print("None found.")
             return []
         # 2. Delete files, Makefile entries and other occurrences
         files_deleted = []
@@ -154,10 +156,10 @@ class ModToolRemove(ModTool):
                 if ans == 'n':
                     continue
             files_deleted.append(b)
-            print "Deleting %s." % f
+            print("Deleting %s." % f)
             self.scm.remove_file(f)
             os.unlink(f)
-            print "Deleting occurrences of %s from %s/CMakeLists.txt..." % (b, 
path)
+            print("Deleting occurrences of %s from %s/CMakeLists.txt..." % (b, 
path))
             for var in makefile_vars:
                 ed.remove_value(var, b)
             if cmakeedit_func is not None:
diff --git a/gr-utils/python/modtool/parser_cc_block.py 
b/gr-utils/python/modtool/parser_cc_block.py
index 703522c..f2dfd43 100644
--- a/gr-utils/python/modtool/parser_cc_block.py
+++ b/gr-utils/python/modtool/parser_cc_block.py
@@ -19,6 +19,9 @@
 # Boston, MA 02110-1301, USA.
 #
 ''' A parser for blocks written in C++ '''
+
+from __future__ import print_function
+
 import re
 import sys
 
@@ -42,7 +45,7 @@ class ParserCCBlock(object):
             E.g., for sizeof(int), it will return 'int'.
             Returns a list! """
             if 'gr::io_signature::makev' in iosigcall:
-                print 'tbi'
+                print('tbi')
                 raise ValueError
             return {'type': [_typestr_to_iotype(x) for x in 
typestr.split(',')],
                     'vlen': [_typestr_to_vlen(x)   for x in typestr.split(',')]
@@ -82,15 +85,15 @@ class ParserCCBlock(object):
                                                       
iosig_match.group('intype'))
             iosig['in']['min_ports'] = iosig_match.group('inmin')
             iosig['in']['max_ports'] = iosig_match.group('inmax')
-        except ValueError, Exception:
-            print "Error: Can't parse input signature."
+        except Exception:
+            print("Error: Can't parse input signature.")
         try:
             iosig['out'] = 
_figure_out_iotype_and_vlen(iosig_match.group('outcall'),
                                                        
iosig_match.group('outtype'))
             iosig['out']['min_ports'] = iosig_match.group('outmin')
             iosig['out']['max_ports'] = iosig_match.group('outmax')
-        except ValueError, Exception:
-            print "Error: Can't parse output signature."
+        except Exception:
+            print("Error: Can't parse output signature.")
         return iosig
 
 
@@ -213,7 +216,7 @@ class ParserCCBlock(object):
         try:
             params_list = _scan_param_list(make_match.end(0))
         except ValueError as ve:
-            print "Can't parse the argument list: ", ve.args[0]
+            print("Can't parse the argument list: ", ve.args[0])
             sys.exit(0)
         params = []
         for plist in params_list:
diff --git a/gr-utils/python/modtool/scm.py b/gr-utils/python/modtool/scm.py
index ec6023a..aa34a27 100644
--- a/gr-utils/python/modtool/scm.py
+++ b/gr-utils/python/modtool/scm.py
@@ -20,6 +20,8 @@
 #
 """ Class to handle source code management repositories. """
 
+from __future__ import print_function
+
 import subprocess
 
 try:
@@ -196,7 +198,7 @@ class SCMRepoFactory(object):
                 if issubclass(glbl, SCMRepository):
                     the_scm = glbl(self.path_to_repo)
                     if the_scm.is_active():
-                        print 'Found SCM of type:', the_scm.handles_scm_type
+                        print('Found SCM of type:', the_scm.handles_scm_type)
                         return the_scm
             except (TypeError, AttributeError, InvalidSCMError):
                 pass
diff --git a/gr-utils/python/utils/gr_modtool b/gr-utils/python/utils/gr_modtool
index d901684..49c58f5 100755
--- a/gr-utils/python/utils/gr_modtool
+++ b/gr-utils/python/utils/gr_modtool
@@ -21,6 +21,8 @@
 #
 """ A tool for editing GNU Radio out-of-tree modules. """
 
+from __future__ import print_function
+
 from gnuradio.modtool import *
 
 
@@ -46,7 +48,7 @@ def main():
     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 ee64455..3199919 100755
--- a/gr-utils/python/utils/gr_plot_char
+++ b/gr-utils/python/utils/gr_plot_char
@@ -20,11 +20,13 @@
 # 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 argparse import ArgumentParser
 from gnuradio.plot_data import plot_data
diff --git a/gr-utils/python/utils/gr_plot_const 
b/gr-utils/python/utils/gr_plot_const
index 653a253..2ec54c3 100755
--- a/gr-utils/python/utils/gr_plot_const
+++ b/gr-utils/python/utils/gr_plot_const
@@ -20,18 +20,20 @@
 # 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 argparse import ArgumentParser
 
@@ -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,9 +217,9 @@ 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():
@@ -241,6 +243,3 @@ if __name__ == "__main__":
         main()
     except KeyboardInterrupt:
         pass
-
-
-
diff --git a/gr-utils/python/utils/gr_plot_float 
b/gr-utils/python/utils/gr_plot_float
index faf8106..4fd8654 100755
--- a/gr-utils/python/utils/gr_plot_float
+++ b/gr-utils/python/utils/gr_plot_float
@@ -20,11 +20,13 @@
 # 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 argparse import ArgumentParser
 from gnuradio.plot_data import plot_data
diff --git a/gr-utils/python/utils/gr_plot_int 
b/gr-utils/python/utils/gr_plot_int
index c687f13..b4051fa 100755
--- a/gr-utils/python/utils/gr_plot_int
+++ b/gr-utils/python/utils/gr_plot_int
@@ -23,8 +23,8 @@
 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 argparse import ArgumentParser
 from gnuradio.plot_data import plot_data
diff --git a/gr-utils/python/utils/gr_plot_iq b/gr-utils/python/utils/gr_plot_iq
index 7409b73..f27f75d 100755
--- a/gr-utils/python/utils/gr_plot_iq
+++ b/gr-utils/python/utils/gr_plot_iq
@@ -20,17 +20,19 @@
 # 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 argparse import ArgumentParser
 
@@ -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,9 +146,9 @@ 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():
     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."
@@ -170,6 +172,3 @@ if __name__ == "__main__":
         main()
     except KeyboardInterrupt:
         pass
-
-
-
diff --git a/gr-utils/python/utils/gr_plot_qt b/gr-utils/python/utils/gr_plot_qt
index 9205d23..cd2db87 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):
diff --git a/gr-utils/python/utils/gr_plot_short 
b/gr-utils/python/utils/gr_plot_short
index f900af1..d367ea3 100755
--- a/gr-utils/python/utils/gr_plot_short
+++ b/gr-utils/python/utils/gr_plot_short
@@ -20,11 +20,13 @@
 # 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 argparse import ArgumentParser
 from gnuradio.plot_data import plot_data
diff --git a/gr-utils/python/utils/gr_read_file_metadata 
b/gr-utils/python/utils/gr_read_file_metadata
index a05e7ad..1a94560 100644
--- a/gr-utils/python/utils/gr_read_file_metadata
+++ b/gr-utils/python/utils/gr_read_file_metadata
@@ -20,6 +20,8 @@
 # Boston, MA 02110-1301, USA.
 #
 
+from __future__ import print_function
+
 import sys
 from argparse import ArgumentParser
 
@@ -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,7 +69,7 @@ def main(filename, detached=False):
         if(not detached):
             nread += info['nbytes']
         handle.seek(nread, 0)
-        print "\n\n"
+        print("\n\n")
 
 
 if __name__ == "__main__":
diff --git a/gr-utils/python/utils/plot_data.py 
b/gr-utils/python/utils/plot_data.py
index 7d80c71..17de851 100644
--- a/gr-utils/python/utils/plot_data.py
+++ b/gr-utils/python/utils/plot_data.py
@@ -22,17 +22,19 @@
 Utility to help plotting data from files.
 """
 
+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)
 
 
 class plot_data:
@@ -86,7 +88,7 @@ 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))])
@@ -162,6 +164,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 c994621..4bb10dc 100755
--- a/gr-utils/python/utils/plot_fft_base.py
+++ b/gr-utils/python/utils/plot_fft_base.py
@@ -20,18 +20,20 @@
 # Boston, MA 02110-1301, USA.
 #
 
+from __future__ import print_function
+
 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 argparse import ArgumentParser
 
@@ -84,7 +86,7 @@ class plot_fft_base:
         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)
 
@@ -228,9 +230,9 @@ class plot_fft_base:
 
 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()
@@ -243,6 +245,3 @@ if __name__ == "__main__":
         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 2611ed4..a3ad8c8 100755
--- a/gr-utils/python/utils/plot_psd_base.py
+++ b/gr-utils/python/utils/plot_psd_base.py
@@ -20,18 +20,20 @@
 # Boston, MA 02110-1301, USA.
 #
 
+from __future__ import print_function
+
 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 argparse import ArgumentParser
 from scipy import log10
@@ -92,7 +94,7 @@ class plot_psd_base:
         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
@@ -105,7 +107,7 @@ class plot_psd_base:
                 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):
@@ -270,9 +272,9 @@ class plot_psd_base:
 
 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()
@@ -285,6 +287,3 @@ if __name__ == "__main__":
         main()
     except KeyboardInterrupt:
         pass
-
-
-



reply via email to

[Prev in Thread] Current Thread [Next in Thread]