mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-15 20:50:33 +00:00
Python 3 compatibility fixes
This commit is contained in:
parent
a25557c868
commit
3404ea1662
@ -200,7 +200,7 @@ function(VOLK_PYTHON_INSTALL)
|
|||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${pyexefile} DEPENDS ${pyfile}
|
OUTPUT ${pyexefile} DEPENDS ${pyfile}
|
||||||
COMMAND ${PYTHON_EXECUTABLE} -c
|
COMMAND ${PYTHON_EXECUTABLE} -c
|
||||||
"open('${pyexefile}','w').write('\#!${pyexe_native}\\n'+open('${pyfile}').read())"
|
"open('${pyexefile}','w').write(r'\#!${pyexe_native}'+'\\n'+open('${pyfile}').read())"
|
||||||
COMMENT "Shebangin ${pyfile_name}"
|
COMMENT "Shebangin ${pyfile_name}"
|
||||||
VERBATIM
|
VERBATIM
|
||||||
)
|
)
|
||||||
|
@ -25,7 +25,7 @@ import six
|
|||||||
archs = list()
|
archs = list()
|
||||||
arch_dict = dict()
|
arch_dict = dict()
|
||||||
|
|
||||||
class arch_class:
|
class arch_class(object):
|
||||||
def __init__(self, flags, checks, **kwargs):
|
def __init__(self, flags, checks, **kwargs):
|
||||||
for key, cast, failval in (
|
for key, cast, failval in (
|
||||||
('name', str, None),
|
('name', str, None),
|
||||||
|
@ -118,7 +118,7 @@ def flatten_section_text(sections):
|
|||||||
########################################################################
|
########################################################################
|
||||||
# Extract kernel info from section, represent as an implementation
|
# Extract kernel info from section, represent as an implementation
|
||||||
########################################################################
|
########################################################################
|
||||||
class impl_class:
|
class impl_class(object):
|
||||||
def __init__(self, kern_name, header, body):
|
def __init__(self, kern_name, header, body):
|
||||||
#extract LV_HAVE_*
|
#extract LV_HAVE_*
|
||||||
self.deps = set(res.lower() for res in re.findall('LV_HAVE_(\w+)', header))
|
self.deps = set(res.lower() for res in re.findall('LV_HAVE_(\w+)', header))
|
||||||
@ -160,7 +160,7 @@ def extract_lv_haves(code):
|
|||||||
########################################################################
|
########################################################################
|
||||||
# Represent a processing kernel, parse from file
|
# Represent a processing kernel, parse from file
|
||||||
########################################################################
|
########################################################################
|
||||||
class kernel_class:
|
class kernel_class(object):
|
||||||
def __init__(self, kernel_file):
|
def __init__(self, kernel_file):
|
||||||
self.name = os.path.splitext(os.path.basename(kernel_file))[0]
|
self.name = os.path.splitext(os.path.basename(kernel_file))[0]
|
||||||
self.pname = self.name.replace('volk_gnsssdr_', 'p_')
|
self.pname = self.name.replace('volk_gnsssdr_', 'p_')
|
||||||
|
@ -26,7 +26,7 @@ from volk_gnsssdr_arch_defs import arch_dict
|
|||||||
machines = list()
|
machines = list()
|
||||||
machine_dict = dict()
|
machine_dict = dict()
|
||||||
|
|
||||||
class machine_class:
|
class machine_class(object):
|
||||||
def __init__(self, name, archs):
|
def __init__(self, name, archs):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.archs = list()
|
self.archs = list()
|
||||||
@ -36,7 +36,7 @@ class machine_class:
|
|||||||
arch = arch_dict[arch_name]
|
arch = arch_dict[arch_name]
|
||||||
self.archs.append(arch)
|
self.archs.append(arch)
|
||||||
self.arch_names.append(arch_name)
|
self.arch_names.append(arch_name)
|
||||||
self.alignment = max(map(lambda a: a.alignment, self.archs))
|
self.alignment = max([a.alignment for a in self.archs])
|
||||||
|
|
||||||
def __repr__(self): return self.name
|
def __repr__(self): return self.name
|
||||||
|
|
||||||
|
@ -19,5 +19,5 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
from cfg import volk_gnsssdr_modtool_config
|
from .cfg import volk_gnsssdr_modtool_config
|
||||||
from volk_gnsssdr_modtool_generate import volk_gnsssdr_modtool
|
from .volk_gnsssdr_modtool_generate import volk_gnsssdr_modtool
|
||||||
|
@ -21,14 +21,13 @@
|
|||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import ConfigParser
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import exceptions
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from six.moves import configparser, input
|
||||||
|
|
||||||
class volk_gnsssdr_modtool_config:
|
class volk_gnsssdr_modtool_config(object):
|
||||||
def key_val_sub(self, num, stuff, section):
|
def key_val_sub(self, num, stuff, section):
|
||||||
return re.sub('\$' + 'k' + str(num), stuff[num][0], (re.sub('\$' + str(num), stuff[num][1], section[1][num])));
|
return re.sub('\$' + 'k' + str(num), stuff[num][0], (re.sub('\$' + str(num), stuff[num][1], section[1][num])));
|
||||||
|
|
||||||
@ -46,11 +45,11 @@ class volk_gnsssdr_modtool_config:
|
|||||||
try:
|
try:
|
||||||
val = eval(self.key_val_sub(i, stuff, section))
|
val = eval(self.key_val_sub(i, stuff, section))
|
||||||
if val == False:
|
if val == False:
|
||||||
raise exceptions.ValueError
|
raise ValueError
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise exceptions.ValueError('Verification function returns False... key:%s, val:%s'%(stuff[i][0], stuff[i][1]))
|
raise ValueError('Verification function returns False... key:%s, val:%s'%(stuff[i][0], stuff[i][1]))
|
||||||
except:
|
except:
|
||||||
raise exceptions.IOError('bad configuration... key:%s, val:%s'%(stuff[i][0], stuff[i][1]))
|
raise IOError('bad configuration... key:%s, val:%s'%(stuff[i][0], stuff[i][1]))
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, cfg=None):
|
def __init__(self, cfg=None):
|
||||||
@ -66,7 +65,7 @@ class volk_gnsssdr_modtool_config:
|
|||||||
self.remapification = [(self.config_name, self.config_defaults_remap)]
|
self.remapification = [(self.config_name, self.config_defaults_remap)]
|
||||||
self.verification = [(self.config_name, self.config_defaults_verify)]
|
self.verification = [(self.config_name, self.config_defaults_verify)]
|
||||||
default = os.path.join(os.getcwd(), 'volk_gnsssdr_modtool.cfg')
|
default = os.path.join(os.getcwd(), 'volk_gnsssdr_modtool.cfg')
|
||||||
icfg = ConfigParser.RawConfigParser()
|
icfg = configparser.RawConfigParser()
|
||||||
if cfg:
|
if cfg:
|
||||||
icfg.read(cfg)
|
icfg.read(cfg)
|
||||||
elif os.path.exists(default):
|
elif os.path.exists(default):
|
||||||
@ -75,7 +74,7 @@ class volk_gnsssdr_modtool_config:
|
|||||||
print("Initializing config file...")
|
print("Initializing config file...")
|
||||||
icfg.add_section(self.config_name)
|
icfg.add_section(self.config_name)
|
||||||
for kn in self.config_defaults:
|
for kn in self.config_defaults:
|
||||||
rv = raw_input("%s: "%(kn))
|
rv = input("%s: "%(kn))
|
||||||
icfg.set(self.config_name, kn, rv)
|
icfg.set(self.config_name, kn, rv)
|
||||||
self.cfg = icfg
|
self.cfg = icfg
|
||||||
self.remap()
|
self.remap()
|
||||||
|
@ -18,10 +18,10 @@
|
|||||||
# along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
|
# along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
from volk_gnsssdr_modtool import volk_gnsssdr_modtool, volk_gnsssdr_modtool_config
|
from volk_gnsssdr_modtool import volk_gnsssdr_modtool, volk_gnsssdr_modtool_config
|
||||||
from optparse import OptionParser, OptionGroup
|
from optparse import OptionParser, OptionGroup
|
||||||
|
|
||||||
import exceptions
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -57,12 +57,12 @@ if __name__ == '__main__':
|
|||||||
parser.print_help()
|
parser.print_help()
|
||||||
|
|
||||||
elif options.moo:
|
elif options.moo:
|
||||||
print " (__) "
|
print(" (__) ")
|
||||||
print " (oo) "
|
print(" (oo) ")
|
||||||
print " /------\/ "
|
print(" /------\/ ")
|
||||||
print " / | || "
|
print(" / | || ")
|
||||||
print " * /\---/\ "
|
print(" * /\---/\ ")
|
||||||
print " ~~ ~~ "
|
print(" ~~ ~~ ")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
my_cfg = volk_gnsssdr_modtool_config(options.config_file);
|
my_cfg = volk_gnsssdr_modtool_config(options.config_file);
|
||||||
@ -77,7 +77,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
if options.add_kernel:
|
if options.add_kernel:
|
||||||
if not options.kernel_name:
|
if not options.kernel_name:
|
||||||
raise exceptions.IOError("This action requires the -n option.");
|
raise IOError("This action requires the -n option.");
|
||||||
else:
|
else:
|
||||||
name = options.kernel_name;
|
name = options.kernel_name;
|
||||||
if options.base_path:
|
if options.base_path:
|
||||||
@ -88,7 +88,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
if options.remove_kernel:
|
if options.remove_kernel:
|
||||||
if not options.kernel_name:
|
if not options.kernel_name:
|
||||||
raise exceptions.IOError("This action requires the -n option.");
|
raise IOError("This action requires the -n option.");
|
||||||
else:
|
else:
|
||||||
name = options.kernel_name;
|
name = options.kernel_name;
|
||||||
my_modtool.remove_kernel(name);
|
my_modtool.remove_kernel(name);
|
||||||
@ -105,17 +105,17 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
if options.remote_list:
|
if options.remote_list:
|
||||||
if not options.base_path:
|
if not options.base_path:
|
||||||
raise exceptions.IOError("This action requires the -b option. Try -l or -k for listing kernels in the base or the module.")
|
raise IOError("This action requires the -b option. Try -l or -k for listing kernels in the base or the module.")
|
||||||
else:
|
else:
|
||||||
base = options.base_path;
|
base = options.base_path;
|
||||||
kernelset = my_modtool.get_current_kernels(base);
|
kernelset = my_modtool.get_current_kernels(base);
|
||||||
for i in kernelset:
|
for i in kernelset:
|
||||||
print i;
|
print(i);
|
||||||
|
|
||||||
if options.list:
|
if options.list:
|
||||||
kernelset = my_modtool.get_current_kernels();
|
kernelset = my_modtool.get_current_kernels();
|
||||||
for i in kernelset:
|
for i in kernelset:
|
||||||
print i;
|
print(i);
|
||||||
|
|
||||||
if options.kernels:
|
if options.kernels:
|
||||||
dest = my_cfg.cfg.get(my_cfg.config_name, 'destination');
|
dest = my_cfg.cfg.get(my_cfg.config_name, 'destination');
|
||||||
@ -123,4 +123,4 @@ if __name__ == '__main__':
|
|||||||
base = os.path.join(dest, 'volk_gnsssdr_' + name);
|
base = os.path.join(dest, 'volk_gnsssdr_' + name);
|
||||||
kernelset = my_modtool.get_current_kernels(base);
|
kernelset = my_modtool.get_current_kernels(base);
|
||||||
for i in kernelset:
|
for i in kernelset:
|
||||||
print i;
|
print(i);
|
||||||
|
@ -21,15 +21,10 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import glob
|
|
||||||
import sys
|
|
||||||
import re
|
import re
|
||||||
import glob
|
import glob
|
||||||
import shutil
|
|
||||||
import exceptions
|
|
||||||
from sets import Set
|
|
||||||
|
|
||||||
class volk_gnsssdr_modtool:
|
class volk_gnsssdr_modtool(object):
|
||||||
def __init__(self, cfg):
|
def __init__(self, cfg):
|
||||||
self.volk_gnsssdr = re.compile('volk_gnsssdr');
|
self.volk_gnsssdr = re.compile('volk_gnsssdr');
|
||||||
self.remove_after_underscore = re.compile("_.*");
|
self.remove_after_underscore = re.compile("_.*");
|
||||||
@ -96,7 +91,7 @@ class volk_gnsssdr_modtool:
|
|||||||
|
|
||||||
dest = os.path.join(self.my_dict['destination'], 'volk_gnsssdr_' + self.my_dict['name'])
|
dest = os.path.join(self.my_dict['destination'], 'volk_gnsssdr_' + self.my_dict['name'])
|
||||||
if os.path.exists(dest):
|
if os.path.exists(dest):
|
||||||
raise exceptions.IOError("Destination %s already exits!"%(dest));
|
raise IOError("Destination %s already exits!" % (dest));
|
||||||
|
|
||||||
if not os.path.exists(os.path.join(self.my_dict['destination'], 'volk_gnsssdr_' + self.my_dict['name'], 'kernels/volk_gnsssdr_' + self.my_dict['name'])):
|
if not os.path.exists(os.path.join(self.my_dict['destination'], 'volk_gnsssdr_' + self.my_dict['name'], 'kernels/volk_gnsssdr_' + self.my_dict['name'])):
|
||||||
os.makedirs(os.path.join(self.my_dict['destination'], 'volk_gnsssdr_' + self.my_dict['name'], 'kernels/volk_gnsssdr_' + self.my_dict['name']))
|
os.makedirs(os.path.join(self.my_dict['destination'], 'volk_gnsssdr_' + self.my_dict['name'], 'kernels/volk_gnsssdr_' + self.my_dict['name']))
|
||||||
@ -108,7 +103,7 @@ class volk_gnsssdr_modtool:
|
|||||||
|
|
||||||
for root, dirnames, filenames in os.walk(self.my_dict['base']):
|
for root, dirnames, filenames in os.walk(self.my_dict['base']):
|
||||||
for name in filenames:
|
for name in filenames:
|
||||||
t_table = map(lambda a: re.search(a, name), current_kernel_names);
|
t_table = [re.search(a, name) for a in current_kernel_names]
|
||||||
t_table = set(t_table);
|
t_table = set(t_table);
|
||||||
if t_table == set([None]):
|
if t_table == set([None]):
|
||||||
infile = os.path.join(root, name);
|
infile = os.path.join(root, name);
|
||||||
@ -188,16 +183,11 @@ class volk_gnsssdr_modtool:
|
|||||||
base = os.path.join(self.my_dict['destination'], top[:-1]) ;
|
base = os.path.join(self.my_dict['destination'], top[:-1]) ;
|
||||||
|
|
||||||
if not name in self.get_current_kernels():
|
if not name in self.get_current_kernels():
|
||||||
|
raise IOError("Requested kernel %s is not in module %s" % (name,base));
|
||||||
raise exceptions.IOError("Requested kernel %s is not in module %s"%(name,base));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inpath = os.path.abspath(base);
|
inpath = os.path.abspath(base);
|
||||||
|
|
||||||
|
|
||||||
kernel = re.compile(name)
|
kernel = re.compile(name)
|
||||||
search_kernels = Set([kernel])
|
search_kernels = set([kernel])
|
||||||
profile = re.compile('^\s*VOLK_PROFILE')
|
profile = re.compile('^\s*VOLK_PROFILE')
|
||||||
puppet = re.compile('^\s*VOLK_PUPPET')
|
puppet = re.compile('^\s*VOLK_PUPPET')
|
||||||
src_dest = os.path.join(inpath, 'apps/', top[:-1] + '_profile.cc');
|
src_dest = os.path.join(inpath, 'apps/', top[:-1] + '_profile.cc');
|
||||||
@ -253,7 +243,7 @@ class volk_gnsssdr_modtool:
|
|||||||
else:
|
else:
|
||||||
basename = self.get_basename(base);
|
basename = self.get_basename(base);
|
||||||
if not name in self.get_current_kernels(base):
|
if not name in self.get_current_kernels(base):
|
||||||
raise exceptions.IOError("Requested kernel %s is not in module %s"%(name,base));
|
raise IOError("Requested kernel %s is not in module %s" % (name, base));
|
||||||
|
|
||||||
inpath = os.path.abspath(base);
|
inpath = os.path.abspath(base);
|
||||||
if len(basename) > 0:
|
if len(basename) > 0:
|
||||||
@ -265,7 +255,7 @@ class volk_gnsssdr_modtool:
|
|||||||
self.convert_kernel(oldvolk_gnsssdr, name, base, inpath, top);
|
self.convert_kernel(oldvolk_gnsssdr, name, base, inpath, top);
|
||||||
|
|
||||||
kernel = re.compile(name)
|
kernel = re.compile(name)
|
||||||
search_kernels = Set([kernel])
|
search_kernels = set([kernel])
|
||||||
|
|
||||||
profile = re.compile('^\s*VOLK_PROFILE')
|
profile = re.compile('^\s*VOLK_PROFILE')
|
||||||
puppet = re.compile('^\s*VOLK_PUPPET')
|
puppet = re.compile('^\s*VOLK_PUPPET')
|
||||||
|
Loading…
Reference in New Issue
Block a user