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_rm.py | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

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

diff --git a/gr-utils/python/modtool/modtool_rm.py b/gr-utils/python/modtool/modtool_rm.py
index eef743dd61..0cb012fe9e 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
-from modtool_base import ModTool
-from cmakefile_editor import CMakeFileEditor
+from .util_functions import remove_pattern_from_file
+from .modtool_base import ModTool
+from .cmakefile_editor import CMakeFileEditor
 
 
 class ModToolRemove(ModTool):
@@ -48,7 +52,7 @@ class ModToolRemove(ModTool):
         if options.blockname is not None:
             self._info['pattern'] = options.blockname
         else:
-            self._info['pattern'] = raw_input('Which blocks do you want to delete? (Regex): ')
+            self._info['pattern'] = eval(input('Which blocks do you want to delete? (Regex): '))
         if len(self._info['pattern']) == 0:
             self._info['pattern'] = '.'
 
@@ -132,12 +136,12 @@ class ModToolRemove(ModTool):
         for g in globs:
             files = files + glob.glob("%s/%s"% (path, g))
         files_filt = []
-        print "Searching for matching files in %s/:" % path
+        print("Searching for matching files in %s/:" % path)
         for f in files:
             if re.search(self._info['pattern'], os.path.basename(f)) is not None:
                 files_filt.append(f)
         if len(files_filt) == 0:
-            print "None found."
+            print("None found.")
             return []
         # 2. Delete files, Makefile entries and other occurrences
         files_deleted = []
@@ -146,7 +150,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':
@@ -154,10 +158,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:
-- 
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_rm.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