From 9e625c4821f4c63421b3d3747c0c4f358fef6c5f Mon Sep 17 00:00:00 2001
From: Douglas Anderson <danderson@ntia.doc.gov>
Date: Sun, 12 Feb 2017 15:52:19 -0800
Subject: python3: update non-GRC components to use python2 or python3

---
 gr-utils/python/modtool/modtool_disable.py | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

(limited to 'gr-utils/python/modtool/modtool_disable.py')

diff --git a/gr-utils/python/modtool/modtool_disable.py b/gr-utils/python/modtool/modtool_disable.py
index 1772a740f3..629a810cb0 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'] = eval(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.")
 
-- 
cgit v1.2.3


From 5ee319cb49a5a344521f33b123b4ad0d0927163a Mon Sep 17 00:00:00 2001
From: Håkon Vågsether <haakonsv@gmail.com>
Date: Mon, 21 Aug 2017 11:35:08 +0200
Subject: Fix typos from switch to Python 3

---
 docs/exploring-gnuradio/dial_tone.py                  | 2 +-
 docs/exploring-gnuradio/fm_demod.py                   | 2 +-
 gnuradio-runtime/examples/mp-sched/affinity_set.py    | 2 +-
 gnuradio-runtime/python/gnuradio/gru/gnuplot_freqz.py | 2 +-
 gr-uhd/apps/uhd_siggen_base.py                        | 2 +-
 gr-utils/python/modtool/modtool_add.py                | 8 ++++----
 gr-utils/python/modtool/modtool_disable.py            | 2 +-
 gr-utils/python/modtool/modtool_makexml.py            | 2 +-
 gr-utils/python/modtool/modtool_newmod.py             | 2 +-
 gr-utils/python/modtool/modtool_rename.py             | 4 ++--
 gr-utils/python/modtool/modtool_rm.py                 | 2 +-
 gr-vocoder/examples/alaw_audio_loopback.py            | 2 +-
 gr-vocoder/examples/codec2_audio_loopback.py          | 2 +-
 gr-vocoder/examples/cvsd_audio_loopback.py            | 2 +-
 gr-vocoder/examples/g721_audio_loopback.py            | 2 +-
 gr-vocoder/examples/g723_24_audio_loopback.py         | 2 +-
 gr-vocoder/examples/g723_40_audio_loopback.py         | 2 +-
 gr-vocoder/examples/gsm_audio_loopback.py             | 2 +-
 gr-vocoder/examples/ulaw_audio_loopback.py            | 2 +-
 19 files changed, 23 insertions(+), 23 deletions(-)

(limited to 'gr-utils/python/modtool/modtool_disable.py')

diff --git a/docs/exploring-gnuradio/dial_tone.py b/docs/exploring-gnuradio/dial_tone.py
index 42cbf3c9d0..08498a84e0 100644
--- a/docs/exploring-gnuradio/dial_tone.py
+++ b/docs/exploring-gnuradio/dial_tone.py
@@ -41,5 +41,5 @@ def build_graph():
 if __name__ == '__main__':
     tb = build_graph()
     tb.start()
-    eval(input('Press Enter to quit: '))
+    input('Press Enter to quit: ')
     tb.stop()
diff --git a/docs/exploring-gnuradio/fm_demod.py b/docs/exploring-gnuradio/fm_demod.py
index 71d7f64c82..a297e78a76 100644
--- a/docs/exploring-gnuradio/fm_demod.py
+++ b/docs/exploring-gnuradio/fm_demod.py
@@ -82,7 +82,7 @@ class build_graph(gr.top_block):
 def main(args):
     tb = build_graph()
     tb.start()        # fork thread and return
-    eval(input('Press Enter to quit: '))
+    input('Press Enter to quit: ')
     tb.stop()
 
 if __name__ == '__main__':
diff --git a/gnuradio-runtime/examples/mp-sched/affinity_set.py b/gnuradio-runtime/examples/mp-sched/affinity_set.py
index b717e1e506..a253c8081c 100644
--- a/gnuradio-runtime/examples/mp-sched/affinity_set.py
+++ b/gnuradio-runtime/examples/mp-sched/affinity_set.py
@@ -59,7 +59,7 @@ if __name__ == '__main__':
     tb.start()
 
     while(1):
-        ret = eval(input('Enter a new Core # or Press Enter to quit: '))
+        ret = input('Enter a new Core # or Press Enter to quit: ')
 	if(len(ret) == 0):
             tb.stop()
 	    sys.exit(0)
diff --git a/gnuradio-runtime/python/gnuradio/gru/gnuplot_freqz.py b/gnuradio-runtime/python/gnuradio/gru/gnuplot_freqz.py
index 5a1ea91cad..71aee11f0b 100644
--- a/gnuradio-runtime/python/gnuradio/gru/gnuplot_freqz.py
+++ b/gnuradio-runtime/python/gnuradio/gru/gnuplot_freqz.py
@@ -101,4 +101,4 @@ def test_plot ():
 
 if __name__ == '__main__':
     handle = test_plot ()
