[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 04/20: python3: update gnuradio-runtime for
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 04/20: python3: update gnuradio-runtime for python3 support |
Date: |
Sun, 25 Dec 2016 03:59:56 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch python3
in repository gnuradio.
commit d18a43a77e1d640d6502911c4cbb32e8a5f1a295
Author: Douglas Anderson <address@hidden>
Date: Thu Dec 22 12:48:22 2016 -0700
python3: update gnuradio-runtime for python3 support
---
gnuradio-runtime/lib/CMakeLists.txt | 6 +-
gnuradio-runtime/lib/pmt/gen-serial-tags.py | 4 +-
gnuradio-runtime/lib/pmt/generate_unv.py | 2 +-
gnuradio-runtime/python/build_utils.py | 8 +-
.../python/gnuradio/ctrlport/GrDataPlotter.py | 6 +-
.../python/gnuradio/ctrlport/gr-perf-monitorx | 16 ++--
.../python/gnuradio/ctrlport/monitor.py | 18 +++--
.../python/gnuradio/gr/gr_threading_23.py | 9 ++-
.../python/gnuradio/gr/gr_threading_24.py | 9 ++-
.../python/gnuradio/gr/packet_utils.py | 2 +-
gnuradio-runtime/python/gnuradio/gr/pubsub.py | 88 +++++++++++-----------
gnuradio-runtime/python/gnuradio/gr_unittest.py | 37 +++++----
gnuradio-runtime/python/gnuradio/gru/daemon.py | 45 +++++------
gnuradio-runtime/python/gnuradio/gru/freqz.py | 8 +-
.../python/gnuradio/gru/msgq_runner.py | 2 +-
.../python/gnuradio/gru/socket_stuff.py | 4 +-
16 files changed, 144 insertions(+), 120 deletions(-)
diff --git a/gnuradio-runtime/lib/CMakeLists.txt
b/gnuradio-runtime/lib/CMakeLists.txt
index c6e4287..e461889 100644
--- a/gnuradio-runtime/lib/CMakeLists.txt
+++ b/gnuradio-runtime/lib/CMakeLists.txt
@@ -24,7 +24,7 @@ GR_CHECK_HDR_N_DEF(sys/resource.h HAVE_SYS_RESOURCE_H)
# Handle the generated constants
########################################################################
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
- "import time;print time.strftime('%a, %d %b %Y %H:%M:%S', time.gmtime())"
+ "import time;print(time.strftime('%a, %d %b %Y %H:%M:%S', time.gmtime()))"
OUTPUT_VARIABLE BUILD_DATE OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "Loading build date ${BUILD_DATE} into constants...")
@@ -53,8 +53,8 @@ list(APPEND gnuradio_runtime_sources
${CMAKE_CURRENT_BINARY_DIR}/constants.cc)
########################################################################
include_directories(${GNURADIO_RUNTIME_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}/../include/
- ${VOLK_INCLUDE_DIRS}
+ ${CMAKE_CURRENT_BINARY_DIR}/../include/
+ ${VOLK_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
)
diff --git a/gnuradio-runtime/lib/pmt/gen-serial-tags.py
b/gnuradio-runtime/lib/pmt/gen-serial-tags.py
index 18e927b..e2e7159 100644
--- a/gnuradio-runtime/lib/pmt/gen-serial-tags.py
+++ b/gnuradio-runtime/lib/pmt/gen-serial-tags.py
@@ -32,11 +32,13 @@ enum pst_tags {
#endif /* INCLUDED_PMT_SERIAL_TAGS_H */
"""
+from __future__ import print_function
+
import sys, os, re
if __name__ == '__main__':
if len(sys.argv) != 3:
- print "Usage %s <input_scm_file> <output_hdr_file>"%__file__
+ print("Usage %s <input_scm_file> <output_hdr_file>"%__file__)
exit()
input_scm_file, output_hdr_file = sys.argv[1:]
enums = list()
diff --git a/gnuradio-runtime/lib/pmt/generate_unv.py
b/gnuradio-runtime/lib/pmt/generate_unv.py
index 6218099..b86f11f 100755
--- a/gnuradio-runtime/lib/pmt/generate_unv.py
+++ b/gnuradio-runtime/lib/pmt/generate_unv.py
@@ -93,7 +93,7 @@ using namespace pmt;
# set srcdir to the directory that contains Makefile.am
try:
srcdir = os.environ['srcdir']
-except KeyError, e:
+except KeyError as e:
srcdir = "."
srcdir = srcdir + '/'
diff --git a/gnuradio-runtime/python/build_utils.py
b/gnuradio-runtime/python/build_utils.py
index cf58a97..f9e5f94 100644
--- a/gnuradio-runtime/python/build_utils.py
+++ b/gnuradio-runtime/python/build_utils.py
@@ -29,7 +29,7 @@ from build_utils_codes import *
# set srcdir to the directory that contains Makefile.am
try:
srcdir = os.environ['srcdir']
-except KeyError, e:
+except KeyError as e:
srcdir = "."
srcdir = srcdir + '/'
@@ -39,7 +39,7 @@ try:
do_makefile = False
else:
do_makefile = True
-except KeyError, e:
+except KeyError as e:
do_makefile = False
# set do_sources to either true or false dependeing on the environment
@@ -48,7 +48,7 @@ try:
do_sources = False
else:
do_sources = True
-except KeyError, e:
+except KeyError as e:
do_sources = True
name_dict = {}
@@ -127,7 +127,7 @@ def extract_extension (template_name):
# we return everything between the penultimate . and .t
mo = re.search (r'\.([a-z]+)\.t$', template_name)
if not mo:
- raise ValueError, "Incorrectly formed template_name '%s'" %
(template_name,)
+ raise ValueError("Incorrectly formed template_name '%s'" %
(template_name,))
return mo.group (1)
def open_src (name, mode):
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
b/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
index c5bfd0a..9000537 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
@@ -20,6 +20,8 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
from gnuradio import gr
from gnuradio import blocks
from gnuradio import filter
@@ -31,7 +33,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):
@@ -411,7 +413,7 @@ class GrDataPlotterValueTable:
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))
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx
b/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx
index 15a2153..302275f 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 f651be2..81c8f02 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/monitor.py
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/monitor.py
@@ -20,12 +20,14 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
import sys, subprocess, re, signal, time, atexit, os
from gnuradio import gr
class monitor:
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 +40,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()
diff --git a/gnuradio-runtime/python/gnuradio/gr/gr_threading_23.py
b/gnuradio-runtime/python/gnuradio/gr/gr_threading_23.py
index dee8034..ed18c33 100644
--- a/gnuradio-runtime/python/gnuradio/gr/gr_threading_23.py
+++ b/gnuradio-runtime/python/gnuradio/gr/gr_threading_23.py
@@ -4,6 +4,8 @@
# 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
+
import sys as _sys
try:
@@ -127,8 +129,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 +316,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)
@@ -698,7 +701,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 8539bfc..fd3f3ed 100644
--- a/gnuradio-runtime/python/gnuradio/gr/gr_threading_24.py
+++ b/gnuradio-runtime/python/gnuradio/gr/gr_threading_24.py
@@ -4,6 +4,8 @@
# 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
+
import sys as _sys
try:
@@ -127,8 +129,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 +314,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)
@@ -767,7 +770,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/packet_utils.py
b/gnuradio-runtime/python/gnuradio/gr/packet_utils.py
index 720cfd9..3dc4e01 100644
--- a/gnuradio-runtime/python/gnuradio/gr/packet_utils.py
+++ b/gnuradio-runtime/python/gnuradio/gr/packet_utils.py
@@ -73,7 +73,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
diff --git a/gnuradio-runtime/python/gnuradio/gr/pubsub.py
b/gnuradio-runtime/python/gnuradio/gr/pubsub.py
index 9056841..fb9add2 100644
--- a/gnuradio-runtime/python/gnuradio/gr/pubsub.py
+++ b/gnuradio-runtime/python/gnuradio/gr/pubsub.py
@@ -26,43 +26,45 @@ Abstract GNU Radio publisher/subscriber interface
This is a proof of concept implementation, will likely change significantly.
"""
+from __future__ import print_function
+
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 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)
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 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)
def publish(self, key, publisher):
- if not self.has_key(key): self.__missing__(key)
+ if not self.has_key(key): self.__missing__(key)
if self._proxies[key] is not None:
(p, newkey) = self._proxies[key]
p.publish(newkey, publisher)
@@ -70,7 +72,7 @@ class pubsub(dict):
self._publishers[key] = publisher
def subscribe(self, key, subscriber):
- if not self.has_key(key): self.__missing__(key)
+ if not self.has_key(key): self.__missing__(key)
if self._proxies[key] is not None:
(p, newkey) = self._proxies[key]
p.subscribe(newkey, subscriber)
@@ -92,9 +94,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 not self.has_key(key): self.__missing__(key)
+ if newkey is None: newkey = key
+ self._proxies[key] = (p, newkey)
def unproxy(self, key):
self._proxies[key] = None
@@ -105,49 +107,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_unittest.py
b/gnuradio-runtime/python/gnuradio/gr_unittest.py
index c729566..7307bca 100755
--- a/gnuradio-runtime/python/gnuradio/gr_unittest.py
+++ b/gnuradio-runtime/python/gnuradio/gr_unittest.py
@@ -43,11 +43,12 @@ class TestCase(unittest.TestCase):
as significant digits (measured from the most signficant digit).
"""
if round(second.real-first.real, places) != 0:
- raise self.failureException, \
- (msg or '%s != %s within %s places' % (`first`, `second`,
`places` ))
+ raise self.failureException(
+ msg or '%r != %r within %r places' % (first, second, places))
if round(second.imag-first.imag, places) != 0:
- raise self.failureException, \
- (msg or '%s != %s within %s places' % (`first`, `second`,
`places` ))
+ raise self.failureException(
+ msg or '%r != %r within %r places' % (first, second, places)
+ )
def assertComplexAlmostEqual2 (self, ref, x, abs_eps=1e-12, rel_eps=1e-6,
msg=None):
"""
@@ -58,13 +59,17 @@ class TestCase(unittest.TestCase):
if abs(ref) > abs_eps:
if abs(ref-x)/abs(ref) > rel_eps:
- raise self.failureException, \
- (msg or '%s != %s rel_error = %s rel_limit = %s' % (
- `ref`, `x`, abs(ref-x)/abs(ref), `rel_eps` ))
+ raise self.failureException(
+ msg or '%r != %r rel_error = %r rel_limit = %r' % (
+ ref, x, abs(ref-x)/abs(ref), rel_eps
+ )
+ )
else:
- raise self.failureException, \
- (msg or '%s != %s rel_error = %s rel_limit = %s' % (
- `ref`, `x`, abs(ref-x)/abs(ref), `rel_eps` ))
+ raise self.failureException(
+ msg or '%r != %r rel_error = %r rel_limit = %r' % (
+ ref, x, abs(ref-x)/abs(ref), rel_eps
+ )
+ )
@@ -79,9 +84,9 @@ class TestCase(unittest.TestCase):
for i in xrange (len(ref)):
try:
self.assertComplexAlmostEqual2 (ref[i], x[i], abs_eps,
rel_eps, msg)
- except self.failureException, e:
+ except self.failureException as e:
#sys.stderr.write("index = %d " % (i,))
- #sys.stderr.write("%s\n" % (e,))
+ #sys.stderr.write("%r\n" % (e,))
raise
def assertFloatTuplesAlmostEqual (self, a, b, places=7, msg=None):
@@ -96,9 +101,9 @@ class TestCase(unittest.TestCase):
for i in xrange (len(ref)):
try:
self.assertComplexAlmostEqual2 (ref[i], x[i], abs_eps,
rel_eps, msg)
- except self.failureException, e:
+ except self.failureException as e:
#sys.stderr.write("index = %d " % (i,))
- #sys.stderr.write("%s\n" % (e,))
+ #sys.stderr.write("%r\n" % (e,))
raise
@@ -124,7 +129,7 @@ def run(PUT, filename=None):
path = basepath + "/python"
if not os.path.exists(basepath):
- os.makedirs(basepath, 0750)
+ os.makedirs(basepath, mode=0o750)
xmlrunner = None
# only proceed if .unittests is writable
@@ -132,7 +137,7 @@ def run(PUT, filename=None):
if(st & stat.S_IWUSR > 0):
# Test if path exists; if not, build it
if not os.path.exists(path):
- os.makedirs(path, 0750)
+ os.makedirs(path, mode=0o750)
# Just for safety: make sure we can write here, too
st = os.stat(path)[stat.ST_MODE]
diff --git a/gnuradio-runtime/python/gnuradio/gru/daemon.py
b/gnuradio-runtime/python/gnuradio/gru/daemon.py
index e047021..3a28903 100644
--- a/gnuradio-runtime/python/gnuradio/gru/daemon.py
+++ b/gnuradio-runtime/python/gnuradio/gru/daemon.py
@@ -18,6 +18,9 @@
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
+
+from __future__ import print_function
+
import os, sys, signal
# Turn application into a background daemon process.
@@ -55,38 +58,38 @@ import os, sys, signal
def daemonize(pidfile=None, logfile=None):
# fork() into background
try:
- pid = os.fork()
- except OSError, e:
- raise Exception, "%s [%d]" % (e.strerror, e.errno)
+ pid = os.fork()
+ except OSError as e:
+ raise Exception("%s [%d]" % (e.strerror, e.errno))
if pid == 0: # First child of first fork()
- # Become session leader of new session
- os.setsid()
+ # Become session leader of new session
+ os.setsid()
- # fork() into background again
- try:
- pid = os.fork()
- except OSError, e:
- raise Exception, "%s [%d]" % (e.strerror, e.errno)
+ # fork() into background again
+ try:
+ pid = os.fork()
+ except OSError as e:
+ raise Exception("%s [%d]" % (e.strerror, e.errno))
- if pid != 0:
- os._exit(0) # Second child of second fork()
+ if pid != 0:
+ os._exit(0) # Second child of second fork()
- else: # Second child of first fork()
- os._exit(0)
+ else: # Second child of first fork()
+ os._exit(0)
- os.umask(0111)
+ os.umask(0o111)
# Write pid
pid = os.getpid()
if pidfile is not None:
- open(pidfile, 'w').write('%d\n'%pid)
+ open(pidfile, 'w').write('%d\n'%pid)
# Redirect streams
if logfile is not None:
- lf = open(logfile, 'a+')
- sys.stdout = lf
- sys.stderr = lf
+ lf = open(logfile, 'a+')
+ sys.stdout = lf
+ sys.stderr = lf
# Prevent pinning any filesystem mounts
os.chdir('/')
@@ -97,6 +100,6 @@ def daemonize(pidfile=None, logfile=None):
if __name__ == "__main__":
import time
daemonize()
- print "Hello, world, from daemon process."
+ print("Hello, world, from daemon process.")
time.sleep(20)
- print "Goodbye, world, from daemon process."
+ print("Goodbye, world, from daemon process.")
diff --git a/gnuradio-runtime/python/gnuradio/gru/freqz.py
b/gnuradio-runtime/python/gnuradio/gru/freqz.py
index 6d8b94d..efaefdc 100644
--- a/gnuradio-runtime/python/gnuradio/gru/freqz.py
+++ b/gnuradio-runtime/python/gnuradio/gru/freqz.py
@@ -132,7 +132,7 @@ class poly1d:
c_or_r = poly(c_or_r)
c_or_r = atleast_1d(c_or_r)
if len(c_or_r.shape) > 1:
- raise ValueError, "Polynomial must be 1d only."
+ raise ValueError("Polynomial must be 1d only.")
c_or_r = trim_zeros(c_or_r, trim='f')
if len(c_or_r) == 0:
c_or_r = numpy.array([0])
@@ -227,7 +227,7 @@ class poly1d:
def __pow__(self, val):
if not isscalar(val) or int(val) != val or val < 0:
- raise ValueError, "Power to non-negative integers only."
+ raise ValueError("Power to non-negative integers only.")
res = [1]
for k in range(val):
res = polymul(self.coeffs, res)
@@ -256,7 +256,7 @@ class poly1d:
return map(poly1d,polydiv(other.coeffs, self.coeffs))
def __setattr__(self, key, val):
- raise ValueError, "Attributes cannot be changed this way."
+ raise ValueError("Attributes cannot be changed this way.")
def __getattr__(self, key):
if key in ['r','roots']:
@@ -279,7 +279,7 @@ class poly1d:
def __setitem__(self, key, val):
ind = self.order - key
if key < 0:
- raise ValueError, "Does not support negative powers."
+ raise ValueError("Does not support negative powers.")
if key > self.order:
zr = numpy.zeros(key-self.order,self.coeffs.typecode())
self.__dict__['coeffs'] = numpy.concatenate((zr,self.coeffs))
diff --git a/gnuradio-runtime/python/gnuradio/gru/msgq_runner.py
b/gnuradio-runtime/python/gnuradio/gru/msgq_runner.py
index 767a74a..e782b52 100644
--- a/gnuradio-runtime/python/gnuradio/gru/msgq_runner.py
+++ b/gnuradio-runtime/python/gnuradio/gru/msgq_runner.py
@@ -66,7 +66,7 @@ class msgq_runner(_threading.Thread):
else:
try:
self._callback(msg)
- except Exception, e:
+ except Exception as e:
if self._exit_on_error:
self._exit_error = e
self.stop()
diff --git a/gnuradio-runtime/python/gnuradio/gru/socket_stuff.py
b/gnuradio-runtime/python/gnuradio/gru/socket_stuff.py
index b7c5ac2..842ac98 100644
--- a/gnuradio-runtime/python/gnuradio/gru/socket_stuff.py
+++ b/gnuradio-runtime/python/gnuradio/gru/socket_stuff.py
@@ -37,7 +37,7 @@ def tcp_connect_or_die(sock_addr):
s = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect(sock_addr)
- except socket.error, err:
+ except socket.error as err:
sys.stderr.write('Failed to connect to %s: %s\n' %
(sock_addr, os.strerror (err.args[0]),))
sys.exit(1)
@@ -55,7 +55,7 @@ def udp_connect_or_die(sock_addr):
s = socket.socket (socket.AF_INET, socket.SOCK_DGRAM)
try:
s.connect(sock_addr)
- except socket.error, err:
+ except socket.error as err:
sys.stderr.write('Failed to connect to %s: %s\n' %
(sock_addr, os.strerror (err.args[0]),))
sys.exit(1)
- [Commit-gnuradio] [gnuradio] 19/20: python3: use site instead of distutils, (continued)
- [Commit-gnuradio] [gnuradio] 19/20: python3: use site instead of distutils, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 20/20: python3: futurize misplaced __future__ import, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 05/20: python3: update gr-analog for python3 support, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 06/20: python3: update gr-blocks python files for python3 support, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 08/20: python3: update gr-dtv for python3 support, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 02/20: python3: add cmake support for python3 at top level, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 17/20: python3: fix issues detected by futurize, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 16/20: python3: update gr-zeromq for python3 support, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 11/20: python3: update gr-qtgui for python3 support, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 13/20: python3: update gr-uhd for python3 support, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 04/20: python3: update gnuradio-runtime for python3 support,
git <=
- [Commit-gnuradio] [gnuradio] 03/20: python3: update doxygen files to build docs with python3, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 09/20: python3: update gr-fec for python3 support, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 14/20: python3: update gr-utils for python3 support, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 10/20: python3: update gr-filter for python3 support, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 07/20: python3: update gr-digital for python3 support, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 18/20: python3: futurize --stage1 --write $(find . -iname '*.py'), git, 2016/12/24