summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/python/gnuradio/ctrlport
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-runtime/python/gnuradio/ctrlport')
-rw-r--r--gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py8
-rw-r--r--gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py23
-rw-r--r--gnuradio-runtime/python/gnuradio/ctrlport/RPCConnection.py1
-rw-r--r--gnuradio-runtime/python/gnuradio/ctrlport/RPCConnectionThrift.py17
-rw-r--r--gnuradio-runtime/python/gnuradio/ctrlport/__init__.py4
-rw-r--r--gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx16
-rw-r--r--gnuradio-runtime/python/gnuradio/ctrlport/monitor.py21
7 files changed, 52 insertions, 38 deletions
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py b/gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py
index 87d2cf5658..beec500023 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py
@@ -27,6 +27,8 @@ Remote Procedure Call (RPC) transports, the Apache Thrift middle-ware RPC
is currently the only supported transport.
"""
+from __future__ import print_function
+from __future__ import unicode_literals
import exceptions
@@ -38,7 +40,7 @@ Two constructors are provided for creating a connection to ControlPort.
"""
-class GNURadioControlPortClient():
+class GNURadioControlPortClient(object):
"""
Constructor for creating a ControlPort connection to a specified host / port
@@ -113,7 +115,7 @@ class GNURadioControlPortClient():
self.client = None
from gnuradio.ctrlport.RPCConnection import RPCMethods
- if RPCMethods.has_key(rpcmethod):
+ if rpcmethod in RPCMethods:
from gnuradio.ctrlport.RPCConnectionThrift import RPCConnectionThrift
if rpcmethod == 'thrift':
#print("making RPCConnectionThrift")
@@ -128,5 +130,5 @@ class GNURadioControlPortClient():
if not blockingcallback is None:
blockingcallback()
else:
- print("Unsupported RPC method: ", rpcmethod)
+ print(("Unsupported RPC method: ", rpcmethod))
raise exceptions.ValueError()
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py b/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
index e0499c5eba..cb66baebb9 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
@@ -20,6 +20,9 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import unicode_literals
+
from gnuradio import gr
from gnuradio import blocks
from gnuradio import filter
@@ -31,7 +34,7 @@ try:
from PyQt4 import QtGui, QtCore
import sip
except ImportError:
- print "Error: Program requires PyQt4 and gr-qtgui."
+ print("Error: Program requires PyQt4 and gr-qtgui.")
sys.exit(1)
class GrDataPlotParent(gr.top_block, QtGui.QWidget):
@@ -62,7 +65,7 @@ class GrDataPlotParent(gr.top_block, QtGui.QWidget):
self.layout.removeWidget(self.py_window)
self.disconnect(self.thr, (self.snk, 0))
self.disconnect(self.src[0], self.thr)
- for n in xrange(1, self._ncons):
+ for n in range(1, self._ncons):
self.disconnect(self.src[n], (self.snk,n))
self._ncons = nconnections
@@ -75,7 +78,7 @@ class GrDataPlotParent(gr.top_block, QtGui.QWidget):
self._last_data = []
self.src = []
- for n in xrange(self._ncons):
+ for n in range(self._ncons):
self.set_line_label(n, self.knobnames[n])
self._last_data.append(int(self._npts)*[0,])
@@ -142,7 +145,7 @@ class GrDataPlotParent(gr.top_block, QtGui.QWidget):
if(self._npts != npts):
# Adjust buffers to accommodate new settings
- for n in xrange(self._ncons):
+ for n in range(self._ncons):
if(npts < self._npts):
if(self._data_len[n] < npts):
self._last_data[n] = self._last_data[n][0:npts]
@@ -156,7 +159,7 @@ class GrDataPlotParent(gr.top_block, QtGui.QWidget):
if(self._stripchart):
# Update the plot data depending on type
- for n in xrange(self._ncons):
+ for n in range(self._ncons):
if(type(data[n]) == list):
data[n] = self.data_to_complex(data[n])
if(len(data[n]) > self._npts):
@@ -179,7 +182,7 @@ class GrDataPlotParent(gr.top_block, QtGui.QWidget):
self._last_data[n].append(data[n])
self.src[n].set_data(self._last_data[n])
else:
- for n in xrange(self._ncons):
+ for n in range(self._ncons):
if(type(data[n]) != list):
data[n] = [data[n],]
data[n] = self.data_to_complex(data[n])
@@ -407,11 +410,11 @@ class GrTimeRasterB(GrDataPlotParent):
self.snk.set_line_label(n, self.knobnames[n])
-class GrDataPlotterValueTable:
+class GrDataPlotterValueTable(object):
def __init__(self, uid, parent, x, y, xsize, ysize,
headers=['Statistic Key ( Source Block :: Stat Name ) ',
'Curent Value', 'Units', 'Description']):
- # must encapsulate, cuz Qt's bases are not classes
+ # must encapsulate, cuz Qt's bases are not classes
self.uid = uid
self.treeWidget = QtGui.QTreeWidget(parent)
self.treeWidget.setColumnCount(len(headers))
@@ -434,7 +437,7 @@ class GrDataPlotterValueTable:
# itemKey is the text in the first column of a QTreeWidgetItem
itemKey = str(item.text(0))
- if itemKey in knobs.keys():
+ if itemKey in list(knobs.keys()):
# This key was found in the tree, update its values.
foundKeys.append(itemKey)
@@ -465,7 +468,7 @@ class GrDataPlotterValueTable:
deleteKeys.append(itemKey)
# Add items to tree that are not currently in the tree.
- for k in knobs.keys():
+ for k in list(knobs.keys()):
if k not in foundKeys:
v = knobs[k].value
if(type(v) == ControlPort.complex):
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/RPCConnection.py b/gnuradio-runtime/python/gnuradio/ctrlport/RPCConnection.py
index 1b129534c9..b85c827f72 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/RPCConnection.py
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/RPCConnection.py
@@ -1,3 +1,4 @@
+from __future__ import unicode_literals
#
# Copyright 2015 Free Software Foundation, Inc.
#
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/RPCConnectionThrift.py b/gnuradio-runtime/python/gnuradio/ctrlport/RPCConnectionThrift.py
index 522c74117b..466fc9fc04 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/RPCConnectionThrift.py
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/RPCConnectionThrift.py
@@ -20,6 +20,7 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import unicode_literals
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
@@ -30,7 +31,7 @@ from gnuradio import gr
import pmt
import sys
-class ThriftRadioClient:
+class ThriftRadioClient(object):
def __init__(self, host, port):
self.tsocket = TSocket.TSocket(host, port)
self.transport = TTransport.TBufferedTransport(self.tsocket)
@@ -55,7 +56,7 @@ Args:
"""
class RPCConnectionThrift(RPCConnection.RPCConnection):
- class Knob():
+ class Knob(object):
def __init__(self, key, value=None, ktype=0):
(self.key, self.value, self.ktype) = (key, value, ktype)
@@ -144,7 +145,7 @@ class RPCConnectionThrift(RPCConnection.RPCConnection):
def properties(self, *args):
knobprops = self.thriftclient.radio.properties(*args)
- for key, knobprop in knobprops.iteritems():
+ for key, knobprop in list(knobprops.items()):
#print("key:", key, "value:", knobprop, "type:", knobprop.type)
knobprops[key].min = self.unpackKnob(key, knobprop.min)
knobprops[key].max = self.unpackKnob(key, knobprop.max)
@@ -153,28 +154,28 @@ class RPCConnectionThrift(RPCConnection.RPCConnection):
def getKnobs(self, *args):
result = {}
- for key, knob in self.thriftclient.radio.getKnobs(*args).iteritems():
+ for key, knob in list(self.thriftclient.radio.getKnobs(*args).items()):
#print("key:", key, "value:", knob, "type:", knob.type)
result[key] = self.unpackKnob(key, knob)
# If complex, convert to Python complex
# FIXME: better list iterator way to handle this?
if(knob.type == self.BaseTypes.C32VECTOR):
- for i in xrange(len(result[key].value)):
+ for i in range(len(result[key].value)):
result[key].value[i] = complex(result[key].value[i].re,
result[key].value[i].im)
return result
def getKnobsRaw(self, *args):
result = {}
- for key, knob in self.thriftclient.radio.getKnobs(*args).iteritems():
+ for key, knob in list(self.thriftclient.radio.getKnobs(*args).items()):
#print("key:", key, "value:", knob, "type:", knob.type)
result[key] = knob
return result
def getRe(self,*args):
result = {}
- for key, knob in self.thriftclient.radio.getRe(*args).iteritems():
+ for key, knob in list(self.thriftclient.radio.getRe(*args).items()):
result[key] = self.unpackKnob(key, knob)
return result
@@ -182,7 +183,7 @@ class RPCConnectionThrift(RPCConnection.RPCConnection):
if(type(*args) == dict):
a = dict(*args)
result = {}
- for key, knob in a.iteritems():
+ for key, knob in list(a.items()):
result[key] = self.packKnob(knob)
self.thriftclient.radio.setKnobs(result)
elif(type(*args) == list or type(*args) == tuple):
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/__init__.py b/gnuradio-runtime/python/gnuradio/ctrlport/__init__.py
index 8f33d65bbc..363d42a68e 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/__init__.py
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/__init__.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+from __future__ import unicode_literals
#
# Copyright 2012 Free Software Foundation, Inc.
#
@@ -22,7 +24,7 @@
# import swig generated symbols into the ctrlport namespace
#from ctrlport_swig import *
-from monitor import *
+from .monitor import *
# import any pure python here
#import GNURadio
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx b/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx
index 15a2153a0f..302275feb1 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx
@@ -20,6 +20,8 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
import sys, time, re, pprint
import random,math,operator
try:
@@ -36,14 +38,14 @@ try:
try:
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar
except ImportError:
- print sys.argv[0], "could not load QTAgg backend."
+ print(sys.argv[0], "could not load QTAgg backend.")
sys.exit(1)
from matplotlib.figure import Figure
except ImportError:
- print sys.argv[0], "requires networkx and matplotlib.", \
- "Please check that they are installed and try again."
+ print(sys.argv[0], "requires networkx and matplotlib.",
+ "Please check that they are installed and try again.")
sys.exit(1)
from PyQt4 import QtCore,Qt
@@ -282,7 +284,7 @@ class ConInfoDialog(QtGui.QDialog):
class DataTable(QtGui.QWidget):
def update(self):
- print "update"
+ print("update")
def closeEvent(self, event):
self.timer = None
@@ -498,7 +500,7 @@ class MForm(QtGui.QWidget):
self.clockSel.setCurrentIndex(self.clockSelIdx)
self.prevent_clock_change = False
except:
- print "WARNING: Failed to get current clock setting!"
+ print("WARNING: Failed to get current clock setting!")
nodes_stream = self.G_stream.nodes()
nodes_msg = self.G_msg.nodes()
@@ -571,7 +573,7 @@ class MForm(QtGui.QWidget):
self.parent.statusBar().showMessage("Current GNU Radio Control Port Query Latency: %f ms"%\
(latency*1000))
- except Exception, e:
+ except Exception as e:
sys.stderr.write("gr-perf-monitorx: radio.getKnobs threw exception ({0}).\n".format(e))
if(type(self.parent) is MAINWindow):
# Find window of connection
@@ -625,7 +627,7 @@ class MForm(QtGui.QWidget):
return;
idx = self.clockSel.currentIndex();
clk = self.clocks.values()[idx]
-# print "UPDATE CLOCK!!! %d -> %d"%(idx,clk);
+# print("UPDATE CLOCK!!! %d -> %d"%(idx,clk);)
k = self.radioclient.getKnobs([self.clockKey]);
k[self.clockKey].value = clk;
km = {};
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/monitor.py b/gnuradio-runtime/python/gnuradio/ctrlport/monitor.py
index f651be2449..49b66e9830 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/monitor.py
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/monitor.py
@@ -20,12 +20,15 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import unicode_literals
+
import sys, subprocess, re, signal, time, atexit, os
from gnuradio import gr
-class monitor:
+class monitor(object):
def __init__(self,tool="gr-ctrlport-monitor"):
- print "ControlPort Monitor running."
+ print("ControlPort Monitor running.")
self.started = False
self.tool = tool
atexit.register(self.shutdown)
@@ -38,35 +41,35 @@ class monitor:
gr.prefs().singleton().set_bool("PerfCounters","on",True);
gr.prefs().singleton().set_bool("PerfCounters","export",True);
except:
- print "no support for gr.prefs setting"
+ print("no support for gr.prefs setting")
def __del__(self):
if(self.started):
self.stop()
def start(self):
- print "monitor::endpoints() = %s" % (gr.rpcmanager_get().endpoints())
+ print("monitor::endpoints() = %s" % (gr.rpcmanager_get().endpoints()))
try:
cmd = map(lambda a: [self.tool,
re.search("-h (\S+|\d+\.\d+\.\d+\.\d+)",a).group(1),
re.search("-p (\d+)",a).group(1)],
gr.rpcmanager_get().endpoints())[0]
- print "running: %s"%(str(cmd))
+ print("running: %s"%(str(cmd)))
self.proc = subprocess.Popen(cmd);
self.started = True
except:
self.proc = None
- print "failed to to start ControlPort Monitor on specified port"
+ print("failed to to start ControlPort Monitor on specified port")
def stop(self):
if(self.proc):
if(self.proc.returncode == None):
- print "\tcalling stop on shutdown"
+ print("\tcalling stop on shutdown")
self.proc.terminate()
else:
- print "\tno proc to shut down, exiting"
+ print("\tno proc to shut down, exiting")
def shutdown(self):
- print "ctrlport.monitor received shutdown signal"
+ print("ctrlport.monitor received shutdown signal")
if(self.started):
self.stop()