summaryrefslogtreecommitdiff
path: root/gr-utils
diff options
context:
space:
mode:
Diffstat (limited to 'gr-utils')
-rw-r--r--gr-utils/CMakeLists.txt2
-rw-r--r--gr-utils/python/modtool/__init__.py28
-rw-r--r--gr-utils/python/modtool/cmakefile_editor.py7
-rw-r--r--gr-utils/python/modtool/code_generator.py14
-rw-r--r--gr-utils/python/modtool/gr-newmod/cmake/Modules/GrMiscUtils.cmake10
-rw-r--r--gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPython.cmake11
-rw-r--r--gr-utils/python/modtool/gr-newmod/cmake/Modules/GrSwig.cmake2
-rw-r--r--gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/__init__.py3
-rw-r--r--gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/base.py18
-rw-r--r--gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/doxyindex.py8
-rw-r--r--gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/__init__.py1
-rw-r--r--gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/compound.py8
-rw-r--r--gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/compoundsuper.py40
-rw-r--r--gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/index.py6
-rw-r--r--gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/indexsuper.py21
-rw-r--r--gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/text.py5
-rw-r--r--gr-utils/python/modtool/gr-newmod/docs/doxygen/swig_doc.py3
-rw-r--r--gr-utils/python/modtool/gr-newmod/python/__init__.py1
-rw-r--r--gr-utils/python/modtool/gr-newmod/python/build_utils.py12
-rw-r--r--gr-utils/python/modtool/gr-newmod/python/build_utils_codes.py1
-rw-r--r--gr-utils/python/modtool/grc_xml_generator.py3
-rw-r--r--gr-utils/python/modtool/modtool_add.py55
-rw-r--r--gr-utils/python/modtool/modtool_base.py18
-rw-r--r--gr-utils/python/modtool/modtool_disable.py24
-rw-r--r--gr-utils/python/modtool/modtool_info.py27
-rw-r--r--gr-utils/python/modtool/modtool_makexml.py28
-rw-r--r--gr-utils/python/modtool/modtool_newmod.py18
-rw-r--r--gr-utils/python/modtool/modtool_rename.py42
-rw-r--r--gr-utils/python/modtool/modtool_rm.py22
-rw-r--r--gr-utils/python/modtool/parser_cc_block.py16
-rw-r--r--gr-utils/python/modtool/scm.py9
-rw-r--r--gr-utils/python/modtool/templates.py1
-rw-r--r--gr-utils/python/modtool/util_functions.py8
-rwxr-xr-xgr-utils/python/utils/gr_modtool4
-rwxr-xr-xgr-utils/python/utils/gr_plot_char6
-rwxr-xr-xgr-utils/python/utils/gr_plot_const21
-rwxr-xr-xgr-utils/python/utils/gr_plot_float6
-rwxr-xr-xgr-utils/python/utils/gr_plot_int4
-rwxr-xr-xgr-utils/python/utils/gr_plot_iq19
-rwxr-xr-xgr-utils/python/utils/gr_plot_qt26
-rwxr-xr-xgr-utils/python/utils/gr_plot_short6
-rw-r--r--gr-utils/python/utils/gr_read_file_metadata8
-rw-r--r--gr-utils/python/utils/plot_data.py22
-rw-r--r--[-rwxr-xr-x]gr-utils/python/utils/plot_fft_base.py35
-rw-r--r--[-rwxr-xr-x]gr-utils/python/utils/plot_psd_base.py35
-rw-r--r--gr-utils/python/utils/pyqt_filter.py1
-rw-r--r--gr-utils/python/utils/pyqt_plot.py1
47 files changed, 377 insertions, 289 deletions
diff --git a/gr-utils/CMakeLists.txt b/gr-utils/CMakeLists.txt
index d54a06abd1..a8dfd91531 100644
--- a/gr-utils/CMakeLists.txt
+++ b/gr-utils/CMakeLists.txt
@@ -22,7 +22,7 @@
########################################################################
include(GrPython)
-GR_PYTHON_CHECK_MODULE("Mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND)
+GR_PYTHON_CHECK_MODULE("Mako >= ${GR_MAKO_MIN_VERSION}" mako "mako.__version__ >= '${GR_MAKO_MIN_VERSION}'" MAKO_FOUND)
########################################################################
# Register component
diff --git a/gr-utils/python/modtool/__init__.py b/gr-utils/python/modtool/__init__.py
index 897ff97fce..b6d719ac1d 100644
--- a/gr-utils/python/modtool/__init__.py
+++ b/gr-utils/python/modtool/__init__.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+from __future__ import unicode_literals
#
# Copyright 2013-2014 Free Software Foundation, Inc.
#
@@ -19,17 +21,17 @@
# Boston, MA 02110-1301, USA.
#
-from cmakefile_editor import CMakeFileEditor
-from grc_xml_generator import GRCXMLGenerator
-from modtool_base import ModTool, ModToolException, get_modtool_modules
-from modtool_add import ModToolAdd
-from modtool_disable import ModToolDisable
-from modtool_info import ModToolInfo
-from modtool_makexml import ModToolMakeXML
-from modtool_newmod import ModToolNewModule
-from modtool_rm import ModToolRemove
-from modtool_rename import ModToolRename
-from templates import Templates
+from .cmakefile_editor import CMakeFileEditor
+from .grc_xml_generator import GRCXMLGenerator
+from .modtool_base import ModTool, ModToolException, get_modtool_modules
+from .modtool_add import ModToolAdd
+from .modtool_disable import ModToolDisable
+from .modtool_info import ModToolInfo
+from .modtool_makexml import ModToolMakeXML
+from .modtool_newmod import ModToolNewModule
+from .modtool_rm import ModToolRemove
+from .modtool_rename import ModToolRename
+from .templates import Templates
# Leave this at the end
-from parser_cc_block import ParserCCBlock
-from util_functions import *
+from .parser_cc_block import ParserCCBlock
+from .util_functions import *
diff --git a/gr-utils/python/modtool/cmakefile_editor.py b/gr-utils/python/modtool/cmakefile_editor.py
index 4148ad1960..1b644287f9 100644
--- a/gr-utils/python/modtool/cmakefile_editor.py
+++ b/gr-utils/python/modtool/cmakefile_editor.py
@@ -20,6 +20,9 @@
#
""" Edit CMakeLists.txt files """
+from __future__ import print_function
+from __future__ import unicode_literals
+
import re
class CMakeFileEditor(object):
@@ -126,9 +129,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/code_generator.py b/gr-utils/python/modtool/code_generator.py
index 326b2d5986..d95434f577 100644
--- a/gr-utils/python/modtool/code_generator.py
+++ b/gr-utils/python/modtool/code_generator.py
@@ -19,14 +19,16 @@
# Boston, MA 02110-1301, USA.
#
""" A code generator (needed by ModToolAdd) """
+from __future__ import absolute_import
+from __future__ import unicode_literals
from mako.template import Template
-from templates import Templates
-from util_functions import str_to_fancyc_comment
-from util_functions import str_to_python_comment
-from util_functions import strip_default_values
-from util_functions import strip_arg_types
-from util_functions import strip_arg_types_grc
+from .templates import Templates
+from .util_functions import str_to_fancyc_comment
+from .util_functions import str_to_python_comment
+from .util_functions import strip_default_values
+from .util_functions import strip_arg_types
+from .util_functions import strip_arg_types_grc
GRTYPELIST = {
'sync': 'sync_block',
diff --git a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrMiscUtils.cmake b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrMiscUtils.cmake
index 50d817aa9e..cc8e7c17dc 100644
--- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrMiscUtils.cmake
+++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrMiscUtils.cmake
@@ -341,7 +341,7 @@ if __name__ == '__main__':
add_custom_command(
OUTPUT ${expanded_files_h}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.h.t
- COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B}
+ COMMAND ${PYTHON_EXECUTABLE} -B
${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py
${root} ${root}.h.t ${ARGN}
)
@@ -387,7 +387,7 @@ if __name__ == '__main__':
add_custom_command(
OUTPUT ${expanded_files_cc}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.cc.t
- COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B}
+ COMMAND ${PYTHON_EXECUTABLE} -B
${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py
${root} ${root}.cc.t ${ARGN}
)
@@ -396,7 +396,7 @@ if __name__ == '__main__':
add_custom_command(
OUTPUT ${expanded_files_h}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.h.t
- COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B}
+ COMMAND ${PYTHON_EXECUTABLE} -B
${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py
${root} ${root}.h.t ${ARGN}
)
@@ -450,7 +450,7 @@ if __name__ == '__main__':
add_custom_command(
OUTPUT ${expanded_files_cc_impl}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}_impl.cc.t
- COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B}
+ COMMAND ${PYTHON_EXECUTABLE} -B
${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py
${root} ${root}_impl.cc.t ${ARGN}
)
@@ -459,7 +459,7 @@ if __name__ == '__main__':
add_custom_command(
OUTPUT ${expanded_files_h_impl}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}_impl.h.t
- COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B}
+ COMMAND ${PYTHON_EXECUTABLE} -B
${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py
${root} ${root}_impl.h.t ${ARGN}
)
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 0bfa92db8d..6b997c0869 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/cmake/Modules/GrSwig.cmake b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrSwig.cmake
index 543562a287..bce51b23dd 100644
--- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrSwig.cmake
+++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrSwig.cmake
@@ -76,7 +76,7 @@ function(GR_SWIG_MAKE_DOCS output_file)
add_custom_command(
OUTPUT ${output_file}
DEPENDS ${input_files} ${stamp-file} ${OUTPUT_DIRECTORY}/xml/index.xml
- COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B}
+ COMMAND ${PYTHON_EXECUTABLE} -B
${CMAKE_SOURCE_DIR}/docs/doxygen/swig_doc.py
${OUTPUT_DIRECTORY}/xml
${output_file}
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 5cd0b3c6c5..b7a8884519 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
@@ -63,8 +63,9 @@ This line is uninformative and is only to test line breaks in the comments.
u'Outputs the vital aadvark statistics.'
"""
+from __future__ import unicode_literals
-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 e8f026ab90..0f0adf255b 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
@@ -24,24 +24,26 @@ A base class is created.
Classes based upon this are used to make more user-friendly interfaces
to the doxygen xml docs than the generated classes provide.
"""
+from __future__ import print_function
+from __future__ import unicode_literals
import os
import pdb
from xml.parsers.expat import ExpatError
-from generated import compound
+from .generated 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 +96,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,11 +104,11 @@ 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:
- print e
+ except Exception as e:
+ print(e)
@classmethod
def includes(cls, inst):
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 78e8153768..4284af25ec 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
@@ -22,12 +22,14 @@
Classes providing more user-friendly interfaces to the doxygen xml
docs than the generated classes provide.
"""
+from __future__ import absolute_import
+from __future__ import unicode_literals
import os
-from generated import index
-from base import Base
-from text import description
+from .generated import index
+from .base import Base
+from .text import description
class DoxyIndex(Base):
"""
diff --git a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/__init__.py b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/__init__.py
index 39823979f6..23095c1f34 100644
--- a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/__init__.py
+++ b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/generated/__init__.py
@@ -5,3 +5,4 @@ These do the real work of parsing the doxygen xml files but the
resultant classes are not very friendly to navigate so the rest of the
doxyxml module processes them further.
"""
+from __future__ import unicode_literals
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 1522ac23f1..acfa0dd5c6 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
@@ -3,15 +3,17 @@
"""
Generated Mon Feb 9 19:08:05 2009 by generateDS.py.
"""
+from __future__ import absolute_import
+from __future__ import unicode_literals
+
-from string import lower as str_lower
from xml.dom import minidom
from xml.dom import Node
import sys
-import compoundsuper as supermod
-from compoundsuper import MixedContainer
+from . import compoundsuper as supermod
+from .compoundsuper import MixedContainer
class DoxygenTypeSub(supermod.DoxygenType):
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 6255dda163..6e984e13ec 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
@@ -4,12 +4,17 @@
# Generated Thu Jun 11 18:44:25 2009 by generateDS.py.
#
+from __future__ import print_function
+from __future__ import unicode_literals
+
import sys
-import getopt
-from string import lower as str_lower
+
from xml.dom import minidom
from xml.dom import Node
+import six
+
+
#
# User methods
#
@@ -19,9 +24,9 @@ from xml.dom import Node
try:
from generatedssuper import GeneratedsSuper
-except ImportError, exp:
+except ImportError as exp:
- class GeneratedsSuper:
+ class GeneratedsSuper(object):
def format_string(self, input_data, input_name=''):
return input_data
def format_integer(self, input_data, input_name=''):
@@ -64,7 +69,7 @@ def showIndent(outfile, level):
outfile.write(' ')
def quote_xml(inStr):
- s1 = (isinstance(inStr, basestring) and inStr or
+ s1 = (isinstance(inStr, six.string_types) and inStr or
'%s' % inStr)
s1 = s1.replace('&', '&')
s1 = s1.replace('<', '&lt;')
@@ -72,7 +77,7 @@ def quote_xml(inStr):
return s1
def quote_attrib(inStr):
- s1 = (isinstance(inStr, basestring) and inStr or
+ s1 = (isinstance(inStr, six.string_types) and inStr or
'%s' % inStr)
s1 = s1.replace('&', '&amp;')
s1 = s1.replace('<', '&lt;')
@@ -102,7 +107,7 @@ def quote_python(inStr):
return '"""%s"""' % s1
-class MixedContainer:
+class MixedContainer(object):
# Constants for category:
CategoryNone = 0
CategoryText = 1
@@ -4221,7 +4226,7 @@ class codelineType(GeneratedsSuper):
if attrs.get('lineno'):
try:
self.lineno = int(attrs.get('lineno').value)
- except ValueError, exp:
+ except ValueError as exp:
raise ValueError('Bad integer attribute (lineno): %s' % exp)
if attrs.get('refkind'):
self.refkind = attrs.get('refkind').value
@@ -4504,12 +4509,12 @@ class referenceType(GeneratedsSuper):
if attrs.get('endline'):
try:
self.endline = int(attrs.get('endline').value)
- except ValueError, exp:
+ except ValueError as exp:
raise ValueError('Bad integer attribute (endline): %s' % exp)
if attrs.get('startline'):
try:
self.startline = int(attrs.get('startline').value)
- except ValueError, exp:
+ except ValueError as exp:
raise ValueError('Bad integer attribute (startline): %s' % exp)
if attrs.get('refid'):
self.refid = attrs.get('refid').value
@@ -4627,17 +4632,17 @@ class locationType(GeneratedsSuper):
if attrs.get('bodystart'):
try:
self.bodystart = int(attrs.get('bodystart').value)
- except ValueError, exp:
+ except ValueError as exp:
raise ValueError('Bad integer attribute (bodystart): %s' % exp)
if attrs.get('line'):
try:
self.line = int(attrs.get('line').value)
- except ValueError, exp:
+ except ValueError as exp:
raise ValueError('Bad integer attribute (line): %s' % exp)
if attrs.get('bodyend'):
try:
self.bodyend = int(attrs.get('bodyend').value)
- except ValueError, exp:
+ except ValueError as exp:
raise ValueError('Bad integer attribute (bodyend): %s' % exp)
if attrs.get('bodyfile'):
self.bodyfile = attrs.get('bodyfile').value
@@ -6778,12 +6783,12 @@ class docTableType(GeneratedsSuper):
if attrs.get('rows'):
try:
self.rows = int(attrs.get('rows').value)
- except ValueError, exp:
+ except ValueError as exp:
raise ValueError('Bad integer attribute (rows): %s' % exp)
if attrs.get('cols'):
try:
self.cols = int(attrs.get('cols').value)
- except ValueError, exp:
+ except ValueError as exp:
raise ValueError('Bad integer attribute (cols): %s' % exp)
def buildChildren(self, child_, nodeName_):
if child_.nodeType == Node.ELEMENT_NODE and \
@@ -7108,7 +7113,7 @@ class docHeadingType(GeneratedsSuper):
if attrs.get('level'):
try:
self.level = int(attrs.get('level').value)
- except ValueError, exp:
+ except ValueError as exp:
raise ValueError('Bad integer attribute (level): %s' % exp)
def buildChildren(self, child_, nodeName_):
if child_.nodeType == Node.TEXT_NODE:
@@ -8283,7 +8288,7 @@ Options:
"""
def usage():
- print USAGE_TEXT
+ print(USAGE_TEXT)
sys.exit(1)
@@ -8339,4 +8344,3 @@ if __name__ == '__main__':
main()
#import pdb
#pdb.run('main()')
-
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 7a70e14a1a..0c63512119 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
@@ -3,14 +3,16 @@
"""
Generated Mon Feb 9 19:08:05 2009 by generateDS.py.
"""
+from __future__ import absolute_import
+from __future__ import unicode_literals
from xml.dom import minidom
import os
import sys
-import compound
+from . import compound
-import indexsuper as supermod
+from . import indexsuper as supermod
class DoxygenTypeSub(supermod.DoxygenType):
def __init__(self, version=None, compound=None):
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 a991530198..11312db635 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
@@ -4,12 +4,16 @@
# Generated Thu Jun 11 18:43:54 2009 by generateDS.py.
#
+from __future__ import print_function
+from __future__ import unicode_literals
+
import sys
-import getopt
-from string import lower as str_lower
+
from xml.dom import minidom
from xml.dom import Node
+import six
+
#
# User methods
#
@@ -19,9 +23,9 @@ from xml.dom import Node
try:
from generatedssuper import GeneratedsSuper
-except ImportError, exp:
+except ImportError as exp:
- class GeneratedsSuper:
+ class GeneratedsSuper(object):
def format_string(self, input_data, input_name=''):
return input_data
def format_integer(self, input_data, input_name=''):
@@ -64,7 +68,7 @@ def showIndent(outfile, level):
outfile.write(' ')
def quote_xml(inStr):
- s1 = (isinstance(inStr, basestring) and inStr or
+ s1 = (isinstance(inStr, six.string_types) and inStr or
'%s' % inStr)
s1 = s1.replace('&', '&amp;')
s1 = s1.replace('<', '&lt;')
@@ -72,7 +76,7 @@ def quote_xml(inStr):
return s1
def quote_attrib(inStr):
- s1 = (isinstance(inStr, basestring) and inStr or
+ s1 = (isinstance(inStr, six.string_types) and inStr or
'%s' % inStr)
s1 = s1.replace('&', '&amp;')
s1 = s1.replace('<', '&lt;')
@@ -102,7 +106,7 @@ def quote_python(inStr):
return '"""%s"""' % s1
-class MixedContainer:
+class MixedContainer(object):
# Constants for category:
CategoryNone = 0
CategoryText = 1
@@ -462,7 +466,7 @@ Options:
"""
def usage():
- print USAGE_TEXT
+ print(USAGE_TEXT)
sys.exit(1)
@@ -520,4 +524,3 @@ if __name__ == '__main__':
main()
#import pdb
#pdb.run('main()')
-
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 629edd180d..de2d19b532 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
@@ -21,12 +21,13 @@
"""
Utilities for extracting text from generated classes.
"""
+from __future__ import unicode_literals
def is_string(txt):
if isinstance(txt, str):
return True
try:
- if isinstance(txt, unicode):
+ if isinstance(txt, str):
return True
except NameError:
pass
@@ -49,7 +50,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 d3536db8d0..c735b1291b 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
@@ -26,6 +26,7 @@ The file instructs SWIG to transfer the doxygen comments into the
python docstrings.
"""
+from __future__ import unicode_literals
import sys, time
@@ -309,7 +310,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/gr-newmod/python/__init__.py b/gr-utils/python/modtool/gr-newmod/python/__init__.py
index ed385a0abe..806f287cc3 100644
--- a/gr-utils/python/modtool/gr-newmod/python/__init__.py
+++ b/gr-utils/python/modtool/gr-newmod/python/__init__.py
@@ -22,6 +22,7 @@
This is the GNU Radio HOWTO module. Place your Python package
description here (python/__init__.py).
'''
+from __future__ import unicode_literals
# import swig generated symbols into the howto namespace
try:
diff --git a/gr-utils/python/modtool/gr-newmod/python/build_utils.py b/gr-utils/python/modtool/gr-newmod/python/build_utils.py
index cf58a97637..0b26844cbf 100644
--- a/gr-utils/python/modtool/gr-newmod/python/build_utils.py
+++ b/gr-utils/python/modtool/gr-newmod/python/build_utils.py
@@ -21,15 +21,17 @@
"""Misc utilities used at build time
"""
+from __future__ import absolute_import
+from __future__ import unicode_literals
import re, os, os.path
-from build_utils_codes import *
+from .build_utils_codes import *
# set srcdir to the directory that contains Makefile.am
try:
srcdir = os.environ['srcdir']
-except KeyError, e:
+except KeyError as e:
srcdir = "."
srcdir = srcdir + '/'
@@ -39,7 +41,7 @@ try:
do_makefile = False
else:
do_makefile = True
-except KeyError, e:
+except KeyError as e:
do_makefile = False
# set do_sources to either true or false dependeing on the environment
@@ -48,7 +50,7 @@ try:
do_sources = False
else:
do_sources = True
-except KeyError, e:
+except KeyError as e:
do_sources = True
name_dict = {}
@@ -127,7 +129,7 @@ def extract_extension (template_name):
# we return everything between the penultimate . and .t
mo = re.search (r'\.([a-z]+)\.t$', template_name)
if not mo:
- raise ValueError, "Incorrectly formed template_name '%s'" % (template_name,)
+ raise ValueError("Incorrectly formed template_name '%s'" % (template_name,))
return mo.group (1)
def open_src (name, mode):
diff --git a/gr-utils/python/modtool/gr-newmod/python/build_utils_codes.py b/gr-utils/python/modtool/gr-newmod/python/build_utils_codes.py
index 9ea96baae4..22a6bdb99b 100644
--- a/gr-utils/python/modtool/gr-newmod/python/build_utils_codes.py
+++ b/gr-utils/python/modtool/gr-newmod/python/build_utils_codes.py
@@ -1,3 +1,4 @@
+from __future__ import unicode_literals
#
# Copyright 2004 Free Software Foundation, Inc.
#
diff --git a/gr-utils/python/modtool/grc_xml_generator.py b/gr-utils/python/modtool/grc_xml_generator.py
index af17ca1822..1109701f7e 100644
--- a/gr-utils/python/modtool/grc_xml_generator.py
+++ b/gr-utils/python/modtool/grc_xml_generator.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
#
# Copyright 2013 Free Software Foundation, Inc.
#
@@ -19,7 +20,7 @@
# Boston, MA 02110-1301, USA.
#
import xml.etree.ElementTree as ET
-from util_functions import is_number, xml_indent
+from .util_functions import is_number, xml_indent
try:
import lxml.etree
diff --git a/gr-utils/python/modtool/modtool_add.py b/gr-utils/python/modtool/modtool_add.py
index b39c4c3f06..acc0385ac4 100644
--- a/gr-utils/python/modtool/modtool_add.py
+++ b/gr-utils/python/modtool/modtool_add.py
@@ -20,14 +20,18 @@
#
""" Module to add new blocks """
+from __future__ import print_function
+from __future__ import absolute_import
+from __future__ import unicode_literals
+
import os
import re
-from util_functions import append_re_line_sequence, ask_yes_no, SequenceCompleter
-from cmakefile_editor import CMakeFileEditor
-from modtool_base import ModTool, ModToolException
-from templates import Templates
-from code_generator import render_template
+from .util_functions import append_re_line_sequence, ask_yes_no, SequenceCompleter
+from .cmakefile_editor import CMakeFileEditor
+from .modtool_base import ModTool, ModToolException
+from .templates import Templates
+from .code_generator import render_template
class ModToolAdd(ModTool):
""" Add block to the out-of-tree module. """
@@ -70,12 +74,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(str(self._block_types))
with SequenceCompleter(sorted(self._block_types)):
while self._info['blocktype'] not in self._block_types:
- self._info['blocktype'] = raw_input("Enter block type: ")
+ self._info['blocktype'] = 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
@@ -83,34 +87,34 @@ class ModToolAdd(ModTool):
language_candidates = ('c++', 'cpp', 'python')
with SequenceCompleter(language_candidates):
while self._info['lang'] not in language_candidates:
- self._info['lang'] = raw_input("Language (python/cpp): ")
+ self._info['lang'] = input("Language (python/cpp): ")
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')):
raise ModToolException('Missing or skipping relevant subdir.')
if self._info['blockname'] is None:
- self._info['blockname'] = raw_input("Enter name of block/code (without module name prefix): ")
+ self._info['blockname'] = 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:
self._info['arglist'] = options.argument_list
else:
- self._info['arglist'] = raw_input('Enter valid argument list, including default arguments: ')
+ self._info['arglist'] = input('Enter valid argument list, including default arguments: ')
if not (self._info['blocktype'] in ('noblock') or self._skip_subdirs['python']):
self._add_py_qa = options.add_python_qa
@@ -122,8 +126,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):
@@ -147,7 +151,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,))
@@ -201,7 +205,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':
@@ -222,9 +226,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'
@@ -241,9 +245,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 = '_'
@@ -270,11 +274,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))
@@ -311,8 +315,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 990e63af14..e0ae963f20 100644
--- a/gr-utils/python/modtool/modtool_base.py
+++ b/gr-utils/python/modtool/modtool_base.py
@@ -20,13 +20,17 @@
#
""" Base class for the modules """
+from __future__ import print_function
+from __future__ import absolute_import
+from __future__ import unicode_literals
+
import os
import re
from argparse import ArgumentParser, RawDescriptionHelpFormatter
from gnuradio import gr
-from util_functions import get_modname
-from scm import SCMRepoFactory
+from .util_functions import get_modname
+from .scm import SCMRepoFactory
class ModToolException(BaseException):
""" Standard exception for modtool classes. """
@@ -94,7 +98,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 +148,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 +160,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:
@@ -170,11 +174,11 @@ class ModTool(object):
has_makefile = True
# TODO search for autofoo
elif os.path.isdir(f):
- if (f in self._has_subdirs.keys()):
+ if (f in list(self._has_subdirs.keys())):
self._has_subdirs[f] = True
else:
self._skip_subdirs[f] = True
- return bool(has_makefile and (self._has_subdirs.values()))
+ return bool(has_makefile and (list(self._has_subdirs.values())))
def _get_mainswigfile(self):
""" Find out which name the main SWIG file has. In particular, is it
diff --git a/gr-utils/python/modtool/modtool_disable.py b/gr-utils/python/modtool/modtool_disable.py
index 1772a740f3..619858978d 100644
--- a/gr-utils/python/modtool/modtool_disable.py
+++ b/gr-utils/python/modtool/modtool_disable.py
@@ -20,12 +20,16 @@
#
""" Disable blocks module """
+from __future__ import print_function
+from __future__ import absolute_import
+from __future__ import unicode_literals
+
import os
import re
import sys
-from modtool_base import ModTool
-from cmakefile_editor import CMakeFileEditor
+from .modtool_base import ModTool
+from .cmakefile_editor import CMakeFileEditor
class ModToolDisable(ModTool):
@@ -46,7 +50,7 @@ class ModToolDisable(ModTool):
if options.blockname is not None:
self._info['pattern'] = options.blockname
else:
- self._info['pattern'] = raw_input('Which blocks do you want to disable? (Regex): ')
+ self._info['pattern'] = input('Which blocks do you want to disable? (Regex): ')
if len(self._info['pattern']) == 0:
self._info['pattern'] = '.'
@@ -62,7 +66,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 +97,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 +116,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,13 +139,13 @@ 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:
file_disabled = False
if not yes:
- ans = raw_input("Really disable %s? [Y/n/a/q]: " % fname).lower().strip()
+ ans = input("Really disable %s? [Y/n/a/q]: " % fname).lower().strip()
if ans == 'a':
yes = True
if ans == 'q':
@@ -155,5 +159,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 317948239e..4be302e03e 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,10 +19,14 @@
#
""" Returns information about a module """
+from __future__ import print_function
+from __future__ import absolute_import
+from __future__ import unicode_literals
+
import os
-from modtool_base import ModTool, ModToolException
-from util_functions import get_modname
+from .modtool_base import ModTool, ModToolException
+from .util_functions import get_modname
class ModToolInfo(ModTool):
@@ -70,7 +73,7 @@ class ModToolInfo(ModTool):
):
self._info['version'] = '37'
mod_info['version'] = self._info['version']
- if 'is_component' in self._info.keys() and self._info['is_component']:
+ if 'is_component' in list(self._info.keys()) and self._info['is_component']:
mod_info['is_component'] = True
mod_info['incdirs'] = []
mod_incl_dir = os.path.join(mod_info['base_dir'], 'include')
@@ -83,7 +86,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)
@@ -106,7 +109,7 @@ class ModToolInfo(ModTool):
If that hasn't happened, the build dir cannot be detected, unless it's
called 'build', which is then assumed to be the build dir. """
base_build_dir = mod_info['base_dir']
- if 'is_component' in mod_info.keys():
+ if 'is_component' in list(mod_info.keys()):
(base_build_dir, rest_dir) = os.path.split(base_build_dir)
has_build_dir = os.path.isdir(os.path.join(base_build_dir , 'build'))
if (has_build_dir and os.path.isfile(os.path.join(base_build_dir, 'CMakeCache.txt'))):
@@ -123,7 +126,7 @@ class ModToolInfo(ModTool):
""" Figure out include dirs for the make process. """
inc_dirs = []
path_or_internal = {True: 'INTERNAL',
- False: 'PATH'}['is_component' in mod_info.keys()]
+ False: 'PATH'}['is_component' in list(mod_info.keys())]
try:
cmakecache_fid = open(os.path.join(mod_info['build_dir'], 'CMakeCache.txt'))
for line in cmakecache_fid:
@@ -135,19 +138,19 @@ 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',
'is_component': 'Is GR component',
'build_dir': 'Build directory',
'incdirs': 'Include directories'}
- for key in mod_info.keys():
+ for key in list(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 311ed96cb4..74fed4b7a1 100644
--- a/gr-utils/python/modtool/modtool_makexml.py
+++ b/gr-utils/python/modtool/modtool_makexml.py
@@ -20,15 +20,19 @@
#
""" Automatically create XML bindings for GRC from block code """
+from __future__ import print_function
+from __future__ import absolute_import
+from __future__ import unicode_literals
+
import os
import re
import glob
-from modtool_base import ModTool, ModToolException
-from parser_cc_block import ParserCCBlock
-from grc_xml_generator import GRCXMLGenerator
-from cmakefile_editor import CMakeFileEditor
-from util_functions import ask_yes_no
+from .modtool_base import ModTool, ModToolException
+from .parser_cc_block import ParserCCBlock
+from .grc_xml_generator import GRCXMLGenerator
+from .cmakefile_editor import CMakeFileEditor
+from .util_functions import ask_yes_no
class ModToolMakeXML(ModTool):
@@ -54,13 +58,13 @@ class ModToolMakeXML(ModTool):
if options.blockname is not None:
self._info['pattern'] = options.blockname
else:
- self._info['pattern'] = raw_input('Which blocks do you want to parse? (Regex): ')
+ self._info['pattern'] = input('Which blocks do you want to parse? (Regex): ')
if len(self._info['pattern']) == 0:
self._info['pattern'] = '.'
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 +84,12 @@ class ModToolMakeXML(ModTool):
""" Search for files matching pattern in the given path. """
files = sorted(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 +114,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 +129,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 +162,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 4382d9be7d..c283204ee2 100644
--- a/gr-utils/python/modtool/modtool_newmod.py
+++ b/gr-utils/python/modtool/modtool_newmod.py
@@ -20,12 +20,16 @@
#
""" Create a whole new out-of-tree module """
+from __future__ import print_function
+from __future__ import absolute_import
+from __future__ import unicode_literals
+
import shutil
import os
import re
from gnuradio import gr
-from modtool_base import ModTool, ModToolException
-from scm import SCMRepoFactory
+from .modtool_base import ModTool, ModToolException
+from .scm import SCMRepoFactory
class ModToolNewModule(ModTool):
""" Create a new out-of-tree module """
@@ -49,7 +53,7 @@ class ModToolNewModule(ModTool):
if options.module_name:
self._info['modname'] = options.module_name
else:
- self._info['modname'] = raw_input('Name of the new module: ')
+ self._info['modname'] = input('Name of the new module: ')
if not re.match('[a-zA-Z0-9_]+$', self._info['modname']):
raise ModToolException('Invalid module name.')
self._dir = options.directory
@@ -76,7 +80,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 +97,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 6b1f6da11d..b9112fb8c4 100644
--- a/gr-utils/python/modtool/modtool_rename.py
+++ b/gr-utils/python/modtool/modtool_rename.py
@@ -20,13 +20,17 @@
#
""" Module to rename blocks """
+from __future__ import print_function
+from __future__ import absolute_import
+from __future__ import unicode_literals
+
import os
import re
-from util_functions import append_re_line_sequence, ask_yes_no
-from cmakefile_editor import CMakeFileEditor
-from modtool_base import ModTool, ModToolException
-from templates import Templates
+from .util_functions import append_re_line_sequence, ask_yes_no
+from .cmakefile_editor import CMakeFileEditor
+from .modtool_base import ModTool, ModToolException
+from .templates import Templates
class ModToolRename(ModTool):
""" Rename a block in the out-of-tree module. """
@@ -58,20 +62,20 @@ class ModToolRename(ModTool):
# first make sure the old block name is provided
self._info['oldname'] = options.blockname
if self._info['oldname'] is None:
- self._info['oldname'] = raw_input("Enter name of block/code to rename (without module name prefix): ")
+ self._info['oldname'] = 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
if options.new_name is None:
- self._info['newname'] = raw_input("Enter name of block/code (without module name prefix): ")
+ self._info['newname'] = input("Enter name of block/code (without module name prefix): ")
else:
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 +84,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 +97,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 +121,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 +129,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 +144,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 +170,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 +179,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 occurrences of '%s' to '%s'" % (filename, old, new)
+ print("In '%s' renaming occurrences 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 767cb6b083..b503fa2bf3 100644
--- a/gr-utils/python/modtool/modtool_rm.py
+++ b/gr-utils/python/modtool/modtool_rm.py
@@ -20,14 +20,18 @@
#
""" Remove blocks module """
+from __future__ import print_function
+from __future__ import absolute_import
+from __future__ import unicode_literals
+
import os
import re
import sys
import glob
-from util_functions import remove_pattern_from_file, SequenceCompleter
-from modtool_base import ModTool
-from cmakefile_editor import CMakeFileEditor
+from .util_functions import remove_pattern_from_file, SequenceCompleter
+from .modtool_base import ModTool
+from .cmakefile_editor import CMakeFileEditor
class ModToolRemove(ModTool):
@@ -49,7 +53,7 @@ class ModToolRemove(ModTool):
self._info['pattern'] = options.blockname
else:
with SequenceCompleter():
- self._info['pattern'] = raw_input('Which blocks do you want to delete? (Regex): ')
+ self._info['pattern'] = input('Which blocks do you want to delete? (Regex): ')
if len(self._info['pattern']) == 0:
self._info['pattern'] = '.'
@@ -133,12 +137,12 @@ class ModToolRemove(ModTool):
for g in globs:
files = files + sorted(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 = []
@@ -147,7 +151,7 @@ class ModToolRemove(ModTool):
for f in files_filt:
b = os.path.basename(f)
if not yes:
- ans = raw_input("Really delete %s? [Y/n/a/q]: " % f).lower().strip()
+ ans = input("Really delete %s? [Y/n/a/q]: " % f).lower().strip()
if ans == 'a':
yes = True
if ans == 'q':
@@ -155,10 +159,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 703522c8fb..fffdf309d8 100644
--- a/gr-utils/python/modtool/parser_cc_block.py
+++ b/gr-utils/python/modtool/parser_cc_block.py
@@ -19,6 +19,10 @@
# Boston, MA 02110-1301, USA.
#
''' A parser for blocks written in C++ '''
+
+from __future__ import print_function
+from __future__ import unicode_literals
+
import re
import sys
@@ -42,7 +46,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 +86,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 +217,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 9b0ef7db5e..5e80e24994 100644
--- a/gr-utils/python/modtool/scm.py
+++ b/gr-utils/python/modtool/scm.py
@@ -20,6 +20,9 @@
#
""" Class to handle source code management repositories. """
+from __future__ import print_function
+from __future__ import unicode_literals
+
import subprocess
try:
@@ -191,12 +194,12 @@ class SCMRepoFactory(object):
""" Returns a valid, usable object of type SCMRepository. """
if self.options.scm_mode == 'no':
return SCMRepository(self.path_to_repo)
- for glbl in globals().values():
+ for glbl in list(globals().values()):
try:
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
@@ -208,7 +211,7 @@ class SCMRepoFactory(object):
""" Returns a valid, usable object of type SCMRepository for an uninitialized dir. """
if self.options.scm_mode == 'no':
return SCMRepository(self.path_to_repo)
- for glbl in globals().values():
+ for glbl in list(globals().values()):
try:
if issubclass(glbl, SCMRepository):
if glbl.handles_scm_type == scm_type:
diff --git a/gr-utils/python/modtool/templates.py b/gr-utils/python/modtool/templates.py
index 3829f7a644..64c99802fe 100644
--- a/gr-utils/python/modtool/templates.py
+++ b/gr-utils/python/modtool/templates.py
@@ -19,6 +19,7 @@
# Boston, MA 02110-1301, USA.
#
''' All the templates for skeleton files (needed by ModToolAdd) '''
+from __future__ import unicode_literals
from datetime import datetime
diff --git a/gr-utils/python/modtool/util_functions.py b/gr-utils/python/modtool/util_functions.py
index 59f8984ca3..6ba73d82ac 100644
--- a/gr-utils/python/modtool/util_functions.py
+++ b/gr-utils/python/modtool/util_functions.py
@@ -20,6 +20,8 @@
#
""" Utility functions for gr_modtool """
+from __future__ import unicode_literals
+
import re
import sys
import readline
@@ -73,7 +75,7 @@ def strip_arg_types(string):
string = strip_default_values(string)
return ", ".join(
[part.strip().split(' ')[-1] for part in string.split(',')]
- ).translate(None, '*&')
+ ).translate(str.maketrans('','','*&'))
def strip_arg_types_grc(string):
"""" Strip the argument types from a list of arguments for GRC make tag.
@@ -98,7 +100,7 @@ def get_modname():
regexp = r'(project\s*\(\s*|GR_REGISTER_COMPONENT\(")gr-(?P<modname>[a-zA-Z0-9-_]+)(\s*(CXX)?|" ENABLE)'
try:
modname = re.search(regexp, cmfile, flags=re.MULTILINE).group('modname').strip()
- if modname in modname_trans.keys():
+ if modname in list(modname_trans.keys()):
modname = modname_trans[modname]
return modname
except AttributeError:
@@ -132,7 +134,7 @@ def ask_yes_no(question, default):
""" Asks a binary question. Returns True for yes, False for no.
default is given as a boolean. """
question += {True: ' [Y/n] ', False: ' [y/N] '}[default]
- if raw_input(question).lower() != {True: 'n', False: 'y'}[default]:
+ if input(question).lower() != {True: 'n', False: 'y'}[default]:
return default
else:
return not default
diff --git a/gr-utils/python/utils/gr_modtool b/gr-utils/python/utils/gr_modtool
index 7d035a6590..f959c91f66 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 ee644557bb..3199919fa9 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 653a2539b4..2ec54c3585 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 faf8106d70..4fd86549e2 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 c687f13b17..b4051fa15f 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 7409b73909..f27f75d412 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 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 f900af1bac..d367ea381f 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 a05e7ad2c7..1a94560ad2 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 7d80c714fe..a054147114 100644
--- a/gr-utils/python/utils/plot_data.py
+++ b/gr-utils/python/utils/plot_data.py
@@ -22,20 +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)
-class plot_data:
+class plot_data(object):
def __init__(self, datatype, filenames, options):
self.hfile = list()
self.legend_text = list()
@@ -86,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])
@@ -162,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 c99462147d..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 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):
@@ -228,9 +232,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 +247,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 2611ed4be2..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 argparse import ArgumentParser
from scipy import log10
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,
@@ -270,9 +274,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 +289,3 @@ if __name__ == "__main__":
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):