summaryrefslogtreecommitdiff
path: root/gr-uhd/python/uhd
diff options
context:
space:
mode:
authorMarcus Müller <marcus@hostalia.de>2018-08-31 23:02:22 +0200
committerMarcus Müller <marcus@hostalia.de>2018-08-31 23:02:22 +0200
commit254fe5e89403d4de1fa6663d09efdf946996aff3 (patch)
tree62877d7ac7fdedf6c397c51e22ac6f97eba97ddf /gr-uhd/python/uhd
parent896d1c9da31963ecf5b0d90942c2af51ca998a69 (diff)
parent5ad935c3a3dd46ce2860b13e2b774e4841784616 (diff)
Merge remote-tracking branch 'origin/next' into merge_next
Diffstat (limited to 'gr-uhd/python/uhd')
-rw-r--r--gr-uhd/python/uhd/CMakeLists.txt3
-rw-r--r--gr-uhd/python/uhd/__init__.py21
-rw-r--r--gr-uhd/python/uhd/qa_uhd.py4
3 files changed, 16 insertions, 12 deletions
diff --git a/gr-uhd/python/uhd/CMakeLists.txt b/gr-uhd/python/uhd/CMakeLists.txt
index ff625f1e78..b173ba01df 100644
--- a/gr-uhd/python/uhd/CMakeLists.txt
+++ b/gr-uhd/python/uhd/CMakeLists.txt
@@ -26,7 +26,6 @@ GR_PYTHON_INSTALL(
FILES
__init__.py
DESTINATION ${GR_PYTHON_DIR}/gnuradio/uhd
- COMPONENT "uhd_python"
)
########################################################################
@@ -47,6 +46,6 @@ include(GrTest)
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/gr-uhd/python/uhd/__init__.py b/gr-uhd/python/uhd/__init__.py
index 0e8176f97f..d9f4eaab3e 100644
--- a/gr-uhd/python/uhd/__init__.py
+++ b/gr-uhd/python/uhd/__init__.py
@@ -25,17 +25,20 @@ Used to send and receive data between the Ettus Research, LLC product
line.
'''
+from __future__ import absolute_import
+from __future__ import unicode_literals
+
########################################################################
# Prepare uhd swig module to make it more pythonic
########################################################################
def _prepare_uhd_swig():
try:
- import uhd_swig
+ from . import uhd_swig
except ImportError:
import os
dirname, filename = os.path.split(os.path.abspath(__file__))
__path__.append(os.path.join(dirname, "..", "..", "swig"))
- import uhd_swig
+ from . import uhd_swig
#some useful typedefs for the user
setattr(uhd_swig, 'freq_range_t', uhd_swig.meta_range_t)
@@ -50,7 +53,7 @@ def _prepare_uhd_swig():
def __float__(self): return self.target_freq
def __init__(self, *args, **kwargs):
super(tune_request_t, self).__init__(*args)
- for key, val in kwargs.iteritems(): setattr(self, key, val)
+ for key, val in list(kwargs.items()): setattr(self, key, val)
setattr(uhd_swig, 'tune_request_t', tune_request_t)
#Make the python tune request object inherit from string
@@ -64,14 +67,14 @@ def _prepare_uhd_swig():
def __init__(self, *args, **kwargs):
super(device_addr_t, self).__init__(*args)
if args and isinstance(args[0], device_addr_t):
- for key in args[0].keys(): self[key] = args[0][key]
+ for key in list(args[0].keys()): self[key] = args[0][key]
setattr(uhd_swig, 'device_addr_t', device_addr_t)
#make the streamer args take **kwargs on init
class stream_args_t(uhd_swig.stream_args_t):
def __init__(self, *args, **kwargs):
super(stream_args_t, self).__init__(*args)
- for key, val in kwargs.iteritems():
+ for key, val in list(kwargs.items()):
#for some reason, I can't assign a list in the constructor
#but what I can do is append the elements individually
if key == 'channels':
@@ -97,7 +100,7 @@ def _prepare_uhd_swig():
def find_devices(*args, **kwargs):
def to_pythonized_dev_addr(dev_addr):
new_dev_addr = uhd_swig.device_addr_t()
- for key in dev_addr.keys(): new_dev_addr[key] = dev_addr.get(key)
+ for key in list(dev_addr.keys()): new_dev_addr[key] = dev_addr.get(key)
return new_dev_addr
return __builtins__['map'](to_pythonized_dev_addr, uhd_swig.find_devices_raw(*args, **kwargs))
setattr(uhd_swig, 'find_devices', find_devices)
@@ -114,11 +117,11 @@ def _prepare_uhd_swig():
):
try:
if len(args) > index: args[index] = cast(args[index])
- if kwargs.has_key(key): kwargs[key] = cast(kwargs[key])
+ if key in kwargs: kwargs[key] = cast(kwargs[key])
except: pass
#don't pass kwargs, it confuses swig, map into args list:
for key in ('device_addr', 'stream_args', 'io_type', 'num_channels', 'msgq'):
- if kwargs.has_key(key): args.append(kwargs[key])
+ if key in kwargs: args.append(kwargs[key])
return old_constructor(*args)
return constructor_interceptor
setattr(uhd_swig, attr, constructor_factory(getattr(uhd_swig, attr)))
@@ -133,4 +136,4 @@ def _prepare_uhd_swig():
# Initialize this module with the contents of uhd swig
########################################################################
_prepare_uhd_swig()
-from uhd_swig import *
+from .uhd_swig import *
diff --git a/gr-uhd/python/uhd/qa_uhd.py b/gr-uhd/python/uhd/qa_uhd.py
index 4df0d4273e..bab029a9a8 100644
--- a/gr-uhd/python/uhd/qa_uhd.py
+++ b/gr-uhd/python/uhd/qa_uhd.py
@@ -20,6 +20,8 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
from gnuradio import gr, gr_unittest, uhd
class test_uhd(gr_unittest.TestCase):
@@ -50,7 +52,7 @@ class test_uhd(gr_unittest.TestCase):
sa = uhd.stream_args_t()
sa.channels.append(1)
sa.channels.append(0)
- print sa.channels
+ print(sa.channels)
self.assertEqual(len(sa.channels), 2)
self.assertEqual(sa.channels[0], 1)
self.assertEqual(sa.channels[1], 0)