summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/python/gnuradio/gr
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-runtime/python/gnuradio/gr')
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt4
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/__init__.py18
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/exceptions.py1
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/gateway.py15
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/gr_threading.py6
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/gr_threading_23.py26
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/gr_threading_24.py26
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/hier_block2.py3
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/packet_utils.py13
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/pubsub.py89
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/python/gnuradio/gr/qa_feval.py1
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/python/gnuradio/gr/qa_flowgraph.py1
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/qa_hier_block2.py8
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/python/gnuradio/gr/qa_kludged_imports.py1
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/qa_random.py1
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/python/gnuradio/gr/qa_tag_utils.py10
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/tag_utils.py17
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/top_block.py15
18 files changed, 145 insertions, 110 deletions
diff --git a/gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt b/gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt
index 30d3d88fd8..1b535ef997 100644
--- a/gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt
+++ b/gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt
@@ -22,6 +22,7 @@ include(GrPython)
GR_PYTHON_INSTALL(FILES
__init__.py
+ exceptions.py
tag_utils.py
packet_utils.py
gateway.py
@@ -32,7 +33,6 @@ GR_PYTHON_INSTALL(FILES
top_block.py
pubsub.py
DESTINATION ${GR_PYTHON_DIR}/gnuradio/gr
- COMPONENT "runtime_python"
)
########################################################################
@@ -54,6 +54,6 @@ if(ENABLE_TESTING)
file(GLOB py_qa_test_files "qa_*.py")
foreach(py_qa_test_file ${py_qa_test_files})
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
- GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file})
+ GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
endforeach(py_qa_test_file)
endif(ENABLE_TESTING)
diff --git a/gnuradio-runtime/python/gnuradio/gr/__init__.py b/gnuradio-runtime/python/gnuradio/gr/__init__.py
index cdfa1a3157..6ec5074fff 100644
--- a/gnuradio-runtime/python/gnuradio/gr/__init__.py
+++ b/gnuradio-runtime/python/gnuradio/gr/__init__.py
@@ -24,6 +24,8 @@
"""
Core contents.
"""
+from __future__ import absolute_import
+from __future__ import unicode_literals
# This is the main GNU Radio python module.
# We pull the swig output and the other modules into the gnuradio.gr namespace
@@ -31,20 +33,20 @@ Core contents.
# If gnuradio is installed then the swig output will be in this directory.
# Otherwise it will reside in ../../../swig.
-import os
+import os, sys
try:
- from runtime_swig import *
+ from .runtime_swig import *
except ImportError:
dirname, filename = os.path.split(os.path.abspath(__file__))
__path__.append(os.path.join(dirname, "..", "..", "..", "swig"))
- from runtime_swig import *
+ from .runtime_swig import *
-from exceptions import *
-from top_block import *
-from hier_block2 import *
-from tag_utils import *
-from gateway import basic_block, sync_block, decim_block, interp_block, py_io_signature
+from .exceptions import *
+from .top_block import *
+from .hier_block2 import *
+from .tag_utils import *
+from .gateway import basic_block, sync_block, decim_block, interp_block, py_io_signature
# Force the preference database to be initialized
prefs = prefs.singleton
diff --git a/gnuradio-runtime/python/gnuradio/gr/exceptions.py b/gnuradio-runtime/python/gnuradio/gr/exceptions.py
index dba04750bc..1b7fd025b7 100644
--- a/gnuradio-runtime/python/gnuradio/gr/exceptions.py
+++ b/gnuradio-runtime/python/gnuradio/gr/exceptions.py
@@ -1,3 +1,4 @@
+from __future__ import unicode_literals
#
# Copyright 2004 Free Software Foundation, Inc.
#
diff --git a/gnuradio-runtime/python/gnuradio/gr/gateway.py b/gnuradio-runtime/python/gnuradio/gr/gateway.py
index 4498729825..4eaa8745ac 100644
--- a/gnuradio-runtime/python/gnuradio/gr/gateway.py
+++ b/gnuradio-runtime/python/gnuradio/gr/gateway.py
@@ -19,18 +19,23 @@
# Boston, MA 02110-1301, USA.
#
-import runtime_swig as gr
-from runtime_swig import io_signature, io_signaturev
-from runtime_swig import block_gw_message_type
-from runtime_swig import block_gateway
+from __future__ import print_function
+from __future__ import unicode_literals
+
+
import numpy
+from . import runtime_swig as gr
+from .runtime_swig import io_signature, io_signaturev
+from .runtime_swig import block_gw_message_type
+from .runtime_swig import block_gateway
+
########################################################################
# Magic to turn pointers into numpy arrays
# http://docs.scipy.org/doc/numpy/reference/arrays.interface.html
########################################################################
def pointer_to_ndarray(addr, dtype, nitems):
- class array_like:
+ class array_like(object):
__array_interface__ = {
'data' : (int(addr), False),
'typestr' : dtype.base.str,
diff --git a/gnuradio-runtime/python/gnuradio/gr/gr_threading.py b/gnuradio-runtime/python/gnuradio/gr/gr_threading.py
index 5d6f0fdaf9..cb0519f6f6 100644
--- a/gnuradio-runtime/python/gnuradio/gr/gr_threading.py
+++ b/gnuradio-runtime/python/gnuradio/gr/gr_threading.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+from __future__ import unicode_literals
#
# Copyright 2005 Free Software Foundation, Inc.
#
@@ -25,10 +27,10 @@ from sys import version_info as _version_info
if _version_info[0:2] == (2, 3):
#print "Importing gr_threading_23"
- from gr_threading_23 import *
+ from .gr_threading_23 import *
elif _version_info[0:2] == (2, 4):
#print "Importing gr_threading_24"
- from gr_threading_24 import *
+ from .gr_threading_24 import *
else:
# assume the patch was applied...
#print "Importing system provided threading"
diff --git a/gnuradio-runtime/python/gnuradio/gr/gr_threading_23.py b/gnuradio-runtime/python/gnuradio/gr/gr_threading_23.py
index 795c1593d4..f4f062f715 100644
--- a/gnuradio-runtime/python/gnuradio/gr/gr_threading_23.py
+++ b/gnuradio-runtime/python/gnuradio/gr/gr_threading_23.py
@@ -4,15 +4,18 @@
# It's been patched to fix a problem with join, where a KeyboardInterrupt
# caused a lock to be left in the acquired state.
+from __future__ import print_function
+from __future__ import unicode_literals
+
import sys as _sys
try:
- import thread
+ import _thread
except ImportError:
del _sys.modules[__name__]
raise
-from StringIO import StringIO as _StringIO
+from io import StringIO as _StringIO
from time import time as _time, sleep as _sleep
from traceback import print_exc as _print_exc
@@ -21,11 +24,11 @@ __all__ = ['activeCount', 'Condition', 'currentThread', 'enumerate', 'Event',
'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread',
'Timer', 'setprofile', 'settrace']
-_start_new_thread = thread.start_new_thread
-_allocate_lock = thread.allocate_lock
-_get_ident = thread.get_ident
-ThreadError = thread.error
-del thread
+_start_new_thread = _thread.start_new_thread
+_allocate_lock = _thread.allocate_lock
+_get_ident = _thread.get_ident
+ThreadError = _thread.error
+del _thread
# Debug support (adapted from ihooks.py).
@@ -127,8 +130,9 @@ class _RLock(_Verbose):
# Internal methods used by condition variables
- def _acquire_restore(self, (count, owner)):
+ def _acquire_restore(self, lock):
self.__block.acquire()
+ count, owner = lock
self.__count = count
self.__owner = owner
if __debug__:
@@ -313,7 +317,7 @@ class _BoundedSemaphore(_Semaphore):
def release(self):
if self._Semaphore__value >= self._initial_value:
- raise ValueError, "Semaphore released too many times"
+ raise ValueError("Semaphore released too many times")
return _Semaphore.release(self)
@@ -627,7 +631,7 @@ def activeCount():
def enumerate():
_active_limbo_lock.acquire()
- active = _active.values() + _limbo.values()
+ active = list(_active.values()) + list(_limbo.values())
_active_limbo_lock.release()
return active
@@ -698,7 +702,7 @@ def _test():
def run(self):
while self.count > 0:
item = self.queue.get()
- print item
+ print(item)
self.count = self.count - 1
NP = 3
diff --git a/gnuradio-runtime/python/gnuradio/gr/gr_threading_24.py b/gnuradio-runtime/python/gnuradio/gr/gr_threading_24.py
index 8ad880b090..6dddce7e22 100644
--- a/gnuradio-runtime/python/gnuradio/gr/gr_threading_24.py
+++ b/gnuradio-runtime/python/gnuradio/gr/gr_threading_24.py
@@ -4,10 +4,13 @@
# It's been patched to fix a problem with join, where a KeyboardInterrupt
# caused a lock to be left in the acquired state.
+from __future__ import print_function
+from __future__ import unicode_literals
+
import sys as _sys
try:
- import thread
+ import _thread
except ImportError:
del _sys.modules[__name__]
raise
@@ -21,11 +24,11 @@ __all__ = ['activeCount', 'Condition', 'currentThread', 'enumerate', 'Event',
'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread',
'Timer', 'setprofile', 'settrace', 'local']
-_start_new_thread = thread.start_new_thread
-_allocate_lock = thread.allocate_lock
-_get_ident = thread.get_ident
-ThreadError = thread.error
-del thread
+_start_new_thread = _thread.start_new_thread
+_allocate_lock = _thread.allocate_lock
+_get_ident = _thread.get_ident
+ThreadError = _thread.error
+del _thread
# Debug support (adapted from ihooks.py).
@@ -127,8 +130,9 @@ class _RLock(_Verbose):
# Internal methods used by condition variables
- def _acquire_restore(self, (count, owner)):
+ def _acquire_restore(self, lock):
self.__block.acquire()
+ count, owner = lock
self.__count = count
self.__owner = owner
if __debug__:
@@ -311,7 +315,7 @@ class _BoundedSemaphore(_Semaphore):
def release(self):
if self._Semaphore__value >= self._initial_value:
- raise ValueError, "Semaphore released too many times"
+ raise ValueError("Semaphore released too many times")
return _Semaphore.release(self)
@@ -688,7 +692,7 @@ def activeCount():
def enumerate():
_active_limbo_lock.acquire()
- active = _active.values() + _limbo.values()
+ active = list(_active.values()) + list(_limbo.values())
_active_limbo_lock.release()
return active
@@ -700,7 +704,7 @@ _MainThread()
# module, or from the python fallback
try:
- from thread import _local as local
+ from _thread import _local as local
except ImportError:
from _threading_local import local
@@ -767,7 +771,7 @@ def _test():
def run(self):
while self.count > 0:
item = self.queue.get()
- print item
+ print(item)
self.count = self.count - 1
NP = 3
diff --git a/gnuradio-runtime/python/gnuradio/gr/hier_block2.py b/gnuradio-runtime/python/gnuradio/gr/hier_block2.py
index 3f4c6aa9c7..8d0533c71c 100644
--- a/gnuradio-runtime/python/gnuradio/gr/hier_block2.py
+++ b/gnuradio-runtime/python/gnuradio/gr/hier_block2.py
@@ -1,3 +1,4 @@
+from __future__ import unicode_literals
#
# Copyright 2006,2007,2014 Free Software Foundation, Inc.
#
@@ -21,7 +22,7 @@
import functools
-from runtime_swig import hier_block2_swig, dot_graph
+from .runtime_swig import hier_block2_swig, dot_graph
import pmt
diff --git a/gnuradio-runtime/python/gnuradio/gr/packet_utils.py b/gnuradio-runtime/python/gnuradio/gr/packet_utils.py
index 720cfd962f..770a5c0b36 100644
--- a/gnuradio-runtime/python/gnuradio/gr/packet_utils.py
+++ b/gnuradio-runtime/python/gnuradio/gr/packet_utils.py
@@ -20,6 +20,9 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import division
+from __future__ import unicode_literals
from gnuradio import gr
import pmt
@@ -28,9 +31,9 @@ def make_lengthtags(lengths, offsets, tagname='length', vlen=1):
assert(len(offsets) == len(lengths))
for offset, length in zip(offsets, lengths):
tag = gr.tag_t()
- tag.offset = offset/vlen
+ tag.offset = offset // vlen
tag.key = pmt.string_to_symbol(tagname)
- tag.value = pmt.from_long(length/vlen)
+ tag.value = pmt.from_long(length // vlen)
tags.append(tag)
return tags
@@ -73,7 +76,7 @@ def count_bursts(data, tags, tsb_tag_key, vlen=1):
if pos in lengths:
if in_packet:
print("Got tag at pos {0} current packet_pos is {1}".format(pos, packet_pos))
- raise StandardError("Received packet tag while in packet.")
+ raise Exception("Received packet tag while in packet.")
packet_pos = -1
packet_length = lengths[pos]
in_packet = True
@@ -128,9 +131,9 @@ def packets_to_vectors(packets, tsb_tag_key, vlen=1):
for packet in packets:
data.extend(packet)
tag = gr.tag_t()
- tag.offset = offset/vlen
+ tag.offset = offset // vlen
tag.key = pmt.string_to_symbol(tsb_tag_key)
- tag.value = pmt.from_long(len(packet)/vlen)
+ tag.value = pmt.from_long(len(packet) // vlen)
tags.append(tag)
offset = offset + len(packet)
return data, tags
diff --git a/gnuradio-runtime/python/gnuradio/gr/pubsub.py b/gnuradio-runtime/python/gnuradio/gr/pubsub.py
index 90568418fc..25108b8f70 100644
--- a/gnuradio-runtime/python/gnuradio/gr/pubsub.py
+++ b/gnuradio-runtime/python/gnuradio/gr/pubsub.py
@@ -26,43 +26,46 @@ Abstract GNU Radio publisher/subscriber interface
This is a proof of concept implementation, will likely change significantly.
"""
+from __future__ import print_function
+from __future__ import unicode_literals
+
class pubsub(dict):
def __init__(self):
- self._publishers = { }
- self._subscribers = { }
- self._proxies = { }
+ self._publishers = { }
+ self._subscribers = { }
+ self._proxies = { }
def __missing__(self, key, value=None):
- dict.__setitem__(self, key, value)
- self._publishers[key] = None
- self._subscribers[key] = []
- self._proxies[key] = None
+ dict.__setitem__(self, key, value)
+ self._publishers[key] = None
+ self._subscribers[key] = []
+ self._proxies[key] = None
def __setitem__(self, key, val):
- if not self.has_key(key):
- self.__missing__(key, val)
- elif self._proxies[key] is not None:
- (p, newkey) = self._proxies[key]
- p[newkey] = val
- else:
- dict.__setitem__(self, key, val)
- for sub in self._subscribers[key]:
- # Note this means subscribers will get called in the thread
- # context of the 'set' caller.
- sub(val)
+ if key not in self:
+ self.__missing__(key, val)
+ elif self._proxies[key] is not None:
+ (p, newkey) = self._proxies[key]
+ p[newkey] = val
+ else:
+ dict.__setitem__(self, key, val)
+ for sub in self._subscribers[key]:
+ # Note this means subscribers will get called in the thread
+ # context of the 'set' caller.
+ sub(val)
def __getitem__(self, key):
- if not self.has_key(key): self.__missing__(key)
- if self._proxies[key] is not None:
- (p, newkey) = self._proxies[key]
- return p[newkey]
- elif self._publishers[key] is not None:
- return self._publishers[key]()
- else:
- return dict.__getitem__(self, key)
+ if key not in self: self.__missing__(key)
+ if self._proxies[key] is not None:
+ (p, newkey) = self._proxies[key]
+ return p[newkey]
+ elif self._publishers[key] is not None:
+ return self._publishers[key]()
+ else:
+ return dict.__getitem__(self, key)
def publish(self, key, publisher):
- if not self.has_key(key): self.__missing__(key)
+ if key not in self: self.__missing__(key)
if self._proxies[key] is not None:
(p, newkey) = self._proxies[key]
p.publish(newkey, publisher)
@@ -70,7 +73,7 @@ class pubsub(dict):
self._publishers[key] = publisher
def subscribe(self, key, subscriber):
- if not self.has_key(key): self.__missing__(key)
+ if key not in self: self.__missing__(key)
if self._proxies[key] is not None:
(p, newkey) = self._proxies[key]
p.subscribe(newkey, subscriber)
@@ -92,9 +95,9 @@ class pubsub(dict):
self._subscribers[key].remove(subscriber)
def proxy(self, key, p, newkey=None):
- if not self.has_key(key): self.__missing__(key)
- if newkey is None: newkey = key
- self._proxies[key] = (p, newkey)
+ if key not in self: self.__missing__(key)
+ if newkey is None: newkey = key
+ self._proxies[key] = (p, newkey)
def unproxy(self, key):
self._proxies[key] = None
@@ -105,49 +108,49 @@ if __name__ == "__main__":
o = pubsub()
# Non-existent key gets auto-created with None value
- print "Auto-created key 'foo' value:", o['foo']
+ print("Auto-created key 'foo' value:", o['foo'])
# Add some subscribers
# First is a bare function
def print_len(x):
- print "len=%i" % (len(x), )
+ print("len=%i" % (len(x), ))
o.subscribe('foo', print_len)
# The second is a class member function
class subber(object):
- def __init__(self, param):
- self._param = param
- def printer(self, x):
- print self._param, `x`
+ def __init__(self, param):
+ self._param = param
+ def printer(self, x):
+ print(self._param, repr(x))
s = subber('param')
o.subscribe('foo', s.printer)
# The third is a lambda function
- o.subscribe('foo', lambda x: sys.stdout.write('val='+`x`+'\n'))
+ o.subscribe('foo', lambda x: sys.stdout.write('val='+repr(x)+'\n'))
# Update key 'foo', will notify subscribers
- print "Updating 'foo' with three subscribers:"
+ print("Updating 'foo' with three subscribers:")
o['foo'] = 'bar';
# Remove first subscriber
o.unsubscribe('foo', print_len)
# Update now will only trigger second and third subscriber
- print "Updating 'foo' after removing a subscriber:"
+ print("Updating 'foo' after removing a subscriber:")
o['foo'] = 'bar2';
# Publish a key as a function, in this case, a lambda function
o.publish('baz', lambda : 42)
- print "Published value of 'baz':", o['baz']
+ print("Published value of 'baz':", o['baz'])
# Unpublish the key
o.unpublish('baz')
# This will return None, as there is no publisher
- print "Value of 'baz' with no publisher:", o['baz']
+ print("Value of 'baz' with no publisher:", o['baz'])
# Set 'baz' key, it gets cached
o['baz'] = 'bazzz'
# Now will return cached value, since no provider
- print "Cached value of 'baz' after being set:", o['baz']
+ print("Cached value of 'baz' after being set:", o['baz'])
diff --git a/gnuradio-runtime/python/gnuradio/gr/qa_feval.py b/gnuradio-runtime/python/gnuradio/gr/qa_feval.py
index 9018e12f36..078e2bf789 100755..100644
--- a/gnuradio-runtime/python/gnuradio/gr/qa_feval.py
+++ b/gnuradio-runtime/python/gnuradio/gr/qa_feval.py
@@ -20,6 +20,7 @@
# Boston, MA 02110-1301, USA.
#
+
from gnuradio import gr, gr_unittest
class my_add2_dd(gr.feval_dd):
diff --git a/gnuradio-runtime/python/gnuradio/gr/qa_flowgraph.py b/gnuradio-runtime/python/gnuradio/gr/qa_flowgraph.py
index fa4fd4910e..f5802c51bc 100755..100644
--- a/gnuradio-runtime/python/gnuradio/gr/qa_flowgraph.py
+++ b/gnuradio-runtime/python/gnuradio/gr/qa_flowgraph.py
@@ -20,6 +20,7 @@
# Boston, MA 02110-1301, USA.
#
+
import time
import pmt
from gnuradio import gr, gr_unittest, blocks
diff --git a/gnuradio-runtime/python/gnuradio/gr/qa_hier_block2.py b/gnuradio-runtime/python/gnuradio/gr/qa_hier_block2.py
index 005331c2ec..c8f3d1a5f9 100644
--- a/gnuradio-runtime/python/gnuradio/gr/qa_hier_block2.py
+++ b/gnuradio-runtime/python/gnuradio/gr/qa_hier_block2.py
@@ -19,9 +19,12 @@
# Boston, MA 02110-1301, USA.
#
-import pmt, time
+import time
+
from gnuradio import gr_unittest, blocks, gr, analog
from gnuradio.gr.hier_block2 import _multiple_endpoints, _optional_endpoints
+import pmt
+
class test_hblk(gr.hier_block2):
def __init__(self, io_sig=1*[gr.sizeof_gr_complex], ndebug=2):
@@ -126,7 +129,7 @@ class test_hier_block2(gr_unittest.TestCase):
time.sleep(1)
tb.stop()
tb.wait()
-
+
def test_012(self):
s, st, h, k = analog.sig_source_c(44100, analog.GR_COS_WAVE, 440, 1.0, 0.0), blocks.message_strobe(pmt.PMT_NIL, 100), blocks.head(gr.sizeof_gr_complex, 1000), test_hblk([gr.sizeof_gr_complex], 16)
tb = gr.top_block()
@@ -139,4 +142,3 @@ class test_hier_block2(gr_unittest.TestCase):
if __name__ == '__main__':
gr_unittest.run(test_hier_block2, "test_hier_block2.xml")
-
diff --git a/gnuradio-runtime/python/gnuradio/gr/qa_kludged_imports.py b/gnuradio-runtime/python/gnuradio/gr/qa_kludged_imports.py
index f80188c9fc..e2e9047c9b 100755..100644
--- a/gnuradio-runtime/python/gnuradio/gr/qa_kludged_imports.py
+++ b/gnuradio-runtime/python/gnuradio/gr/qa_kludged_imports.py
@@ -20,6 +20,7 @@
# Boston, MA 02110-1301, USA.
#
+
from gnuradio import gr, gr_unittest
class test_kludged_imports (gr_unittest.TestCase):
diff --git a/gnuradio-runtime/python/gnuradio/gr/qa_random.py b/gnuradio-runtime/python/gnuradio/gr/qa_random.py
index d3e5410454..6fbf5e478a 100644
--- a/gnuradio-runtime/python/gnuradio/gr/qa_random.py
+++ b/gnuradio-runtime/python/gnuradio/gr/qa_random.py
@@ -20,6 +20,7 @@
# Boston, MA 02110-1301, USA.
#
+
from gnuradio import gr, gr_unittest
import numpy as np
diff --git a/gnuradio-runtime/python/gnuradio/gr/qa_tag_utils.py b/gnuradio-runtime/python/gnuradio/gr/qa_tag_utils.py
index 55b62a12ac..3d7b99d12c 100755..100644
--- a/gnuradio-runtime/python/gnuradio/gr/qa_tag_utils.py
+++ b/gnuradio-runtime/python/gnuradio/gr/qa_tag_utils.py
@@ -20,12 +20,12 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
+
from gnuradio import gr, gr_unittest
+import pmt
-try:
- import pmt_swig as pmt
-except ImportError:
- import pmt
class test_tag_utils (gr_unittest.TestCase):
@@ -111,6 +111,6 @@ class test_tag_utils (gr_unittest.TestCase):
if __name__ == '__main__':
- print 'hi'
+ print('hi')
gr_unittest.run(test_tag_utils, "test_tag_utils.xml")
diff --git a/gnuradio-runtime/python/gnuradio/gr/tag_utils.py b/gnuradio-runtime/python/gnuradio/gr/tag_utils.py
index 0d4805a8b8..d054865c22 100644
--- a/gnuradio-runtime/python/gnuradio/gr/tag_utils.py
+++ b/gnuradio-runtime/python/gnuradio/gr/tag_utils.py
@@ -1,6 +1,7 @@
+from __future__ import unicode_literals
import pmt
-import runtime_swig as gr
+from . import runtime_swig as gr
class PythonTag(object):
" Python container for tags "
@@ -51,29 +52,29 @@ def python_to_tag(tag_struct):
good = False
tag = gr.tag_t()
if(type(tag_struct) == dict):
- if(tag_struct.has_key('offset')):
- if(isinstance(tag_struct['offset'], (int,long))):
+ if('offset' in tag_struct):
+ if(isinstance(tag_struct['offset'], int)):
tag.offset = tag_struct['offset']
good = True
- if(tag_struct.has_key('key')):
+ if('key' in tag_struct):
if(isinstance(tag_struct['key'], pmt.swig_int_ptr)):
tag.key = tag_struct['key']
good = True
- if(tag_struct.has_key('value')):
+ if('value' in tag_struct):
if(isinstance(tag_struct['value'], pmt.swig_int_ptr)):
tag.value = tag_struct['value']
good = True
- if(tag_struct.has_key('srcid')):
+ if('srcid' in tag_struct):
if(isinstance(tag_struct['srcid'], pmt.swig_int_ptr)):
tag.srcid = tag_struct['srcid']
good = True
elif(type(tag_struct) == list or type(tag_struct) == tuple):
if(len(tag_struct) == 4):
- if(isinstance(tag_struct[0], (int,long))):
+ if(isinstance(tag_struct[0], int)):
tag.offset = tag_struct[0]
good = True
@@ -90,7 +91,7 @@ def python_to_tag(tag_struct):
good = True
elif(len(tag_struct) == 3):
- if(isinstance(tag_struct[0], (int,long))):
+ if(isinstance(tag_struct[0], int)):
tag.offset = tag_struct[0]
good = True
diff --git a/gnuradio-runtime/python/gnuradio/gr/top_block.py b/gnuradio-runtime/python/gnuradio/gr/top_block.py
index 2efcbd9aae..e7608bf5e9 100644
--- a/gnuradio-runtime/python/gnuradio/gr/top_block.py
+++ b/gnuradio-runtime/python/gnuradio/gr/top_block.py
@@ -19,15 +19,18 @@
# Boston, MA 02110-1301, USA.
#
-from runtime_swig import top_block_swig, \
- top_block_wait_unlocked, top_block_run_unlocked, \
- top_block_start_unlocked, top_block_stop_unlocked, \
- top_block_unlock_unlocked, dot_graph_tb
+from __future__ import absolute_import
+from __future__ import unicode_literals
+
+from .runtime_swig import (top_block_swig,
+ top_block_wait_unlocked, top_block_run_unlocked,
+ top_block_start_unlocked, top_block_stop_unlocked,
+ top_block_unlock_unlocked, dot_graph_tb)
#import gnuradio.gr.gr_threading as _threading
-import gr_threading as _threading
+from . import gr_threading as _threading
-from hier_block2 import hier_block2
+from .hier_block2 import hier_block2
class _top_block_waiter(_threading.Thread):
"""