1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

python3: 2to3 changes

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
This commit is contained in:
Julien Fortin
2019-12-17 16:55:49 +01:00
parent 35681c0608
commit 3b01ed7618
41 changed files with 479 additions and 488 deletions

View File

@@ -67,15 +67,15 @@ def get_swp_interfaces():
try:
ports = get_pci_interfaces()
except Exception as e:
print 'Error: Unsupported script: %s' % str(e)
print('Error: Unsupported script: %s' % str(e))
exit(1)
if not ports:
print 'Error: No ports found in %s' % porttab_path
print('Error: No ports found in %s' % porttab_path)
exit(1)
return ports
def print_swp_defaults_header():
print '''
print('''
# ** This file is autogenerated by /usr/share/doc/ifupdown2/generate_interfaces.py **
#
# This is /etc/network/interfaces section for all available swp
@@ -89,10 +89,10 @@ def print_swp_defaults_header():
# source /etc/network/interfaces.d/<filename>
#
# See manpage interfaces(5) for details.
'''
''')
def print_bridge_untagged_defaults_header():
print '''
print('''
# ** This file is autogenerated by /usr/share/doc/ifupdown2/generate_interfaces.py **
#
# This is /etc/network/interfaces section for a bridge device with all swp
@@ -107,7 +107,7 @@ def print_bridge_untagged_defaults_header():
# source /etc/network/interfaces.d/filename
#
# See manpage interfaces(5) for details
'''
''')
def interfaces_print_swp_default(swp_intf):
outbuf = None
@@ -115,7 +115,7 @@ def interfaces_print_swp_default(swp_intf):
try:
cmd = ['/sbin/ifquery', '%s' %swp_intf, '-i', '%s' %args.mergefile]
outbuf = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
except Exception, e:
except Exception as e:
# no interface found gen latest
pass
if not outbuf:
@@ -127,7 +127,7 @@ def interfaces_print_swp_defaults(swp_intfs):
outbuf = ''
for i in swp_intfs:
outbuf += interfaces_print_swp_default(i)
print outbuf
print(outbuf)
def interfaces_print_bridge_default(swp_intfs):
print_bridge_untagged_defaults_header()
@@ -141,7 +141,7 @@ def interfaces_print_bridge_default(swp_intfs):
ports += ' \\\n'
ports += ' %s' %(' '.join(swp_intfs[i:i+linen]))
outbuf += ports
print outbuf
print(outbuf)
def populate_argparser(argparser):
group = argparser.add_mutually_exclusive_group(required=False)
@@ -162,7 +162,7 @@ if not args.swpdefaults and not args.bridgedefault:
exit(1)
if args.bridgedefault and args.mergefile:
print 'error: mergefile option currently only supported with -s'
print('error: mergefile option currently only supported with -s')
argparser.print_help()
exit(1)