diff --git a/docs/user_manual/cli_intro.tex b/docs/user_manual/cli_intro.tex index b306b856f..207e0d55e 100644 --- a/docs/user_manual/cli_intro.tex +++ b/docs/user_manual/cli_intro.tex @@ -902,7 +902,7 @@ \section{Running xorpsh in Non-Interactive Mode} \item Running \xorpsh as part of an ``expect'' script: \begin{verbatim} -#!/usr/bin/env python +#!/usr/bin/env python2 import time import sys import pexpect diff --git a/docs/wiki/pages/latex2wiki/user_manual/command_structure.txt b/docs/wiki/pages/latex2wiki/user_manual/command_structure.txt index 5accaee2d..57d1b33cc 100644 --- a/docs/wiki/pages/latex2wiki/user_manual/command_structure.txt +++ b/docs/wiki/pages/latex2wiki/user_manual/command_structure.txt @@ -562,7 +562,7 @@ show host os xorpsh -c "show host os" The “-c” option can be used more than once to execute multiple commands. * Running xorpsh as part of an “expect” script: -#!/usr/bin/env python +#!/usr/bin/env python2 import time import sys import pexpect diff --git a/other/testbed/tools/xtconf.py b/other/testbed/tools/xtconf.py index 1f683bb11..7939ff673 100755 --- a/other/testbed/tools/xtconf.py +++ b/other/testbed/tools/xtconf.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 # $XORP: other/testbed/tools/xtconf.py,v 1.17 2002/03/08 22:57:36 atanu Exp $ diff --git a/other/testbed/tools/xthpconfig.py b/other/testbed/tools/xthpconfig.py index 90d38081f..ee4c82acf 100755 --- a/other/testbed/tools/xthpconfig.py +++ b/other/testbed/tools/xthpconfig.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 # $XORP: other/testbed/tools/xthpconfig.py,v 1.9 2002/12/06 03:17:50 pavlin Exp $ diff --git a/other/testbed/tools/xtifset.py b/other/testbed/tools/xtifset.py index c432d857e..05340399d 100755 --- a/other/testbed/tools/xtifset.py +++ b/other/testbed/tools/xtifset.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 # $XORP: other/testbed/tools/xtifset.py,v 1.19 2002/07/03 00:18:58 atanu Exp $ diff --git a/other/testbed/tools/xtparse.py b/other/testbed/tools/xtparse.py index 679cb534f..6da2efbf4 100755 --- a/other/testbed/tools/xtparse.py +++ b/other/testbed/tools/xtparse.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 # $XORP: other/testbed/tools/xtparse.py,v 1.7 2002/03/08 22:57:36 atanu Exp $ diff --git a/other/testbed/tools/xtreset.py b/other/testbed/tools/xtreset.py index 3e7e689da..83fe37be1 100755 --- a/other/testbed/tools/xtreset.py +++ b/other/testbed/tools/xtreset.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 # $XORP: other/testbed/tools/xtreset.py,v 1.5 2003/07/27 10:34:17 pavlin Exp $ diff --git a/other/testbed/tools/xttable.py b/other/testbed/tools/xttable.py index 21edee470..c59fdd0ea 100755 --- a/other/testbed/tools/xttable.py +++ b/other/testbed/tools/xttable.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 # $XORP: other/testbed/tools/xttable.py,v 1.8 2001/11/02 23:57:44 atanu Exp $ diff --git a/other/testbed/tools/xtxml.py b/other/testbed/tools/xtxml.py index 0818b8be8..2a3f4c0e6 100755 --- a/other/testbed/tools/xtxml.py +++ b/other/testbed/tools/xtxml.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 # $XORP: other/testbed/tools/xtxml.py,v 1.10 2002/03/08 22:57:36 atanu Exp $ diff --git a/www/scripts/XorpOrgGenerator.py b/www/scripts/XorpOrgGenerator.py index 0628f6925..ef9cf154e 100755 --- a/www/scripts/XorpOrgGenerator.py +++ b/www/scripts/XorpOrgGenerator.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 import getopt, re, sys, time diff --git a/xorp/BUILD_NOTES b/xorp/BUILD_NOTES index 548cef778..585ef57e1 100644 --- a/xorp/BUILD_NOTES +++ b/xorp/BUILD_NOTES @@ -115,13 +115,8 @@ http://xorp.run.montefiore.ulg.ac.be/latex2wiki/user_manual More tests need to be written/enabled, but a fair amount of tests are enabled currently. -To run the internal tests, you must have "bash" and "python" installed. -Note that if the python's executable filename is not "python", then -you would have to create a symbolic link with such name. E.g., execute -as a root: +To run the internal tests, you must have "bash" and "python3" installed. -cd /path/to/python/binary -ln -s python2.4 python After the code is compiled, you need to run the following command in the top-level XORP directory: diff --git a/xorp/SConscript b/xorp/SConscript index ba5400b19..e2392b6f2 100644 --- a/xorp/SConscript +++ b/xorp/SConscript @@ -53,7 +53,7 @@ if env['enable_bgp']: if env['enable_ospf']: subdirs.append('ospf') - + if env['enable_rip']: subdirs.append('rip') diff --git a/xorp/SConstruct b/xorp/SConstruct index 9e6556372..2f610feba 100644 --- a/xorp/SConstruct +++ b/xorp/SConstruct @@ -31,7 +31,7 @@ may not function correctly. # The XRL tgt-gen and clnt-gen scripts use Python 2.3+'s optparse # class. However, os.path.relpath() requires Python 2.6. -EnsurePythonVersion(2, 3) +EnsurePythonVersion(3, 8) Help(""" builddir= to specify a different build directory. @@ -56,8 +56,8 @@ try: # be relaxed. EnsureSConsVersion(0, 98, 4) except SystemExit: - print "WARNING: Actually, SCONS version 0.98.4 or later is _preferred_." - print "Attempting to continue with version: " + SCons.__version__ + " but it may not work properly.\n" + print("WARNING: Actually, SCONS version 0.98.4 or later is _preferred_.") + print("Attempting to continue with version: {} but it may not work properly.\n".format(Scons.__version__)) vars = Variables() @@ -122,9 +122,9 @@ vars.AddVariables( def log_args(afname): f = open(afname, 'w') - for a in ARGUMENTS.iteritems(): - print >>f, "%s=%s" % a, - print >>f + for a in ARGUMENTS.items(): + f.write('{0}={0}'.format(a)) + f.write('\n') f.close() def tgt_guess(): @@ -144,13 +144,13 @@ def tgt_canonicalize(alias): build_alias = ARGUMENTS.get('build', None) if build_alias == None: build_alias = tgt_guess() -build = tgt_canonicalize(build_alias) +build = tgt_canonicalize(build_alias).decode('utf-8') (build_cpu, build_vendor, build_os) = build.split('-', 2) host_alias = ARGUMENTS.get('host', None) if host_alias == None: host_alias = build_alias -host = tgt_canonicalize(host_alias) +host = tgt_canonicalize(host_alias).decode('utf-8') (host_cpu, host_vendor, host_os) = host.split('-', 2) @@ -165,7 +165,7 @@ except: pass # Only save args when doing the default build process. -if (len(COMMAND_LINE_TARGETS) == 0): +if len(COMMAND_LINE_TARGETS) == 0: log_args(builddir + '/.scons_build_args') # XXX TODO: Make initial CPPPATH/LIBPATH derive from @@ -180,54 +180,49 @@ if (len(COMMAND_LINE_TARGETS) == 0): # variables = vars) env = Environment( - TOOLS = ['default', 'autotest', 'clntgen', 'tgtgen', - 'TOOL_SUBST'], - ENV = os.environ, - BUILDDIR = builddir, - CPPPATH=['$BUILDDIR'], - LIBPATH=['usr/lib'], - variables = vars) + TOOLS=['default', 'autotest', 'clntgen', 'tgtgen', 'TOOL_SUBST'], ENV=os.environ, + BUILDDIR=builddir, CPPPATH=['$BUILDDIR'], LIBPATH=['usr/lib'], variables=vars) prefix = env['prefix'] env['builddir'] = builddir; -print 'Build System Type: ', build -print 'Host System Type: ', host -print 'Source path: ', sourcedir -print 'Build path: ', builddir -print 'Install prefix: ', prefix +print('Build System Type: {}'.format(build)) +print('Host System Type: {}'.format(host)) +print('Source path: {}'.format(sourcedir)) +print('Build path: {}'.format(builddir)) +print('Install prefix: {}'.format(prefix)) env['DESTDIR'] = ARGUMENTS.get('DESTDIR', '') # Provide mechanism to override CC, CXX, etc. if ARGUMENTS.get('CC', None): env['CC'] = ARGUMENTS.get('CC') -print 'CC: ', env['CC'] +print('CC: {}'.format(env['CC'])) if ARGUMENTS.get('CXX', None): env['CXX'] = ARGUMENTS.get('CXX') -print 'CXX: ', env['CXX'] +print('CXX: {}'.format(env['CXX'])) if ARGUMENTS.get('RANLIB', None): env['RANLIB'] = ARGUMENTS.get('RANLIB') -print 'RANLIB: ', env['RANLIB'] +print('RANLIB: {}'.format(env['RANLIB'])) if ARGUMENTS.get('AR', None): env['AR'] = ARGUMENTS.get('AR') - print 'AR: ', env['AR'] + print('AR: {}'.format(env['AR'])) if ARGUMENTS.get('LD', None): env['LD'] = ARGUMENTS.get('LD') - print 'LD: ', env['LD'] + print('LD: {}'.format(env['LD'])) env['STRIP'] = ARGUMENTS.get('STRIP', 'strip') -print 'STRIP: ', env['STRIP'] +print('STRIP: {}'.format(env['STRIP'])) if env['strip']: env['strip'] = True -print 'Strip binaries: ', env.has_key('strip') +print('Strip binaries: {}'.format('strip' in env)) # POSIX strip has no options by the strict letter of the law. # Assume we have GNU binutils strip until proven otherwise. @@ -238,70 +233,70 @@ if gnustrip: # User can override this. Defaults to gcc's -O1, as this trims # most of the template fat. -print 'Optimize code: ', env['optimize'] +print('Optimize code: {}'.format(env['optimize'])) # Default to disable; wrapper for compiler profiling support. -print 'Profile code: ', env['profile'] +print('Profile code: {}'.format(env['profile'])) # Default to local (UNIX domain sockets). -print 'Default XRL transport:', env['transport'] +print('Default XRL transport: {}'.format(env['transport'])) # Most of our shared library tweaks are specific to GNU ld. # Check if the GNU linker is available, and print a warning if not. if env['shared']: if SCons.Tool.FindTool(['gnulink'], env) is None: - print gnutoolwarning % 'ld linker' + print(gnutoolwarning % 'ld linker') env['SHAREDLIBS'] = "defined" -print 'Shared libraries: ', env.has_key('SHAREDLIBS') -print 'Use rtld ORIGIN: ', env['rtld_origin'] +print('Shared libraries: {}'.format('SHAREDLIBS' in env)) +print('Use rtld ORIGIN: {}'.format(env['rtld_origin'])) # AUTOTEST_SKIP_ERRORS is SetDefault() by site_scons/site_tools/autotest.py, # so print its value here. if env['ignore_check_errors']: env['AUTOTEST_SKIP_ERRORS'] = True -print 'Ignore check errors: ', env['AUTOTEST_SKIP_ERRORS'] +print('Ignore check errors: {}'.format(env['AUTOTEST_SKIP_ERRORS'])) # NOTE: Enabling debug messages for the whole tree may not be what you want, # as it can lead to premature timeouts. # Enabling callback debugging is currently not advised as it does # inline printfs. -print 'Debug symbols: ', env['debug'] -print 'Debug STL: ', env['debug_stl'] -print 'Debug messages: ', env['debug_msg'] -print 'Debug function names: ', env['debug_fn'] -print 'Debug callbacks: ', env['debug_cb'] -print 'Debug XRL syntax: ', env['debug_xrldb'] -print 'Enable OLSR: ', env['enable_olsr'] -print 'Enable Wrapper: ', env['enable_wrapper'] -print 'Enable OSPF: ', env['enable_ospf'] -print 'Enable RIP: ', env['enable_rip'] -print 'Enable VRRP: ', env['enable_vrrp'] -print 'Enable xorpsh ', env['enable_xorpsh'] -print 'Enable Test Programs: ', env['enable_tests'] -print 'Enable CLICK: ', env['enable_click'] -print 'Enable FEA Dummy: ', env['enable_fea_dummy'] -print 'Enable VIFF_USE_IFINDEX: ', env['enable_viff_use_ifindex'] -print 'Enable async method impls: ', env['enable_async_server'] -print 'Enable BGP: ', env['enable_bgp'] -print 'Enable BuildInfo: ', env['enable_buildinfo'] -print 'Xorp can run from BUILD_DIR: ', env['enable_builddirrun'] -print 'Try Enable BOOST: ', env['enable_boost'] -print 'Try Enable uSTL : ', env['enable_ustl'] -print 'Disable IPv6: ', env['disable_ipv6'] -print 'Disable libtecla: ', env['disable_libtecla'] -print 'Disable Firewall: ', env['disable_fw'] -print 'Disable Profile : ', env['disable_profile'] -print 'Disable -Werror : ', env['disable_werror'] -print 'Disable deprecated warnings: ', env['disable_wdeprecated'] -print 'Enable lex hack : ', env['enable_lex_hack'] -print 'Disable warning logs : ', env['disable_warninglogs'] -print 'Disable error logs : ', env['disable_errorlogs'] -print 'Disable trace logs : ', env['disable_tracelogs'] -print 'Disable fatal logs : ', env['disable_fatallogs'] -print 'Disable info logs : ', env['disable_infologs'] -print 'Disable assert logs : ', env['disable_assertlogs'] -print 'Disable other logs : ', env['disable_otherlogs'] -print 'Disable assert: ', env['disable_assert'] +print('Debug symbols: {}'.format(env['debug'])) +print('Debug STL: {}'.format(env['debug_stl'])) +print('Debug messages: {}'.format(env['debug_msg'])) +print('Debug function names: {}'.format(env['debug_fn'])) +print('Debug callbacks: {}'.format(env['debug_cb'])) +print('Debug XRL syntax: {}'.format(env['debug_xrldb'])) +print('Enable OLSR: {}'.format(env['enable_olsr'])) +print('Enable Wrapper: {}'.format(env['enable_wrapper'])) +print('Enable OSPF: {}'.format(env['enable_ospf'])) +print('Enable RIP: {}'.format(env['enable_rip'])) +print('Enable VRRP: {}'.format(env['enable_vrrp'])) +print('Enable xorpsh {}'.format(env['enable_xorpsh'])) +print('Enable Test Programs: {}'.format(env['enable_tests'])) +print('Enable CLICK: {}'.format(env['enable_click'])) +print('Enable FEA Dummy: {}'.format(env['enable_fea_dummy'])) +print('Enable VIFF_USE_IFINDEX: {}'.format(env['enable_viff_use_ifindex'])) +print('Enable async method impls: {}'.format(env['enable_async_server'])) +print('Enable BGP: {}'.format(env['enable_bgp'])) +print('Enable BuildInfo: {}'.format(env['enable_buildinfo'])) +print('Xorp can run from BUILD_DIR: {}'.format(env['enable_builddirrun'])) +print('Try Enable BOOST: {}'.format(env['enable_boost'])) +print('Try Enable uSTL : {}'.format(env['enable_ustl'])) +print('Disable IPv6: {}'.format(env['disable_ipv6'])) +print('Disable libtecla: {}'.format(env['disable_libtecla'])) +print('Disable Firewall: {}'.format(env['disable_fw'])) +print('Disable Profile : {}'.format(env['disable_profile'])) +print('Disable -Werror : {}'.format(env['disable_werror'])) +print('Disable deprecated warnings: {}'.format(env['disable_wdeprecated'])) +print('Enable lex hack : {}'.format(env['enable_lex_hack'])) +print('Disable warning logs : {}'.format(env['disable_warninglogs'])) +print('Disable error logs : {}'.format(env['disable_errorlogs'])) +print('Disable trace logs : {}'.format(env['disable_tracelogs'])) +print('Disable fatal logs : {}'.format(env['disable_fatallogs'])) +print('Disable info logs : {}'.format(env['disable_infologs'])) +print('Disable assert logs : {}'.format(env['disable_assertlogs'])) +print('Disable other logs : {}'.format(env['disable_otherlogs'])) +print('Disable assert: {}'.format(env['disable_assert'])) env['CONFIGURELOG'] = str(builddir) + os.sep + 'config.log' @@ -325,50 +320,49 @@ def Symlink(src, link_name): except OSError: pass os.symlink(src, link_name) -SConsEnvironment.Symlink = SCons.Action.ActionFactory(Symlink, - lambda src, link_name: 'Symlink("%s", as "%s")' % (src, link_name)) +SConsEnvironment.Symlink = SCons.Action.ActionFactory(Symlink, lambda src, link_name: 'Symlink("%s", as "%s")' % (src, link_name)) -def InstallProgram(env, dest, files, perm = 0755): - if env.has_key('DESTDIR'): - # NB: use simple concatenation - dest = env.Dir(env['DESTDIR'] + env.Dir(dest).path) +def InstallProgram(env, dest, files, perm=0O755): + if 'DESTDIR' in env: + # NB: use simple concatenation + dest = env.Dir(env['DESTDIR'] + env.Dir(dest).path) obj = env.Install(dest, files) for i in obj: - env.AddPostAction(i, env.Chmod(str(i), perm)) - if env['strip']: - env.AddPostAction(i, Action("$STRIP $TARGET")) + env.AddPostAction(i, env.Chmod(str(i), perm)) + if env['strip']: + env.AddPostAction(i, Action("$STRIP $TARGET")) return obj SConsEnvironment.InstallProgram = InstallProgram -def InstallScript(env, dest, files, perm = 0555): - if env.has_key('DESTDIR'): - # NB: use simple concatenation - dest = env.Dir(env['DESTDIR'] + env.Dir(dest).path) +def InstallScript(env, dest, files, perm = 0O555): + if 'DESTDIR' in env: + # NB: use simple concatenation + dest = env.Dir(env['DESTDIR'] + env.Dir(dest).path) obj = env.Install(dest, files) for i in obj: - env.AddPostAction(i, env.Chmod(str(i), perm)) + env.AddPostAction(i, env.Chmod(str(i), perm)) return obj SConsEnvironment.InstallScript = InstallScript -def InstallLibrary(env, dest, files, perm = 0644): - if env.has_key('DESTDIR'): - # NB: use simple concatenation - dest = env.Dir(env['DESTDIR'] + env.Dir(dest).path) +def InstallLibrary(env, dest, files, perm = 0O644): + if 'DESTDIR' in env: + # NB: use simple concatenation + dest = env.Dir(env['DESTDIR'] + env.Dir(dest).path) obj = env.Install(dest, files) for i in obj: - env.AddPostAction(i, env.Chmod(str(i), perm)) - if env['strip']: - env.AddPostAction(i, Action("$STRIP $_STRIP_UNNEEDED $TARGET")) + env.AddPostAction(i, env.Chmod(str(i), perm)) + if env['strip']: + env.AddPostAction(i, Action("$STRIP $_STRIP_UNNEEDED $TARGET")) return obj SConsEnvironment.InstallLibrary = InstallLibrary -def InstallData(env, dest, files, perm = 0644): - if env.has_key('DESTDIR'): - # NB: use simple concatenation - dest = env.Dir(env['DESTDIR'] + env.Dir(dest).path) +def InstallData(env, dest, files, perm = 0O644): + if 'DESTDIR' in env: + # NB: use simple concatenation + dest = env.Dir(env['DESTDIR'] + env.Dir(dest).path) obj = env.Install(dest, files) for i in obj: - env.AddPostAction(i, env.Chmod(str(i), perm)) + env.AddPostAction(i, env.Chmod(str(i), perm)) return obj SConsEnvironment.InstallData = InstallData @@ -480,8 +474,8 @@ else: if not env.GetOption('clean') and \ not env.GetOption('help'): if os.system("./libxorp/create_buildinfo.sh") != 0: - print "ERROR: Failed to generate libxorp/build_info.cc." - print "You can disable this feature with: enable_buildinfo=no" + print("ERROR: Failed to generate libxorp/build_info.cc.") + print("You can disable this feature with: enable_buildinfo=no") exit(1) if env.GetOption('clean'): @@ -630,7 +624,7 @@ else: ########## start configure magic -if env.has_key('LIBS'): +if 'LIBS' in env: pre_LIBS = env['LIBS'] else: pre_LIBS = [] @@ -682,14 +676,14 @@ if not env.GetOption('clean') and \ conf.Define('HAVE_PROC_LINUX') conf.Define('ENABLE_ADVANCED_MULTICAST_API') elif fnmatch.fnmatch(host_os, 'netbsd*'): - osname = "NetBSD" - conf.Define('HOST_OS_NETBSD') + osname = "NetBSD" + conf.Define('HOST_OS_NETBSD') conf.Define('ENABLE_ADVANCED_MULTICAST_API') elif fnmatch.fnmatch(host_os, 'sunos*'): osname = "Solaris" conf.Define('HOST_OS_SOLARIS') else: - osname = sys.platform.upper() + osname = sys.platform.upper() conf.Define('HOST_OS_NAME', '"' + osname + '"') #export osname - needed for lex and yacc @@ -711,8 +705,8 @@ if not env.GetOption('clean') and \ if env['enable_boost']: # Boost #env['boost_suffix'] = "-mt" # Not for FreeBSD - if not conf.CheckBoost(require_version='1.34'): - print "Boost version check for 1.34 failed, disabling boost support.\n" + if not conf.CheckBoost(require_version='1.34'): + print("Boost version check for 1.34 failed, disabling boost support.\n") env['enable_boost'] = False #conf.CheckBoostLibrary('system') @@ -762,13 +756,13 @@ if not env.GetOption('clean') and \ # Print warnings about missing/skipped dependencies. if env['MISSING_DEPS']: - print '\nRequired dependencies not found, exiting:\n - %s' % '\n - '.join(env['MISSING_DEPS']) + print('\nRequired dependencies not found, exiting:\n - %s' % '\n - '.join(env['MISSING_DEPS'])) if env['SKIPPED_DEPS']: - print 'Optional dependencies not found:\n - %s' % '\n - '.join(env['SKIPPED_DEPS']) + print('Optional dependencies not found:\n - %s' % '\n - '.join(env['SKIPPED_DEPS'])) Exit(1) if env['SKIPPED_DEPS']: - print 'Optional dependencies not found:\n - %s' % '\n - '.join(env['SKIPPED_DEPS']) + print('Optional dependencies not found:\n - %s' % '\n - '.join(env['SKIPPED_DEPS'])) newenv = conf.Finish() # @@ -783,28 +777,29 @@ if not env.GetOption('clean') and \ # For now, let's assume that libraries are present, and link against # them on a piecemeal basis. # - post_LIBS = env['LIBS'] + post_LIBS = [] + if 'LIBS' in env: + post_LIBS = env['LIBS'] env['LIBS'] = pre_LIBS - print 'Detected libraries:', + print('Detected libraries:', end=' ') for x in post_LIBS: - print x, - print + print(x, end=' ') ########## end configure magic if SCons.Tool.FindTool(['gcc'], env) is None or \ SCons.Tool.FindTool(['g++'], env) is None: - print gnutoolwarning % 'gcc or g++ compiler' + print(gnutoolwarning % 'gcc or g++ compiler') # If the user didn't override our default optimization, then # sanitize user's CFLAGS/CXXFLAGS to not contain optimization options, # and map to an appropriate GCC flag. if not env['optimize'] == 'override': - env.Replace( CFLAGS = filter(lambda s: not s.startswith('-O'), - Split(env['CFLAGS']))) - env.Replace( CXXFLAGS = filter(lambda s: not s.startswith('-O'), - Split(env['CXXFLAGS']))) + env.Replace( CFLAGS = list(filter(lambda s: not s.startswith('-O'), + Split(env['CFLAGS'])))) + env.Replace( CXXFLAGS = list(filter(lambda s: not s.startswith('-O'), + Split(env['CXXFLAGS'])))) bigodict = { 'no': '-O0', # 'minimal' denotes only those optimizations # necessary to force gcc to perform the tree_sink @@ -832,10 +827,10 @@ if not env['optimize'] == 'override': # Do the same for the flags which control debug symbols. if not env['debug'] == 'override': - env.Replace( CFLAGS = filter(lambda s: not s.startswith('-g'), - Split(env['CFLAGS']))) - env.Replace( CXXFLAGS = filter(lambda s: not s.startswith('-g'), - Split(env['CXXFLAGS']))) + env.Replace( CFLAGS = list(filter(lambda s: not s.startswith('-g'), + Split(env['CFLAGS'])))) + env.Replace( CXXFLAGS = list(filter(lambda s: not s.startswith('-g'), + Split(env['CXXFLAGS'])))) gdict = { 'no': '', 'yes': '-g', 'full': '-g3' } gflag = gdict[env['debug']] if not env['debug'] == 'no': @@ -844,28 +839,28 @@ if not env['debug'] == 'override': # Do the same for the flags which control code profiling. if not env['profile'] == 'override': - if env['profile'] == 'gprof' and env.has_key('SHAREDLIBS'): - print """ + if env['profile'] == 'gprof' and 'SHAREDLIBS' in env: + print(""" WARNING: You have requested GNU gprof style profiling and shared libraries. This is UNSUPPORTED, and probably will not link. -""" +""") strip_pg_flags = [ '-pg', '-finstrument-functions', '-fno-omit-frame-pointer', '-fno-optimize-sibling-calls' ] try: - env.Replace( CFLAGS = filter( + env.Replace( CFLAGS = list(filter( lambda s: not s.startswith(tuple(strip_pg_flags)), - Split(env['CFLAGS'])) + Split(env['CFLAGS']))) ) - env.Replace( CXXFLAGS = filter( + env.Replace( CXXFLAGS = list(filter( lambda s: not s.startswith(tuple(strip_pg_flags)), - Split(env['CXXFLAGS'])) + Split(env['CXXFLAGS']))) ) except TypeError: - print """ + print(""" WARNING: Your version of scons and/or python has a syntax issue with this code. It cannot strip out the gprof related flags. If your compile fails, please try disabling gprof profiling and/or shared libraries. If the compile works, then you can ignore this warning. - """ + """) # Full use of profiling may require more than one flag, so Split() them. pgdict = {'no': '', @@ -937,7 +932,7 @@ if env['enable_boost']: ]) if env['disable_wdeprecated']: - print "WARNING: Adding -Wno-deprecated on user command." + print("WARNING: Adding -Wno-deprecated on user command.") env.AppendUnique(CFLAGS = [ '-Wno-deprecated', ]) @@ -952,16 +947,16 @@ if ((build != "i386-pc-mingw32") and host_cpu == "i386" or host_cpu == "x86_64")): if env['disable_werror']: - print "WARNING: Disabling -Werror on user command." + print("WARNING: Disabling -Werror on user command.") else: env.AppendUnique(CFLAGS = [ - '-Werror', - ]) - env.AppendUnique(CXXFLAGS = [ - '-Werror', - ]) + '-Werror', + ]) + env.AppendUnique(CXXFLAGS = [ + '-Werror', + ]) else: - print "WARNING: Detected funky platform, will not enable -Werror compile option: ", host_cpu + print('WARNING: Detected funky platform, will not enable -Werror compile option: {}'.format(host_cpu)) # NOTE: gcc specific flags. @@ -1063,65 +1058,65 @@ env['xorp_sbin_rpath'] = env['xorp_libdir'] env['xorp_tool_rpath'] = env['xorp_libdir'] env['xorp_module_rpath'] = env['xorp_libdir'] -if env.has_key('SHAREDLIBS'): +if 'SHAREDLIBS' in env: if env['rtld_origin']: - # - # Build a subdirectory for holding symlinks to libraries upfront, so - # that binaries about to be built can be run from inside the BUILDDIR. - # - # XXX Assumes that $libdir is below $exec_prefix. If the - # user changes this, results are undefined. - # - # $BUILDIR/lib will contain .so symlinks - # - xorp_alias_libdir = os.path.join(builddir, 'lib') - # XXX workaround Mkdir() failure on EEXIST, SCons < 20090223. - try: - Execute(Mkdir(xorp_alias_libdir)) - except: - pass - env['xorp_alias_libdir'] = xorp_alias_libdir - # - # Build a further alias for the benefit of entities which - # will be later installed in $xorp_sbindir. - # - # $BUILDIR/lib/xorp/lib will point to $BUILDIR/lib - # - xorp_alias_subdir = os.path.join(xorp_alias_libdir, 'xorp') - # - # XXX workaround Mkdir() failure on EEXIST, SCons < 20090223. - xorp_module_alias_libdir = os.path.join(xorp_alias_subdir, 'lib') - try: - Execute(Mkdir(xorp_alias_subdir)) - except: - pass - Execute(env.Symlink(xorp_alias_libdir, xorp_module_alias_libdir)) - env['xorp_module_alias_libdir'] = xorp_module_alias_libdir + # + # Build a subdirectory for holding symlinks to libraries upfront, so + # that binaries about to be built can be run from inside the BUILDDIR. + # + # XXX Assumes that $libdir is below $exec_prefix. If the + # user changes this, results are undefined. + # + # $BUILDIR/lib will contain .so symlinks + # + xorp_alias_libdir = os.path.join(builddir, 'lib') + # XXX workaround Mkdir() failure on EEXIST, SCons < 20090223. + try: + Execute(Mkdir(xorp_alias_libdir)) + except: + pass + env['xorp_alias_libdir'] = xorp_alias_libdir + # + # Build a further alias for the benefit of entities which + # will be later installed in $xorp_sbindir. + # + # $BUILDIR/lib/xorp/lib will point to $BUILDIR/lib + # + xorp_alias_subdir = os.path.join(xorp_alias_libdir, 'xorp') + # + # XXX workaround Mkdir() failure on EEXIST, SCons < 20090223. + xorp_module_alias_libdir = os.path.join(xorp_alias_subdir, 'lib') + try: + Execute(Mkdir(xorp_alias_subdir)) + except: + pass + Execute(env.Symlink(xorp_alias_libdir, xorp_module_alias_libdir)) + env['xorp_module_alias_libdir'] = xorp_module_alias_libdir if not fnmatch.fnmatch(host_os, 'mingw32*'): # Tell rtld to turn on $ORIGIN processing by default. # NOTE: GNU ld specific flag. env.PrependUnique( LINKFLAGS = [ '-Wl,-z,origin' ] ) - # Set relative RPATH for each kind of installed XORP component. - env['xorp_sbin_rpath'] = os.path.join('\\$$ORIGIN', - os.path.relpath(env.Dir('$xorp_libdir').abspath, - env.Dir('$xorp_sbindir').abspath)) - env['xorp_tool_rpath'] = os.path.join('\\$$ORIGIN', - os.path.relpath(env.Dir('$xorp_libdir').abspath, - env.Dir('$xorp_tooldir').abspath)) - env['xorp_module_rpath'] = os.path.join('\\$$ORIGIN', - os.path.relpath(env.Dir('$xorp_libdir').abspath, - env.Dir('$xorp_moduledir').abspath)) + # Set relative RPATH for each kind of installed XORP component. + env['xorp_sbin_rpath'] = os.path.join('\\$$ORIGIN', + os.path.relpath(env.Dir('$xorp_libdir').abspath, + env.Dir('$xorp_sbindir').abspath)) + env['xorp_tool_rpath'] = os.path.join('\\$$ORIGIN', + os.path.relpath(env.Dir('$xorp_libdir').abspath, + env.Dir('$xorp_tooldir').abspath)) + env['xorp_module_rpath'] = os.path.join('\\$$ORIGIN', + os.path.relpath(env.Dir('$xorp_libdir').abspath, + env.Dir('$xorp_moduledir').abspath)) if env['enable_builddirrun']: - # - # Build a subdirectories for holding symlinks to modules and command binaries, - # so that xorpsh and rtrmngr, about to be built, can be run from inside the BUILDDIR. - # - # $BUILDIR/lib/bin will contain symlinks to command bins - # $BUILDIR/lib/sbin will contain symlinks to module bins - # + # + # Build a subdirectories for holding symlinks to modules and command binaries, + # so that xorpsh and rtrmngr, about to be built, can be run from inside the BUILDDIR. + # + # $BUILDIR/lib/bin will contain symlinks to command bins + # $BUILDIR/lib/sbin will contain symlinks to module bins + # xorp_alias_subdir = os.path.join(builddir, 'lib') xorp_alias_subdir = os.path.join(xorp_alias_subdir, 'xorp') xorp_alias_moduledir = os.path.join(xorp_alias_subdir, 'sbin') @@ -1154,7 +1149,6 @@ if not fnmatch.fnmatch(host_os, 'mingw32*'): '-rdynamic', ]) -env.SConscript(['SConscript'], variant_dir='$BUILDDIR', - exports='env', duplicate=0) +env.SConscript(['SConscript'], exports='env', variant_dir='$BUILDDIR', duplicate=0) env.Help(vars.GenerateHelpText(env)) diff --git a/xorp/bgp/SConscript b/xorp/bgp/SConscript index 46d89d7c5..fdb0c8613 100644 --- a/xorp/bgp/SConscript +++ b/xorp/bgp/SConscript @@ -21,26 +21,26 @@ import os Import('env') subdirs = [ - 'tools', - 'tests', - 'harness', + 'tools', + 'tests', + 'harness', ] SConscript(dirs = subdirs, exports='env') -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env if not is_shared: env.AppendUnique(LIBS = [ "crypto", ]) - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ "rt", ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ 'ws2_32', 'iphlpapi', @@ -87,7 +87,7 @@ bgp_env.AppendUnique(LIBS = [ ]) -if not (bgp_env.has_key('disable_profile') and bgp_env['disable_profile']): +if not ('disable_profile' in bgp_env and bgp_env['disable_profile']): bgp_env.AppendUnique(LIBS = [ 'xif_profile_client' ]) bgp_env.Replace(RPATH = [ @@ -99,60 +99,60 @@ bgp_env.Replace(RPATH = [ libxorp_bgp_env = bgp_env.Clone() libxorp_bgp_srcs = [ - 'aspath.cc', - 'attribute_manager.cc', + # 'aspath.cc', + 'attribute_manager.cc', 'bgp.cc', - 'bgp_trie.cc', - 'bgp_varrw.cc', - 'bgp_varrw_export.cc', - 'crash_dump.cc', - 'damping.cc', - 'dump_iterators.cc', - 'internal_message.cc', - 'iptuple.cc', - 'local_data.cc', - 'next_hop_resolver.cc', - 'notification_packet.cc', - 'open_packet.cc', - 'packet.cc', - 'parameter.cc', - 'path_attribute.cc', - 'peer.cc', - 'peer_data.cc', - 'peer_handler.cc', - 'peer_list.cc', - 'plumbing.cc', - 'process_watch.cc', - 'rib_ipc_handler.cc', - 'route_queue.cc', - 'route_table_aggregation.cc', - 'route_table_base.cc', - 'route_table_cache.cc', - 'route_table_damping.cc', - 'route_table_decision.cc', - 'route_table_deletion.cc', - 'route_table_dump.cc', - 'route_table_fanout.cc', - 'route_table_filter.cc', - 'route_table_nhlookup.cc', - 'route_table_policy.cc', - 'route_table_policy_ex.cc', - 'route_table_policy_im.cc', - 'route_table_policy_sm.cc', - 'route_table_reader.cc', - 'route_table_ribin.cc', - 'route_table_ribout.cc', - 'socket.cc', - 'subnet_route.cc', - 'update_attrib.cc', - 'update_packet.cc', - 'xrl_target.cc', - ] - -if not (bgp_env.has_key('disable_profile') and bgp_env['disable_profile']): + 'bgp_trie.cc', + 'bgp_varrw.cc', + 'bgp_varrw_export.cc', + 'crash_dump.cc', + 'damping.cc', + 'dump_iterators.cc', + 'internal_message.cc', + 'iptuple.cc', + 'local_data.cc', + 'next_hop_resolver.cc', + 'notification_packet.cc', + 'open_packet.cc', + 'packet.cc', + 'parameter.cc', + 'path_attribute.cc', + 'peer.cc', + 'peer_data.cc', + 'peer_handler.cc', + 'peer_list.cc', + 'plumbing.cc', + 'process_watch.cc', + 'rib_ipc_handler.cc', + 'route_queue.cc', + 'route_table_aggregation.cc', + 'route_table_base.cc', + 'route_table_cache.cc', + 'route_table_damping.cc', + 'route_table_decision.cc', + 'route_table_deletion.cc', + 'route_table_dump.cc', + 'route_table_fanout.cc', + 'route_table_filter.cc', + 'route_table_nhlookup.cc', + 'route_table_policy.cc', + 'route_table_policy_ex.cc', + 'route_table_policy_im.cc', + 'route_table_policy_sm.cc', + 'route_table_reader.cc', + 'route_table_ribin.cc', + 'route_table_ribout.cc', + 'socket.cc', + 'subnet_route.cc', + 'update_attrib.cc', + 'update_packet.cc', + 'xrl_target.cc', + ] + +if not ('disable_profile' in bgp_env and bgp_env['disable_profile']): libxorp_bgp_srcs.append('profile_vars.cc') -if (bgp_env.has_key('mingw') and bgp_env['mingw']): +if ('mingw' in bgp_env and bgp_env['mingw']): bgp_env.Append(LIBS = [ 'ws2_32', 'iphlpapi', diff --git a/xorp/bgp/harness/SConscript b/xorp/bgp/harness/SConscript index c1ac76dab..045442732 100644 --- a/xorp/bgp/harness/SConscript +++ b/xorp/bgp/harness/SConscript @@ -62,23 +62,23 @@ env.AppendUnique(LIBS = [ 'xif_finder_event_notifier', ]) -if not (env.has_key('disable_profile') and env['disable_profile']): +if not ('disable_profile' in env and env['disable_profile']): env.AppendUnique(LIBS = [ 'xif_profile_client', ]) -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env if not is_shared: env.AppendUnique(LIBS = [ "crypto", ]) - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ "rt", ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ 'ws2_32', 'iphlpapi', diff --git a/xorp/bgp/harness/harness.py b/xorp/bgp/harness/harness.py index 8877e888b..fa0d3a70f 100755 --- a/xorp/bgp/harness/harness.py +++ b/xorp/bgp/harness/harness.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # $XORP: xorp/bgp/harness/harness.py,v 1.1 2005/03/23 19:58:44 atanu Exp $ @@ -53,7 +53,7 @@ def coord(command): return time.sleep(1) - print >> sys.stderr, "Still pending" + print("Still pending", sys.stderr) def pending(): """ @@ -121,11 +121,11 @@ def stop(): def main(): def usage(): global us - print us % sys.argv[0] + print(us % sys.argv[0]) try: - opts, args = getopt.getopt(sys.argv[1:], "hei:c:p:a:b:l:rs46", \ - ["help", \ + opts, args = getopt.getopt(sys.argv[1:], "hei:c:p:a:b:l:rs46", \ + ["help", \ "establish", \ "inject=", \ "count=", \ @@ -139,8 +139,8 @@ def usage(): "ipv6", \ ]) except getopt.GetoptError: - usage() - sys.exit(1) + usage() + sys.exit(1) establishp = False injectp = False @@ -154,33 +154,33 @@ def usage(): logfile = None remove_logfile = False for o, a in opts: - if o in ("-h", "--help"): - usage() - sys.exit() - if o in ("-e", "--establish"): - establishp = True - if o in ("-i", "--inject"): - injectp = True - injectfile = a - if o in ("-c", "--count"): - route_count = a - if o in ("-p", "--peer"): - peer = a - if o in ("-a", "--asnum"): - asnum = a - if o in ("-b", "--bgp-id"): - router_id = a - if o in ("-l", "--logfile"): - logfile = a - if o in ("-r", "--remove"): - remove_logfile = True - if o in ("-s", "--stop"): - stopp = True - if o in ("-4", "--ipv4"): - ipv4 = True - if o in ("-6", "--ipv6"): - ipv4 = False - + if o in ("-h", "--help"): + usage() + sys.exit() + if o in ("-e", "--establish"): + establishp = True + if o in ("-i", "--inject"): + injectp = True + injectfile = a + if o in ("-c", "--count"): + route_count = a + if o in ("-p", "--peer"): + peer = a + if o in ("-a", "--asnum"): + asnum = a + if o in ("-b", "--bgp-id"): + router_id = a + if o in ("-l", "--logfile"): + logfile = a + if o in ("-r", "--remove"): + remove_logfile = True + if o in ("-s", "--stop"): + stopp = True + if o in ("-4", "--ipv4"): + ipv4 = True + if o in ("-6", "--ipv6"): + ipv4 = False + if establishp: establish(peer, asnum, router_id, ipv4, logfile, remove_logfile) diff --git a/xorp/bgp/harness/lookup.py b/xorp/bgp/harness/lookup.py index 40e557d65..905867818 100644 --- a/xorp/bgp/harness/lookup.py +++ b/xorp/bgp/harness/lookup.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # $XORP: xorp/bgp/harness/lookup.py,v 1.3 2007/12/10 23:26:32 mjh Exp $ @@ -16,7 +16,7 @@ def coord(command): """ command = command.replace(' ', '+') - print "finder://coord/coord/0.1/command?command:txt=%s" % command + print("finder://coord/coord/0.1/command?command:txt={}".format(command)) def lookup(peer, trie, add, remove): """ @@ -72,40 +72,41 @@ def lookup(peer, trie, add, remove): def main(): def usage(): global us - print >> sys.stderr, us % sys.argv[0] + print(us % sys.argv[0], sys.stderr) + try: - opts, args = getopt.getopt(sys.argv[1:], "hp:t:a:r:", \ - ["help", \ + opts, args = getopt.getopt(sys.argv[1:], "hp:t:a:r:", \ + ["help", \ "peer=", \ "trie=", \ "add=", \ "remove=", \ ]) except getopt.GetoptError: - usage() - sys.exit(1) + usage() + sys.exit(1) peer = "" trie = "" add = "" remove = "" for o, a in opts: - if o in ("-h", "-help"): - usage() - sys.exit() - if o in ("-p", "--peer"): - peer = a - if o in ("-t", "--trie"): - trie = a - if o in ("-a", "--add"): - add = a - if o in ("-r", "--remove"): - remove = a + if o in ("-h", "-help"): + usage() + sys.exit() + if o in ("-p", "--peer"): + peer = a + if o in ("-t", "--trie"): + trie = a + if o in ("-a", "--add"): + add = a + if o in ("-r", "--remove"): + remove = a if not peer and not trie: - usage() - sys.exit(1) + usage() + sys.exit(1) lookup(peer, trie, add, remove) diff --git a/xorp/bgp/tools/SConscript b/xorp/bgp/tools/SConscript index d71fbdb33..4fe6ab591 100644 --- a/xorp/bgp/tools/SConscript +++ b/xorp/bgp/tools/SConscript @@ -22,7 +22,7 @@ Import('env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#', @@ -64,12 +64,12 @@ if not is_shared: "crypto", ]) - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ "rt", ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ 'ws2_32', 'iphlpapi', @@ -80,7 +80,7 @@ if (env.has_key('mingw') and env['mingw']): env.Append(LIBS = ['xorp_core']) -if not (env.has_key('disable_profile') and env['disable_profile']): +if not ('disable_profile' in env and env['disable_profile']): env.AppendUnique(LIBS = [ 'xif_profile_client', ]) diff --git a/xorp/cli/SConscript b/xorp/cli/SConscript index 6359ca334..0b554b55c 100644 --- a/xorp/cli/SConscript +++ b/xorp/cli/SConscript @@ -1,4 +1,4 @@ - # Copyright (c) 2009-2011 XORP, Inc and Others +# Copyright (c) 2009-2011 XORP, Inc and Others # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, Version 2, June @@ -31,7 +31,7 @@ if not env['disable_libtecla']: SConscript(dirs = subdirs, exports = 'env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#', @@ -63,7 +63,7 @@ env.AppendUnique(LIBS = [ 'xorp_core', ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ 'winmm' ]) if not env['disable_libtecla']: diff --git a/xorp/cli/libtecla/SConscript b/xorp/cli/libtecla/SConscript index e86e6b333..52881f06e 100644 --- a/xorp/cli/libtecla/SConscript +++ b/xorp/cli/libtecla/SConscript @@ -22,7 +22,7 @@ Import('env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#' ]) @@ -46,7 +46,7 @@ env['CPPDEFINES'] = { 'HAVE_TERMINFO_H': 1, } -if not (env.has_key('mingw') and env['mingw']): +if not ('mingw' in env and env['mingw']): env.Append(CPPDEFINES={ 'HAVE_SYS_IOCTL_H': 1, 'HAVE_TERMIOS_H': 1, @@ -72,7 +72,7 @@ libtecla_srcs = [ # External libraries # Some sort of curses library is required. -if env.has_key('has_libncurses') and env['has_libncurses']: +if 'has_libncurses' in env and env['has_libncurses']: env.AppendUnique(LIBS = [ 'ncurses' ]) diff --git a/xorp/cli/tools/SConscript b/xorp/cli/tools/SConscript index bb5f94a5f..a9a1ac37d 100644 --- a/xorp/cli/tools/SConscript +++ b/xorp/cli/tools/SConscript @@ -21,7 +21,7 @@ Import('env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#', @@ -46,11 +46,11 @@ env.AppendUnique(LIBS = [ 'xorp_comm', ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ 'winmm' ]) if not is_shared: - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ "rt", ]) @@ -59,7 +59,7 @@ if not is_shared: "crypto", ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ 'ws2_32', 'iphlpapi', diff --git a/xorp/contrib/mld6igmp_lite/SConscript b/xorp/contrib/mld6igmp_lite/SConscript index 0d9784ec1..d0a871f82 100644 --- a/xorp/contrib/mld6igmp_lite/SConscript +++ b/xorp/contrib/mld6igmp_lite/SConscript @@ -22,7 +22,7 @@ Import('env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#', diff --git a/xorp/contrib/olsr/SConscript b/xorp/contrib/olsr/SConscript index dcd288d29..895463a4b 100644 --- a/xorp/contrib/olsr/SConscript +++ b/xorp/contrib/olsr/SConscript @@ -24,7 +24,7 @@ Import('env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env subdirs = ['tools'] @@ -75,12 +75,12 @@ if not is_shared: "crypto", ]) - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ "rt", ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ 'ws2_32', 'iphlpapi', @@ -91,7 +91,7 @@ if (env.has_key('mingw') and env['mingw']): env.Append(LIBS = ['xorp_core']) -if not (env.has_key('disable_ipv6') and env['disable_ipv6']): +if not ('disable_ipv6' in env and env['disable_ipv6']): env.AppendUnique(LIBS = [ 'xif_fea_rawpkt6', ]) diff --git a/xorp/contrib/olsr/test_routing1.py b/xorp/contrib/olsr/test_routing1.py index 0101b88e1..f33c9aaa6 100755 --- a/xorp/contrib/olsr/test_routing1.py +++ b/xorp/contrib/olsr/test_routing1.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # vim:set sts=4 ts=8 sw=4: # Copyright (c) 2001-2009 XORP, Inc. @@ -62,19 +62,19 @@ def start_routing_interactive(verbose, valgrind): # I should really import a which() here. if valgrind: - valgrind_path = "/usr/local/bin/valgrind" - valgrind_flags = "--tool=memcheck " \ - "--leak-check=yes " \ - "--leak-resolution=high " \ - "--num-callers=10 " \ - "--show-reachable=yes " \ - "--suppressions=/home/bms/.valgrind/fbsd.supp " \ - "--suppressions=/home/bms/.valgrind/xorp.supp " \ - "--logfile=test_simulator.log " \ - "--demangle=no " \ - "--verbose " - #"--undef-value-errors=no " # not in old valgrind - command = valgrind_path + ' ' + valgrind_flags + command + valgrind_path = "/usr/local/bin/valgrind" + valgrind_flags = "--tool=memcheck " \ + "--leak-check=yes " \ + "--leak-resolution=high " \ + "--num-callers=10 " \ + "--show-reachable=yes " \ + "--suppressions=/home/bms/.valgrind/fbsd.supp " \ + "--suppressions=/home/bms/.valgrind/xorp.supp " \ + "--logfile=test_simulator.log " \ + "--demangle=no " \ + "--verbose " + #"--undef-value-errors=no " # not in old valgrind + command = valgrind_path + ' ' + valgrind_flags + command fp = os.popen(command, "w") @@ -95,7 +95,7 @@ def test_create(verbose, valgrind): destroy 192.168.0.1 """ - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -436,7 +436,7 @@ def test_3line(verbose, valgrind): """ - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -654,7 +654,7 @@ def test_3line_always(verbose, valgrind): """ - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -920,7 +920,7 @@ def test_c4_partial(verbose, valgrind): """ - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -1213,7 +1213,7 @@ def test_c4_full(verbose, valgrind): """ - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -1298,7 +1298,7 @@ def test_c5_partial(verbose, valgrind): """ - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -1381,7 +1381,7 @@ def test_c5_full(verbose, valgrind): """ - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -1469,8 +1469,8 @@ def test_c6_partial(verbose, valgrind): verify_all_link_state_empty """ - print >>fp, command - + print(command, file=fp) + if not fp.close(): return True else: @@ -1558,7 +1558,7 @@ def test_c6_full(verbose, valgrind): verify_all_link_state_empty """ - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -1678,7 +1678,7 @@ def test_7up(verbose, valgrind): verify_all_link_state_empty """ - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -1691,8 +1691,8 @@ def main(): def usage(): us = \ "usage: %s [-h|--help] [-g|--valgrind] [-v|--verbose] " \ - "[-t|--test] [-b|--bad]" - print us % sys.argv[0] + "[-t|--test] [-b|--bad]" + print(us % sys.argv[0]) try: @@ -1712,24 +1712,24 @@ def usage(): verbose = False valgrind = False for o, a in opts: - if o in ("-h", "--help"): - usage() - sys.exit() - if o in ("-v", "--verbose"): - verbose = True - if o in ("-g", "--valgrind"): - valgrind = True - if o in ("-t", "--test"): - tests.append(a) - if o in ("-b", "--bad"): - bad = True + if o in ("-h", "--help"): + usage() + sys.exit() + if o in ("-v", "--verbose"): + verbose = True + if o in ("-g", "--valgrind"): + valgrind = True + if o in ("-t", "--test"): + tests.append(a) + if o in ("-b", "--bad"): + bad = True if not tests: for i in TESTS: if bad != i[1]: tests.append(i[0]) - print tests + print(tests) for i in tests: protocol = 'unknown' @@ -1738,12 +1738,12 @@ def usage(): if len(j) > 2: protocol = j[2] test = i + '(verbose, valgrind)' - print 'Running: ' + i, + print('Running: ' + i, end=' ') if not eval(test): - print "FAILED" + print("FAILED") sys.exit(-1) else: - print + print() sys.exit(0) diff --git a/xorp/contrib/olsr/tools/SConscript b/xorp/contrib/olsr/tools/SConscript index 7f0557e61..0d24d06ad 100644 --- a/xorp/contrib/olsr/tools/SConscript +++ b/xorp/contrib/olsr/tools/SConscript @@ -22,7 +22,7 @@ Import('env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#', @@ -54,12 +54,12 @@ if not is_shared: "crypto", ]) - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ "rt", ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ 'ws2_32', 'iphlpapi', diff --git a/xorp/contrib/wrapper/SConscript b/xorp/contrib/wrapper/SConscript index 0df131a23..960b77f76 100644 --- a/xorp/contrib/wrapper/SConscript +++ b/xorp/contrib/wrapper/SConscript @@ -29,7 +29,7 @@ try: except ValueError: pass -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#', @@ -76,12 +76,12 @@ if not is_shared: "crypto", ]) - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ "rt", ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ 'ws2_32', 'iphlpapi', @@ -92,7 +92,7 @@ if (env.has_key('mingw') and env['mingw']): env.Append(LIBS = ['xorp_core']) -if not (env.has_key('disable_ipv6') and env['disable_ipv6']): +if not ('disable_ipv6' in env and env['disable_ipv6']): env.AppendUnique(LIBS = [ 'xif_fea_rawpkt6', ]) diff --git a/xorp/devnotes/template_gpl.py b/xorp/devnotes/template_gpl.py index 7ce3e1554..35118961f 100644 --- a/xorp/devnotes/template_gpl.py +++ b/xorp/devnotes/template_gpl.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2008-2012 XORP, Inc and Others # diff --git a/xorp/devnotes/template_lgpl.py b/xorp/devnotes/template_lgpl.py index 781209d83..9d67a8c38 100644 --- a/xorp/devnotes/template_lgpl.py +++ b/xorp/devnotes/template_lgpl.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2008-2009 XORP, Inc. # diff --git a/xorp/etc/templates/SConscript b/xorp/etc/templates/SConscript index fcf4ea202..22b814b2a 100644 --- a/xorp/etc/templates/SConscript +++ b/xorp/etc/templates/SConscript @@ -53,7 +53,7 @@ tp_raw = [ 'fea' ] -if not (env.has_key('disable_ipv6') and env['disable_ipv6']): +if not ('disable_ipv6' in env and env['disable_ipv6']): cmds.append('mfea6') tps.append('mfea6') cmds.append('pim6') @@ -63,7 +63,7 @@ if not (env.has_key('disable_ipv6') and env['disable_ipv6']): cmds.append('ospfv3') tps.append('ospfv3') -if not (env.has_key('disable_fw') and env['disable_fw']): +if not ('disable_fw' in env and env['disable_fw']): tps.append('firewall') if env['enable_olsr']: @@ -97,16 +97,16 @@ def BuildXrlTemplate(target, source, env): # base = tp[:-len('.raw')] skip_fw = False skip_click = True - if (env.has_key('disable_fw') and env['disable_fw']): + if ('disable_fw' in env and env['disable_fw']): skip_fw = True - if (env.has_key('enable_click') and env['enable_click']): + if ('enable_click' in env and env['enable_click']): skip_click = False sfname = str(source[0]) - print "source: ", sfname - print "target: ", str(target[0]) + print("source: ", sfname) + print("target: ", str(target[0])) ifile = open(sfname, 'r') ofile = open(str(target[0]), 'w') @@ -134,7 +134,7 @@ def BuildXrlTemplate(target, source, env): if line[-1] == "\n": # trim trailing newline line = line[0 : -1] - print >>ofile, "%s" % line + ofile.write(line) else: return -1 # error @@ -159,21 +159,18 @@ if env['enable_builddirrun']: cmd_files = [c.__add__('.cmds') for c in cmds] for obj in cmd_files: - #copy all necessary cmd_files in $BUILDDIR/etc/templates - Execute(Copy(os.path.join(env['xorp_alias_templatedir'], str(obj)), - os.path.join(template_source_dir, str(obj)))) + #copy all necessary cmd_files in $BUILDDIR/etc/templates + Execute(Copy(os.path.join(env['xorp_alias_templatedir'], str(obj)), os.path.join(template_source_dir, str(obj)))) tp_files = [t.__add__('.tp') for t in tps] for obj in tp_files: - #copy all necessary tp_files in $BUILDDIR/etc/templates - Execute(Copy(os.path.join(env['xorp_alias_templatedir'], str(obj)), - os.path.join(template_source_dir, str(obj)))) + #copy all necessary tp_files in $BUILDDIR/etc/templates + Execute(Copy(os.path.join(env['xorp_alias_templatedir'], str(obj)), os.path.join(template_source_dir, str(obj)))) tp_raw_files = [t.__add__('.tp') for t in tp_raw] for obj in tp_raw_files: - #copy all necessary tp_files in $BUILDDIR/etc/templates - Execute(Copy(os.path.join(env['xorp_alias_templatedir'], str(obj)), - os.path.join(template_source_dir, str(obj)))) + #copy all necessary tp_files in $BUILDDIR/etc/templates + Execute(Copy(os.path.join(env['xorp_alias_templatedir'], str(obj)), os.path.join(template_source_dir, str(obj)))) e.Alias('install', [ e.InstallData(env['xorp_templatedir'], diff --git a/xorp/fea/SConscript b/xorp/fea/SConscript index 1af1b0d66..e33aabb62 100644 --- a/xorp/fea/SConscript +++ b/xorp/fea/SConscript @@ -30,7 +30,7 @@ SConscript(dirs = subdirs, exports='env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#', @@ -102,7 +102,7 @@ libxorp_fea_linkorder += [ 'xorp_core' ] -if not (env.has_key('disable_libtecla') and env['disable_libtecla']): +if not ('disable_libtecla' in env and env['disable_libtecla']): libxorp_fea_linkorder += [ 'xorp_tecla', ] @@ -112,16 +112,16 @@ else: 'tecla', ] -if not (env.has_key('disable_ipv6') and env['disable_ipv6']): +if not ('disable_ipv6' in env and env['disable_ipv6']): libxorp_fea_linkorder += [ 'xif_socket6_user', 'xif_fea_rawpkt6_client', ] -if not (env.has_key('disable_fw') and env['disable_fw']): +if not ('disable_fw' in env and env['disable_fw']): env.PrependUnique(LIBPATH = [ '$BUILDDIR/fea/data_plane/firewall' ]) libxorp_fea_linkorder += [ 'xorp_fea_firewall' ] -if not (env.has_key('disable_profile') and env['disable_profile']): +if not ('disable_profile' in env and env['disable_profile']): libxorp_fea_linkorder += [ 'xif_profile_client' ] # Internal libraries. @@ -129,7 +129,7 @@ if not (env.has_key('disable_profile') and env['disable_profile']): env.PrependUnique(LIBS = libxorp_fea_linkorder) # External libraries. -if env.has_key('has_libpcap') and env['has_libpcap']: +if 'has_libpcap' in env and env['has_libpcap']: env.AppendUnique(LIBS = [ 'pcap' ]) @@ -143,12 +143,12 @@ else: "crypto", ]) - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ "rt", ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ 'ws2_32', 'iphlpapi', @@ -186,13 +186,13 @@ libxorp_fea_srcs = [ 'xrl_mfea_node.cc' ] -if not (env.has_key('disable_fw') and env['disable_fw']): +if not ('disable_fw' in env and env['disable_fw']): libxorp_fea_srcs += [ 'firewall_entry.cc', 'firewall_manager.cc', 'firewall_transaction.cc', ] -if not (env.has_key('disable_profile') and env['disable_profile']): +if not ('disable_profile' in env and env['disable_profile']): libxorp_fea_srcs += [ 'profile_vars.cc' ] diff --git a/xorp/fea/data_plane/SConscript b/xorp/fea/data_plane/SConscript index d134614f1..272723eb0 100644 --- a/xorp/fea/data_plane/SConscript +++ b/xorp/fea/data_plane/SConscript @@ -19,15 +19,15 @@ import os Import('env') -subdirs = [ - 'ifconfig', - 'fibconfig', - 'io', - 'control_socket', - 'managers' +subdirs = [ + 'ifconfig', + 'fibconfig', + 'io', + 'control_socket', + 'managers' ] -if not (env.has_key('disable_fw') and env['disable_fw']): +if not ('disable_fw' in env and env['disable_fw']): subdirs.append('firewall') SConscript(dirs = subdirs, exports='env') diff --git a/xorp/fea/data_plane/control_socket/SConscript b/xorp/fea/data_plane/control_socket/SConscript index afb67962b..fd7bc3900 100644 --- a/xorp/fea/data_plane/control_socket/SConscript +++ b/xorp/fea/data_plane/control_socket/SConscript @@ -27,7 +27,7 @@ env.AppendUnique(CPPPATH = [ '$BUILDDIR', ]) -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env sources = [ # C++ files diff --git a/xorp/fea/data_plane/fibconfig/SConscript b/xorp/fea/data_plane/fibconfig/SConscript index 02b9a23a3..8bdac73d2 100644 --- a/xorp/fea/data_plane/fibconfig/SConscript +++ b/xorp/fea/data_plane/fibconfig/SConscript @@ -27,66 +27,66 @@ env.AppendUnique(CPPPATH = [ '$BUILDDIR', ]) -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env sources = [ - # C++ files - 'fibconfig_entry_get_iphelper.cc', - 'fibconfig_entry_get_routing_socket.cc', - 'fibconfig_entry_get_rtmv2.cc', - 'fibconfig_entry_observer_iphelper.cc', - 'fibconfig_entry_observer_routing_socket.cc', - 'fibconfig_entry_observer_rtmv2.cc', - 'fibconfig_entry_parse_routing_socket.cc', - 'fibconfig_entry_set_iphelper.cc', - 'fibconfig_entry_set_routing_socket.cc', - 'fibconfig_entry_set_rtmv2.cc', - 'fibconfig_forwarding_proc_linux.cc', - 'fibconfig_forwarding_solaris.cc', - 'fibconfig_forwarding_sysctl.cc', - 'fibconfig_forwarding_windows.cc', - 'fibconfig_table_get_iphelper.cc', - 'fibconfig_table_get_sysctl.cc', - 'fibconfig_table_observer_iphelper.cc', - 'fibconfig_table_observer_routing_socket.cc', - 'fibconfig_table_observer_rtmv2.cc', - 'fibconfig_table_parse_routing_socket.cc', - 'fibconfig_table_set_iphelper.cc', - 'fibconfig_table_set_routing_socket.cc', - 'fibconfig_table_set_rtmv2.cc', - ] + # C++ files + 'fibconfig_entry_get_iphelper.cc', + 'fibconfig_entry_get_routing_socket.cc', + 'fibconfig_entry_get_rtmv2.cc', + 'fibconfig_entry_observer_iphelper.cc', + 'fibconfig_entry_observer_routing_socket.cc', + 'fibconfig_entry_observer_rtmv2.cc', + 'fibconfig_entry_parse_routing_socket.cc', + 'fibconfig_entry_set_iphelper.cc', + 'fibconfig_entry_set_routing_socket.cc', + 'fibconfig_entry_set_rtmv2.cc', + 'fibconfig_forwarding_proc_linux.cc', + 'fibconfig_forwarding_solaris.cc', + 'fibconfig_forwarding_sysctl.cc', + 'fibconfig_forwarding_windows.cc', + 'fibconfig_table_get_iphelper.cc', + 'fibconfig_table_get_sysctl.cc', + 'fibconfig_table_observer_iphelper.cc', + 'fibconfig_table_observer_routing_socket.cc', + 'fibconfig_table_observer_rtmv2.cc', + 'fibconfig_table_parse_routing_socket.cc', + 'fibconfig_table_set_iphelper.cc', + 'fibconfig_table_set_routing_socket.cc', + 'fibconfig_table_set_rtmv2.cc', + ] + +if not ('mingw' in env and env['mingw']): + sources.append('fibconfig_table_set_netlink_socket.cc') + sources.append('fibconfig_table_get_netlink_socket.cc') + sources.append('fibconfig_table_parse_netlink_socket.cc') + sources.append('fibconfig_table_observer_netlink_socket.cc') + sources.append('fibconfig_entry_get_netlink_socket.cc') + sources.append('fibconfig_entry_set_netlink_socket.cc') + sources.append('fibconfig_entry_observer_netlink_socket.cc') -if not (env.has_key('mingw') and env['mingw']): - sources.append('fibconfig_table_set_netlink_socket.cc') - sources.append('fibconfig_table_get_netlink_socket.cc') - sources.append('fibconfig_table_parse_netlink_socket.cc') - sources.append('fibconfig_table_observer_netlink_socket.cc') - sources.append('fibconfig_entry_get_netlink_socket.cc') - sources.append('fibconfig_entry_set_netlink_socket.cc') - sources.append('fibconfig_entry_observer_netlink_socket.cc') - if env['enable_click']: - sources.append('fibconfig_entry_get_click.cc') - sources.append('fibconfig_entry_set_click.cc') - sources.append('fibconfig_table_set_click.cc') - sources.append('fibconfig_table_get_click.cc') + sources.append('fibconfig_entry_get_click.cc') + sources.append('fibconfig_entry_set_click.cc') + sources.append('fibconfig_table_set_click.cc') + sources.append('fibconfig_table_get_click.cc') if env['enable_fea_dummy']: sources += [ - 'fibconfig_entry_get_dummy.cc', - 'fibconfig_entry_observer_dummy.cc', - 'fibconfig_entry_set_dummy.cc', - 'fibconfig_forwarding_dummy.cc', - 'fibconfig_table_get_dummy.cc', - 'fibconfig_table_observer_dummy.cc', - 'fibconfig_table_set_dummy.cc', + 'fibconfig_entry_get_dummy.cc', + 'fibconfig_entry_observer_dummy.cc', + 'fibconfig_entry_set_dummy.cc', + 'fibconfig_forwarding_dummy.cc', + 'fibconfig_table_get_dummy.cc', + 'fibconfig_table_observer_dummy.cc', + 'fibconfig_table_set_dummy.cc', ] if is_shared: libxfc = env.SharedLibrary(target = 'libxorp_fea_fibconfig', - source = sources) + source = sources) if env['rtld_origin']: for obj in libxfc: env.AddPostAction(libxfc, @@ -96,6 +96,6 @@ if is_shared: env.Alias('install', env.InstallLibrary(env['xorp_libdir'], libxfc)) else: libxfc = env.StaticLibrary(target = 'libxorp_fea_fibconfig', - source = sources) + source = sources) Default(libxfc) diff --git a/xorp/fea/data_plane/firewall/SConscript b/xorp/fea/data_plane/firewall/SConscript index 1f50e7129..0bd523d6f 100644 --- a/xorp/fea/data_plane/firewall/SConscript +++ b/xorp/fea/data_plane/firewall/SConscript @@ -22,7 +22,7 @@ Import("env") env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#', @@ -30,20 +30,20 @@ env.AppendUnique(CPPPATH = [ ]) sources = [ - # C++ files - 'firewall_get_dummy.cc', - 'firewall_get_ipfw2.cc', - 'firewall_get_netfilter.cc', - 'firewall_get_pf.cc', - 'firewall_set_dummy.cc', - 'firewall_set_ipfw2.cc', - 'firewall_set_netfilter.cc', - 'firewall_set_pf.cc', - ] + # C++ files + 'firewall_get_dummy.cc', + 'firewall_get_ipfw2.cc', + 'firewall_get_netfilter.cc', + 'firewall_get_pf.cc', + 'firewall_set_dummy.cc', + 'firewall_set_ipfw2.cc', + 'firewall_set_netfilter.cc', + 'firewall_set_pf.cc', + ] if is_shared: libxfw = env.SharedLibrary(target = 'libxorp_fea_firewall', - source = sources) + source = sources) if env['rtld_origin']: for obj in libxfw: env.AddPostAction(libxfw, @@ -53,6 +53,6 @@ if is_shared: env.Alias('install', env.InstallLibrary(env['xorp_libdir'], libxfw)) else: libxfw = env.StaticLibrary(target = 'libxorp_fea_firewall', - source = sources) + source = sources) Default(libxfw) diff --git a/xorp/fea/data_plane/ifconfig/SConscript b/xorp/fea/data_plane/ifconfig/SConscript index 241f71891..b4986dc90 100644 --- a/xorp/fea/data_plane/ifconfig/SConscript +++ b/xorp/fea/data_plane/ifconfig/SConscript @@ -22,7 +22,7 @@ Import("env") env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#', diff --git a/xorp/fea/data_plane/io/SConscript b/xorp/fea/data_plane/io/SConscript index 0cd0fdb19..63cab28d7 100644 --- a/xorp/fea/data_plane/io/SConscript +++ b/xorp/fea/data_plane/io/SConscript @@ -27,7 +27,7 @@ env.AppendUnique(CPPPATH = [ '$BUILDDIR', ]) -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env sources = [ # C++ files diff --git a/xorp/fea/data_plane/managers/SConscript b/xorp/fea/data_plane/managers/SConscript index 18ca0735f..12e919900 100644 --- a/xorp/fea/data_plane/managers/SConscript +++ b/xorp/fea/data_plane/managers/SConscript @@ -27,7 +27,7 @@ env.AppendUnique(CPPPATH = [ '$BUILDDIR', ]) -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env sources = [ # C++ files diff --git a/xorp/fea/tests/SConscript b/xorp/fea/tests/SConscript index 9f523302d..fef9fe034 100644 --- a/xorp/fea/tests/SConscript +++ b/xorp/fea/tests/SConscript @@ -29,7 +29,7 @@ env.AppendUnique(CPPPATH = [ '$BUILDDIR/fea/tests', ]) -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env ############### begin linking gunk ### XXX Linking the FEA statically vs shared is gnarly. diff --git a/xorp/fea/tools/SConscript b/xorp/fea/tools/SConscript index 4304525c8..c0c3079cf 100644 --- a/xorp/fea/tools/SConscript +++ b/xorp/fea/tools/SConscript @@ -22,7 +22,7 @@ Import('env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#', @@ -56,12 +56,12 @@ if not is_shared: "crypto", ]) - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ "rt", ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ 'ws2_32', 'iphlpapi', diff --git a/xorp/fib2mrib/SConscript b/xorp/fib2mrib/SConscript index 57d830ee0..7ad0a576d 100644 --- a/xorp/fib2mrib/SConscript +++ b/xorp/fib2mrib/SConscript @@ -22,7 +22,7 @@ Import('env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#', @@ -66,12 +66,12 @@ if not is_shared: "crypto", ]) - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ "rt", ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ 'ws2_32', 'iphlpapi', diff --git a/xorp/libcomm/SConscript b/xorp/libcomm/SConscript index 35898cf30..63f6d5d78 100644 --- a/xorp/libcomm/SConscript +++ b/xorp/libcomm/SConscript @@ -25,7 +25,7 @@ subdirs = [ 'tests' ] SConscript(dirs = subdirs, exports='env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ "#" ]) env.PrependUnique(LIBPATH = [ '$BUILDDIR/libxorp' ] ) diff --git a/xorp/libfeaclient/SConscript b/xorp/libfeaclient/SConscript index cb44dad1c..408a1ad9f 100644 --- a/xorp/libfeaclient/SConscript +++ b/xorp/libfeaclient/SConscript @@ -25,7 +25,7 @@ subdirs = [ 'tests' ] SConscript(dirs = subdirs, exports='env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#', diff --git a/xorp/libproto/SConscript b/xorp/libproto/SConscript index d40cef6a3..e12000aeb 100644 --- a/xorp/libproto/SConscript +++ b/xorp/libproto/SConscript @@ -24,7 +24,7 @@ subdirs = [ 'tests' ] SConscript(dirs = subdirs, exports='env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ "#" ]) env.PrependUnique(LIBPATH = [ '$BUILDDIR/libxorp'] ) diff --git a/xorp/libxipc/SConscript b/xorp/libxipc/SConscript index 5bbd275db..7370d1e45 100644 --- a/xorp/libxipc/SConscript +++ b/xorp/libxipc/SConscript @@ -28,7 +28,7 @@ if env['enable_tests']: subdirs = [ 'tests' ] SConscript(dirs=subdirs, exports='env') -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env # # XIPC Library @@ -217,12 +217,12 @@ if not is_shared: "crypto", ]) - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ "rt", ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ 'ws2_32', 'iphlpapi', diff --git a/xorp/libxipc/tests/SConscript b/xorp/libxipc/tests/SConscript index b22f54c72..5560b623c 100644 --- a/xorp/libxipc/tests/SConscript +++ b/xorp/libxipc/tests/SConscript @@ -49,7 +49,7 @@ env.AppendUnique(LIBS = [ ]) if not is_shared: - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ "rt", ]) diff --git a/xorp/libxorp/SConscript b/xorp/libxorp/SConscript index c6f71734e..31019ec2d 100644 --- a/xorp/libxorp/SConscript +++ b/xorp/libxorp/SConscript @@ -24,13 +24,13 @@ subdirs = [ 'tests' ] SConscript(dirs = subdirs, exports='env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#' ]) # External libraries. # On BSD, and others, we need -lrt for clock_gettime(). -if not (env.has_key('mingw') and env['mingw']): +if not ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ 'rt' ]) else: env.AppendUnique(LIBS = [ 'ws2_32' ]) @@ -85,12 +85,12 @@ libxorp_core_srcs = [ 'win_dispatcher.cc', ] -if not (env.has_key('disable_profile') and env['disable_profile']): +if not ('disable_profile' in env and env['disable_profile']): libxorp_core_srcs.append('profile.cc'); # build_info.cc will be generated by the SConstruct file # when this option is enabled. -if (env.has_key('enable_buildinfo') and env['enable_buildinfo']): +if ('enable_buildinfo' in env and env['enable_buildinfo']): libxorp_core_srcs.append('build_info.cc'); if is_shared: diff --git a/xorp/libxorp/tests/SConscript b/xorp/libxorp/tests/SConscript index 03545e2fd..1b9e1fbdb 100644 --- a/xorp/libxorp/tests/SConscript +++ b/xorp/libxorp/tests/SConscript @@ -55,7 +55,7 @@ tests = [ 'vif', ] -if not (env.has_key('disable_profile') and env['disable_profile']): +if not ('disable_profile' in env and env['disable_profile']): tests.append('profile') libxorptestpath = '$exec_prefix/libxorp/tests' diff --git a/xorp/mld6igmp/SConscript b/xorp/mld6igmp/SConscript index 54ad03051..2df49925c 100644 --- a/xorp/mld6igmp/SConscript +++ b/xorp/mld6igmp/SConscript @@ -21,7 +21,7 @@ import os Import('env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#', @@ -66,12 +66,12 @@ if not is_shared: "crypto", ]) - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ "rt", ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ 'ws2_32', 'iphlpapi', @@ -93,7 +93,7 @@ libxorp_mld6igmp_srcs = [ 'xrl_mld6igmp_node.cc' ] -if not (env.has_key('disable_ipv6') and env['disable_ipv6']): +if not ('disable_ipv6' in env and env['disable_ipv6']): env.AppendUnique(LIBS = [ 'xif_fea_rawpkt6', ]) diff --git a/xorp/mrt/SConscript b/xorp/mrt/SConscript index 8fd728f5b..48f8b6974 100644 --- a/xorp/mrt/SConscript +++ b/xorp/mrt/SConscript @@ -24,7 +24,7 @@ subdirs = [ 'tests' ] SConscript(dirs = subdirs, exports='env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#' ]) diff --git a/xorp/ospf/SConscript b/xorp/ospf/SConscript index 81cc5d123..a58bbb78e 100644 --- a/xorp/ospf/SConscript +++ b/xorp/ospf/SConscript @@ -28,7 +28,7 @@ subdirs = [ SConscript(dirs = subdirs, exports='env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#', @@ -67,7 +67,7 @@ env.AppendUnique(LIBS = [ 'xorp_comm', ]) -if not (env.has_key('disable_ipv6') and env['disable_ipv6']): +if not ('disable_ipv6' in env and env['disable_ipv6']): env.AppendUnique(LIBS = [ 'xif_fea_rawpkt6', 'xst_ospfv3', @@ -94,15 +94,15 @@ libxorp_ospf_srcs = [ 'vlink.cc' ] -if not (env.has_key('disable_ipv6') and env['disable_ipv6']): +if not ('disable_ipv6' in env and env['disable_ipv6']): libxorp_ospf_srcs.append('xrl_target3.cc') -if not (env.has_key('disable_profile') and env['disable_profile']): +if not ('disable_profile' in env and env['disable_profile']): env.AppendUnique(LIBS = [ 'xif_profile_client', ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.Append(LIBS = [ 'ws2_32', 'iphlpapi', @@ -139,7 +139,7 @@ env.Alias('install', env.InstallProgram(env['xorp_moduledir'], ospfv2)) if is_shared: env.Alias('install', env.InstallLibrary(env['xorp_libdir'], libxorp_ospf)) -if not (env.has_key('disable_ipv6') and env['disable_ipv6']): +if not ('disable_ipv6' in env and env['disable_ipv6']): ospfv3srcs = [ 'xorp_ospfv3.cc' ] ospfv3 = env.Program(target = 'xorp_ospfv3', source = ospfv3srcs) if env['enable_builddirrun']: diff --git a/xorp/ospf/tests/SConscript b/xorp/ospf/tests/SConscript index 86a274931..d9fd54b3f 100644 --- a/xorp/ospf/tests/SConscript +++ b/xorp/ospf/tests/SConscript @@ -21,7 +21,7 @@ import os Import("env") env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#', diff --git a/xorp/ospf/tests/test_routing1.py b/xorp/ospf/tests/test_routing1.py index bda998acc..bcc54a815 100755 --- a/xorp/ospf/tests/test_routing1.py +++ b/xorp/ospf/tests/test_routing1.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2001-2009 XORP, Inc. # @@ -59,7 +59,7 @@ def start_routing_interactive(verbose, protocol): elif protocol == 'v3': flags = ' --OSPFv3' else: - print "unknown protocol " + protocol + print("unknown protocol {}".format(protocol)) sys.exit(-1) if verbose: @@ -220,7 +220,7 @@ def test1(verbose, protocol): destroy 0.0.0.0 """ - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -242,7 +242,7 @@ def test2(verbose, protocol): compute 0.0.0.0 """ - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -279,7 +279,7 @@ def r1V2(verbose, protocol): verify_routing_entry 0.4.0.0/16 0.0.0.7 8 false false """ % (RT6,RT3) - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -322,7 +322,7 @@ def r1V3(verbose, protocol): verify_routing_entry 5f00:0000:c001:0200::/56 fe80:0001::3 9 false false """ % (RT6,RT3,RT3_LINK,RT3_INTRA) - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -422,7 +422,7 @@ def r2V3(verbose, protocol): RT3,RT3_LINK,RT3_INTRA, RT4,RT4_LINK) - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -494,7 +494,7 @@ def r3V3(verbose, protocol): """ % (RT1,RT1_LINK, RT2,RT2_LINK,RT2_INTRA,RT2_NETWORK) - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -593,7 +593,7 @@ def r4V3(verbose, protocol): RT3,RT3_LINK,RT3_INTRA, RT4,RT4_LINK) - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -660,7 +660,7 @@ def r5V3(verbose, protocol): """ % (RT1,RT1_LINK, RT2,RT2_LINK,RT2_INTER) - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -727,7 +727,7 @@ def r6V3(verbose, protocol): """ % (RT1,RT1_LINK, RT2,RT2_LINK,RT2_INTER) - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -802,7 +802,7 @@ def r7V3(verbose, protocol): """ % (RT1,RT1_LINK,RT1_INTRA_R, RT2,RT2_LINK,RT2_INTRA_R) - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -868,7 +868,7 @@ def r8V2(verbose, protocol): verify_routing_entry 10.1.1.0/24 10.1.2.1 2 false false """ % (RT1, RT2, RT1_NETWORK1, RT1_NETWORK2) - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -941,7 +941,7 @@ def r9V2(verbose, protocol): verify_routing_entry 10.1.1.0/24 10.1.2.1 2 false false """ % (RT1, RT2, RT1_NETWORK1, RT1_NETWORK2) - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -1015,7 +1015,7 @@ def r10V2(verbose, protocol): verify_routing_entry 10.1.1.0/24 10.1.2.1 2 false false """ % (RT1, RT2, RT1_NETWORK1, RT1_NETWORK2) - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -1099,7 +1099,7 @@ def r11V3(verbose, protocol): verify_routing_entry 3ffe:4725:c404::/64 fe80::8:800:200c:4350 2 false false """ % r11database() - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -1182,7 +1182,7 @@ def r12V3(verbose, protocol): verify_routing_entry 3ffe:4725:c404::/64 fe80::8:800:200c:4250 4 false false """ % r12database() - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -1229,37 +1229,38 @@ def r13V3(verbose, protocol): fp = start_routing_interactive(verbose, protocol) - print >>fp, init - print >>fp, area0 - print >>fp, "compute 0.0.0.0" - print >>fp, verify0 - print >>fp, area36 - print >>fp, "compute 36.0.0.0" - print >>fp, verify36 + print(init, file=fp) + print(area0, file=fp) + print("compute 0.0.0.0", file=fp) + print(verify0, file=fp) + print(area36, file=fp) + print("compute 36.0.0.0", file=fp) + print(verify36) + if fp.close(): return False fp = start_routing_interactive(verbose, protocol) - print >>fp, init - print >>fp, area36 - print >>fp, "compute 36.0.0.0" - print >>fp, verify36 - print >>fp, area0 - print >>fp, "compute 0.0.0.0" - print >>fp, verify36 - + print(init, file=fp) + print(area36, file=fp) + print("compute 36.0.0.0", file=fp) + print(verify36) + print(area0, file=fp) + print("compute 0.0.0.0", file=fp) + print(verify36, file=fp) + if fp.close(): return False fp = start_routing_interactive(verbose, protocol) - print >>fp, init - print >>fp, area0 - print >>fp, area36 - print >>fp, "compute 0.0.0.0" - print >>fp, verify0 + print(init, file=fp) + print(area0, file=fp) + print(area36, file=fp) + print("compute 0.0.0.0", file=fp) + print(verify0, file=fp) if fp.close(): return False @@ -1360,7 +1361,7 @@ def r14V3(verbose, protocol): RT2,RT2_LINK1,RT2_LINK2, RTC,RTC_LINK,RTC_AS_EXTERNAL) - print >>fp, command + print(command, file=fp) if not fp.close(): return True @@ -1371,7 +1372,7 @@ def main(): def usage(): us = \ "usage: %s [-h|--help] [-v|--verbose] ][-t|--test] [-b|--bad]" - print us % sys.argv[0] + print(us % sys.argv[0]) try: @@ -1404,7 +1405,7 @@ def usage(): if bad != i[1]: tests.append(i[0]) - print tests + print(tests) for i in tests: protocol = 'unknown' @@ -1413,12 +1414,12 @@ def usage(): if len(j) > 2: protocol = j[2] test = i + '(verbose,protocol)' - print 'Running: ' + i, + print('Running: ' + i, end=' ') if not eval(test): - print "FAILED" + print("FAILED") sys.exit(-1) else: - print + print() sys.exit(0) diff --git a/xorp/ospf/tools/SConscript b/xorp/ospf/tools/SConscript index 04c4783f9..fa678eb03 100644 --- a/xorp/ospf/tools/SConscript +++ b/xorp/ospf/tools/SConscript @@ -22,7 +22,7 @@ Import('env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#', @@ -47,7 +47,7 @@ env.AppendUnique(LIBS = [ 'xorp_comm', ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.Append(LIBS = [ 'iphlpapi', # 'mprapi', @@ -58,7 +58,7 @@ if (env.has_key('mingw') and env['mingw']): env.Append(LIBS = ['xorp_core', 'crypto', 'ws2_32']) -if not (env.has_key('disable_ipv6') and env['disable_ipv6']): +if not ('disable_ipv6' in env and env['disable_ipv6']): env.AppendUnique(LIBS = [ 'xif_ospfv3', ]) diff --git a/xorp/pim/SConscript b/xorp/pim/SConscript index d0e8ba952..5e9fe3213 100644 --- a/xorp/pim/SConscript +++ b/xorp/pim/SConscript @@ -22,7 +22,7 @@ Import('env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#', @@ -68,19 +68,19 @@ if not is_shared: "crypto", ]) - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ "rt", ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ 'ws2_32', 'iphlpapi', 'winmm', ]) -if not (env.has_key('disable_ipv6') and env['disable_ipv6']): +if not ('disable_ipv6' in env and env['disable_ipv6']): env.AppendUnique(LIBS = [ 'xif_fea_rawpkt6', ]) @@ -150,7 +150,7 @@ if env['enable_builddirrun']: os.path.join(env['xorp_alias_moduledir'], str(obj)))) env.Alias('install', env.InstallProgram(env['xorp_moduledir'], pim4)) -if not (env.has_key('disable_ipv6') and env['disable_ipv6']): +if not ('disable_ipv6' in env and env['disable_ipv6']): pim6srcs = [ 'xorp_pimsm6.cc', ] diff --git a/xorp/policy/SConscript b/xorp/policy/SConscript index f54e3fecd..ed43ff9f7 100644 --- a/xorp/policy/SConscript +++ b/xorp/policy/SConscript @@ -27,7 +27,7 @@ SConscript([ 'backend/SConscript', 'common/SConscript' ], exports='env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env # Fedora 19 has broken-ish lex...work around it for now. env.AppendUnique(CCFLAGS = [ @@ -72,12 +72,12 @@ if not is_shared: "crypto", ]) - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ "rt", ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ 'ws2_32', 'iphlpapi', diff --git a/xorp/policy/backend/SConscript b/xorp/policy/backend/SConscript index f2f5034d4..9d3a59bbd 100644 --- a/xorp/policy/backend/SConscript +++ b/xorp/policy/backend/SConscript @@ -22,7 +22,7 @@ Import('env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env # Fedora 19 has broken-ish lex...work around it for now. env.AppendUnique(CCFLAGS = [ @@ -72,7 +72,7 @@ libpbesrcs = [ 'version_filters.cc', ] -if not (env.has_key('disable_profile') and env['disable_profile']): +if not ('disable_profile' in env and env['disable_profile']): libpbesrcs.append('policy_profiler.cc') if is_shared: diff --git a/xorp/policy/common/SConscript b/xorp/policy/common/SConscript index aab6c4527..0dd373030 100644 --- a/xorp/policy/common/SConscript +++ b/xorp/policy/common/SConscript @@ -38,7 +38,7 @@ libpcmsrcs = [ 'varrw.cc' ] -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env # deal with bgp aspath shared code if is_shared: diff --git a/xorp/relpath.py b/xorp/relpath.py index a618c0052..8d7f89d80 100644 --- a/xorp/relpath.py +++ b/xorp/relpath.py @@ -11,7 +11,7 @@ def relpath(target, base=os.curdir): base_list = (os.path.abspath(base)).split(os.sep) target_list = (os.path.abspath(target)).split(os.sep) for i in range(min(len(base_list), len(target_list))): - if base_list[i] <> target_list[i]: break + if base_list[i] != target_list[i]: break else: i += 1 rel_list = [os.pardir] * (len(base_list)-i) + target_list[i:] diff --git a/xorp/rib/SConscript b/xorp/rib/SConscript index 71c7044ef..f25ce65d6 100644 --- a/xorp/rib/SConscript +++ b/xorp/rib/SConscript @@ -22,7 +22,7 @@ Import('env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env subdirs = [ 'tests', @@ -79,12 +79,12 @@ if not is_shared: "crypto", ]) - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ "rt", ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ 'ws2_32', 'iphlpapi', @@ -119,7 +119,7 @@ libxorp_rib_srcs = [ 'xrl_target.cc' ] -if not (env.has_key('disable_profile') and env['disable_profile']): +if not ('disable_profile' in env and env['disable_profile']): libxorp_rib_srcs.append('profile_vars.cc') env.AppendUnique(LIBS = [ 'xif_profile_client', diff --git a/xorp/rib/tools/SConscript b/xorp/rib/tools/SConscript index dc187434b..6f9b30e14 100644 --- a/xorp/rib/tools/SConscript +++ b/xorp/rib/tools/SConscript @@ -48,19 +48,19 @@ env.AppendUnique(LIBS = [ 'xorp_comm', ]) -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env if not is_shared: env.AppendUnique(LIBS = [ "crypto", ]) - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ "rt", ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ 'ws2_32', 'iphlpapi', diff --git a/xorp/rip/SConscript b/xorp/rip/SConscript index 98727d540..1688d709c 100644 --- a/xorp/rip/SConscript +++ b/xorp/rip/SConscript @@ -28,7 +28,7 @@ subdirs = [ SConscript(dirs = subdirs, exports='env') e = env.Clone() -is_shared = e.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env # # NB: The same sources are used for RIP and RIPng. We use separate @@ -128,12 +128,12 @@ if not is_shared: "crypto", ]) - if not (e.has_key('mingw') and e['mingw']): + if not ('mingw' in e and e['mingw']): e.AppendUnique(LIBS = [ "rt", ]) -if (e.has_key('mingw') and e['mingw']): +if ('mingw' in e and e['mingw']): e.AppendUnique(LIBS = [ 'iphlpapi', # 'mprapi', @@ -182,7 +182,7 @@ if env['enable_builddirrun']: os.path.join(env['xorp_alias_moduledir'], str(obj)))) e.Alias('install', e.InstallProgram(e['xorp_moduledir'], rip)) -if not (env.has_key('disable_ipv6') and env['disable_ipv6']): +if not ('disable_ipv6' in env and env['disable_ipv6']): # # RIPng # @@ -196,7 +196,7 @@ if not (env.has_key('disable_ipv6') and env['disable_ipv6']): '$BUILDDIR', ]) - if not (env.has_key('disable_ipv6') and env['disable_ipv6']): + if not ('disable_ipv6' in env and env['disable_ipv6']): e.AppendUnique(CPPDEFINES = [ 'INSTANTIATE_IPV6' ]) @@ -238,12 +238,12 @@ if not (env.has_key('disable_ipv6') and env['disable_ipv6']): "crypto", ]) - if not (e.has_key('mingw') and e['mingw']): + if not ('mingw' in e and e['mingw']): e.AppendUnique(LIBS = [ "rt", ]) - if (e.has_key('mingw') and e['mingw']): + if ('mingw' in e and e['mingw']): e.AppendUnique(LIBS = [ 'iphlpapi', 'regex', diff --git a/xorp/rip/tools/SConscript b/xorp/rip/tools/SConscript index 7980646dc..dc4e14379 100644 --- a/xorp/rip/tools/SConscript +++ b/xorp/rip/tools/SConscript @@ -46,7 +46,7 @@ env.AppendUnique(LIBS = [ 'xorp_comm', ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.Append(LIBS = [ 'iphlpapi', # 'mprapi', diff --git a/xorp/rtrmgr/SConscript b/xorp/rtrmgr/SConscript index c3a8fbf48..ef49bfdc4 100644 --- a/xorp/rtrmgr/SConscript +++ b/xorp/rtrmgr/SConscript @@ -20,8 +20,8 @@ import os Import('env') subdirs = [ - #'config', # FIXME install - 'tests', + #'config', # FIXME install + 'tests', ] SConscript(dirs = subdirs, exports='env') @@ -34,10 +34,10 @@ env.AppendUnique(CCFLAGS = [ ]) env.AppendUnique(CPPPATH = [ - '.', - '$BUILDDIR', - env['xorp_sourcedir'], #this is needed for lex and yacc generated files - ]) + '.', + '$BUILDDIR', + env['xorp_sourcedir'], #this is needed for lex and yacc generated files + ]) env.PrependUnique(LIBPATH = [ '$BUILDDIR/libxorp', @@ -72,19 +72,19 @@ tplt_env_y = yacc_env.Clone() tplt_env_y.AppendUnique(YACCFLAGS='-ptplt') tplt_yacc = tplt_env_y.CXXFile(target='y.tplt_tab.cc', - source='template.yy') + source='template.yy') boot_env_y = yacc_env.Clone() boot_env_y.AppendUnique(YACCFLAGS='-pboot') boot_yacc = boot_env_y.CXXFile(target='y.boot_tab.cc', - source='boot.yy') + source='boot.yy') opcmd_env_y = yacc_env.Clone() opcmd_env_y.AppendUnique(YACCFLAGS='-popcmd') opcmd_yacc = opcmd_env_y.CXXFile(target='y.opcmd_tab.cc', - source='op_commands.yy') + source='op_commands.yy') #create lex files lex_env = env.Clone() @@ -93,54 +93,54 @@ tplt_env_l = lex_env.Clone() tplt_env_l.AppendUnique(LEXFLAGS='-Ptplt') tplt_lex = tplt_env_l.CXXFile(target='lex.tplt.cc', - source='template.ll') + source='template.ll') boot_env_l = lex_env.Clone() boot_env_l.AppendUnique(LEXFLAGS='-Pboot') boot_lex = boot_env_l.CXXFile(target='lex.boot.cc', - source='boot.ll') + source='boot.ll') opcmd_env_l = lex_env.Clone() opcmd_env_l.AppendUnique(LEXFLAGS='-Popcmd') opcmd_lex = opcmd_env_l.CXXFile(target='lex.opcmd.cc', - source='op_commands.ll') + source='op_commands.ll') libxorp_rtrmgr_srcs = [ - 'command_tree.cc', - 'conf_tree.cc', - 'conf_tree_node.cc', - 'config_operators.cc', - 'generic_module_manager.cc', - 'glob_win32.c', - tplt_lex[0], - opcmd_lex[0], - boot_lex[0], - opcmd_yacc[0], - boot_yacc[0], - tplt_yacc[0], - 'master_conf_tree.cc', - 'master_conf_tree_node.cc', - 'master_template_tree.cc', - 'master_template_tree_node.cc', - 'module_command.cc', - 'module_manager.cc', - 'op_commands.cc', - 'randomness.cc', - 'slave_conf_tree.cc', - 'slave_conf_tree_node.cc', - 'slave_module_manager.cc', - 'task.cc', - 'template_base_command.cc', - 'template_commands.cc', - 'template_tree.cc', - 'template_tree_node.cc', - 'unexpanded_program.cc', - 'unexpanded_xrl.cc', - 'userdb.cc', - 'xorp_client.cc', - ] + 'command_tree.cc', + 'conf_tree.cc', + 'conf_tree_node.cc', + 'config_operators.cc', + 'generic_module_manager.cc', + 'glob_win32.c', + tplt_lex[0], + opcmd_lex[0], + boot_lex[0], + opcmd_yacc[0], + boot_yacc[0], + tplt_yacc[0], + 'master_conf_tree.cc', + 'master_conf_tree_node.cc', + 'master_template_tree.cc', + 'master_template_tree_node.cc', + 'module_command.cc', + 'module_manager.cc', + 'op_commands.cc', + 'randomness.cc', + 'slave_conf_tree.cc', + 'slave_conf_tree_node.cc', + 'slave_module_manager.cc', + 'task.cc', + 'template_base_command.cc', + 'template_commands.cc', + 'template_tree.cc', + 'template_tree_node.cc', + 'unexpanded_program.cc', + 'unexpanded_xrl.cc', + 'userdb.cc', + 'xorp_client.cc', + ] # Runtime XRL syntax validation for developers. if env['debug_xrldb']: @@ -157,24 +157,24 @@ xorp_paths = { } -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env if not is_shared: libxorp_rtrmgr_env.AppendUnique(LIBS = [ "crypto", ]) - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): libxorp_rtrmgr_env.AppendUnique(LIBS = [ "rt", ]) util_cc_env = env.Clone() -util_cc_env.AppendUnique(CPPDEFINES=xorp_paths.items()) +util_cc_env.AppendUnique(CPPDEFINES=list(xorp_paths.items())) obj_util = util_cc_env.StaticObject(source='util.cc') libxorp_rtrmgr_srcs += [ obj_util ] libxorp_rtrmgr = libxorp_rtrmgr_env.StaticLibrary(target = 'libxorp_rtrmgr', - source = libxorp_rtrmgr_srcs) + source = libxorp_rtrmgr_srcs) # # Common RPATH. @@ -207,12 +207,12 @@ rtrmgr_env.AppendUnique(LIBS = [ ]) if not is_shared: - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): rtrmgr_env.AppendUnique(LIBS = [ "rt", ]) -if (rtrmgr_env.has_key('mingw') and rtrmgr_env['mingw']): +if ('mingw' in rtrmgr_env and rtrmgr_env['mingw']): rtrmgr_env.AppendUnique(LIBS = [ 'ws2_32', 'iphlpapi', @@ -225,9 +225,9 @@ if (rtrmgr_env.has_key('mingw') and rtrmgr_env['mingw']): rtrmgr_srcs = [ - 'main_rtrmgr.cc', - 'xrl_rtrmgr_interface.cc', - ] + 'main_rtrmgr.cc', + 'xrl_rtrmgr_interface.cc', + ] rtrmgr = rtrmgr_env.Program(target = 'xorp_rtrmgr', source = rtrmgr_srcs) @@ -255,11 +255,11 @@ if env['enable_xorpsh']: ]) # Some sort of curses library is required. - if xorpsh_env.has_key('has_libncurses') and xorpsh_env['has_libncurses']: + if 'has_libncurses' in xorpsh_env and xorpsh_env['has_libncurses']: xorpsh_env.AppendUnique(LIBS = [ 'ncurses' ]) - elif xorpsh_env.has_key('has_libpdcurses') and xorpsh_env['has_libpdcurses']: + elif 'has_libpdcurses' in xorpsh_env and xorpsh_env['has_libpdcurses']: xorpsh_env.AppendUnique(LIBS = [ 'pdcurses' ]) @@ -270,13 +270,13 @@ if env['enable_xorpsh']: ]) if not is_shared: - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): xorpsh_env.AppendUnique(LIBS = [ "rt", "crypto", ]) - if (xorpsh_env.has_key('mingw') and xorpsh_env['mingw']): + if ('mingw' in xorpsh_env and xorpsh_env['mingw']): xorpsh_env.AppendUnique(LIBS = [ 'ws2_32', 'iphlpapi', @@ -288,17 +288,17 @@ if env['enable_xorpsh']: xorpsh_env.Append(LIBS = ['xorp_core', 'crypto']) xorpsh_srcs = [ - 'xorpsh_main.cc', - 'xrl_xorpsh_interface.cc', - 'cli.cc', - ] + 'xorpsh_main.cc', + 'xrl_xorpsh_interface.cc', + 'cli.cc', + ] xorpsh = xorpsh_env.Program(target = 'xorpsh', source = xorpsh_srcs) env.Alias('install', env.InstallProgram(env['xorp_sbindir'], xorpsh)) -if not (env.has_key('disable_profile') and env['disable_profile']): +if not ('disable_profile' in env and env['disable_profile']): ### profiler profiler_env = env.Clone() @@ -313,13 +313,13 @@ if not (env.has_key('disable_profile') and env['disable_profile']): ]) if not is_shared: - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): profiler_env.AppendUnique(LIBS = [ "rt", "crypto", ]) - if (profiler_env.has_key('mingw') and profiler_env['mingw']): + if ('mingw' in profiler_env and profiler_env['mingw']): profiler_env.AppendUnique(LIBS = [ 'ws2_32', 'iphlpapi', @@ -331,8 +331,8 @@ if not (env.has_key('disable_profile') and env['disable_profile']): profiler_env.Append(LIBS = ['xorp_core', 'crypto']) profiler_srcs = [ - 'profiler.cc', - ] + 'profiler.cc', + ] profiler = profiler_env.Program(target = 'xorp_profiler', source = profiler_srcs) diff --git a/xorp/site_scons/config/allconfig.py b/xorp/site_scons/config/allconfig.py index 1f1b927d5..af874e8b0 100644 --- a/xorp/site_scons/config/allconfig.py +++ b/xorp/site_scons/config/allconfig.py @@ -41,35 +41,35 @@ def DoAllConfig(env, conf, host_os): # Bleh, FC8 era scons doesn't have this check. try: if not conf.CheckCC: - print "\nERROR: Cannot find functional cc compiler." - print " On Fedora/RedHat: yum install gcc" + print("\nERROR: Cannot find functional cc compiler.") + print(" On Fedora/RedHat: dnf install gcc") sys.exit(1); - print "OK: c compiler appears functional."; + print("OK: c compiler appears functional.") if not conf.CheckCXX: - print "\nERROR: Cannot find functional c++ compiler." - print " On Fedora/RedHat: yum install gcc-g++" + print("\nERROR: Cannot find functional c++ compiler.") + print(" On Fedora/RedHat: yum install gcc-g++") sys.exit(1); - print "OK: C++ compiler appears functional."; + print("OK: C++ compiler appears functional.") except: - print "NOTE: This version of scons cannot check for" - print " existence of gcc and g++ compilers." - print " Will assume the exist and function properly...\n" + print("NOTE: This version of scons cannot check for") + print(" existence of gcc and g++ compilers.") + print(" Will assume the exist and function properly...\n") # Check for Flex and Bison - if not (env.has_key('LEX') and env['LEX']): - print "\nERROR: Cannot find flex." - print " On Ubuntu: sudo apt-get install flex" - print " On Fedora/RedHat: yum install flex" + if not ('LEX' in env and env['LEX']): + print("\nERROR: Cannot find flex.") + print(" On Ubuntu: sudo apt-get install flex") + print(" On Fedora/RedHat: yum install flex") sys.exit(1); - print "OK: flex appears functional." + print("OK: flex appears functional.") - if not (env.has_key('YACC') and env['YACC']): - print "\nERROR: Cannot find bison." - print " On Ubuntu: sudo apt-get install bison" - print " On Fedora/RedHat: yum install bison" + if not ('YACC' in env and env['YACC']): + print("\nERROR: Cannot find bison.") + print(" On Ubuntu: sudo apt-get install bison") + print(" On Fedora/RedHat: yum install bison") sys.exit(1); - print "OK: bison appears functional." + print("OK: bison appears functional.") # Mingw/windows stuff has_iphlpapi_h = conf.CheckHeader(['winsock2.h', 'iphlpapi.h']) @@ -84,12 +84,12 @@ def DoAllConfig(env, conf, host_os): 'int32_t', 'uint32_t', 'int64_t', 'uint64_t' ]: includes = "" - if has_inttypes_h: - includes += '#include \n' - if has_stdint_h: - includes += '#include \n' - conf.CheckType(type, includes) - + if has_inttypes_h: + includes += '#include \n' + if has_stdint_h: + includes += '#include \n' + conf.CheckType(type, includes) + has_stdbool_h = conf.CheckHeader('stdbool.h') ########## @@ -102,16 +102,16 @@ def DoAllConfig(env, conf, host_os): has_signal_h = conf.CheckHeader('signal.h') has_math_h = conf.CheckHeader('math.h') # SUNWlibm has_memory_h = conf.CheckHeader('memory.h') - + # c90, libc: functions has_strftime = conf.CheckFunc('strftime') has_strlcpy = conf.CheckFunc('strlcpy') # not in glibc! has_strlcat = conf.CheckFunc('strlcat') # not in glibc! - + has_va_copy = conf.CheckDeclaration('va_copy', '#include ') if has_va_copy: conf.Define('HAVE_VA_COPY') # autoconf compat - + ########## # posix has_sys_types_h = conf.CheckHeader('sys/types.h') @@ -126,7 +126,7 @@ def DoAllConfig(env, conf, host_os): prereq_regex_h = [] if has_sys_types_h: - prereq_regex_h.append('sys/types.h') + prereq_regex_h.append('sys/types.h') has_regex_h = conf.CheckHeader(prereq_regex_h + ['regex.h']) has_syslog_h = conf.CheckHeader('syslog.h') @@ -134,7 +134,7 @@ def DoAllConfig(env, conf, host_os): has_time_h = conf.CheckHeader('time.h') has_unistd_h = conf.CheckHeader('unistd.h') has_vfork_h = conf.CheckHeader('vfork.h') - + # posix: function tests has_readv = conf.CheckFunc('readv') has_strerror = conf.CheckFunc('strerror') @@ -146,7 +146,7 @@ def DoAllConfig(env, conf, host_os): has_libxnet = conf.CheckLib('xnet') has_recvmsg = conf.CheckFunc('recvmsg') has_sendmsg = conf.CheckFunc('sendmsg') - + # may be in -lrt has_librt = conf.CheckLib('rt') has_clock_gettime = conf.CheckFunc('clock_gettime') @@ -154,18 +154,17 @@ def DoAllConfig(env, conf, host_os): if has_clock_monotonic: conf.Define('HAVE_CLOCK_MONOTONIC') # autoconf compat # BSD extension - has_clock_monotonic_fast = conf.CheckDeclaration( - 'CLOCK_MONOTONIC_FAST', '#include ') + has_clock_monotonic_fast = conf.CheckDeclaration('CLOCK_MONOTONIC_FAST', '#include ') if has_clock_monotonic_fast: conf.Define('HAVE_CLOCK_MONOTONIC_FAST') - + has_struct_timespec = conf.CheckType('struct timespec', includes='#include ') - + ########## # bsd: headers has_paths_h = conf.CheckHeader('paths.h') has_sysexits_h = conf.CheckHeader('sysexits.h') - + # bsd: functions has_realpath = conf.CheckFunc('realpath') has_strptime = conf.CheckFunc('strptime') @@ -175,7 +174,7 @@ def DoAllConfig(env, conf, host_os): has_netdb_h = conf.CheckHeader('netdb.h') has_libresolv = conf.CheckLib('resolv') # opensolaris needs it has_hstrerror = conf.CheckFunc('hstrerror') - + ########## # unix: system headers has_sys_cdefs_h = conf.CheckHeader('sys/cdefs.h') @@ -202,15 +201,15 @@ def DoAllConfig(env, conf, host_os): has_sys_resource_h = conf.CheckHeader('sys/resource.h') has_sys_stat_h = conf.CheckHeader('sys/stat.h') has_sys_syslog_h = conf.CheckHeader('sys/syslog.h') - + # bsd has_sys_linker_h = conf.CheckHeader(['sys/param.h', 'sys/linker.h']) has_sys_sysctl_h = conf.CheckHeader(['sys/param.h', 'sys/sysctl.h']) - + # linux has_linux_types_h = conf.CheckHeader('linux/types.h') has_linux_sockios_h = conf.CheckHeader('linux/sockios.h') - + # XXX needs header conditionals has_struct_iovec = conf.CheckType('struct iovec', includes='#include ') has_struct_msghdr = conf.CheckType('struct msghdr', includes='#include ') @@ -221,24 +220,24 @@ def DoAllConfig(env, conf, host_os): #has_boost_noncopyable_hpp = conf.CheckHeader('boost/noncopyable.hpp'); #if has_boost_noncopyable_hpp: # conf.Define('HAS_BOOST_NONCOPYABLE_INC') - + ########## # Socket support checks - if (env.has_key('mingw') and env['mingw']): + if ('mingw' in env and env['mingw']): prereq_af_inet_includes = [ 'winsock2.h' ] else: prereq_af_inet_includes = [ 'sys/types.h', 'sys/socket.h' ] af_inet_includes = [] for s in prereq_af_inet_includes: af_inet_includes.append("#include <%s>\n" % s) - af_inet_includes = string.join(af_inet_includes, '') - + af_inet_includes = ''.join(af_inet_includes) + has_af_inet = conf.CheckDeclaration('AF_INET', af_inet_includes) has_af_inet6 = conf.CheckDeclaration('AF_INET6', af_inet_includes) has_sock_stream = conf.CheckDeclaration('SOCK_STREAM', af_inet_includes) has_sock_dgram = conf.CheckDeclaration('SOCK_DGRAM', af_inet_includes) has_sock_raw = conf.CheckDeclaration('SOCK_RAW', af_inet_includes) - + if has_af_inet and has_sock_stream and has_sock_dgram: conf.Define('HAVE_TCPUDP_UNIX_SOCKETS') if has_af_inet and has_sock_raw: @@ -247,22 +246,22 @@ def DoAllConfig(env, conf, host_os): # TODO: This used to check for openbsd and linux in an error prone # way. Now, do negative checks, but this could break Solaris and other OS # (or not..no idea if it supports raw or not). - if not ((env.has_key('mingw') and env['mingw']) or + if not (('mingw' in env and env['mingw']) or fnmatch.fnmatch(host_os, 'freebsd*')): conf.Define('IPV4_RAW_OUTPUT_IS_RAW') conf.Define('IPV4_RAW_INPUT_IS_RAW') - + if has_struct_msghdr: has_struct_msghdr_msg_control = conf.CheckTypeMember('struct msghdr', 'msg_control', includes='#include ') has_struct_msghdr_msg_iov = conf.CheckTypeMember('struct msghdr', 'msg_iov', includes='#include ') has_struct_msghdr_msg_name = conf.CheckTypeMember('struct msghdr', 'msg_name', includes='#include ') has_struct_msghdr_msg_namelen = conf.CheckTypeMember('struct msghdr', 'msg_namelen', includes='#include ') - + has_struct_sockaddr_sa_len = conf.CheckTypeMember('struct sockaddr', 'sa_len', includes='#include ') has_struct_sockaddr_storage_ss_len = conf.CheckTypeMember('struct sockaddr_storage', 'ss_len', includes='#include ') - + has_struct_sockaddr_un_sun_len = conf.CheckTypeMember('struct sockaddr_un', 'sun_len', includes='#include \n#include ') - + ########## # net stack has_net_ethernet_h = conf.CheckHeader(['sys/types.h', 'net/ethernet.h']) @@ -272,7 +271,7 @@ def DoAllConfig(env, conf, host_os): has_net_if_dl_h = conf.CheckHeader(['sys/types.h', 'net/if_dl.h']) has_net_if_ether_h = conf.CheckHeader(['sys/types.h', 'net/if.h', 'net/if_ether.h']) has_net_if_media_h = conf.CheckHeader(['sys/types.h', 'net/if_media.h']) - + has_net_if_var_h = conf.CheckHeader(['sys/types.h', 'sys/ioctl.h', 'sys/socket.h', 'net/if.h', 'net/if_var.h']) has_net_if_types_h = conf.CheckHeader('net/if_types.h') has_net_route_h = conf.CheckHeader(['sys/types.h', 'sys/ioctl.h', 'sys/socket.h', 'net/if.h', 'net/route.h']) @@ -283,11 +282,11 @@ def DoAllConfig(env, conf, host_os): # and/or prereq_linux_ethtool_h = [] if has_inttypes_h: - prereq_linux_ethtool_h.append('inttypes.h') + prereq_linux_ethtool_h.append('inttypes.h') if has_stdint_h: - prereq_linux_ethtool_h.append('stdint.h') + prereq_linux_ethtool_h.append('stdint.h') if has_linux_types_h: - prereq_linux_ethtool_h.append('linux/types.h') + prereq_linux_ethtool_h.append('linux/types.h') has_linux_ethtool_h = conf.CheckHeader(prereq_linux_ethtool_h + ['linux/ethtool.h']) has_linux_if_tun_h = conf.CheckHeader('linux/if_tun.h') @@ -313,7 +312,7 @@ def DoAllConfig(env, conf, host_os): if has_linux_types_h: prereq_linux_rtnetlink_h.append('linux/types.h') has_linux_rtnetlink_h = conf.CheckHeader(prereq_linux_rtnetlink_h + ['linux/rtnetlink.h']) - + if has_linux_netlink_h: conf.Define('HAVE_NETLINK_SOCKETS') elif has_net_route_h and host_os != 'linux-gnu': @@ -323,19 +322,19 @@ def DoAllConfig(env, conf, host_os): rta_nl_includes = [] for s in prereq_linux_rtnetlink_h: rta_nl_includes.append("#include <%s>\n" % s) - + rta_nl_includes.append("#include \n"); - rta_nl_includes = string.join(rta_nl_includes, '') + rta_nl_includes = ''.join(rta_nl_includes) has_netlink_rta_table = conf.CheckDeclaration('RTA_TABLE', rta_nl_includes) if has_netlink_rta_table: conf.Define('HAVE_NETLINK_SOCKET_ATTRIBUTE_RTA_TABLE') - + # net stack: struct members # XXX header conditionals for linux/bsd variants needed. has_struct_sockaddr_dl_sdl_len = conf.CheckTypeMember('struct sockaddr_dl', 'sdl_len', includes='#include \n#include ') has_struct_ifreq_ifr_hwaddr = conf.CheckTypeMember('struct ifreq', 'ifr_hwaddr', includes='#include \n#include ') has_struct_ifreq_ifr_ifindex = conf.CheckTypeMember('struct ifreq', 'ifr_ifindex', includes='#include \n#include ') - + # net stack: functions # XXX some may be in libc or libnsl has_ether_aton = conf.CheckFunc('ether_aton') @@ -349,26 +348,26 @@ def DoAllConfig(env, conf, host_os): has_if_nametoindex = conf.CheckFunc('if_nametoindex') has_inet_ntop = conf.CheckFunc('inet_ntop') has_inet_pton = conf.CheckFunc('inet_pton') - + # net stack: types # XXX header conditionals for linux/bsd variants needed. prereq_ether_includes = [ 'sys/types.h', 'sys/socket.h' ] if has_net_ethernet_h: - prereq_ether_includes.append('net/ethernet.h') + prereq_ether_includes.append('net/ethernet.h') if has_net_if_h: - prereq_ether_includes.append('net/if.h') + prereq_ether_includes.append('net/if.h') if has_net_if_ether_h: - prereq_ether_includes.append('net/if_ether.h') + prereq_ether_includes.append('net/if_ether.h') ether_includes = [] for s in prereq_ether_includes: ether_includes.append("#include <%s>\n" % s) - ether_includes = string.join(ether_includes, '') + ether_includes = ''.join(ether_includes) has_struct_ether_addr = conf.CheckType('struct ether_addr', includes=ether_includes) - + # net stack: sysctl (bsd) conf.CheckSysctl('NET_RT_DUMP', oid='CTL_NET, AF_ROUTE, 0, AF_INET, NET_RT_DUMP, 0', includes='#include ') conf.CheckSysctl('NET_RT_IFLIST', oid='CTL_NET, AF_ROUTE, 0, AF_INET, NET_RT_IFLIST, 0', includes='#include ') - + # XXX test for SIOCGIFCONF. Very gnarly. siocgifconf_includes = [ 'stdlib.h', 'errno.h' ] if has_sys_types_h: @@ -384,7 +383,7 @@ def DoAllConfig(env, conf, host_os): si = [] for s in siocgifconf_includes: si.append("#include <%s>\n" % s) - si = string.join(si, '') + si = ''.join(si) has_siocgifconf = conf.CheckDeclaration('SIOCGIFCONF', si) if has_siocgifconf: conf.Define('HAVE_IOCTL_SIOCGIFCONF') # autoconf compat @@ -410,11 +409,11 @@ def DoAllConfig(env, conf, host_os): # and/or prereq_netinet_ip_h = [] if has_sys_types_h: - prereq_netinet_ip_h.append('sys/types.h') + prereq_netinet_ip_h.append('sys/types.h') if has_netinet_in_h: prereq_netinet_ip_h.append('netinet/in.h') if has_netinet_in_systm_h: - prereq_netinet_ip_h.append('netinet/in_systm.h') + prereq_netinet_ip_h.append('netinet/in_systm.h') prereq_mreqn_h = prereq_netinet_ip_h has_netinet_ip_h = conf.CheckHeader(prereq_netinet_ip_h + ['netinet/ip.h']) if has_netinet_ip_h: @@ -428,24 +427,24 @@ def DoAllConfig(env, conf, host_os): mreqn_header_includes = [] for s in prereq_mreqn_h: mreqn_header_includes.append("#include <%s>\n" % s) - mreqn_header_includes = string.join(mreqn_header_includes, '') + mreqn_header_includes = ''.join(mreqn_header_includes) has_struct_ip_mreqn = conf.CheckType('struct ip_mreqn', includes=mreqn_header_includes) if not has_struct_ip_mreqn: - print "\nWARNING: No struct ip_mreqn found. Each interface must" - print " have a unique IP address or IP multicast (at least) will not" - print " be transmitted on the correct interface." + print("\nWARNING: No struct ip_mreqn found. Each interface must") + print(" have a unique IP address or IP multicast (at least) will not") + print(" be transmitted on the correct interface.") - # Header file might need , + # Header file might need , # , , and/or prereq_netinet_if_ether_h = [] - if has_sys_types_h: - prereq_netinet_if_ether_h.append('sys/types.h') - if has_sys_socket_h: - prereq_netinet_if_ether_h.append('sys/socket.h') - if has_net_if_h: - prereq_netinet_if_ether_h.append('net/if.h') + if has_sys_types_h: + prereq_netinet_if_ether_h.append('sys/types.h') + if has_sys_socket_h: + prereq_netinet_if_ether_h.append('sys/socket.h') + if has_net_if_h: + prereq_netinet_if_ether_h.append('net/if.h') if has_netinet_in_h: - prereq_netinet_if_ether_h.append('netinet/in.h') + prereq_netinet_if_ether_h.append('netinet/in.h') has_netinet_if_ether_h = conf.CheckHeader(prereq_netinet_if_ether_h + ['netinet/if_ether.h']) # opensolaris @@ -455,9 +454,9 @@ def DoAllConfig(env, conf, host_os): # name lookup, telnet has_arpa_inet_h = conf.CheckHeader('arpa/inet.h') has_arpa_telnet_h = conf.CheckHeader('arpa/telnet.h') - + has_struct_sockaddr_in_sin_len = conf.CheckTypeMember('struct sockaddr_in', 'sin_len', includes='#include \n#include ') - + # check for v4 multicast capability # XXX conditional on these headers please prereq_v4mcast = [ 'sys/types.h', 'sys/socket.h', 'netinet/in.h' ] @@ -466,7 +465,7 @@ def DoAllConfig(env, conf, host_os): v4mcast_includes = [] for s in prereq_v4mcast: v4mcast_includes.append("#include <%s>\n" % s) - v4mcast_includes = string.join(v4mcast_includes, '') + v4mcast_includes = ''.join(v4mcast_includes) # check for each symbol gotv4sym = True for s in v4mcast_symbols: @@ -476,74 +475,74 @@ def DoAllConfig(env, conf, host_os): if has_v4_mcast: conf.Define('HAVE_IPV4_MULTICAST') if host_os == 'linux-gnu' or host_os == 'linux-gnueabi': - print "Enabling MULT_MCAST_TABLES logic since we are compiling for Linux.\n" + print("Enabling MULT_MCAST_TABLES logic since we are compiling for Linux.\n") conf.Define('USE_MULT_MCAST_TABLES') else: - print "Disabling MULT_MCAST_TABLES, host_os:", host_os, "\n" + print("Disabling MULT_MCAST_TABLES, host_os: {}\n".format(host_os)) # v4 stack: sysctl (bsd) conf.CheckSysctl('IPCTL_FORWARDING', oid='CTL_NET, AF_INET, IPPROTO_IP, IPCTL_FORWARDING', includes='#include \n#include ') - + ########## # logs - if not (env.has_key('disable_warninglogs') and env['disable_warninglogs']): + if not ('disable_warninglogs' in env and env['disable_warninglogs']): conf.Define('L_WARNING') - if not (env.has_key('disable_infologs') and env['disable_infologs']): + if not ('disable_infologs' in env and env['disable_infologs']): conf.Define('L_INFO') - if not (env.has_key('disable_errorlogs') and env['disable_errorlogs']): + if not ('disable_errorlogs' in env and env['disable_errorlogs']): conf.Define('L_ERROR') - if not (env.has_key('disable_tracelogs') and env['disable_tracelogs']): + if not ('disable_tracelogs' in env and env['disable_tracelogs']): conf.Define('L_TRACE') - if not (env.has_key('disable_assertlogs') and env['disable_assertlogs']): + if not ('disable_assertlogs' in env and env['disable_assertlogs']): conf.Define('L_ASSERT') - if not (env.has_key('disable_otherlogs') and env['disable_otherlogs']): + if not ('disable_otherlogs' in env and env['disable_otherlogs']): conf.Define('L_OTHER') - if not (env.has_key('disable_fatallogs') and env['disable_fatallogs']): + if not ('disable_fatallogs' in env and env['disable_fatallogs']): conf.Define('L_FATAL') - if (env.has_key('disable_assert') and env['disable_assert']): + if ('disable_assert' in env and env['disable_assert']): conf.Define('NO_ASSERT') ########## # v6 stack if has_af_inet6 and has_sock_stream: - if not (env.has_key('disable_ipv6') and env['disable_ipv6']): + if not ('disable_ipv6' in env and env['disable_ipv6']): conf.Define('HAVE_IPV6') prereq_rfc3542 = ['stdlib.h', 'sys/types.h', 'netinet/in.h'] rfc3542_includes = [] for s in prereq_rfc3542: - # XXX: __USE_GNU must be defined for RFC3542 defines under Linux. - if host_os == 'linux-gnu' and s == 'netinet/in.h': - rfc3542_includes.append("#define __USE_GNU\n") + # XXX: __USE_GNU must be defined for RFC3542 defines under Linux. + if host_os == 'linux-gnu' and s == 'netinet/in.h': + rfc3542_includes.append("#define __USE_GNU\n") rfc3542_includes.append("#include <%s>\n" % s) - rfc3542_includes = string.join(rfc3542_includes, '') + rfc3542_includes = ''.join(rfc3542_includes) has___kame__ = conf.CheckDeclaration('__KAME__', rfc3542_includes) # CheckFunc() too tight. has_inet6_opt_init = conf.CheckDeclaration('inet6_opt_init', rfc3542_includes) - + if has___kame__: conf.Define('IPV6_STACK_KAME') if has_inet6_opt_init: conf.Define('HAVE_RFC3542') - + has_struct_sockaddr_in6_sin6_len = conf.CheckTypeMember('struct sockaddr_in6', 'sin6_len', includes='#include \n#include ') has_struct_sockaddr_in6_sin6_scope_id = conf.CheckTypeMember('struct sockaddr_in6', 'sin6_scope_id', includes='#include \n#include ') - + has_netinet_ip6_h = conf.CheckHeader(['sys/types.h', 'netinet/in.h', 'netinet/ip6.h']) - + prereq_netinet_icmp6_h = ['sys/types.h', 'sys/socket.h', 'netinet/in.h', 'netinet/ip6.h'] netinet_icmp6_h = 'netinet/icmp6.h' has_netinet_icmp6_h = conf.CheckHeader(prereq_netinet_icmp6_h + [ netinet_icmp6_h ]) - + # struct mld_hdr normally defined in mld_hdr_includes = [] for s in prereq_netinet_icmp6_h + [ netinet_icmp6_h ]: mld_hdr_includes.append("#include <%s>\n" % s) - mld_hdr_includes = string.join(mld_hdr_includes, '') + mld_hdr_includes = ''.join(mld_hdr_includes) has_struct_mld_hdr = conf.CheckType('struct mld_hdr', includes=mld_hdr_includes) - + # Header file might need , , # , , and/or . prereq_netinet6_in6_var_h = [] @@ -558,28 +557,28 @@ def DoAllConfig(env, conf, host_os): if has_netinet_in_h: prereq_netinet6_in6_var_h.append('netinet/in.h') has_netinet6_in6_var_h = conf.CheckHeader(prereq_netinet6_in6_var_h + ['netinet6/in6_var.h']) - + # Header file might need , , - # , , , and/or + # , , , and/or prereq_netinet6_nd6_h = [] if has_sys_types_h: - prereq_netinet6_nd6_h.append('sys/types.h') + prereq_netinet6_nd6_h.append('sys/types.h') if has_sys_socket_h: - prereq_netinet6_nd6_h.append('sys/socket.h') + prereq_netinet6_nd6_h.append('sys/socket.h') if has_net_if_h: - prereq_netinet6_nd6_h.append('net/if.h') + prereq_netinet6_nd6_h.append('net/if.h') if has_net_if_var_h: - prereq_netinet6_nd6_h.append('net/if_var.h') + prereq_netinet6_nd6_h.append('net/if_var.h') if has_netinet_in_h: - prereq_netinet6_nd6_h.append('netinet/in.h') + prereq_netinet6_nd6_h.append('netinet/in.h') if has_netinet6_in6_var_h: - prereq_netinet6_nd6_h.append('netinet6/in6_var.h') + prereq_netinet6_nd6_h.append('netinet6/in6_var.h') netinet6_nd6_h = 'netinet6/nd6.h' has_netinet6_nd6_h = conf.CheckHeader(prereq_netinet6_nd6_h + [ netinet6_nd6_h ]) has_cxx_netinet6_nd6_h = conf.CheckHeader(prereq_netinet6_nd6_h + [ netinet6_nd6_h ], language='C++') if has_netinet6_nd6_h and not has_cxx_netinet6_nd6_h: conf.Define('HAVE_BROKEN_CXX_NETINET6_ND6_H') - + # v6 stack: sysctl (bsd) conf.CheckSysctl('IPV6CTL_FORWARDING', oid='CTL_NET, AF_INET6, IPPROTO_IPV6, IPV6CTL_FORWARDING', includes='#include \n#include ') conf.CheckSysctl('IPV6CTL_ACCEPT_RTADV', oid='CTL_NET, AF_INET6, IPPROTO_IPV6, IPV6CTL_ACCEPT_RTADV', includes='#include \n#include ') @@ -592,7 +591,7 @@ def DoAllConfig(env, conf, host_os): v6mcast_includes = [] for s in prereq_v6mcast: v6mcast_includes.append("#include <%s>\n" % s) - v6mcast_includes = string.join(v6mcast_includes, '') + v6mcast_includes = ''.join(v6mcast_includes) # check for each symbol gotv6sym = True for s in v6mcast_symbols: @@ -600,7 +599,7 @@ def DoAllConfig(env, conf, host_os): has_v6_mcast = gotv6sym # test result if has_v6_mcast: - if not (env.has_key('disable_ipv6') and env['disable_ipv6']): + if not ('disable_ipv6' in env and env['disable_ipv6']): conf.Define('HAVE_IPV6_MULTICAST') # See if we need -std=gnu99 for fpclassify (math.h) @@ -608,24 +607,24 @@ def DoAllConfig(env, conf, host_os): fpclassify_includes = [] for s in prereq_fpclassify: fpclassify_includes.append("#include <%s>\n" % s) - fpclassify_includes = string.join(fpclassify_includes, '') + fpclassify_includes = ''.join(fpclassify_includes) has_fpclassify = conf.CheckDeclaration('fpclassify', fpclassify_includes) if not has_fpclassify: env.AppendUnique(CFLAGS = '-std=gnu99') has_fpclassify = conf.CheckDeclaration('fpclassify', fpclassify_includes) if not has_fpclassify: - print "\nERROR: Cannot find fpclassify, tried -std=gnu99 as well." + print("\nERROR: Cannot find fpclassify, tried -std=gnu99 as well.") sys.exit(1) else: - print "\nNOTE: Using -std=gnu99 for fpclassify (math.h)\n" + print("\nNOTE: Using -std=gnu99 for fpclassify (math.h)\n") ########## # v4 mforwarding - + # this platform's multicast forwarding header(s) prereq_mroute_h = [] mroute_h = None - + if host_os == 'sunos': prereq_netinet_ip_mroute_h = ['sys/types.h', 'sys/ioctl.h', 'sys/socket.h', 'sys/time.h', 'inet/ip.h', 'netinet/in.h'] else: @@ -638,7 +637,7 @@ def DoAllConfig(env, conf, host_os): if has_netinet_ip_mroute_h: prereq_mroute_h = prereq_netinet_ip_mroute_h mroute_h = netinet_ip_mroute_h - + prereq_net_ip_mroute_ip_mroute_h = ['sys/types.h', 'sys/ioctl.h', 'sys/socket.h', 'sys/time.h', 'net/if.h', 'net/route.h', 'netinet/in.h'] if has_net_if_var_h: prereq_net_ip_mroute_ip_mroute_h.append('net/if_var.h') @@ -648,24 +647,24 @@ def DoAllConfig(env, conf, host_os): if has_net_ip_mroute_ip_mroute_h: prereq_mroute_h = prereq_net_ip_mroute_ip_mroute_h mroute_h = net_ip_mroute_ip_mroute_h - + # Header file might need , , # , and/or # - # TODO: The autoconf feature test for this contained a hack to exclude + # TODO: The autoconf feature test for this contained a hack to exclude # that might be included by , because # might conflict with that was included # earlier. This is currently difficult to replicate in SCons, as # you can't pass arbitrary code that is prepended to the test. prereq_linux_mroute_h = [] if has_sys_types_h: - prereq_linux_mroute_h.append('sys/types.h') + prereq_linux_mroute_h.append('sys/types.h') if has_sys_socket_h: - prereq_linux_mroute_h.append('sys/socket.h') + prereq_linux_mroute_h.append('sys/socket.h') if has_netinet_in_h: - prereq_linux_mroute_h.append('netinet/in.h') + prereq_linux_mroute_h.append('netinet/in.h') if has_linux_types_h: - prereq_linux_mroute_h.append('linux/types.h') + prereq_linux_mroute_h.append('linux/types.h') linux_mroute_h = 'linux/mroute.h' has_linux_mroute_h = conf.CheckHeader(prereq_linux_mroute_h + [ linux_mroute_h ]) if has_linux_mroute_h: @@ -686,33 +685,33 @@ def DoAllConfig(env, conf, host_os): if has_linux_mroute_h: prereq_mroute_h = prereq_linux_mroute_h mroute_h = linux_mroute_h - + mfcctl2_includes = [] for s in prereq_mroute_h + [ mroute_h ]: mfcctl2_includes.append("#include <%s>\n" % s) - mfcctl2_includes = string.join(mfcctl2_includes, '') - + mfcctl2_includes = ''.join(mfcctl2_includes) + # common structs has_struct_mfcctl2 = conf.CheckType('struct mfcctl2', includes=mfcctl2_includes) has_struct_mfcctl2_mfcc_flags = conf.CheckTypeMember('struct mfcctl2', 'mfcc_flags', includes=mfcctl2_includes) has_struct_mfcctl2_mfcc_rp = conf.CheckTypeMember('struct mfcctl2', 'mfcc_rp', includes=mfcctl2_includes) - + # pim has_netinet_pim_h = conf.CheckHeader('netinet/pim.h') has_struct_pim = conf.CheckType('struct pim', includes='#include ') has_struct_pim_pim_vt = conf.CheckTypeMember('struct pim', 'pim_vt', includes='#include ') - + if has_netinet_ip_mroute_h or has_net_ip_mroute_ip_mroute_h or has_linux_mroute_h: conf.Define('HAVE_IPV4_MULTICAST_ROUTING') - - + + ########## # v6 mforwarding - + # this platform's v6 multicast forwarding header(s) prereq_mroute6_h = [] mroute6_h = None - + # bsd prereq_netinet6_ip6_mroute_h = ['sys/param.h', 'sys/socket.h', 'sys/time.h', 'net/if.h', 'net/route.h', 'netinet/in.h'] if has_net_if_var_h: @@ -722,7 +721,7 @@ def DoAllConfig(env, conf, host_os): if has_netinet6_ip6_mroute_h: prereq_mroute6_h = prereq_netinet6_ip6_mroute_h mroute6_h = netinet6_ip6_mroute_h - + # linux prereq_linux_mroute6_h = ['sys/types.h', 'sys/socket.h', 'netinet/in.h', 'linux/types.h'] linux_mroute6_h = 'linux/mroute6.h' @@ -735,32 +734,32 @@ def DoAllConfig(env, conf, host_os): for s in prereq_linux_mroute6_h: i6o_includes.append("#include <%s>\n" % s) i6o_includes.append("#include <%s>\n" % linux_mroute6_h); - i6o_includes = string.join(i6o_includes, '') + i6o_includes = ''.join(i6o_includes) has_inet6_option_space = conf.CheckDeclaration('inet6_option_space', i6o_includes); - + # common structs mf6cctl2_includes = [] for s in prereq_mroute6_h + [ mroute6_h ]: mf6cctl2_includes.append("#include <%s>\n" % s) - mf6cctl2_includes = string.join(mf6cctl2_includes, '') - + mf6cctl2_includes = ''.join(mf6cctl2_includes) + has_struct_mf6cctl2 = conf.CheckType('struct mf6cctl2', includes=mf6cctl2_includes) has_struct_mfcctl2_mfcc_flags = conf.CheckTypeMember('struct mf6cctl2', 'mf6cc_flags', includes=mf6cctl2_includes) has_struct_mfcctl2_mfcc_rp = conf.CheckTypeMember('struct mf6cctl2', 'mf6cc_rp', includes=mf6cctl2_includes) - + # XXX: linux marked inet6_option_space() and friends as deprecated; # either rework mfea code or do this. if has_netinet6_ip6_mroute_h or has_linux_mroute6_h: - if not (env.has_key('disable_ipv6') and env['disable_ipv6']): + if not ('disable_ipv6' in env and env['disable_ipv6']): conf.Define('HAVE_IPV6_MULTICAST_ROUTING') if has_inet6_option_space: conf.Define('HAVE_IPV6_OPTION_SPACE') else: if not has_inet6_opt_init: - print "\nWARNING: inet6_option_* and inet6_opt_* are not supported on this system." - print " this might cause some problems with IPv6 multicast routing.\n" + print("\nWARNING: inet6_option_* and inet6_opt_* are not supported on this system.") + print(" this might cause some problems with IPv6 multicast routing.\n") - has_struct_mif6ctl_vifc_threshold = conf.CheckTypeMember('struct mif6ctl', 'vifc_threshold', includes=mf6cctl2_includes) + has_struct_mif6ctl_vifc_threshold = conf.CheckTypeMember('struct mif6ctl', 'vifc_threshold', includes=mf6cctl2_includes) ########## # packet filters has_netinet_ip_compat_h = conf.CheckHeader(['sys/types.h', 'netinet/ip_compat.h']) @@ -781,29 +780,29 @@ def DoAllConfig(env, conf, host_os): has_linux_netfilter_ipv6_ip6_tables_h = conf.CheckHeader(['sys/param.h', 'net/if.h', 'netinet/in.h', 'linux/netfilter_ipv6/ip6_tables.h'], language = "C++") if has_linux_netfilter_ipv4_ip_tables_h or has_linux_netfilter_ipv6_ip6_tables_h: - if not (env.has_key('disable_fw') and env['disable_fw']): + if not ('disable_fw' in env and env['disable_fw']): conf.Define('HAVE_FIREWALL_NETFILTER') - + ########## # vlan - - # Header files , , and + + # Header files , , and # might need a list of other files. prereq_vlan = [] if has_sys_types_h: - prereq_vlan.append('sys/types.h') + prereq_vlan.append('sys/types.h') if has_sys_socket_h: - prereq_vlan.append('sys/socket.h') + prereq_vlan.append('sys/socket.h') if has_net_if_h: - prereq_vlan.append('net/if.h') + prereq_vlan.append('net/if.h') if has_net_ethernet_h: - prereq_vlan.append('net/ethernet.h') + prereq_vlan.append('net/ethernet.h') if has_net_if_ether_h: - prereq_vlan.append('net/if_ether.h') + prereq_vlan.append('net/if_ether.h') if has_netinet_in_h: - prereq_vlan.append('netinet/in.h') + prereq_vlan.append('netinet/in.h') if has_netinet_if_ether_h: - prereq_vlan.append('netinet/if_ether.h') + prereq_vlan.append('netinet/if_ether.h') has_net_if_vlanvar_h = conf.CheckHeader(prereq_vlan + ['net/if_vlanvar.h']) @@ -821,10 +820,10 @@ def DoAllConfig(env, conf, host_os): if not conf.CheckDeclaration('GET_VLAN_VID_CMD', '#include '): conf.Define('GET_VLAN_VID_CMD', '9') else: - if has_net_if_vlanvar_h or has_net_if_vlan_var_h: + if has_net_if_vlanvar_h or has_net_if_vlan_var_h: conf.Define('HAVE_VLAN_BSD') - + ########## # pcre posix regexp emulation # used by policy for regexps. @@ -832,30 +831,31 @@ def DoAllConfig(env, conf, host_os): has_pcreposix_h = conf.CheckHeader('pcreposix.h') has_libpcre = conf.CheckLib('pcre') has_libpcreposix = conf.CheckLib('pcreposix') - + ########## # openssl for md5 # XXX Check for MD5_Init() prereq_md5 = [] if has_sys_types_h: - prereq_md5.append('sys/types.h') + prereq_md5.append('sys/types.h') has_openssl_md5_h = conf.CheckHeader(prereq_md5 + ['openssl/md5.h']) if not has_openssl_md5_h: - print "\nERROR: Cannot find required openssl/md5.h." - print " On Fedora/RedHat: yum install openssl-devel" - print " On Ubuntu: apt-get install libssl-dev" - print " After install, rm -fr xorp/obj build directory to" - print " clear the configure cache before re-building." + print(""" + \nERROR: Cannot find required openssl/md5.h. + On Fedora/RedHat: yum install openssl-devel + On Ubuntu: apt-get install libssl-dev + After install, rm -fr xorp/obj build directory to + clear the configure cache before re-building.""") sys.exit(1) - + has_libcrypto = conf.CheckLib('crypto') if not has_libcrypto: - print "\nERROR: Cannot find required crypto library." - print " clear the configure cache before re-building." + print("\nERROR: Cannot find required crypto library.") + print(" clear the configure cache before re-building.") sys.exit(1) - + has_md5_init = conf.CheckFunc('MD5_Init') - + ########## # x/open dynamic linker # XXX Check for dlopen() for fea use. @@ -863,7 +863,7 @@ def DoAllConfig(env, conf, host_os): has_libdl = conf.CheckLib('dl') has_dl_open = conf.CheckFunc('dlopen') - + ########## # pcap for l2 comms has_pcap_h = conf.CheckHeader('pcap.h') @@ -871,48 +871,51 @@ def DoAllConfig(env, conf, host_os): env['has_libpcap'] = has_libpcap has_pcap_sendpacket = conf.CheckFunc('pcap_sendpacket') if not has_libpcap: - print "\nWARNING: Libpcap was not detected.\n VRRP and other protocols may have issues." - print " On Fedora/RedHat: yum install libpcap-devel" - print " On Ubuntu: apt-get install libpcap-dev" - print " After install, rm -fr xorp/obj build directory to" - print " clear the configure cache before re-building.\n" + print(""" + \nWARNING: Libpcap was not detected. + VRRP and other protocols may have issues. + On Fedora/RedHat: dnf install libpcap-devel + On Ubuntu: apt-get install libpcap-dev + After install, rm -fr xorp/obj build directory to + clear the configure cache before re-building.\n""") # pcap filtering can be used to cut down on un-needed netlink packets. # This is a performance gain only, can function fine without it. prereq_pcap_bpf = [] if has_sys_types_h: - prereq_pcap_bpf.append('sys/types.h') + prereq_pcap_bpf.append('sys/types.h') has_pcap_bpf_h = conf.CheckHeader(prereq_pcap_bpf + ['pcap-bpf.h']) if not has_pcap_bpf_h: - print "\nWARNING: PCAP-BPF is not supported on this system," - print " socket filtering will not work." - print " This is not a real problem, just a small performance" - print " loss when using multiple virtual routers on the same system." - print " On Debian: apt-get install libpcap-dev" - print " On Older Ubuntu: apt-get install pcap-dev\n" - print " On Newer Ubuntu: apt-get install libpcap-dev\n" + print(""" + \nWARNING: PCAP-BPF is not supported on this system, + socket filtering will not work. + This is not a real problem, just a small performance + loss when using multiple virtual routers on the same system. + On Debian/Ubuntu: apt-get install libpcap-dev + """) if not (has_linux_netfilter_ipv4_ip_tables_h or has_linux_netfilter_ipv6_ip6_tables_h): - if not (env.has_key('disable_fw') and env['disable_fw']): + if not ('disable_fw' in env and env['disable_fw']): if has_linux_mroute_h: # We are Linux...should warn users about how to make netfiltering work since # it appears their headers are busted. - print "\nWARNING: Netfilter include files are broken or do not exist." - print " This means the Linux firewall support will not be compiled in." - print " To fix, you may edit: /usr/include/linux/netfilter_ipv4/ip_tables.h" - print " line 222 or so, to look like this:" - print " /* Helper functions */" - print " static __inline__ struct ipt_entry_target *" - print " ipt_get_target(struct ipt_entry *e)" - print "{" - print " /* BEN: Was void* */" - print " return (struct ipt_entry_target *)((char*)e + e->target_offset);" - print "}" - print "\nYou will also want to edit similar code around line 282 of:" - print "/usr/include/linux/netfilter_ipv6/ip6_tables.h" - print "NOTE: Recent kernels use struct xt_entry_target for the argument" - print " for these methods, so use that instead of ipt_entry_target if that" - print " is the case for your system." + print(""" + \nWARNING: Netfilter include files are broken or do not exist. + This means the Linux firewall support will not be compiled in. + To fix, you may edit: /usr/include/linux/netfilter_ipv4/ip_tables.h + line 222 or so, to look like this: + /* Helper functions */" + static __inline__ struct ipt_entry_target * + ipt_get_target(struct ipt_entry *e) + { + /* BEN: Was void* */" + return (struct ipt_entry_target *)((char*)e + e->target_offset); + } + \nYou will also want to edit similar code around line 282 of: + /usr/include/linux/netfilter_ipv6/ip6_tables.h + NOTE: Recent kernels use struct xt_entry_target for the argument + for these methods, so use that instead of ipt_entry_target if that + is the case for your system.""") ########## # curses for cli/libtecla @@ -923,9 +926,9 @@ def DoAllConfig(env, conf, host_os): env['has_libpdcurses'] = has_libpdcurses env['has_libncurses'] = has_libncurses if not has_libcurses and not has_libncurses and not has_libpdcurses: - print "\nERROR: Cannot find required (n)curses or pdcurses library." - print " On Fedora/RedHat: yum install ncurses-devel" - print " On Debian/Ubuntu: apt-get install ncurses-dev" - print " After install, rm -fr xorp/obj build directory to" - print " clear the configure cache before re-building." + print("\nERROR: Cannot find required (n)curses or pdcurses library.") + print(" On Fedora/RedHat: yum install ncurses-devel") + print(" On Debian/Ubuntu: apt-get install ncurses-dev") + print(" After install, rm -fr xorp/obj build directory to") + print(" clear the configure cache before re-building.") sys.exit(1) diff --git a/xorp/site_scons/config/boost.py b/xorp/site_scons/config/boost.py index 0ed227655..fede54f6f 100644 --- a/xorp/site_scons/config/boost.py +++ b/xorp/site_scons/config/boost.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # # vim:set sts=4 ts=8 syntax=python: # diff --git a/xorp/site_scons/config/member.py b/xorp/site_scons/config/member.py index 7a84f9d29..0c0e24d6a 100644 --- a/xorp/site_scons/config/member.py +++ b/xorp/site_scons/config/member.py @@ -19,7 +19,6 @@ import re import string -from types import IntType from SCons.Conftest import LogInputFiles, LogErrorMessages # TODO: Support C++. @@ -112,18 +111,18 @@ def _Have(context, key, have, comment = None): Give "have" as is should appear in the header file, include quotes when desired and escape special characters! """ - key_up = string.upper(key) + key_up = key.upper() key_up = re.sub('[^A-Z0-9_]', '_', key_up) context.havedict[key_up] = have if have == 1: line = "#define %s 1\n" % key_up elif have == 0: line = "/* #undef %s */\n" % key_up - elif type(have) == IntType: + elif type(have) == int: line = "#define %s %d\n" % (key_up, have) else: line = "#define %s %s\n" % (key_up, str(have)) - + if comment is not None: lines = "\n/* %s */\n" % comment + line else: diff --git a/xorp/site_scons/config/sysctl.py b/xorp/site_scons/config/sysctl.py index b83d37f20..899acb094 100644 --- a/xorp/site_scons/config/sysctl.py +++ b/xorp/site_scons/config/sysctl.py @@ -19,7 +19,6 @@ import re import string -from types import IntType from SCons.Conftest import LogInputFiles, LogErrorMessages # TODO: Support C++. @@ -120,18 +119,18 @@ def _Have(context, key, have, comment = None): Give "have" as is should appear in the header file, include quotes when desired and escape special characters! """ - key_up = string.upper(key) + key_up = key.upper() key_up = re.sub('[^A-Z0-9_]', '_', key_up) context.havedict[key_up] = have if have == 1: line = "#define %s 1\n" % key_up elif have == 0: line = "/* #undef %s */\n" % key_up - elif type(have) == IntType: + elif type(have) == int: line = "#define %s %d\n" % (key_up, have) else: line = "#define %s %s\n" % (key_up, str(have)) - + if comment is not None: lines = "\n/* %s */\n" % comment + line else: @@ -152,7 +151,7 @@ def _LogFailed(context, text, msg): """ if LogInputFiles: context.Log("Failed program was:\n") - lines = string.split(text, '\n') + lines = text.split('\n') if len(lines) and lines[-1] == '': lines = lines[:-1] # remove trailing empty line n = 1 diff --git a/xorp/site_scons/site_tools/TOOL_SUBST.py b/xorp/site_scons/site_tools/TOOL_SUBST.py index 7162e0649..3c6a7882c 100644 --- a/xorp/site_scons/site_tools/TOOL_SUBST.py +++ b/xorp/site_scons/site_tools/TOOL_SUBST.py @@ -22,7 +22,7 @@ def do_subst_in_file(targetfile, sourcefile, dict): contents = f.read() f.close() except: - raise SCons.Errors.UserError, "Can't read source file %s"%sourcefile + raise SCons.Errors.UserError("Can't read source file {}".format(sourcefile)) for (k,v) in dict.items(): contents = re.sub(k, v, contents) try: @@ -30,12 +30,12 @@ def do_subst_in_file(targetfile, sourcefile, dict): f.write(contents) f.close() except: - raise SCons.Errors.UserError, "Can't write target file %s"%targetfile + raise SCons.Errors.UserError("Can't write target file {}".format(targetfile)) return 0 # success def subst_in_file(target, source, env): - if not env.has_key('SUBST_DICT'): - raise SCons.Errors.UserError, "SubstInFile requires SUBST_DICT to be set." + if not 'SUBST_DICT' in env: + raise SCons.Errors.UserError("SubstInFile requires SUBST_DICT to be set.") d = dict(env['SUBST_DICT']) # copy it for (k,v) in d.items(): if callable(v): @@ -43,7 +43,7 @@ def subst_in_file(target, source, env): elif SCons.Util.is_String(v): d[k]=env.subst(v) else: - raise SCons.Errors.UserError, "SubstInFile: key %s: %s must be a string or callable"%(k, repr(v)) + raise SCons.Errors.UserError("SubstInFile: key %s: %s must be a string or callable"%(k, repr(v))) for (t,s) in zip(target, source): return do_subst_in_file(str(t), str(s), d) diff --git a/xorp/site_scons/site_tools/autotest.py b/xorp/site_scons/site_tools/autotest.py index e1099dae1..ec4c94491 100644 --- a/xorp/site_scons/site_tools/autotest.py +++ b/xorp/site_scons/site_tools/autotest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # vim:set sts=4 ts=4 sw=4: # coding=UTF-8 # @@ -32,10 +32,11 @@ from SCons.Script import * from SCons.Builder import Builder +import SCons.Warnings import os # A warning class to notify users of problems -class ToolAutoTestWarning(SCons.Warnings.Warning): +class ToolAutoTestWarning(SCons.Warnings.SConsWarning): pass SCons.Warnings.enableWarningClass(ToolAutoTestWarning) @@ -46,9 +47,9 @@ def multiget(dictlist, key, default = None): in each one and returns the 1st one it finds. If the key is found in no dictionaries, the default is returned. """ - for dict in dictlist: - if dict.has_key(key): - return dict[key] + for d in dictlist: + if key in d: + return d[key] else: return default @@ -70,7 +71,7 @@ def _UnitTest(env, target, source = [], **kwargs): # Tests are not intended to be installed, so we don't do any # further RPATH magic here. myrpath = rpath - if env.has_key('SHAREDLIBS'): + if 'SHAREDLIBS' in env: baserpath = Dir(env['BUILDDIR']).abspath myrpath += [ x.replace('$BUILDDIR', baserpath) for x in libpath ] @@ -111,7 +112,7 @@ def generate(env, **kwargs): env.SetDefault( AUTOTEST_SKIP_ERRORS = False ) #Here's where keyword arguments are applied - apply(env.Replace, (), kwargs) + # apply(env.Replace, (), kwargs) def AutoTest(env, target, source = None, **kwargs): """Usage: diff --git a/xorp/site_scons/site_tools/tgtgen.py b/xorp/site_scons/site_tools/tgtgen.py index d0357d363..55a2ac9da 100644 --- a/xorp/site_scons/site_tools/tgtgen.py +++ b/xorp/site_scons/site_tools/tgtgen.py @@ -6,7 +6,7 @@ def tgtgen_emitter(target, source, env): base,ext = SCons.Util.splitext(str(source[0])) - base = base[base.rfind("/") + 1:] + base = base[base.rfind("/") + 1:] cc = base + "_base.cc" hh = base + "_base.hh" xrls = base + ".xrls" diff --git a/xorp/static_routes/SConscript b/xorp/static_routes/SConscript index 5b69ef9fd..8d7acb182 100644 --- a/xorp/static_routes/SConscript +++ b/xorp/static_routes/SConscript @@ -22,7 +22,7 @@ Import('env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#', @@ -66,12 +66,12 @@ if not is_shared: "crypto", ]) - if not (env.has_key('mingw') and env['mingw']): + if not ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ "rt", ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ 'ws2_32', 'iphlpapi', diff --git a/xorp/tests/bgp/test_bgp_config.py b/xorp/tests/bgp/test_bgp_config.py index eadfc5f6d..2db8de4c3 100644 --- a/xorp/tests/bgp/test_bgp_config.py +++ b/xorp/tests/bgp/test_bgp_config.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Copyright (c) 2001-2009 XORP, Inc. # diff --git a/xorp/tests/bgp/test_bgp_dump1.py b/xorp/tests/bgp/test_bgp_dump1.py index aa0ecba37..95e993a00 100755 --- a/xorp/tests/bgp/test_bgp_dump1.py +++ b/xorp/tests/bgp/test_bgp_dump1.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Copyright (c) 2001-2009 XORP, Inc. # diff --git a/xorp/tests/bgp/test_bgp_policy1.py b/xorp/tests/bgp/test_bgp_policy1.py index 4a436dc5d..19eb937ce 100755 --- a/xorp/tests/bgp/test_bgp_policy1.py +++ b/xorp/tests/bgp/test_bgp_policy1.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Copyright (c) 2001-2009 XORP, Inc. # diff --git a/xorp/tests/bgp/test_bgp_reports1.py b/xorp/tests/bgp/test_bgp_reports1.py index 708239d66..2bf0ec10a 100755 --- a/xorp/tests/bgp/test_bgp_reports1.py +++ b/xorp/tests/bgp/test_bgp_reports1.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Copyright (c) 2001-2009 XORP, Inc. # diff --git a/xorp/tests/bgp/test_unh1.py b/xorp/tests/bgp/test_unh1.py index 9ef0cd10f..a7480da11 100755 --- a/xorp/tests/bgp/test_unh1.py +++ b/xorp/tests/bgp/test_unh1.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Copyright (c) 2001-2009 XORP, Inc. # diff --git a/xorp/tests/test_builddir.py b/xorp/tests/test_builddir.py index 1c8b6b6b4..dd7f5e4bf 100644 --- a/xorp/tests/test_builddir.py +++ b/xorp/tests/test_builddir.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Copyright (c) 2001-2009 XORP, Inc. # diff --git a/xorp/tests/test_call_xrl.py b/xorp/tests/test_call_xrl.py index ad388e131..f3fd70c79 100644 --- a/xorp/tests/test_call_xrl.py +++ b/xorp/tests/test_call_xrl.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Copyright (c) 2001-2009 XORP, Inc. # diff --git a/xorp/tests/test_main.py b/xorp/tests/test_main.py index 601d3f80a..c22f1eb2e 100644 --- a/xorp/tests/test_main.py +++ b/xorp/tests/test_main.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Copyright (c) 2001-2011 XORP, Inc and Others # diff --git a/xorp/tests/test_process.py b/xorp/tests/test_process.py index 9f1d7b5fe..6815fab29 100755 --- a/xorp/tests/test_process.py +++ b/xorp/tests/test_process.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Copyright (c) 2001-2009 XORP, Inc. # diff --git a/xorp/tests/test_start.py b/xorp/tests/test_start.py index 15eb1a28c..35db4d31b 100755 --- a/xorp/tests/test_start.py +++ b/xorp/tests/test_start.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Copyright (c) 2001-2009 XORP, Inc. # diff --git a/xorp/tests/test_stop.py b/xorp/tests/test_stop.py index f1b6378e9..6d02bc809 100755 --- a/xorp/tests/test_stop.py +++ b/xorp/tests/test_stop.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Copyright (c) 2001-2009 XORP, Inc. # diff --git a/xorp/tests/test_xorpsh.py b/xorp/tests/test_xorpsh.py index 539a66529..99bcad203 100644 --- a/xorp/tests/test_xorpsh.py +++ b/xorp/tests/test_xorpsh.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Copyright (c) 2001-2009 XORP, Inc. # diff --git a/xorp/utils/SConscript b/xorp/utils/SConscript index 88e5cd698..03f8e46f2 100644 --- a/xorp/utils/SConscript +++ b/xorp/utils/SConscript @@ -22,7 +22,7 @@ Import('env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#', diff --git a/xorp/vrrp/SConscript b/xorp/vrrp/SConscript index 56795ad0c..394e9881e 100644 --- a/xorp/vrrp/SConscript +++ b/xorp/vrrp/SConscript @@ -27,7 +27,7 @@ Import('env') #SConscript(dirs = subdirs, exports='env') env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ '#', @@ -61,7 +61,7 @@ env.AppendUnique(LIBS = [ 'xorp_comm' ]) -if (env.has_key('mingw') and env['mingw']): +if ('mingw' in env and env['mingw']): env.AppendUnique(LIBS = [ # 'mprapi', 'regex', diff --git a/xorp/xrl/interfaces/SConscript b/xorp/xrl/interfaces/SConscript index 8e4c8931b..e781a35df 100644 --- a/xorp/xrl/interfaces/SConscript +++ b/xorp/xrl/interfaces/SConscript @@ -24,7 +24,7 @@ Import("env") env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ "#" ]) env.AppendUnique(LIBPATH = [ '$BUILDDIR/libxipc', @@ -83,7 +83,7 @@ xifs = [ if env['enable_bgp']: xifs.append('bgp.xif') -if not (env.has_key('disable_ipv6') and env['disable_ipv6']): +if not ('disable_ipv6' in env and env['disable_ipv6']): xifs.append('socket6.xif') xifs.append('socket6_user.xif') xifs.append('fea_rawpkt6_client.xif') @@ -91,11 +91,11 @@ if not (env.has_key('disable_ipv6') and env['disable_ipv6']): if env['enable_ospf']: xifs.append('ospfv3.xif') -if not (env.has_key('disable_profile') and env['disable_profile']): +if not ('disable_profile' in env and env['disable_profile']): xifs.append('profile_client.xif') xifs.append('profile.xif') -if not (env.has_key('disable_fw') and env['disable_fw']): +if not ('disable_fw' in env and env['disable_fw']): xifs.append('fea_firewall.xif') if env['enable_olsr']: diff --git a/xorp/xrl/scripts/Xif/kdoc.py b/xorp/xrl/scripts/Xif/kdoc.py index 411a18593..c9bdafb92 100644 --- a/xorp/xrl/scripts/Xif/kdoc.py +++ b/xorp/xrl/scripts/Xif/kdoc.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 """ This file provides kdoc comment support for XIF interface files. It helps propagate kdoc comments from interface definitions into C++ files. @@ -55,12 +56,12 @@ def __init__(self, kdoc_comment): kdoc_sections = cleaned_kdoc_comment.split("@") for s in kdoc_sections: if s.find("return") == 0: - print "Ignoring kdoc @return primitive in input file." + print("Ignoring kdoc @return primitive in input file.") continue elif s.find("param") == 0: pc = s.split(None, 2) if len(pc) != 3: - print "@param with missing variable or description: \"%s\"" % s + print("@param with missing variable or description: \"%s\"" % s) continue self._params[pc[1]] = pc[2] elif s.find("ROOT") == 0: @@ -99,13 +100,13 @@ def output_kdoc(self, indent_string, paramlist, comment = "", width = 80): s += indent_string + " * " + l + "\n" for p in paramlist: - if self._params.has_key(p): + if p in self._params: line = "@param " + p + " " + self._params[p] lines = break_into_lines(line, width) lines.insert(0, "") for l in lines: s += indent_string + " * " + l + "\n" - + for o in self._other: lines = break_into_lines(o, width) lines.insert(0, "") @@ -127,14 +128,14 @@ def test(): * @param planet any planet you happen to pick * but don't let it be jupiter. Really, that's ridiculous * @batman Mr dean - * @return pants + * @return pants */ """ p = parse_kdoc_comment(comment) p.add_kdoc_param("tgt_name", "Xrl Target to handle command") s = p.output_kdoc(" ", ["tgt_name", "planet", "plig"], \ "This is not an original comment") - print s - + print(s) + if __name__ == '__main__': test() diff --git a/xorp/xrl/scripts/Xif/parse.py b/xorp/xrl/scripts/Xif/parse.py index d96c73911..41a4e4879 100644 --- a/xorp/xrl/scripts/Xif/parse.py +++ b/xorp/xrl/scripts/Xif/parse.py @@ -1,7 +1,8 @@ +#!/usr/bin/env python3 # Python imports import string, re, sys -from xiftypes import * -from util import quit, warn +from .xiftypes import * +from .util import quit, warn # XIF specific imports @@ -42,7 +43,7 @@ def parse_cpp_hash(line): # Check if line looks like a pragma, if so ignore it p = pragma.match(line) if p: - return 1 + return 1 # Format is '# LINENUM FILENAME [FLAG]' where FLAG is either: # @@ -63,7 +64,7 @@ def parse_cpp_hash(line): if flag == '' or flag == '3': flag = "1" else: - return 0 + return 0 if flag == "1": push_file(file, line) @@ -72,22 +73,22 @@ def parse_cpp_hash(line): pop_file() push_file(file, line) else: - print "Invalid pre-processor #line flag (%d)\n", flag + print("Invalid pre-processor #line flag ({})\n".format(flag)) sys.exit(1) return 1 -def validate_name(file, line, type, value, extra): +def validate_name(file, line, type_, value, extra): pattern = "[A-Za-z][A-z0-9%s]?" % extra if re.match(pattern, value) == None: errmsg = "%s name \"%s\" has chars other than %s" \ - % (type, value, pattern) + % (type_, value, pattern) quit(file, line, errmsg) -def parse_args(file, lineno, str): - if str == "": +def parse_args(file, lineno, s): + if s == "": return [] - toks = string.split(str, "&") + toks = s.split("&") # arg format is [] # ^ ^ @@ -96,33 +97,33 @@ def parse_args(file, lineno, str): xrl_args = [] for t in toks: - lb = string.find(t, ":") + lb = t.find(":") if lb == -1: quit(file, lineno, "Missing \":\" in xrlatom \"%s\"" % t) - + name = t[:lb] - type = t[lb + 1:] + type_ = t[lb + 1:] validate_name(file, lineno, "Atom", name, '_-') # Parse \<\> (\<\> are literal angle brackets). - lab = string.find(type, "<") + lab = type_.find("<") member_type = None if lab != -1: - rab = string.find(type, ">") + rab = type_.find(">") if rab == -1: - quit(file, lineno, "Invalid type spec \"%s\"" % type) - member_type = type[lab + 1:rab] - type = type[:lab] + quit(file, lineno, "Invalid type spec \"%s\"" % type_) + member_type = type_[lab + 1:rab] + type_ = type_[:lab] - if xrl_atom_type.has_key(type) == 0: + if type_ not in xrl_atom_type: quit(file, lineno, "Atom type \"%s\" not amongst those known %s" - % (type, xrl_atom_type.keys())) - xa = XrlArg(name, type) - if type == 'list': + % (type_, xrl_atom_type.keys())) + xa = XrlArg(name, type_) + if type_ == 'list': # Deal with type of members embedded in the container. These # are now mandatory for XIF in this branch. - if xrl_atom_type.has_key(member_type) == 0: + if member_type not in xrl_atom_type == 0: quit(file, lineno, "Member atom type \"%s\" not amongst those known %s" % (member_type, xrl_atom_type.keys())) xa.set_member_type(member_type) @@ -132,8 +133,8 @@ def parse_args(file, lineno, str): """ Fill in any missing separators in Xrl to make parsing trivial""" def fix_up_line(line): # chomp whitespace - table = string.maketrans("","") - line = string.translate(line, table, string.whitespace) + for l in string.whitespace: + line = line.replace(l, "") # Fill in missing component separators. if line.find("->") < 0: @@ -159,8 +160,7 @@ def parse_target_interfaces(file, lineno, line): while (line != ""): m = target_if.match(line) if m == None: - print "Bad interface in file %s at line %d\n\"%s\"\n" % \ - (file, lineno, line) + print("Bad interface in file %s at line %d\n\"%s\"\n" % (file, lineno, line)) sys.exit(1) ifs.append((m.group(1), m.group(2))) line = line[m.end():] @@ -176,8 +176,7 @@ def parse_method(file, lineno, line): m = method_outline.match(line) if m == None: - print "Bad method declaration from %s line %d:\n\"%s\"\n" %\ - (file, lineno, line) + print("Bad method declaration from %s line %d:\n\"%s\"\n" % (file, lineno, line)) sys.exit(1) method, args, rargs = m.groups() @@ -324,12 +323,10 @@ def __init__(self, file): if tif_name == i.name(): found = 1 if found == 0: - print "Interface %s/%s not defined" % tif, \ - "in file %s line %d\n" % \ - (get_input_file(), get_input_line()) - print "Valid interfaces are:" + print("Interface {0}/{0} not defined in file %{1} line %{2}\n".format(tif, get_input_file(), get_input_line())) + print("Valid interfaces are:") for i in self._interfaces: - print "\t%s/%s"% (i.name(), i.version()) + print("\t{0}/{1}".format(i.name(), i.version())) sys.exit(1) else: tgt.add_interface(tif) @@ -344,8 +341,8 @@ def __init__(self, file): line_buffer = line_buffer[m.end():].strip() continue - print "Unrecognized command in file %s at line %d:\n\"%s\"\n" \ - % (get_input_file(), get_input_line(), line_buffer) + print("Unrecognized command in file %s at line %d:\n\"%s\"\n" \ + % (get_input_file(), get_input_line(), line_buffer)) sys.exit(1) else: m = not_grouping_end.match(line_buffer) diff --git a/xorp/xrl/scripts/Xif/thrifttypes.py b/xorp/xrl/scripts/Xif/thrifttypes.py index 9f18420a6..1257999b4 100644 --- a/xorp/xrl/scripts/Xif/thrifttypes.py +++ b/xorp/xrl/scripts/Xif/thrifttypes.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # vim:set sts=4 ts=8 sw=4: # in this namespace @@ -49,8 +50,7 @@ def send_ipv4net(fname, sname='ipv4net'): lines = [] lines.append("nout += outp->writeStructBegin(\"%s\");" % sname) lines.append("nout += outp->writeFieldBegin(\"network\", T_I32, 1);") - lines.append("nout += outp->writeI32(ntohl(%s.masked_addr().addr()));" % \ - fname) + lines.append("nout += outp->writeI32(ntohl(%s.masked_addr().addr()));" % fname) lines.append("nout += outp->writeFieldEnd();") lines.append("nout += outp->writeFieldBegin(\"prefix\", T_BYTE, 2);") lines.append("nout += outp->writeByte(%s.prefix_len());" % fname) @@ -62,15 +62,14 @@ def send_ipv4net(fname, sname='ipv4net'): def send_ipv6(fname, sname='ipv6', addrmethod='addr()'): lines = [] lines.append("nout += outp->writeStructBegin(\"%s\");" % sname) - lines.append("const uint32_t* pa_%s = %s.%s;" % \ - (fname, fname, addrmethod)) + lines.append("const uint32_t* pa_%s = %s.%s;" % (fname, fname, addrmethod)) for i in xrange(1,5): - lines.append(\ - "nout += outp->writeFieldBegin(\"addr32_%d\", T_I32, %d);" % \ - (i, i)) - lines.append("nout += outp->writeI32(pa_%s[%d]);" % \ - (fname, (i-1))) - lines.append("nout += outp->writeFieldEnd();") + lines.append(\ + "nout += outp->writeFieldBegin(\"addr32_%d\", T_I32, %d);" % \ + (i, i)) + lines.append("nout += outp->writeI32(pa_%s[%d]);" % \ + (fname, (i-1))) + lines.append("nout += outp->writeFieldEnd();") lines.append("nout += outp->writeFieldStop();") lines.append("nout += outp->writeStructEnd();") return lines @@ -153,8 +152,7 @@ def recv_ipv4(fname): lines = [] lines.append("int32_t i32_%s;" % fname) lines.append("nin += inp->readI32(i32_%s);" % fname) - lines.append("%s = IPv4(htonl(static_cast(i32_%s)));" % \ - (fname, fname)) + lines.append("%s = IPv4(htonl(static_cast(i32_%s)));" % (fname, fname)) return lines # Shim these to support functions to handle embedded struct. @@ -186,8 +184,7 @@ def recv_mac(fname): # XXX: We should sanity check the length of the binary data once read. lines.append("//assert(tmp_%s.size() == Mac::ADDR_BYTELEN);" % fname) lines.append("%s.copy_in(\n" % fname) - lines.append(" reinterpret_cast(tmp_%s.data()));" % \ - fname) + lines.append(" reinterpret_cast(tmp_%s.data()));" % fname) return lines def recv_txt(fname): @@ -208,8 +205,7 @@ def recv_binary(fname): lines.append("string tmp_%s;" % fname) lines.append("nin += inp->readBinary(tmp_%s);" % fname) lines.append("%s.resize(tmp_%s.size());" % (fname, fname)) - lines.append("memcpy(&%s[0], tmp_%s.data(), tmp_%s.size());" % \ - (fname, fname, fname)) + lines.append("memcpy(&%s[0], tmp_%s.data(), tmp_%s.size());" % (fname, fname, fname)) return lines # ----------------------------------------------------------------------------- @@ -239,21 +235,21 @@ def wire_type(a): def send_arg(a, fname=None): lines = [] if fname is None: - fname = a.name() + fname = a.name() if a.is_list(): - lines += send_list(a) + lines += send_list(a) else: - lines += (xiftothrift[a.type()][1])(fname) + lines += (xiftothrift[a.type()][1])(fname) return lines def recv_arg(a, fname=None): lines = [] if fname is None: - fname = a.name() + fname = a.name() if a.is_list(): - lines += recv_list(a, fname) + lines += recv_list(a, fname) else: - lines += (xiftothrift[a.type()][2])(fname) + lines += (xiftothrift[a.type()][2])(fname) return lines # ----------------------------------------------------------------------------- @@ -267,27 +263,24 @@ def recv_list(a, fname): m = a.member() if a.member().is_list(): - print "Lists-of-lists are currently not implemented, sorry." - sys.exit(1) + print "Lists-of-lists are currently not implemented, sorry." + sys.exit(1) tab = xorp_indent(1) lines.append("uint32_t sz_%s;" % fname) lines.append("TType mt_%s;" % fname) - lines.append("nin += inp->readListBegin(mt_%s, sz_%s);" % \ - tuple([fname] * 2)) - lines.append("for (uint32_t i_%s = 0; i_%s < sz_%s; i_%s++) {" % \ - tuple([fname] * 4)) + lines.append("nin += inp->readListBegin(mt_%s, sz_%s);" % tuple([fname] * 2)) + lines.append("for (uint32_t i_%s = 0; i_%s < sz_%s; i_%s++) {" % tuple([fname] * 4)) # Now read in base type. mfname = "tmp_%s" % fname lines.append(tab + "%s %s;" % (m.cpp_type(), mfname)) for l in recv_arg(m, mfname): - lines.append(tab + l) + lines.append(tab + l) # now convert to XrlAtom and append to our collection in local scope. - lines.append(tab + ("%s.append(XrlAtom(tmp_%s));" % \ - tuple([fname] * 2))) + lines.append(tab + ("%s.append(XrlAtom(tmp_%s));" % tuple([fname] * 2))) lines.append("}") lines.append("nin += inp->readListEnd();") return lines @@ -315,31 +308,27 @@ def send_list(a): m = a.member() if a.member().is_list(): - print "Lists-of-lists are currently not implemented, sorry." - sys.exit(1) + print "Lists-of-lists are currently not implemented, sorry." + sys.exit(1) tab = xorp_indent(1) tab2 = xorp_indent(2) lines.append("size_t sz_%s = %s.size();" % (fname, fname)) - lines.append("nout += outp->writeListBegin(%s, sz_%s);" % \ - (wire_type(m), fname)) + lines.append("nout += outp->writeListBegin(%s, sz_%s);" % (wire_type(m), fname)) lines.append("if (sz_%s > 0) {" % fname) - lines.append(tab + "for (size_t i_%s = 1; i_%s <= sz_%s; i_%s++) {" % \ - (fname, fname, fname, fname)) - lines.append(tab2 + "const XrlAtom& xa = %s.get(i_%s);" % \ - (fname, fname)) + lines.append(tab + "for (size_t i_%s = 1; i_%s <= sz_%s; i_%s++) {" % (fname, fname, fname, fname)) + lines.append(tab2 + "const XrlAtom& xa = %s.get(i_%s);" % (fname, fname)) mfname = "xa_%s" % m.type() # member field name with XIF type - lines.append(tab2 + "const %s& %s = xa.%s();" % \ - (m.cpp_type(), mfname, m.accessor())) + lines.append(tab2 + "const %s& %s = xa.%s();" % (m.cpp_type(), mfname, m.accessor())) # now marshal out the member type, indented at this level correctly. for l in send_arg(m, mfname): - lines.append(tab2 + l) + lines.append(tab2 + l) - lines.append(tab + "}") # close for - lines.append("}") # close if + lines.append(tab + "}") # close for + lines.append("}") # close if lines.append("nout += outp->writeListEnd();") # close thrift list return lines diff --git a/xorp/xrl/scripts/Xif/util.py b/xorp/xrl/scripts/Xif/util.py index 9e4043beb..1441fea45 100644 --- a/xorp/xrl/scripts/Xif/util.py +++ b/xorp/xrl/scripts/Xif/util.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import sys, traceback, string, re from time import time, localtime, strftime @@ -5,8 +6,7 @@ # Utility methods and structures def warn(file, lineno, reason): - print "In Xrl starting at line %d in %s:" % (lineno, file) - print "\t", reason + print("In Xrl starting at line {} in {}:\t{}".format(lineno, file, reason)) def quit(file, lineno, reason): warn(file, lineno, reason) @@ -31,7 +31,7 @@ def xorp_indent(level): if level <= 0: return "" s = "" - ntabs = level / 2 + ntabs = level // 2 for i in range(0, ntabs): s += "\t" @@ -43,18 +43,15 @@ def xorp_indent(level): def xorp_indent_string(level, x): return xorp_indent(level) + x -def xorp_indent_list(level, list): - r = [] - for l in list: - r.append(xorp_indent_string(level, l)); - return r; +def xorp_indent_list(level, list_arg): + return [xorp_indent_string(level, x) for x in list_arg] -# Fix Xrl interface, method, and argument names for c++ +# Fix Xrl interface, method, and argument names for c++ def cpp_name(xrl_name): new_name = "" for i in range(0, len(xrl_name)): c = xrl_name[i] - if (c == '/') | (c == '-') | (c == "."): + if (c == '/') or (c == '-') or (c == "."): c = "_" new_name += c return new_name @@ -76,10 +73,10 @@ def proper(n): l = ' ' r = "" for i in range(0, len(n)): - if string.find(string.whitespace, l) >= 0: - r += string.upper(n[i]) + if l in string.whitespace: + r += n[i].upper() else: - r += string.lower(n[i]) + r += n[i].lower() l = n[i] return r @@ -92,14 +89,13 @@ def caps_cpp_classname(s): apply_cap = 1 r = "" for l in s: - digit = (string.find(string.digits, l) >= 0); - if (digit): + if l in string.digits: apply_cap = 1 - elif (string.find(string.letters, l) < 0): + elif l not in string.ascii_letters: apply_cap = 1 l = '' elif (apply_cap): - l = string.upper(l) + l = l.upper() apply_cap = 0 r += l return r diff --git a/xorp/xrl/scripts/Xif/xiftypes.py b/xorp/xrl/scripts/Xif/xiftypes.py index 85489f29e..dd4607632 100644 --- a/xorp/xrl/scripts/Xif/xiftypes.py +++ b/xorp/xrl/scripts/Xif/xiftypes.py @@ -1,3 +1,4 @@ +#!/usr/bin/python3 xrl_atom_type = { # : (, , ) 'bool' : ('bool', 'boolean', 'bool'), diff --git a/xorp/xrl/scripts/clnt-gen b/xorp/xrl/scripts/clnt-gen index 8f8024758..564dacc75 100755 --- a/xorp/xrl/scripts/clnt-gen +++ b/xorp/xrl/scripts/clnt-gen @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Program to generate Xrl Interface Client related files""" @@ -8,8 +8,8 @@ import os, sys # This is a bit of mess as this code was split into separate files import Xif.util -from Xif.util import \ - joining_csv, csv, cpp_name, cpp_classname, caps_cpp_classname, \ +from Xif.util import \ + joining_csv, csv, cpp_name, cpp_classname, caps_cpp_classname, \ cpp_version, xorp_indent_string, xorp_indent from Xif.xiftypes import \ @@ -79,7 +79,7 @@ def implement_send_xrl(cls, method_no, method, ifqname): i = 0 for a in method.args(): s += " x->args().set_arg(%d, %s);\n" % (i, a.name()) - i += 1 + i += 1 s += "\n" s += " return _sender->send(*x, callback(&%s::unmarshall_%s, cb));\n" % (cls, method.name()) s += "}\n\n" @@ -116,7 +116,7 @@ def implement_unmarshall(cls, method_no, method): for i in range(0, len(args)): args[i] = "\n\t" + args[i] s += csv(args) - s += "\n)\n" + s += "\n)\n" s += "{\n" s += " if (e != XrlError::OKAY()) {\n" s += "\tcb->dispatch(e%s);\n" % fail_args @@ -225,10 +225,10 @@ def main(): usage = "usage: %prog [options] arg" parser = OptionParser(usage) parser.add_option("-o", "--output-dir", - action="store", - type="string", - dest="output_dir", - metavar="DIR") + action="store", + type="string", + dest="output_dir", + metavar="DIR") parser.add_option("-I", action="append", type="string", @@ -242,21 +242,21 @@ def main(): # Command line arguments passed on to cpp pipe_string = "cpp -C " if options.includes: - for a in options.includes: - pipe_string += "-I%s " % a - pipe_string += args[0] + for a in options.includes: + pipe_string += "-I%s " % a + pipe_string += args[0] cpp_pipe = os.popen(pipe_string, 'r') xp = XifParser(cpp_pipe) if len(xp.targets()): - print "Found targets (used a .ent rather than .xif input?)" + print("Found targets (used a .ent rather than .xif input?)") sys.exit(1) xifs = xp.interfaces() if len(xifs) == 0: - print "No interface definitions provided" + print("No interface definitions provided") sys.exit(1) # Check all interface definitions come from same source file. @@ -265,12 +265,12 @@ def main(): sourcefile = xifs[0].sourcefile() for xif in xifs: if (xif.sourcefile() != sourcefile): - print "Multiple .xif files presented, expected one." + print("Multiple .xif files presented, expected one.") sys.exit(1) # basename transformation - this is a lame test if sourcefile[-4:] != ".xif": - print "Source file does not end in .xif suffix - basename transform failure." + print("Source file does not end in .xif suffix - basename transform failure.") sys.exit(1) basename = sourcefile[:-4] @@ -281,9 +281,9 @@ def main(): cc_file = "%s_xif.cc" % basename if options.output_dir: - hh_file = os.path.join(options.output_dir, hh_file) - cc_file = os.path.join(options.output_dir, cc_file) - + hh_file = os.path.join(options.output_dir, hh_file) + cc_file = os.path.join(options.output_dir, cc_file) + # Generate header file hh_txt = prepare_client_if_hh(modulename, hh_file) for xif in xifs: diff --git a/xorp/xrl/scripts/skel-gen b/xorp/xrl/scripts/skel-gen index 5f2f73733..07f6e58f7 100755 --- a/xorp/xrl/scripts/skel-gen +++ b/xorp/xrl/scripts/skel-gen @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Program to generate a skeleton Xrl Target derived class""" @@ -66,42 +66,42 @@ def generate_method_args(method, indent_level): args = [] # input args if len(method.args()): - args.append("\n%s// Input values" % xorp_indent(indent_level)) + args.append("\n%s// Input values" % xorp_indent(indent_level)) for a in method.args(): - cpa = "\n%sconst %s&\t%s" % \ - (xorp_indent(indent_level), a.cpp_type(), cpp_name(a.name())) - args.append(cpa) + cpa = "\n%sconst %s&\t%s" % \ + (xorp_indent(indent_level), a.cpp_type(), cpp_name(a.name())) + args.append(cpa) # output args if len(method.rargs()): - args.append("\n%s// Output values" % xorp_indent(indent_level)) + args.append("\n%s// Output values" % xorp_indent(indent_level)) for r in method.rargs(): - cpa = "\n%s%s&\t%s" % \ - (xorp_indent(indent_level), r.cpp_type(), cpp_name(r.name())) - args.append(cpa) + cpa = "\n%s%s&\t%s" % \ + (xorp_indent(indent_level), r.cpp_type(), cpp_name(r.name())) + args.append(cpa) return csv(args) def target_declare_derived(methods): s = "" for m in methods: - cpp_method_name = cpp_name(m.name()) - args = generate_method_args(m, indent_level=2) - s += " XrlCmdError %s(%s);\n\n" % (cpp_method_name, args) + cpp_method_name = cpp_name(m.name()) + args = generate_method_args(m, indent_level=2) + s += " XrlCmdError %s(%s);\n\n" % (cpp_method_name, args) return s; def target_derived_methods(cls, name, methods): s = "" for m in methods: - cpp_method_name = cpp_name(m.name()) - args = generate_method_args(m, indent_level=1) - s += "XrlCmdError\n%s::%s(%s)\n" % (cls, cpp_method_name, args) - s += "{\n" - s += " return XrlCmdError::COMMAND_FAILED(\"Not implemented\");\n" - for a in m.args(): - s += " UNUSED(%s);\n" % a.name(); - for r in m.rargs(): - s += " UNUSED(%s);\n" % r.name(); - s += "}\n" - s += "\n" + cpp_method_name = cpp_name(m.name()) + args = generate_method_args(m, indent_level=1) + s += "XrlCmdError\n%s::%s(%s)\n" % (cls, cpp_method_name, args) + s += "{\n" + s += " return XrlCmdError::COMMAND_FAILED(\"Not implemented\");\n" + for a in m.args(): + s += " UNUSED(%s);\n" % a.name(); + for r in m.rargs(): + s += " UNUSED(%s);\n" % r.name(); + s += "}\n" + s += "\n" return s def protect(file): @@ -178,7 +178,7 @@ def generate_target_methods(tgt, interfaces): found = 1 break if found == 0: - print "Error interface %s data not found" % tif_info[0] + print("Error interface %s data not found" % tif_info[0]) sys.exit(1) for m in tif.methods(): full_name = Xif.util.xrl_method_name(tif.name(), tif.version(), m.name()) @@ -192,10 +192,10 @@ def main(): usage = "usage: %prog [options] arg" parser = OptionParser(usage) parser.add_option("-o", "--output-dir", - action="store", - type="string", - dest="output_dir", - metavar="DIR") + action="store", + type="string", + dest="output_dir", + metavar="DIR") parser.add_option("-I", action="append", type="string", @@ -209,9 +209,9 @@ def main(): # Command line arguments passed on to cpp pipe_string = "cpp -C " if options.includes: - for a in options.includes: - pipe_string += "-I%s " % a - pipe_string += args[0] + for a in options.includes: + pipe_string += "-I%s " % a + pipe_string += args[0] cpp_pipe = os.popen(pipe_string, 'r') @@ -219,20 +219,20 @@ def main(): tgts = xp.targets() if len(tgts) == 0: - print "Not targets found in input files." + print("Not targets found in input files.") sys.exit(1) sourcefile = tgts[0].sourcefile() for tgt in tgts: if (tgt.sourcefile() != sourcefile): - print "Multiple .tgt files presented, expected just one." + print("Multiple .tgt files presented, expected just one.") sys.exit(1) # basename transformation - this is a lame test if sourcefile[-4:] != ".tgt": - print "Source file does not end in .tgt suffix - basename transform failure." + print("Source file does not end in .tgt suffix - basename transform failure.") sys.exit(1) - + basename = sourcefile[:-4] basename = basename[basename.rfind("/") + 1:] diff --git a/xorp/xrl/scripts/tgt-gen b/xorp/xrl/scripts/tgt-gen index 29988102f..ee4305dd6 100755 --- a/xorp/xrl/scripts/tgt-gen +++ b/xorp/xrl/scripts/tgt-gen @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Program to generate Xrl Target related files""" @@ -39,10 +39,10 @@ def output_xrls(tgt_name, methods): s += "finder://%s/%s" % (tgt_name, m.name()) if len(m.args()): s += "?" - s += csv(map(xrl_arg_str, m.args()), "&") + s += csv(list(map(xrl_arg_str, m.args())), "&") if len(m.rargs()): s += "->" - s += csv(map(xrl_arg_str, m.rargs()), "&") + s += csv(list(map(xrl_arg_str, m.rargs())), "&") s += "\n\n" return s @@ -252,7 +252,7 @@ def target_handler_hooks(cls, name): s += " }\n" s += " _cmds->finalize();\n" s += "}\n\n" - + s += "void\n%s::remove_handlers()\n{\n" %cls s += " for (size_t i = 0; i < num_handlers; ++i) {\n" s += " _cmds->remove_handler(handlers[i].name);\n" @@ -276,9 +276,9 @@ def target_handler_methods(cls, name, methods): s += \ """ if (e != XrlCmdError::OKAY()) { - XLOG_WARNING(\"Handling method for %%s failed: %%s\", - \"%s\", e.str().c_str()); - return c_b->dispatch(e, NULL); + XLOG_WARNING(\"Handling method for %%s failed: %%s\", + \"%s\", e.str().c_str()); + return c_b->dispatch(e, NULL); } else { """ % m.name() @@ -290,7 +290,7 @@ def target_handler_methods(cls, name, methods): (r.name(), cpp_name(r.name())) s += \ """ } catch (const XrlArgs::XrlAtomFound& ) { - XLOG_FATAL("Duplicate atom name"); /* XXX Should never happen */ + XLOG_FATAL("Duplicate atom name"); /* XXX Should never happen */ } """ @@ -310,13 +310,13 @@ def target_handler_methods(cls, name, methods): s += "\n%s%sCB c_b)\n{\n" % \ (xorp_indent(2), caps_cpp_classname(m.name())) - s += "\n /* Return value declarations */\n" - for r in m.rargs(): + s += "\n /* Return value declarations */\n" + for r in m.rargs(): s += " %s rarg_%s;\n" % (r.cpp_type(), cpp_name(r.name())) s += " XrlCmdError e = %s(" % cpp_name(m.name()) sep = "" - for r in m.args(): + for r in m.args(): s += "%s\n arg_%s" % (sep, cpp_name(r.name())) sep = "," for r in m.rargs(): @@ -324,7 +324,7 @@ def target_handler_methods(cls, name, methods): sep = "," s += ");\n" s += " return c_b->dispatch(e" - for r in m.rargs(): + for r in m.rargs(): s += ",\n &rarg_%s" % (cpp_name(r.name())) sep = "," s += ");\n" @@ -339,9 +339,9 @@ def target_handler_methods(cls, name, methods): s += "{" s += """ if (xa_inputs.size() != %d) { - XLOG_ERROR(\"Wrong number of arguments (%%u != %%u) handling %%s\", + XLOG_ERROR(\"Wrong number of arguments (%%u != %%u) handling %%s\", XORP_UINT_CAST(%d), XORP_UINT_CAST(xa_inputs.size()), \"%s\"); - XRL_CMD_RETURN_ERROR(pxa_outputs, XrlCmdError::BAD_ARGS()); + XRL_CMD_RETURN_ERROR(pxa_outputs, XrlCmdError::BAD_ARGS()); } """ % (len(m.args()), len(m.args()), m.name()) @@ -349,8 +349,8 @@ def target_handler_methods(cls, name, methods): s += """ #ifndef XORP_ENABLE_ASYNC_SERVER if (pxa_outputs == 0) { - XLOG_FATAL(\"Return list empty\"); - return XrlCmdError::BAD_ARGS(); + XLOG_FATAL(\"Return list empty\"); + return XrlCmdError::BAD_ARGS(); } #endif @@ -373,7 +373,7 @@ def target_handler_methods(cls, name, methods): cls, cpp_name(m.name())) s += xorp_indent(2) + "async_%s(" % cpp_name(m.name()) - i = 0 + i = 0 for a in m.args(): s += "\n" + xorp_indent(3) + \ "xa_inputs.get(%d, \"%s\").%s()," \ @@ -382,10 +382,10 @@ def target_handler_methods(cls, name, methods): s += " mycb);\n" - s += \ + s += \ """ } catch (const XrlArgs::BadArgs& e) { - XLOG_ERROR(\"Error decoding the arguments: %s\", e.str().c_str()); - return pxa_outputs->dispatch(XrlCmdError::BAD_ARGS(e.str()), NULL); + XLOG_ERROR(\"Error decoding the arguments: %s\", e.str().c_str()); + return pxa_outputs->dispatch(XrlCmdError::BAD_ARGS(e.str()), NULL); } """ @@ -393,37 +393,37 @@ def target_handler_methods(cls, name, methods): s += "#else\n" - s += "\n /* Return value declarations */\n" - for r in m.rargs(): + s += "\n /* Return value declarations */\n" + for r in m.rargs(): s += " %s r_%s;\n" % (r.cpp_type(), cpp_name(r.name())) s += xorp_indent(1) + "try {\n" s += xorp_indent(2) + "XrlCmdError e = %s(" % cpp_name(m.name()) get_reqs = [] - i = 0 + i = 0 for a in m.args(): get_reqs.append("\n" + xorp_indent(3) + \ "xa_inputs.get(%d, \"%s\").%s()" \ % (i, a.name(), a.accessor())) - i += 1 + i += 1 ret_vals = [] for r in m.rargs(): ret_vals.append("\n" + xorp_indent(3) + "r_%s" % cpp_name(r.name())) s += csv(get_reqs + ret_vals, ",") + ");\n" s += \ -""" if (e != XrlCmdError::OKAY()) { - XLOG_WARNING(\"Handling method for %%s failed: %%s\", - \"%s\", e.str().c_str()); - return e; +""" if (e != XrlCmdError::OKAY()) { + XLOG_WARNING(\"Handling method for %%s failed: %%s\", + \"%s\", e.str().c_str()); + return e; } """ % m.name() - s += \ + s += \ """ } catch (const XrlArgs::BadArgs& e) { - XLOG_ERROR(\"Error decoding the arguments: %s\", e.str().c_str()); - return XrlCmdError::BAD_ARGS(e.str()); + XLOG_ERROR(\"Error decoding the arguments: %s\", e.str().c_str()); + return XrlCmdError::BAD_ARGS(e.str()); } """ @@ -434,7 +434,7 @@ def target_handler_methods(cls, name, methods): (r.name(), cpp_name(r.name())) s += \ """ } catch (const XrlArgs::XrlAtomFound& ) { - XLOG_FATAL("Duplicate atom name"); /* XXX Should never happen */ + XLOG_FATAL("Duplicate atom name"); /* XXX Should never happen */ } """ @@ -476,8 +476,8 @@ public: * Constructor. * * @param cmds an XrlCmdMap that the commands associated with the target - * should be added to. This is typically the XrlRouter - * associated with the target. + * should be added to. This is typically the XrlRouter + * associated with the target. */ %s(XrlCmdMap* cmds = 0); @@ -540,13 +540,13 @@ def output_target_cc(cls, tgt_name, methods): : _cmds(cmds) { if (_cmds) - add_handlers(); + add_handlers(); } %s::~%s() { if (_cmds) - remove_handlers(); + remove_handlers(); } bool @@ -558,7 +558,7 @@ bool return true; } if (_cmds && cmds == 0) { - remove_handlers(); + remove_handlers(); _cmds = cmds; return true; } @@ -582,7 +582,7 @@ def generate_target_methods(tgt, interfaces): found = 1 break if found == 0: - print "Error interface %s data not found" % tif_info[0] + print("Error interface %s data not found" % tif_info[0]) sys.exit(1) for m in tif.methods(): full_name = Xif.util.xrl_method_name(tif.name(), tif.version(), m.name()) @@ -596,10 +596,10 @@ def main(): usage = "usage: %prog [options] arg" parser = OptionParser(usage) parser.add_option("-o", "--output-dir", - action="store", - type="string", - dest="output_dir", - metavar="DIR") + action="store", + type="string", + dest="output_dir", + metavar="DIR") parser.add_option("-I", action="append", type="string", @@ -613,9 +613,9 @@ def main(): # Command line arguments passed on to cpp pipe_string = "cpp -C " if options.includes: - for a in options.includes: - pipe_string += "-I%s " % a - pipe_string += args[0] + for a in options.includes: + pipe_string += "-I%s " % a + pipe_string += args[0] cpp_pipe = os.popen(pipe_string, 'r') @@ -623,20 +623,20 @@ def main(): tgts = xp.targets() if len(tgts) == 0: - print "No targets found in input files." + print("No targets found in input files.") sys.exit(1) sourcefile = tgts[0].sourcefile() for tgt in tgts: if (tgt.sourcefile() != sourcefile): - print "Multiple .tgt files presented, expected just one." + print("Multiple .tgt files presented, expected just one.") sys.exit(1) # basename transformation - this is a lame test if sourcefile[-4:] != ".tgt": - print "Source file does not end in .tgt suffix - basename transform failure." + print("Source file does not end in .tgt suffix - basename transform failure.") sys.exit(1) - + basename = sourcefile[:-4] basename = basename[basename.rfind("/") + 1:] diff --git a/xorp/xrl/scripts/thrift-clnt-gen b/xorp/xrl/scripts/thrift-clnt-gen index 2987a6b12..2eff5864f 100755 --- a/xorp/xrl/scripts/thrift-clnt-gen +++ b/xorp/xrl/scripts/thrift-clnt-gen @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 # vim:set sts=4 ts=8 sw=4: """Program to generate Xrl Interface Client related files""" @@ -365,8 +365,8 @@ def main(): usage = "usage: %prog [options] arg" parser = OptionParser(usage) parser.add_option("-o", "--output-dir", - action="store", - type="string", + action="store", + type="string", dest="output_dir", metavar="DIR") parser.add_option("-I", @@ -384,7 +384,7 @@ def main(): if options.includes: for a in options.includes: pipe_string += "-I%s " % a - pipe_string += args[0] + pipe_string += args[0] cpp_pipe = os.popen(pipe_string, 'r') diff --git a/xorp/xrl/scripts/thrift-gen b/xorp/xrl/scripts/thrift-gen index 455e6f0ae..136e003dc 100755 --- a/xorp/xrl/scripts/thrift-gen +++ b/xorp/xrl/scripts/thrift-gen @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 # vim:set sts=4 ts=8 sw=4: """Program to generate compatible Thrift service defintions from a Xif spec""" @@ -91,8 +91,8 @@ def main(): usage = "usage: %prog [options] arg" parser = OptionParser(usage) parser.add_option("-o", "--output-dir", - action="store", - type="string", + action="store", + type="string", dest="output_dir", metavar="DIR") parser.add_option("-I", @@ -110,7 +110,7 @@ def main(): if options.includes: for a in options.includes: pipe_string += "-I%s " % a - pipe_string += args[0] + pipe_string += args[0] cpp_pipe = os.popen(pipe_string, 'r') diff --git a/xorp/xrl/scripts/thrift-tgt-gen b/xorp/xrl/scripts/thrift-tgt-gen index 28759f6f7..d0651b81f 100755 --- a/xorp/xrl/scripts/thrift-tgt-gen +++ b/xorp/xrl/scripts/thrift-tgt-gen @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 # vim:set sts=4 ts=8 sw=4: """Program to generate Xrl Target related files""" @@ -450,8 +450,8 @@ def main(): usage = "usage: %prog [options] arg" parser = OptionParser(usage) parser.add_option("-o", "--output-dir", - action="store", - type="string", + action="store", + type="string", dest="output_dir", metavar="DIR") parser.add_option("-I", @@ -469,7 +469,7 @@ def main(): if options.includes: for a in options.includes: pipe_string += "-I%s " % a - pipe_string += args[0] + pipe_string += args[0] cpp_pipe = os.popen(pipe_string, 'r') @@ -490,7 +490,7 @@ def main(): if sourcefile[-4:] != ".tgt": print "Source file does not end in .tgt suffix - basename transform failure." sys.exit(1) - + basename = sourcefile[:-4] basename = basename[basename.rfind("/") + 1:] diff --git a/xorp/xrl/targets/SConscript b/xorp/xrl/targets/SConscript index 8a63bc861..08321aefa 100644 --- a/xorp/xrl/targets/SConscript +++ b/xorp/xrl/targets/SConscript @@ -22,7 +22,7 @@ import string Import("env") env = env.Clone() -is_shared = env.has_key('SHAREDLIBS') +is_shared = 'SHAREDLIBS' in env env.AppendUnique(CPPPATH = [ "#" ]) env.AppendUnique(LIBPATH = [ @@ -69,7 +69,7 @@ tgts = [ if env['enable_bgp']: tgts.append('bgp.tgt') -if not (env.has_key('disable_ipv6') and env['disable_ipv6']): +if not ('disable_ipv6' in env and env['disable_ipv6']): tgts.append('test_socket6.tgt') if env['enable_ospf']: tgts.append('ospfv3.tgt') @@ -93,7 +93,7 @@ if env['enable_vrrp']: if env['enable_xorpsh']: tgts.append('xorpsh.tgt') -if not (env.has_key('disable_profile') and env['disable_profile']): +if not ('disable_profile' in env and env['disable_profile']): tgts.append('profiler.tgt') #xrls_path = '$datadir'