updated caught exceptions to be 2/3 compliant

This commit is contained in:
bharnden 2019-05-05 16:58:08 -07:00
parent b42b5b1a5a
commit 5b7453b906
3 changed files with 6 additions and 6 deletions

View file

@ -150,7 +150,7 @@ def main():
switch = session.create_node(cls=core.nodes.network.SwitchNode)
switchlist.append(switch)
print("\nAdded bridge %s (%d) for node %d." % (switch.brname, len(switchlist), i))
except Exception, e:
except Exception as e:
print("At %d bridges (%d nodes) caught exception:\n%s\n" % (len(switchlist), i - 1, e))
break
@ -177,7 +177,7 @@ def main():
sys.stdout.write(".")
sys.stdout.flush()
time.sleep(options.waittime)
except Exception, e:
except Exception as e:
print("At %d nodes caught exception:\n" % i, e)
if retry_count > 0:
print("\nWill retry creating node %d." % i)

View file

@ -129,7 +129,7 @@ class Route(object):
def __init__(self, prefix=None, gw=None, metric=None):
try:
self.prefix = ipaddress.Ipv4Prefix(prefix)
except Exception, e:
except Exception as e:
raise ValueError("Invalid prefix given to Route object: %s\n%s" % (prefix, e))
self.gw = gw
self.metric = metric

View file

@ -49,11 +49,11 @@ from core.nodes import ipaddress
try:
import emaneeventservice
import emaneeventpathloss
except Exception, e:
except Exception as e:
try:
from emanesh.events import EventService
from emanesh.events import PathlossEvent
except Exception, e2:
except Exception as e2:
raise ImportError("failed to import EMANE Python bindings:\n%s\n%s" % (e, e2))
# global Experiment object (for interaction with "python -i")
@ -256,7 +256,7 @@ class IperfCmd(ClientServerCmd):
lines = self.out.readlines()
try:
bps = int(lines[-1].split(",")[-1].strip("\n"))
except Exception, e:
except Exception as e:
self.warn("iperf parsing exception: %s" % e)
bps = 0
return bps