Skip to content

Commit bedc6e1

Browse files
committed
Python 3 syntax (print function, exception as e)
1 parent 959251d commit bedc6e1

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

scripts/pethtool

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import getopt, ethtool, sys
1616

1717
def usage():
18-
print '''Usage: pethtool [OPTIONS] [<interface>]
18+
print('''Usage: pethtool [OPTIONS] [<interface>]
1919
-h|--help Give this help list
2020
-c|--show-coalesce Show coalesce options
2121
-C|--coalesce Set coalesce options
@@ -44,12 +44,12 @@ def usage():
4444
-i|--driver Show driver information
4545
-k|--show-offload Get protocol offload information
4646
-K|--offload Set protocol offload
47-
[ tso on|off ]'''
47+
[ tso on|off ]''')
4848

4949
tab = ""
5050

5151
def printtab(msg):
52-
print tab + msg
52+
print(tab + msg)
5353

5454
all_devices = []
5555

@@ -300,7 +300,7 @@ def run_cmd(cmd, interface, args):
300300
inactive = " (not active)"
301301
if interface in active_devices:
302302
inactive = ""
303-
print "%s%s:" % (interface, inactive)
303+
print("%s%s:" % (interface, inactive))
304304
cmd(interface, args)
305305
else:
306306
cmd(interface, args)
@@ -327,9 +327,9 @@ def main():
327327
"driver",
328328
"show-offload",
329329
"offload"))
330-
except getopt.GetoptError, err:
330+
except getopt.GetoptError as err:
331331
usage()
332-
print str(err)
332+
print(err)
333333
sys.exit(2)
334334

335335
if not opts:

scripts/pifconfig

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,21 @@ def show_config(device):
5858
ipaddr = ethtool.get_ipaddr(device)
5959
netmask = ethtool.get_netmask(device)
6060
flags = ethtool.get_flags(device)
61-
print '%-9.9s' % device,
61+
print('%-9.9s' % device)
6262
if not (flags & ethtool.IFF_LOOPBACK):
63-
print "HWaddr %s" % ethtool.get_hwaddr(device),
64-
print '''
65-
inet addr:%s''' % ipaddr,
63+
print("HWaddr %s" % ethtool.get_hwaddr(device))
64+
print('''
65+
inet addr:%s''' % ipaddr)
6666
if not (flags & (ethtool.IFF_LOOPBACK | ethtool.IFF_POINTOPOINT)):
67-
print "Bcast:%s" % ethtool.get_broadcast(device),
68-
print ' Mask:%s' % netmask
67+
print("Bcast:%s" % ethtool.get_broadcast(device))
68+
print(' Mask:%s' % netmask)
6969
for info in ethtool.get_interfaces_info(device):
7070
for addr in info.get_ipv6_addresses():
71-
print (" inet6 addr: %s/%s Scope: %s"
71+
print(" inet6 addr: %s/%s Scope: %s"
7272
% (addr.address,
7373
addr.netmask,
7474
addr.scope))
75-
print ' %s' % flags2str(flags)
75+
print(' %s' % flags2str(flags))
7676
print
7777

7878
def main():
@@ -90,8 +90,8 @@ def main():
9090
for device in sel_devs:
9191
try:
9292
show_config(device)
93-
except Exception, ex:
94-
print "** ERROR ** [Device %s]: %s" % (device, str(ex))
93+
except Exception as ex:
94+
print("** ERROR ** [Device %s]: %s" % (device, str(ex)))
9595
sys.exit(2)
9696

9797
if __name__ == '__main__':

0 commit comments

Comments
 (0)