-    eval(input ('Press Enter to continue: '))
+    input ('Press Enter to continue: ')
diff --git a/gr-uhd/apps/uhd_siggen_base.py b/gr-uhd/apps/uhd_siggen_base.py
index 98dda1084b..9714810cdd 100644
--- a/gr-uhd/apps/uhd_siggen_base.py
+++ b/gr-uhd/apps/uhd_siggen_base.py
@@ -295,7 +295,7 @@ def main():
         print(ex)
         exit(1)
     tb.start()
-    eval(input('[UHD-SIGGEN] Press Enter to quit:\n'))
+    input('[UHD-SIGGEN] Press Enter to quit:\n')
     tb.stop()
     tb.wait()
 
diff --git a/gr-utils/python/modtool/modtool_add.py b/gr-utils/python/modtool/modtool_add.py
index 74f11318d0..8c5eed29ec 100644
--- a/gr-utils/python/modtool/modtool_add.py
+++ b/gr-utils/python/modtool/modtool_add.py
@@ -76,14 +76,14 @@ class ModToolAdd(ModTool):
             # 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'] = eval(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))
         # Allow user to specify language interactively if not set
         self._info['lang'] = options.lang
         if self._info['lang'] is None:
             while self._info['lang'] not in ['c++', 'cpp', 'python']:
-                self._info['lang'] = eval(input("Language (python/cpp): "))
+                self._info['lang'] = input("Language (python/cpp): ")
         if self._info['lang'] == 'c++':
             self._info['lang'] = 'cpp'
 
@@ -94,7 +94,7 @@ class ModToolAdd(ModTool):
             raise ModToolException('Missing or skipping relevant subdir.')
 
         if self._info['blockname'] is None:
