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-blocks/python/blocks/qa_bin_statistics.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) mode change 100755 => 100644 gr-blocks/python/blocks/qa_bin_statistics.py (limited to 'gr-blocks/python/blocks/qa_bin_statistics.py') diff --git a/gr-blocks/python/blocks/qa_bin_statistics.py b/gr-blocks/python/blocks/qa_bin_statistics.py old mode 100755 new mode 100644 index 52b8585721..e6bdfaca5b --- a/gr-blocks/python/blocks/qa_bin_statistics.py +++ b/gr-blocks/python/blocks/qa_bin_statistics.py @@ -20,17 +20,21 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gr_unittest, blocks - -import random -import struct - """ Note: There has been an issue with this block in the past, see Issue #199. This test is being enabled only on the 'next' branch for version v3.7 for now. TWR """ +from __future__ import print_function + +import struct + +import six + +from gnuradio import gr, gr_unittest, blocks + + class counter(gr.feval_dd): def __init__(self, step_size=1): gr.feval_dd.__init__(self) @@ -57,8 +61,8 @@ class counter3(gr.feval_dd): t = self.count self.count = self.count + self.step_size self.f(self.count) - except Exception, e: - print "Exception: ", e + except Exception as e: + print("Exception: ", e) return t def foobar3(new_t): @@ -79,8 +83,8 @@ class counter4(gr.feval_dd): t = self.count self.count = self.count + self.step_size self.obj_instance.foobar4(self.count) - except Exception, e: - print "Exception: ", e + except Exception as e: + print("Exception: ", e) return t @@ -89,7 +93,8 @@ class parse_msg(object): self.center_freq = msg.arg1() self.vlen = int(msg.arg2()) assert(msg.length() == self.vlen * gr.sizeof_float) - self.data = struct.unpack('%df' % (self.vlen,), msg.to_string()) + self.data = struct.unpack(b'%df' % self.vlen, six.b(msg.to_string())) + class test_bin_statistics(gr_unittest.TestCase): -- cgit v1.2.3