-            self._info['blockname'] = eval(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'])
@@ -110,7 +110,7 @@ class ModToolAdd(ModTool):
         if options.argument_list is not None:
             self._info['arglist'] = options.argument_list
         else:
-            self._info['arglist'] = eval(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
diff --git a/gr-utils/python/modtool/modtool_disable.py b/gr-utils/python/modtool/modtool_disable.py
index 629a810cb0..619858978d 100644
--- a/gr-utils/python/modtool/modtool_disable.py
+++ b/gr-utils/python/modtool/modtool_disable.py
@@ -50,7 +50,7 @@ class ModToolDisable(ModTool):
         if options.blockname is not None:
             self._info['pattern'] = options.blockname
         else:
-            self._info['pattern'] = eval(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'] = '.'
 
diff --git a/gr-utils/python/modtool/modtool_makexml.py b/gr-utils/python/modtool/modtool_makexml.py
index dffd403a37..74fed4b7a1 100644
--- a/gr-utils/python/modtool/modtool_makexml.py
+++ b/gr-utils/python/modtool/modtool_makexml.py
@@ -58,7 +58,7 @@ class ModToolMakeXML(ModTool):
         if options.blockname is not None:
             self._info['pattern'] = options.blockname
         else:
-            self._info['pattern'] = eval(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'] = '.'
 
diff --git a/gr-utils/python/modtool/modtool_newmod.py b/gr-utils/python/modtool/modtool_newmod.py
index b3e384d122..c283204ee2 100644
--- a/gr-utils/python/modtool/modtool_newmod.py
+++ b/gr-utils/python/modtool/modtool_newmod.py
@@ -53,7 +53,7 @@ class ModToolNewModule(ModTool):
             if options.module_name:
                 self._info['modname'] = options.module_name
             else:
-                self._info['modname'] = eval(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
diff --git a/gr-utils/python/modtool/modtool_rename.py b/gr-utils/python/modtool/modtool_rename.py
index 4973aa9e78..c2229f28fb 100644
--- a/gr-utils/python/modtool/modtool_rename.py
+++ b/gr-utils/python/modtool/modtool_rename.py
@@ -62,7 +62,7 @@ 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'] = eval(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'])
@@ -70,7 +70,7 @@ class ModToolRename(ModTool):
 
         # now get the new block name
         if options.new_name is None:
-            self._info['newname'] = eval(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']):
diff --git a/gr-utils/python/modtool/modtool_rm.py b/gr-utils/python/modtool/modtool_rm.py
index 248d1b7ca8..dffd5c2e45 100644
--- a/gr-utils/python/modtool/modtool_rm.py
+++ b/gr-utils/python/modtool/modtool_rm.py
@@ -52,7 +52,7 @@ class ModToolRemove(ModTool):
         if options.blockname is not None:
             self._info['pattern'] = options.blockname
         else:
-            self._info['pattern'] = eval(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'] = '.'
 
diff --git a/gr-vocoder/examples/alaw_audio_loopback.py b/gr-vocoder/examples/alaw_audio_loopback.py
index 6f43322470..7dbcbb209c 100644
--- a/gr-vocoder/examples/alaw_audio_loopback.py
+++ b/gr-vocoder/examples/alaw_audio_loopback.py
@@ -43,6 +43,6 @@ def build_graph():
 if __name__ == '__main__':
     tb = build_graph()
     tb.start()
-    eval(input ('Press Enter to exit: '))
+    input ('Press Enter to exit: ')
     tb.stop()
     tb.wait()
diff --git a/gr-vocoder/examples/codec2_audio_loopback.py b/gr-vocoder/examples/codec2_audio_loopback.py
index 9c51d2f49c..ea690861aa 100644
--- a/gr-vocoder/examples/codec2_audio_loopback.py
+++ b/gr-vocoder/examples/codec2_audio_loopback.py
@@ -44,6 +44,6 @@ def build_graph():
 if __name__ == '__main__':
     tb = build_graph()
     tb.start()
-    eval(input ('Press Enter to exit: '))
+    input ('Press Enter to exit: ')
     tb.stop()
     tb.wait()
diff --git a/gr-vocoder/examples/cvsd_audio_loopback.py b/gr-vocoder/examples/cvsd_audio_loopback.py
index 603a7194a4..15074d62cd 100644
--- a/gr-vocoder/examples/cvsd_audio_loopback.py
+++ b/gr-vocoder/examples/cvsd_audio_loopback.py
@@ -67,6 +67,6 @@ def build_graph():
 if __name__ == '__main__':
     tb = build_graph()
     tb.start()
-    eval(input ('Press Enter to exit: '))
+    input ('Press Enter to exit: ')
     tb.stop()
     tb.wait()
diff --git a/gr-vocoder/examples/g721_audio_loopback.py b/gr-vocoder/examples/g721_audio_loopback.py
index 790cbfcb48..afe9b04b91 100644
--- a/gr-vocoder/examples/g721_audio_loopback.py
+++ b/gr-vocoder/examples/g721_audio_loopback.py
@@ -43,6 +43,6 @@ def build_graph():
 if __name__ == '__main__':
     tb = build_graph()
     tb.start()
-    eval(input ('Press Enter to exit: '))
+    input ('Press Enter to exit: ')
     tb.stop()
     tb.wait()
diff --git a/gr-vocoder/examples/g723_24_audio_loopback.py b/gr-vocoder/examples/g723_24_audio_loopback.py
index 7390aa0151..62e58c1412 100644
--- a/gr-vocoder/examples/g723_24_audio_loopback.py
+++ b/gr-vocoder/examples/g723_24_audio_loopback.py
@@ -43,6 +43,6 @@ def build_graph():
 if __name__ == '__main__':
     tb = build_graph()
     tb.start()
-    eval(input ('Press Enter to exit: '))
+    input ('Press Enter to exit: ')
     tb.stop()
     tb.wait()
diff --git a/gr-vocoder/examples/g723_40_audio_loopback.py b/gr-vocoder/examples/g723_40_audio_loopback.py
index c016193382..edc8f5716e 100644
--- a/gr-vocoder/examples/g723_40_audio_loopback.py
+++ b/gr-vocoder/examples/g723_40_audio_loopback.py
@@ -43,6 +43,6 @@ def build_graph():
 if __name__ == '__main__':
     tb = build_graph()
     tb.start()
-    eval(input ('Press Enter to exit: '))
+    input ('Press Enter to exit: ')
     tb.stop()
     tb.wait()
diff --git a/gr-vocoder/examples/gsm_audio_loopback.py b/gr-vocoder/examples/gsm_audio_loopback.py
index b21b9da410..c71e6fd384 100644
--- a/gr-vocoder/examples/gsm_audio_loopback.py
+++ b/gr-vocoder/examples/gsm_audio_loopback.py
@@ -43,6 +43,6 @@ def build_graph():
 if __name__ == '__main__':
     tb = build_graph()
     tb.start()
-    eval(input ('Press Enter to exit: '))
+    input ('Press Enter to exit: ')
     tb.stop()
     tb.wait()
diff --git a/gr-vocoder/examples/ulaw_audio_loopback.py b/gr-vocoder/examples/ulaw_audio_loopback.py
index aeb7411e0b..6a8a493f30 100644
--- a/gr-vocoder/examples/ulaw_audio_loopback.py
+++ b/gr-vocoder/examples/ulaw_audio_loopback.py
@@ -43,6 +43,6 @@ def build_graph():
 if __name__ == '__main__':
     tb = build_graph()
     tb.start()
-    eval(input ('Press Enter to exit: '))
+    input ('Press Enter to exit: ')
     tb.stop()
     tb.wait()
-- 
cgit v1.2.3