applied the except and raise fixers to the master branch to close the gap with py3
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 14 Oct 2015 12:40:40 +0000 (14:40 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 14 Oct 2015 12:40:40 +0000 (14:40 +0200)
should have done first off - will know better next time

81 files changed:
src/nepi/data/processing/ccn/parser.py
src/nepi/data/processing/ping/parser.py
src/nepi/execution/resource.py
src/nepi/execution/runner.py
src/nepi/resources/all/collector.py
src/nepi/resources/linux/application.py
src/nepi/resources/linux/ccn/ccncontent.py
src/nepi/resources/linux/ccn/ccnd.py
src/nepi/resources/linux/ccn/ccnr.py
src/nepi/resources/linux/ccn/fibentry.py
src/nepi/resources/linux/gretunnel.py
src/nepi/resources/linux/interface.py
src/nepi/resources/linux/mtr.py
src/nepi/resources/linux/netns/netnsemulation.py
src/nepi/resources/linux/node.py
src/nepi/resources/linux/ns3/fdudptunnel.py
src/nepi/resources/linux/ns3/ns3simulation.py
src/nepi/resources/linux/ns3/tuntapfdlink.py
src/nepi/resources/linux/ping.py
src/nepi/resources/linux/route.py
src/nepi/resources/linux/scripts/linux-tap-create.py
src/nepi/resources/linux/scripts/tunchannel.py
src/nepi/resources/linux/tap.py
src/nepi/resources/linux/traceroute.py
src/nepi/resources/linux/tunnel.py
src/nepi/resources/linux/udptest.py
src/nepi/resources/netns/netnsapplication.py
src/nepi/resources/netns/netnsbase.py
src/nepi/resources/netns/netnsipv4address.py
src/nepi/resources/netns/netnsnode.py
src/nepi/resources/netns/netnsnodeinterface.py
src/nepi/resources/netns/netnsroute.py
src/nepi/resources/netns/netnsserver.py
src/nepi/resources/netns/netnsswitch.py
src/nepi/resources/ns3/ns3application.py
src/nepi/resources/ns3/ns3arpl3protocol.py
src/nepi/resources/ns3/ns3base.py
src/nepi/resources/ns3/ns3channel.py
src/nepi/resources/ns3/ns3errormodel.py
src/nepi/resources/ns3/ns3errorratemodel.py
src/nepi/resources/ns3/ns3fdnetdevice.py
src/nepi/resources/ns3/ns3icmpv4l4protocol.py
src/nepi/resources/ns3/ns3ipv4l3protocol.py
src/nepi/resources/ns3/ns3netdevice.py
src/nepi/resources/ns3/ns3node.py
src/nepi/resources/ns3/ns3pipechanel.py
src/nepi/resources/ns3/ns3propagationdelaymodel.py
src/nepi/resources/ns3/ns3propagationlossmodel.py
src/nepi/resources/ns3/ns3queue.py
src/nepi/resources/ns3/ns3route.py
src/nepi/resources/ns3/ns3server.py
src/nepi/resources/ns3/ns3wifichannel.py
src/nepi/resources/ns3/ns3wifimac.py
src/nepi/resources/ns3/ns3wifiphy.py
src/nepi/resources/ns3/ns3wifiremotestationmanager.py
src/nepi/resources/omf/application.py
src/nepi/resources/omf/channel.py
src/nepi/resources/omf/interface.py
src/nepi/resources/omf/node.py
src/nepi/resources/omf/omf6_api.py
src/nepi/resources/omf/wilabt_node.py
src/nepi/resources/planetlab/node.py
src/nepi/resources/planetlab/ns3/fdudptunnel.py
src/nepi/resources/planetlab/ns3/tuntapfdlink.py
src/nepi/resources/planetlab/openvswitch/ovs.py
src/nepi/resources/planetlab/openvswitch/ovsport.py
src/nepi/resources/planetlab/plcapi.py
src/nepi/resources/planetlab/scripts/pl-vif-create.py
src/nepi/resources/planetlab/sfa_node.py
src/nepi/resources/planetlab/tap.py
src/nepi/resources/planetlab/vroute.py
src/nepi/util/environ.py
src/nepi/util/execfuncs.py
src/nepi/util/manifoldapi.py
src/nepi/util/netgraph.py
src/nepi/util/parallel.py
src/nepi/util/sfarspec_proc.py
src/nepi/util/sshfuncs.py
test/execution/ec.py
test/execution/resource.py
test/util/sshfuncs.py

index 676a205..cd89549 100644 (file)
@@ -239,7 +239,7 @@ def annotate_cn_graph(logs_dir, graph, parse_ping_logs = False):
 
     if not found_files:
         msg = "No CCND output files were found to parse at %s " % logs_dir
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
 
     if parse_ping_logs:
         ping_parser.annotate_cn_graph(logs_dir, graph)
index b51f37f..d531118 100644 (file)
@@ -106,7 +106,7 @@ def annotate_cn_graph(logs_dir, graph):
 
     if not found_files:
         msg = "No PING output files were found to parse at %s " % logs_dir 
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
 
     # Take as weight the most frequent value
     for nid1, nid2 in graph.edges():
index 89a395d..525b8fd 100644 (file)
@@ -838,7 +838,7 @@ class ResourceManager(Logger):
                 if not rm.get('critical'):
                     continue
                 msg = "Resource can not wait for FAILED RM %d. Setting Resource to FAILED"
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
             # If the RM state is lower than the requested state we must
             # reschedule (e.g. if RM is READY but we required STARTED).
index 0ab8731..dd2f7da 100644 (file)
@@ -89,7 +89,7 @@ class ExperimentRunner(object):
 
         if (not max_runs or max_runs < 0) and not compute_metric_callback:
             msg = "Undefined STOP condition, set stop_callback or max_runs"
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         if compute_metric_callback and not evaluate_convergence_callback:
             evaluate_convergence_callback = self.evaluate_normal_convergence
@@ -138,7 +138,7 @@ class ExperimentRunner(object):
 
         if len(metrics) == 0:
             msg = "0 samples collected"
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         x = numpy.array(metrics)
         n = len(metrics)
@@ -170,7 +170,7 @@ class ExperimentRunner(object):
         ec.release()
 
         if ec.state == ECState.FAILED:
-            raise RuntimeError, "Experiment failed"
+            raise RuntimeError("Experiment failed")
 
         return ec
 
index 3573a03..4729e01 100644 (file)
@@ -77,7 +77,7 @@ class Collector(ResourceManager):
             
             msg = "No traceName was specified"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         self._store_path = self.ec.run_dir
 
index 7f7fbca..1574f63 100644 (file)
@@ -200,7 +200,7 @@ class LinuxApplication(ResourceManager):
             if not node: 
                 msg = "Application %s guid %d NOT connected to Node" % (
                         self._rtype, self.guid)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
             self._node = node[0]
 
@@ -573,7 +573,7 @@ class LinuxApplication(ResourceManager):
 
         if self._proc.poll():
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
     def _run_in_background(self):
         command = self.get("command")
@@ -602,7 +602,7 @@ class LinuxApplication(ResourceManager):
         
         if proc.poll():
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
     
         # Wait for pid file to be generated
         pid, ppid = self.node.wait_pid(self.run_home)
@@ -619,7 +619,7 @@ class LinuxApplication(ResourceManager):
             if err:
                 msg = " Failed to start command '%s' " % command
                 self.error(msg, out, err)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
     
     def do_stop(self):
         """ Stops application execution
index 6a32e1e..da8c2ab 100644 (file)
@@ -117,7 +117,7 @@ class LinuxCCNContent(LinuxApplication):
         if proc.poll():
             msg = "Failed to execute command"
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
     def do_start(self):
         if self.state == ResourceState.READY:
@@ -128,7 +128,7 @@ class LinuxCCNContent(LinuxApplication):
         else:
             msg = " Failed to execute command '%s'" % command
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
     @property
     def _start_command(self):
index b930cb7..48ce86f 100644 (file)
@@ -204,7 +204,7 @@ class LinuxCCND(LinuxApplication):
         else:
             msg = " Failed to execute command '%s'" % command
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
     def do_stop(self):
         command = self.get('command') or ''
index a9b9836..53e4ccd 100644 (file)
@@ -257,7 +257,7 @@ class LinuxCCNR(LinuxApplication):
         else:
             msg = " Failed to execute command '%s'" % command
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
     @property
     def _start_command(self):
index 24b729d..8712708 100644 (file)
@@ -181,7 +181,7 @@ class LinuxFIBEntry(LinuxApplication):
         if proc.poll():
             msg = "Failed to execute command"
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
         
     def configure(self):
         if self.trace_enabled("ping") and not self.ping:
@@ -216,7 +216,7 @@ class LinuxFIBEntry(LinuxApplication):
         else:
             msg = " Failed to execute command '%s'" % command
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
     def do_stop(self):
         command = self.get('command')
@@ -234,7 +234,7 @@ class LinuxFIBEntry(LinuxApplication):
             if err:
                 msg = " Failed to execute command '%s'" % command
                 self.error(msg, out, err)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
     @property
     def _start_command(self):
index 6ca021b..f422a63 100644 (file)
@@ -72,7 +72,7 @@ class LinuxGRETunnel(LinuxTunnel):
         if not m or int(m.groups()[0]) == 100:
              msg = " Error establishing GRE Tunnel"
              self.error(msg, out, err)
-             raise RuntimeError, msg
+             raise RuntimeError(msg)
 
     def terminate_connection(self, endpoint, remote_endpoint):
         pass
index 7e3d25e..04d7959 100644 (file)
@@ -117,7 +117,7 @@ class LinuxInterface(ResourceManager):
         if err and proc.poll():
             msg = " Error retrieving interface information "
             self.error(msg, out, err)
-            raise RuntimeError, "%s - %s - %s" % (msg, out, err)
+            raise RuntimeError("%s - %s - %s" % (msg, out, err))
         
         # Check if an interface is found matching the RM attributes
         ifaces = out.split("\n\n")
@@ -179,7 +179,7 @@ class LinuxInterface(ResourceManager):
         if not self.get("deviceName"):
             msg = "Unable to resolve interface "
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         super(LinuxInterface, self).do_discover()
 
@@ -209,7 +209,7 @@ class LinuxInterface(ResourceManager):
             if err and proc.poll():
                 msg = "Error configuring interface with command '%s'" % cmd
                 self.error(msg, out, err)
-                raise RuntimeError, "%s - %s - %s" % (msg, out, err)
+                raise RuntimeError("%s - %s - %s" % (msg, out, err))
 
             if ip6 and mask6:
                 cmd = "ifconfig %(devname)s inet6 add %(ip6)s/%(mask6)d" % ({
@@ -222,7 +222,7 @@ class LinuxInterface(ResourceManager):
             if err and proc.poll():
                 msg = "Error seting ipv6 for interface using command '%s' " % cmd
                 self.error(msg, out, err)
-                raise RuntimeError, "%s - %s - %s" % (msg, out, err)
+                raise RuntimeError("%s - %s - %s" % (msg, out, err))
 
         super(LinuxInterface, self).do_provision()
 
index c5895fc..6327128 100644 (file)
@@ -117,7 +117,7 @@ class LinuxMtr(LinuxApplication):
             else:
                 msg = " Failed to execute command '%s'" % command
                 self.error(msg, out, err)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
         else:
            super(LinuxMtr, self).do_start()
 
index ede07eb..904be9f 100644 (file)
@@ -184,7 +184,7 @@ class LinuxNetNSEmulation(LinuxApplication, NetNSEmulation):
         else:
             msg = " Failed to execute command '%s'" % command
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
     def do_stop(self):
         """ Stops simulation execution
index df3030b..ee7e2e1 100644 (file)
@@ -297,7 +297,7 @@ class LinuxNode(ResourceManager):
         if not self.localhost and not self.get("username"):
             msg = "Can't resolve OS, insufficient data "
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         out = self.get_os()
 
@@ -355,7 +355,7 @@ class LinuxNode(ResourceManager):
             trace = traceback.format_exc()
             msg = "Deploy failed. Unresponsive node {} -- traceback {}".format(self.get("hostname"), trace)
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         self.find_home()
 
@@ -797,7 +797,7 @@ class LinuxNode(ResourceManager):
             
             msg = "{} out: {} err: {}".format(msg, out, err)
             if raise_on_error:
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
         return ((out, err), proc)
 
@@ -813,7 +813,7 @@ class LinuxNode(ResourceManager):
             self.error(msg, out, err)
 
             if raise_on_error:
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
         return ((out, err), proc)
 
@@ -826,7 +826,7 @@ class LinuxNode(ResourceManager):
         else:
             msg = "Error installing packages ( OS not known ) "
             self.error(msg, self.os)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return command
 
@@ -867,7 +867,7 @@ class LinuxNode(ResourceManager):
         else:
             msg = "Error removing packages ( OS not known ) "
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         run_home = run_home or home
 
@@ -951,7 +951,7 @@ class LinuxNode(ResourceManager):
             msg = " Failed to run command '{}' ".format(command)
             self.error(msg, out, err)
             if raise_on_error:
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
         # Wait for pid file to be generated
         pid, ppid = self.wait_pid(
@@ -973,7 +973,7 @@ class LinuxNode(ResourceManager):
                 self.error(msg, eout, err)
 
                 if raise_on_error:
-                    raise RuntimeError, msg
+                    raise RuntimeError(msg)
 
         (out, oerr), proc = self.check_output(home, stdout)
         
@@ -1088,7 +1088,7 @@ class LinuxNode(ResourceManager):
             self.error(msg)
     
             if raise_on_error:
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
         return pid, ppid
 
@@ -1167,7 +1167,7 @@ class LinuxNode(ResourceManager):
 
         if not self._home_dir:
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
     def filter_existing_files(self, src, dst):
         """ Removes files that already exist in the Linux host from src list
index 16816ef..5e766f1 100644 (file)
@@ -93,7 +93,7 @@ class LinuxNs3FdUdpTunnel(LinuxUdpTunnel):
             if not devices or len(devices) != 2: 
                 msg = "linux::ns3::TunTapFdLink must be connected to exactly one FdNetDevice"
                 self.error(msg)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
             self._fd1 = devices[0]
             self._fd2 = devices[1]
@@ -112,7 +112,7 @@ class LinuxNs3FdUdpTunnel(LinuxUdpTunnel):
                     self._fd2node.get("hostname"):
                 msg = "linux::ns3::FdUdpTunnel requires endpoints on different hosts"
                 self.error(msg)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
         return [self._fd1, self._fd2]
 
@@ -275,7 +275,7 @@ class LinuxNs3FdUdpTunnel(LinuxUdpTunnel):
         else:
             msg = "Couldn't retrieve %s" % filename
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return result
 
@@ -304,7 +304,7 @@ class LinuxNs3FdUdpTunnel(LinuxUdpTunnel):
         
         if proc.poll():
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
     
         # Wait for pid file to be generated
         pid, ppid = node.wait_pid(run_home)
@@ -317,7 +317,7 @@ class LinuxNs3FdUdpTunnel(LinuxUdpTunnel):
         if err:
             msg = " Failed to start command '%s' " % command
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         port = self.wait_local_port(endpoint)
 
index f6be975..0a44d7a 100644 (file)
@@ -311,7 +311,7 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation):
         else:
             msg = " Failed to execute command '%s'" % command
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
     def do_stop(self):
         """ Stops simulation execution
index be6f982..3fac31f 100644 (file)
@@ -46,7 +46,7 @@ class LinuxTunTapFdLink(LinuxApplication):
             if not devices or len(devices) != 1: 
                 msg = "TunTapFdLink must be connected to exactly one FdNetDevice"
                 self.error(msg)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
             self._fdnetdevice = devices[0]
         
@@ -69,7 +69,7 @@ class LinuxTunTapFdLink(LinuxApplication):
             if not devices or len(devices) != 1: 
                 msg = "TunTapLink must be connected to exactly one Tap or Tun"
                 self.error(msg)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
             self._tap = devices[0]
         
@@ -106,7 +106,7 @@ class LinuxTunTapFdLink(LinuxApplication):
                 self.fdnode.get("hostname"):
             msg = "Tap and FdNetDevice are not in the same host"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         self.send_address = self.fdnetdevice.recv_fd()
         self.set("command", self._start_command)
@@ -139,7 +139,7 @@ class LinuxTunTapFdLink(LinuxApplication):
         else:
             msg = " Failed to execute command '%s'" % command
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
     @property
     def _start_command(self):
index c660e8e..f585b2e 100644 (file)
@@ -212,7 +212,7 @@ class LinuxPing(LinuxApplication):
             else:
                 msg = " Failed to execute command '%s'" % command
                 self.error(msg, out, err)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
         else:
            super(LinuxPing, self).do_start()
 
index 7c6d292..28f6160 100644 (file)
@@ -55,8 +55,8 @@ class LinuxRoute(LinuxApplication):
             elif tun: self._device = tun[0]
             elif interface: self._device = interface[0]
             else:
-                raise RuntimeError"linux::Routes must be connected to a "\
-                        "linux::TAP, linux::TUN, or linux::Interface"
+                raise RuntimeError("linux::Routes must be connected to a "\
+                        "linux::TAP, linux::TUN, or linux::Interface")
         return self._device
 
     @property
@@ -108,7 +108,7 @@ class LinuxRoute(LinuxApplication):
         else:
             msg = " Failed to execute command '%s'" % command
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
     def do_stop(self):
         command = self.get('command') or ''
index 5792e7d..256aff6 100644 (file)
@@ -57,7 +57,7 @@ def recv_msg(conn):
     while '\n' not in chunk:
         try:
             chunk = conn.recv(1024)
-        except (OSError, socket.error), e:
+        except (OSError, socket.error) as e:
             if e[0] != errno.EINTR:
                 raise
             # Ignore eintr errors
@@ -227,7 +227,7 @@ if __name__ == '__main__':
         while not stop:
             try:
                 (msg, args) = recv_msg(conn)
-            except socket.timeout, e:
+            except socket.timeout as e:
                 # Ingore time-out
                 continue
 
index 170bf9d..8a3047c 100644 (file)
@@ -202,7 +202,7 @@ def decrypt(packet, crypter, ord=ord):
         padding = ord(packet[-1])
         if not (0 < padding <= crypter.block_size):
             # wrong padding
-            raise RuntimeError, "Truncated packet %s"
+            raise RuntimeError("Truncated packet %s")
         packet = packet[:-padding]
     
     return packet
@@ -404,7 +404,7 @@ def tun_fwd(tun, remote, with_pi, ether_mode, cipher_key, udp, TERMINATE, SUSPEN
         
         try:
             rdrdy, wrdy, errs = select(rset,wset,eset,1)
-        except selecterror, e:
+        except selecterror as e:
             if e.args[0] == errno.EINTR:
                 # just retry
                 continue
@@ -460,7 +460,7 @@ def tun_fwd(tun, remote, with_pi, ether_mode, cipher_key, udp, TERMINATE, SUSPEN
                         
                         if not rnonblock or not fpacketReady(fwbuf):
                             break
-                except OSError,e:
+                except OSError as e:
                     # This except handles the entire While block on PURPOSE
                     # as an optimization (setting a try/except block is expensive)
                     # The only operation that can raise this exception is rwrite
@@ -500,7 +500,7 @@ def tun_fwd(tun, remote, with_pi, ether_mode, cipher_key, udp, TERMINATE, SUSPEN
                     if slowlocal:
                         # Give some time for the kernel to process the packets
                         time.sleep(0)
-            except OSError,e:
+            except OSError as e:
                 # This except handles the entire While block on PURPOSE
                 # as an optimization (setting a try/except block is expensive)
                 # The only operation that can raise this exception is os_write
@@ -522,7 +522,7 @@ def tun_fwd(tun, remote, with_pi, ether_mode, cipher_key, udp, TERMINATE, SUSPEN
                     
                     if not tnonblock or len(fwbuf) >= maxfwbuf:
                         break
-            except OSError,e:
+            except OSError as e:
                 # This except handles the entire While block on PURPOSE
                 # as an optimization (setting a try/except block is expensive)
                 # The only operation that can raise this exception is os_read
@@ -543,7 +543,7 @@ def tun_fwd(tun, remote, with_pi, ether_mode, cipher_key, udp, TERMINATE, SUSPEN
                         elif not packet:
                             if not udp and packet == "":
                                 # Connection broken, try to reconnect (or just die)
-                                raise RuntimeError, "Connection broken"
+                                raise RuntimeError("Connection broken")
                             else:
                                 continue
 
@@ -551,13 +551,13 @@ def tun_fwd(tun, remote, with_pi, ether_mode, cipher_key, udp, TERMINATE, SUSPEN
                         
                         if not rnonblock or len(bkbuf) >= maxbkbuf:
                             break
-                except OSError,e:
+                except OSError as e:
                     # This except handles the entire While block on PURPOSE
                     # as an optimization (setting a try/except block is expensive)
                     # The only operation that can raise this exception is rread
                     if e.errno not in retrycodes:
                         raise
-            except Exception, e:
+            except Exception as e:
                 if reconnect is not None:
                     # in UDP mode, sometimes connected sockets can return a connection refused
                     # on read. Give the caller a chance to reconnect
@@ -587,7 +587,7 @@ def udp_connect(TERMINATE, local_addr, local_port, peer_addr, peer_port):
         # TERMINATE is a array. An item can be added to TERMINATE, from
         # outside this function to force termination of the loop
         if TERMINATE:
-            raise OSError, "Killed"
+            raise OSError("Killed")
         try:
             rsock.bind((local_addr, local_port))
             break
@@ -620,7 +620,7 @@ def udp_handshake(TERMINATE, rsock):
     keepalive_thread.start()
     for i in xrange(900):
         if TERMINATE:
-            raise OSError, "Killed"
+            raise OSError("Killed")
         try:
             heartbeat = rsock.recv(10)
             break
@@ -648,7 +648,7 @@ def tcp_connect(TERMINATE, stop, rsock, peer_addr, peer_port):
         if stop:
             break
         if TERMINATE:
-            raise OSError, "Killed"
+            raise OSError("Killed")
         try:
             rsock.connect((peer_addr, peer_port))
             sock = rsock
@@ -678,7 +678,7 @@ def tcp_listen(TERMINATE, stop, lsock, local_addr, local_port):
         if stop:
             break
         if TERMINATE:
-            raise OSError, "Killed"
+            raise OSError("Killed")
         try:
             lsock.bind((local_addr, local_port))
             break
@@ -697,7 +697,7 @@ def tcp_listen(TERMINATE, stop, lsock, local_addr, local_port):
     lsock.listen(1)
     for i in xrange(30):
         if TERMINATE:
-            raise OSError, "Killed"
+            raise OSError("Killed")
         rlist, wlist, xlist = select.select([lsock], [], [], timeout)
         if stop:
             break
@@ -755,7 +755,7 @@ def tcp_establish(TERMINATE, local_addr, local_port, peer_addr, peer_port):
         if end:
             break
         if TERMINATE:
-            raise OSError, "Killed"
+            raise OSError("Killed")
         hand = struct.pack("!L", random.randint(0, 2**30))
         stop = []
         lresult = []
@@ -786,5 +786,5 @@ def tcp_establish(TERMINATE, local_addr, local_port, peer_addr, peer_port):
                 end = True
 
     if not sock:
-        raise OSError, "Error: tcp_establish could not establish connection."
+        raise OSError("Error: tcp_establish could not establish connection.")
     return sock
index 9aba916..ac11eb0 100644 (file)
@@ -107,7 +107,7 @@ class LinuxTap(LinuxApplication):
     def node(self):
         node = self.get_connected(LinuxNode.get_rtype())
         if node: return node[0]
-        raise RuntimeError, "linux::TAP/TUN devices must be connected to a linux::Node"
+        raise RuntimeError("linux::TAP/TUN devices must be connected to a linux::Node")
 
     @property
     def gre_enabled(self):
@@ -243,7 +243,7 @@ class LinuxTap(LinuxApplication):
         else:
             msg = " Failed to execute command '%s'" % command
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
     def do_stop(self):
         command = self.get('command') or ''
@@ -315,7 +315,7 @@ class LinuxTap(LinuxApplication):
         
         if proc.poll() or err:
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
     
         # Wait for pid file to be generated
         pid, ppid = self.node.wait_pid(connection_run_home, 
@@ -331,7 +331,7 @@ class LinuxTap(LinuxApplication):
             if err:
                 msg = " Failed to start command '%s' " % command
                 self.error(msg, out, err)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
         
         return True
 
@@ -366,7 +366,7 @@ class LinuxTap(LinuxApplication):
         
         if proc.poll():
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
     
         # Wait for pid file to be generated
         self._pid, self._ppid = self.node.wait_pid(
@@ -384,7 +384,7 @@ class LinuxTap(LinuxApplication):
             if err:
                 msg = " Failed to start command '%s' " % command
                 self.error(msg, out, err)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
         return self.wait_file(connection_run_home, "local_port")
 
@@ -412,7 +412,7 @@ class LinuxTap(LinuxApplication):
             if proc.poll() and err:
                 msg = " Failed to Kill the Tap"
                 self.error(msg, out, err)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
     def check_status(self):
         return self.node.status(self._pid, self._ppid)
@@ -433,7 +433,7 @@ class LinuxTap(LinuxApplication):
         else:
             msg = "Couldn't retrieve %s" % filename
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return result
 
index 595fa01..b9cdf99 100644 (file)
@@ -95,7 +95,7 @@ class LinuxTraceroute(LinuxApplication):
             else:
                 msg = " Failed to execute command '%s'" % command
                 self.error(msg, out, err)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
         else:
            super(LinuxTraceroute, self).do_start()
 
index 1566654..1bb587d 100644 (file)
@@ -129,7 +129,7 @@ class LinuxTunnel(LinuxApplication):
         else:
             msg = " Failed to execute command '%s'" % command
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
     def do_stop(self):
         """ Stops application execution
index 2e86470..4ef2b2b 100644 (file)
@@ -254,7 +254,7 @@ class LinuxUdpTest(LinuxApplication):
             else:
                 msg = " Failed to execute command '%s'" % command
                 self.error(msg, out, err)
-                raise RuntimeError, err
+                raise RuntimeError(err)
         else:
             super(LinuxUdpTest, self).do_start()
  
index 691ee32..68d64ef 100644 (file)
@@ -47,7 +47,7 @@ class NetNSApplication(NetNSBase):
         if not node: 
             msg = "Route not connected to Node!!"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return node[0]
 
index dcf27cb..3fee62e 100644 (file)
@@ -57,7 +57,7 @@ class NetNSBase(ResourceManager):
         objects to be deployed before proceeding with the deployment
 
         """
-        raise RuntimeError, "No dependencies defined!"
+        raise RuntimeError("No dependencies defined!")
 
     def _instantiate_object(self):
         pass
@@ -99,7 +99,7 @@ class NetNSBase(ResourceManager):
         else:
             msg = " Failed "
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
     def do_stop(self):
         if self.state == ResourceState.STARTED:
index d59a6fd..353e4a7 100644 (file)
@@ -48,7 +48,7 @@ class NetNSIPv4Address(NetNSBase):
         if not interface: 
             msg = "IPv4Address not connected to Interface!!"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return interface[0]
 
index a0748c2..cb0e0ad 100644 (file)
@@ -35,7 +35,7 @@ class NetNSNode(NetNSBase):
 
         msg = "Node not connected to Emulation"
         self.error(msg)
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
  
     @property
     def _rms_to_wait(self):
index ab627fc..4c2795b 100644 (file)
@@ -44,7 +44,7 @@ class NetNSNodeInterface(NetNSInterface):
         if not node: 
             msg = "Route not connected to Node!!"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return node[0]
 
index 147d012..d304fa0 100644 (file)
@@ -46,7 +46,7 @@ class NetNSIPv4Route(NetNSBase):
         if not node: 
             msg = "Route not connected to Node!!"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return node[0]
 
index a7ddb4d..224a603 100644 (file)
@@ -89,7 +89,7 @@ def recv_msg(conn):
     while '\n' not in chunk:
         try:
             chunk = conn.recv(1024)
-        except (OSError, socket.error), e:
+        except (OSError, socket.error) as e:
             if e[0] != errno.EINTR:
                 raise
             # Ignore eintr errors
@@ -175,7 +175,7 @@ def run_server(socket_name, level = logging.INFO,
 
         try:
             (msg_type, args, kwargs) = recv_msg(conn)
-        except socket.timeout, e:
+        except socket.timeout as e:
             # Ingore time-out
             continue
 
index 90b981c..1387f61 100644 (file)
@@ -48,7 +48,7 @@ class NetNSSwitch(NetNSBase):
         if not interface: 
             msg = "Switch not connected to any Interface!!"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return interface[0]
 
index aa17028..681e1a1 100644 (file)
@@ -36,7 +36,7 @@ class NS3BaseApplication(NS3Base):
             if not nodes: 
                 msg = "Application not connected to node"
                 self.error(msg)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
             self._node = nodes[0]
 
index be086de..708b37c 100644 (file)
@@ -31,7 +31,7 @@ class NS3BaseArpL3Protocol(NS3Base):
         if not nodes: 
             msg = "ArpL3Protocol not connected to node"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return nodes[0]
 
index 714f40f..26632e0 100644 (file)
@@ -132,7 +132,7 @@ class NS3Base(ResourceManager):
         else:
             msg = "Failed"
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
     def do_stop(self):
         if self.state == ResourceState.STARTED:
index 70b03fc..b218e51 100644 (file)
@@ -35,7 +35,7 @@ class NS3BaseChannel(NS3Base):
         if not devices: 
             msg = "Channel not connected to devices"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return devices
 
index b9ef4dc..7068158 100644 (file)
@@ -31,7 +31,7 @@ class NS3BaseErrorModel(NS3Base):
         if not devices: 
             msg = "ErrorModel not connected to device"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return devices[0]
 
index 80bc43e..c7182d0 100644 (file)
@@ -35,7 +35,7 @@ class NS3BaseErrorRateModel(NS3Base):
         if not phys: 
             msg = "ErrorRateModel not connected to phy"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return phys[0]
 
index 4473980..8ba29df 100644 (file)
@@ -48,7 +48,7 @@ class NS3BaseFdNetDevice(NS3BaseNetDevice):
         if mode != "ns3::RealtimeSimulatorImpl":
             msg = "The simulation must run in real time!!"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
         
         super(NS3BaseFdNetDevice, self)._instantiate_object()
 
index f653e9c..ae39a5e 100644 (file)
@@ -31,7 +31,7 @@ class NS3BaseIcmpv4L4Protocol(NS3Base):
         if not nodes: 
             msg = "Icmp4L4Protocol not connected to node"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return nodes[0]
 
index 11a85ea..c82e9a1 100644 (file)
@@ -37,7 +37,7 @@ class NS3BaseIpv4L3Protocol(NS3Base):
         if not nodes: 
             msg = "Ipv4L3Protocol not connected to node"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return nodes[0]
 
index 3d74a72..946f01a 100644 (file)
@@ -65,7 +65,7 @@ class NS3BaseNetDevice(NS3Base):
         if not nodes: 
             msg = "Device not connected to node"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return nodes[0]
 
@@ -77,7 +77,7 @@ class NS3BaseNetDevice(NS3Base):
         if not channels: 
             msg = "Device not connected to channel"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return channels[0]
 
@@ -89,7 +89,7 @@ class NS3BaseNetDevice(NS3Base):
         if not queue: 
             msg = "Device not connected to queue"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return queue[0]
 
index c158728..ca63c3c 100644 (file)
@@ -57,7 +57,7 @@ class NS3BaseNode(NS3Base):
             if not self._simulation:
                 msg = "Node not connected to simulation"
                 self.error(msg)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
         return self._simulation
          
@@ -100,7 +100,7 @@ class NS3BaseNode(NS3Base):
             if not devices: 
                 msg = "Node not connected to devices"
                 self.error(msg)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
             self._devices = devices
 
index 2a85e69..40b3ab5 100644 (file)
@@ -40,7 +40,7 @@ class NS3BasePipeChannel(NS3Base):
             if not devices or len(devices) != 2: 
                 msg = "PipeChannel must be connected to exactly to two FdNetDevices"
                 self.error(msg)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
             self._devices = devices
         
index 240094e..9f61915 100644 (file)
@@ -35,7 +35,7 @@ class NS3BasePropagationDelayModel(NS3Base):
         if not channels: 
             msg = "PropagationDelayModel not connected to channel"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return channels[0]
 
index f723e9c..9c6c3c7 100644 (file)
@@ -35,7 +35,7 @@ class NS3BasePropagationLossModel(NS3Base):
         if not channels: 
             msg = "PropagationLossModel not connected to channel"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return channels[0]
 
index c7edad2..1341e96 100644 (file)
@@ -31,7 +31,7 @@ class NS3BaseQueue(NS3Base):
         if not devices: 
             msg = "Queue not connected to device"
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return devices[0]
 
index db2c147..15d4005 100644 (file)
@@ -53,7 +53,7 @@ class NS3Route(NS3Base):
         if not nodes: 
             msg = "Device not connected to node"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return nodes[0]
 
@@ -83,7 +83,7 @@ class NS3Route(NS3Base):
             msg = "Could not configure route %s/%s hop: %s" % (network, prefix, 
                     nexthop)
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
     def _connect_object(self):
         node = self.node
index e8a6f7d..8b3cd79 100644 (file)
@@ -115,7 +115,7 @@ def recv_msg(conn):
     while '\n' not in chunk:
         try:
             chunk = conn.recv(1024)
-        except (OSError, socket.error), e:
+        except (OSError, socket.error) as e:
             if e[0] != errno.EINTR:
                 raise
             # Ignore eintr errors
@@ -206,7 +206,7 @@ def run_server(socket_name, level = logging.INFO, ns_log = None,
 
         try:
             (msg_type, args, kwargs) = recv_msg(conn)
-        except socket.timeout, e:
+        except socket.timeout as e:
             # Ingore time-out
             close_socket(conn)
             continue
index 2645a5d..8bce654 100644 (file)
@@ -35,7 +35,7 @@ class NS3BaseWifiChannel(NS3Base):
         if not phys: 
             msg = "Channel not connected to phy"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return phys
 
index 373b7e0..7b48830 100644 (file)
@@ -47,7 +47,7 @@ class NS3BaseWifiMac(NS3Base):
         if not devices: 
             msg = "WifiMac not connected to device"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return devices[0]
 
index 22513aa..331c944 100644 (file)
@@ -47,7 +47,7 @@ class NS3BaseWifiPhy(NS3Base):
         if not devices: 
             msg = "WifiPhy not connected to device"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return devices[0]
 
@@ -59,7 +59,7 @@ class NS3BaseWifiPhy(NS3Base):
         if not channels: 
             msg = "WifiPhy not connected to channel"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return channels[0]
 
index bdbe98a..94cfd2a 100644 (file)
@@ -36,7 +36,7 @@ class NS3BaseWifiRemoteStationManager(NS3Base):
         if not devices: 
             msg = "WifiRemoteStationManager not connected to device"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return devices[0]
 
index 8afb7c1..03db088 100644 (file)
@@ -202,7 +202,7 @@ class OMFApplication(OMFResource):
         if not self.get('xmppServer'):
             msg = "XmppServer is not initialzed. XMPP Connections impossible"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         if not (self.get('xmppUser') or self.get('xmppPort') 
                    or self.get('xmppPassword')):
@@ -212,7 +212,7 @@ class OMFApplication(OMFResource):
         if not self.get('command') :
             msg = "Application's Command is not initialized"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         if not self._omf_api :
             self._omf_api = OMFAPIFactory.get_api(self.get('version'), 
@@ -244,7 +244,7 @@ class OMFApplication(OMFResource):
             if self._create_cnt > confirmation_counter:
                 msg = "Couldn't retrieve the confirmation of the creation"
                 self.error(msg)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
             uid = self.check_deploy(self.create_id)
             if not uid:
@@ -331,7 +331,7 @@ class OMFApplication(OMFResource):
             if self._start_cnt > confirmation_counter:
                 msg = "Couldn't retrieve the confirmation that the application started"
                 self.error(msg)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
             res = self.check_start(self._topic_app)
             if not res:
index 1c14304..bac1119 100644 (file)
@@ -153,7 +153,7 @@ class OMFChannel(OMFResource):
         if not self.get('channel'):
             msg = "Channel's value is not initialized"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         if self.get('version') == "6":
             self.frequency = self.get_frequency(self.get('channel'))
@@ -163,7 +163,7 @@ class OMFChannel(OMFResource):
         if not self.get('xmppServer'):
             msg = "XmppServer is not initialzed. XMPP Connections impossible"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         if not (self.get('xmppUser') or self.get('xmppPort') 
                    or self.get('xmppPassword')):
index aa4d5bc..e776785 100644 (file)
@@ -228,7 +228,7 @@ class OMFWifiInterface(OMFResource):
         if not self.get('xmppServer'):
             msg = "XmppServer is not initialzed. XMPP Connections impossible"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         if not (self.get('xmppUser') or self.get('xmppPort') 
                    or self.get('xmppPassword')):
@@ -243,13 +243,13 @@ class OMFWifiInterface(OMFResource):
         if not (self.get('name')):
             msg = "Interface's name is not initialized"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         if not (self.get('mode') and self.get('essid') \
                  and self.get('hw_mode') and self.get('ip')):
             msg = "Interface's variable are not initialized"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         if self.get('version') == "5":
             res = self.configure_on_omf5()        
@@ -285,7 +285,7 @@ class OMFWifiInterface(OMFResource):
         if self._create_cnt > confirmation_counter:
             msg = "Couldn't retrieve the confirmation of the creation"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         uid = self.check_deploy(self.create_id)
         if not uid:
index d51725e..b898f7e 100644 (file)
@@ -112,12 +112,12 @@ class OMFNode(OMFResource):
         if not self.get('xmppServer'):
             msg = "XmppServer is not initialzed. XMPP Connections impossible"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         if not self.get('version'):
             msg = "Version of OMF is not indicated"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         if not (self.get('xmppUser') or self.get('xmppPort') 
                    or self.get('xmppPassword')):
@@ -132,7 +132,7 @@ class OMFNode(OMFResource):
         if not self.get('hostname') :
             msg = "Hostname's value is not initialized"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         if self.get('version') == "5":
             self._omf_api.enroll_host(self.get('hostname'))
index 35aa219..3401c32 100644 (file)
@@ -123,7 +123,7 @@ class OMF6API(Logger):
         else:
             msg = "XMPP Client is not ready after long time"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
     @property
     def _nepi_topic(self):
index 41d4664..f9b118f 100644 (file)
@@ -444,23 +444,23 @@ class WilabtSfaNode(OMFNode):
     def fail_discovery(self):
         msg = "Discovery failed. No candidates found for node"
         self.error(msg)
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
 
     def fail_node_not_alive(self, host=None):
         msg = "Node %s not alive" % host
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
     
     def fail_node_not_available(self, host):
         msg = "Some nodes not available for provisioning"
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
 
     def fail_not_enough_nodes(self):
         msg = "Not enough nodes available for provisioning"
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
 
     def fail_sfaapi(self):
         msg = "Failing while trying to instanciate the SFA API."
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
 
     def valid_connection(self, guid):
         # TODO: Validate!
index 9ef4a19..c6f7bde 100644 (file)
@@ -661,24 +661,24 @@ class PlanetlabNode(LinuxNode):
     def fail_discovery(self):
         msg = "Discovery failed. No candidates found for node"
         self.error(msg)
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
 
     def fail_node_not_alive(self, hostname=None):
         msg = "Node %s not alive" % hostname
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
     
     def fail_node_not_available(self, hostname):
         msg = "Node %s not available for provisioning" % hostname
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
 
     def fail_not_enough_nodes(self):
         msg = "Not enough nodes available for provisioning"
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
 
     def fail_plapi(self):
         msg = "Failing while trying to instanciate the PLC API.\nSet the" + \
             " attributes pluser and plpassword."
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
 
     def valid_connection(self, guid):
         # TODO: Validate!
index 173049c..3b9abae 100644 (file)
@@ -43,7 +43,7 @@ class PlanetlabNs3FdUdpTunnel(LinuxNs3FdUdpTunnel):
             if not devices or len(devices) != 2: 
                 msg = "Tunnel must be connected to exactly two FdNetDevices"
                 self.error(msg)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
             self._fd1 = devices[0]
             self._fd2 = devices[1]
@@ -67,7 +67,7 @@ class PlanetlabNs3FdUdpTunnel(LinuxNs3FdUdpTunnel):
                     self._fd2node.get("hostname"):
                 msg = "Tunnel requires endpoints on different hosts"
                 self.error(msg)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
         return [self._fd1, self._fd2]
 
index 6909571..510a595 100644 (file)
@@ -42,7 +42,7 @@ class PlanetlabTunTapFdLink(LinuxTunTapFdLink):
             if not devices or len(devices) != 1: 
                 msg = "planetlab::ns3::TunTapFdLink must be connected to exactly one FdNetDevice"
                 self.error(msg)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
             self._fdnetdevice = devices[0]
 
@@ -65,7 +65,7 @@ class PlanetlabTunTapFdLink(LinuxTunTapFdLink):
             if not devices or len(devices) != 1: 
                 msg = "planetlab::ns3::TunTapFdLink must be connected to exactly one PlanetlabTap"
                 self.error(msg)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
             self._tap = devices[0]
         
index 7797465..a3cf2fa 100644 (file)
@@ -88,7 +88,7 @@ class PlanetlabOVSSwitch(LinuxApplication):
             if not nodes or len(nodes) != 1: 
                 msg = "PlanetlabOVSSwitch must be connected to exactly one PlanetlabNode"
                 #self.error(msg)
-                raise RuntimeError, msg
+                raise RuntimeError(msg)
 
             self._node = nodes[0]
 
@@ -148,7 +148,7 @@ class PlanetlabOVSSwitch(LinuxApplication):
         except RuntimeError:
             msg = "Command sliver-ovs does not exist on the VM"         
             self.debug(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
     def servers_on(self):
         """ Start the openvswitch servers and check it
@@ -179,7 +179,7 @@ class PlanetlabOVSSwitch(LinuxApplication):
         except RuntimeError:
             msg = "Failed to start ovs-server on VM"            
             self.debug(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         command = "ps -A | grep ovsdb-server"
         shfile = os.path.join(self.app_home, "ovsdb_status.sh")
@@ -194,7 +194,7 @@ class PlanetlabOVSSwitch(LinuxApplication):
         except RuntimeError:
             msg = "ovsdb-server not running on VM"      
             self.debug(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
         
         self.info("Server OVS Started...")  
 
@@ -206,7 +206,7 @@ class PlanetlabOVSSwitch(LinuxApplication):
         if not (self.get("bridge_name") and self.get("virtual_ip_pref")):
             msg = "No assignment in one or both attributes"
             self.error(msg)
-            raise AttributeError, msg
+            raise AttributeError(msg)
 
         command = "sliver-ovs create-bridge '%s' '%s'" % (
                           self.get("bridge_name"), 
@@ -224,7 +224,7 @@ class PlanetlabOVSSwitch(LinuxApplication):
         except RuntimeError:
             msg = "No such pltap netdev\novs-appctl: ovs-vswitchd: server returned an error"
             self.debug(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         self.info(" Bridge %s Created and Assigned to %s" %\
             (self.get("bridge_name"), self.get("virtual_ip_pref")) )
@@ -259,7 +259,7 @@ class PlanetlabOVSSwitch(LinuxApplication):
         except RuntimeError:
             msg = "SSH connection in the method assign_controller"
             self.debug(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         self.info("Controller assigned to the bridge %s" % self.get("bridge_name"))
            
@@ -279,7 +279,7 @@ class PlanetlabOVSSwitch(LinuxApplication):
         except RuntimeError:
             msg = "Error when checking the status of the OpenVswitch"
             self.debug(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
     def do_release(self):
         """ Delete the bridge and close the server.  
index 6ec1a12..9db4885 100644 (file)
@@ -116,12 +116,12 @@ class PlanetlabOVSPort(LinuxApplication):
         if not self.get('port_name'):
             msg = "The port name is not assigned"
             self.error(msg)
-            raise AttributeError, msg
+            raise AttributeError(msg)
 
         if not self.ovsswitch:
             msg = "The OVSwitch RM is not running"
             self.error(msg)
-            raise AttributeError, msg
+            raise AttributeError(msg)
 
         command = "sliver-ovs create-port %s %s" % (
                 self.ovsswitch.get('bridge_name'),
@@ -139,7 +139,7 @@ class PlanetlabOVSPort(LinuxApplication):
         except RuntimeError:
             msg = "Could not create ovs-port"           
             self.debug(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         self.info("Created port %s on switch %s" % (
             self.get('port_name'),
@@ -167,7 +167,7 @@ class PlanetlabOVSPort(LinuxApplication):
         if err != "":
             msg = "Error retrieving the local endpoint of the port"
             self.error(msg)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         if out:
             self._port_number = out.strip()
index 683a4d4..d2970e8 100644 (file)
@@ -212,7 +212,7 @@ class PLCAPI(object):
         try:
             # test authorization
             network_types = _retry(self.mcapi.GetNetworkTypes)(self.auth)
-        except (xmlrpclib.ProtocolError, xmlrpclib.Fault),e:
+        except (xmlrpclib.ProtocolError, xmlrpclib.Fault) as e:
             warnings.warn(str(e))
         
         return True
@@ -284,7 +284,7 @@ class PLCAPI(object):
                 * plain : boolean, use plain bootstrapfs image if set (for tests)  
         """
         if not isinstance(node, (str, int, long)):
-            raise ValueError, "Node must be either a non-unicode string or an int"
+            raise ValueError("Node must be either a non-unicode string or an int")
         return _retry(self.mcapi.GetNodeFlavour)(self.auth, node)
     
     def get_nodes(self, node_id_or_name = None, fields = None, **kw):
index df9fbdf..6b72278 100644 (file)
@@ -40,7 +40,7 @@ def recv_msg(conn):
     while '\n' not in chunk:
         try:
             chunk = conn.recv(1024)
-        except (OSError, socket.error), e:
+        except (OSError, socket.error) as e:
             if e[0] != errno.EINTR:
                 raise
             # Ignore eintr errors
@@ -163,7 +163,7 @@ if __name__ == '__main__':
         while not stop:
             try:
                 (msg, args) = recv_msg(conn)
-            except socket.timeout, e:
+            except socket.timeout as e:
                 # Ingore time-out
                 continue
 
index d122cb4..fca374e 100644 (file)
@@ -650,24 +650,24 @@ class PlanetlabSfaNode(LinuxNode):
     def fail_discovery(self):
         msg = "Discovery failed. No candidates found for node"
         self.error(msg)
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
 
     def fail_node_not_alive(self, hostname=None):
         msg = "Node %s not alive" % hostname
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
     
     def fail_node_not_available(self, hostname):
         msg = "Node %s not available for provisioning" % hostname
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
 
     def fail_not_enough_nodes(self):
         msg = "Not enough nodes available for provisioning"
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
 
     def fail_sfaapi(self):
         msg = "Failing while trying to instanciate the SFA API.\nSet the" + \
             " attributes sfauser and sfaPrivateKey."
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
 
     def valid_connection(self, guid):
         # TODO: Validate!
index 73c5df7..56517c3 100644 (file)
@@ -50,7 +50,7 @@ class PlanetlabTap(LinuxTap):
     def node(self):
         node = self.get_connected(PlanetlabNode.get_rtype())
         if node: return node[0]
-        raise RuntimeError, "TAP/TUN devices must be connected to Node"
+        raise RuntimeError("TAP/TUN devices must be connected to Node")
 
     def upload_sources(self):
         scripts = []
@@ -140,7 +140,7 @@ class PlanetlabTap(LinuxTap):
                 (out, err), proc = self.node.check_errors(exec_run_home)
                 
                 if err.strip():
-                    raise RuntimeError, err
+                    raise RuntimeError(err)
 
             if out:
                 vif_name = out.strip()
@@ -151,7 +151,7 @@ class PlanetlabTap(LinuxTap):
         else:
             msg = "Couldn't retrieve vif_name"
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         return vif_name
 
index 4e5df43..ea4fbbb 100644 (file)
@@ -124,7 +124,7 @@ class PlanetlabVroute(LinuxApplication):
         else:
             msg = " Failed to execute command '%s'" % command
             self.error(msg, out, err)
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
     def do_stop(self):
 
index 32ed19b..e67249a 100644 (file)
@@ -62,7 +62,7 @@ def find_bin(name, extra_path = None):
             try:
                 os.stat(d + "/" + name)
                 return d + "/" + name
-            except OSError, e:
+            except OSError as e:
                 if e.errno != os.errno.ENOENT:
                     raise
     return None
@@ -88,7 +88,7 @@ def find_bin(name, extra_path = None):
             try:
                 os.stat(d + "/" + name)
                 return d + "/" + name
-            except OSError, e:
+            except OSError as e:
                 if e.errno != os.errno.ENOENT:
                     raise
     return None
index 1753119..cc95bdf 100644 (file)
@@ -155,7 +155,7 @@ def lspawn(command, pidfile,
     (out,err), proc = lexec(cmd)
     
     if proc.wait():
-        raise RuntimeError, "Failed to set up application on host %s: %s %s" % (host, out,err,)
+        raise RuntimeError("Failed to set up application on host %s: %s %s" % (host, out,err,))
 
     return ((out,err), proc)
 
index 9630127..5827d4f 100644 (file)
@@ -52,7 +52,7 @@ class MANIFOLDAPI(object):
 
         if not session['value']:
             msg = "Can not authenticate in Manifold API"
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         session_key = session['value'][0]['session']
         return dict(AuthMethod='session', session=session_key)
index 8a36d15..49a194b 100644 (file)
@@ -188,7 +188,7 @@ class NetGraph(object):
     def annotate_node(self, nid, name, value):
         if not isinstance(value, str) and not isinstance(value, int) and \
                 not isinstance(value, float) and not isinstance(value, bool):
-            raise RuntimeError, "Non-serializable annotation"
+            raise RuntimeError("Non-serializable annotation")
 
         self.topology.node[nid][name] = value
     
@@ -204,7 +204,7 @@ class NetGraph(object):
     def annotate_edge(self, nid1, nid2, name, value):
         if not isinstance(value, str) and not isinstance(value, int) and \
                 not isinstance(value, float) and not isinstance(value, bool):
-            raise RuntimeError, "Non-serializable annotation"
+            raise RuntimeError("Non-serializable annotation")
 
         self.topology.edge[nid1][nid2][name] = value
    
@@ -256,7 +256,7 @@ class NetGraph(object):
             net = ipaddr.IPv6Network(netblock)
             new_prefix = 30
         else:
-            raise RuntimeError, "Invalid IP version %d" % version
+            raise RuntimeError("Invalid IP version %d" % version)
         
         ## Clear all previusly assigned IPs
         for nid in self.topology.nodes():
index bf86b57..49b27b5 100644 (file)
@@ -144,7 +144,7 @@ class ParallelRun(object):
         if self.delayed_exceptions:
             typ,val,loc = self.delayed_exceptions[0]
             del self.delayed_exceptions[:]
-            raise typ,val,loc
+            raise typ(val).with_traceback(loc)
         
     def __iter__(self):
         if self.rvqueue is not None:
index e013e1a..f8c8bb2 100644 (file)
@@ -66,19 +66,19 @@ class SfaRSpecProcessing(object):
         
         try:
             nodes = rspec.version.get_nodes()
-        except Exception, e:
+        except Exception as e:
             self._log.warn("Could not retrieve nodes in RSpec: %s" % e)
         try:
             leases = rspec.version.get_leases()
-        except Exception, e:
+        except Exception as e:
             self._log.warn("Could not retrieve leases in RSpec: %s" % e)
         try:
             links = rspec.version.get_links()
-        except Exception, e:
+        except Exception as e:
             self._log.warn("Could not retrieve links in RSpec: %s" % e)
         try:
             channels = rspec.version.get_channels()
-        except Exception, e:
+        except Exception as e:
             self._log.warn("Could not retrieve channels in RSpec: %s" % e)
   
         resources = [] 
@@ -197,7 +197,7 @@ class SfaRSpecProcessing(object):
             elif resource_type == 'channel':
                 channels.append(resource)
             else:
-                raise Exception, "Not supported type of resource" 
+                raise Exception("Not supported type of resource") 
         
         rspec.version.add_nodes(nodes, rspec_content_type="request")
         #rspec.version.add_leases(leases)
index cfb9908..1899de2 100644 (file)
@@ -211,12 +211,12 @@ def eintr_retry(func):
         for i in xrange(0 if retry else 4):
             try:
                 return func(*p, **kw)
-            except (select.error, socket.error), args:
+            except (select.error, socket.error) as args:
                 if args[0] == errno.EINTR:
                     continue
                 else:
                     raise 
-            except OSError, e:
+            except OSError as e:
                 if e.errno == errno.EINTR:
                     continue
                 else:
@@ -342,7 +342,7 @@ def rcopy(source, dest,
     elif isinstance(source, str) and ':' in source:
         remspec, path = source.split(':',1)
     else:
-        raise ValueError, "Both endpoints cannot be local"
+        raise ValueError("Both endpoints cannot be local")
     user,host = remspec.rsplit('@',1)
     
     # plain scp
@@ -503,7 +503,7 @@ def rspawn(command, pidfile,
         )
     
     if proc.wait():
-        raise RuntimeError, "Failed to set up application on host %s: %s %s" % (host, out,err,)
+        raise RuntimeError("Failed to set up application on host %s: %s %s" % (host, out,err,))
 
     return ((out, err), proc)
 
@@ -750,7 +750,7 @@ def _retry_rexec(args,
                     time.sleep(t)
                     continue
             break
-        except RuntimeError, e:
+        except RuntimeError as e:
             msg = " rexec EXCEPTION - TIMEOUT -> %s \n %s" % ( e.args, log_msg )
             log(msg, logging.DEBUG, out, err)
 
@@ -816,7 +816,7 @@ def _communicate(proc, input, timeout=None, err_on_timeout=True):
 
         try:
             rlist, wlist, xlist = select.select(read_set, write_set, [], select_timeout)
-        except select.error,e:
+        except select.error as e:
             if e[0] != 4:
                 raise
             else:
@@ -870,7 +870,7 @@ def _communicate(proc, input, timeout=None, err_on_timeout=True):
 
     if killed and err_on_timeout:
         errcode = proc.poll()
-        raise RuntimeError("Operation timed out", errcode, stdout, stderr)
+        raise RuntimeError("Operation timed out", errcode, stdout, stderr)
     else:
         if killed:
             proc.poll()
index 40d66c0..1bf20b1 100755 (executable)
@@ -74,7 +74,7 @@ class ExecuteControllersTestCase(unittest.TestCase):
             # When this task is executed and the error raise,
             # the FailureManager should set its failure level to 
             # TASK_FAILURE
-            raise RuntimeError, "NOT A REAL ERROR. JUST TESTING!"
+            raise RuntimeError("NOT A REAL ERROR. JUST TESTING!")
 
         ec = ExperimentController()
 
index 188dbaf..0945e9b 100755 (executable)
@@ -130,7 +130,7 @@ class ErrorApplication(ResourceManager):
             self.ec.schedule("0.5s", self.deploy)
         else:
             time.sleep(random.random() * 2)
-            raise RuntimeError, "NOT A REAL ERROR. JUST TESTING"
+            raise RuntimeError("NOT A REAL ERROR. JUST TESTING")
 
 class ResourceFactoryTestCase(unittest.TestCase):
     def test_add_resource_factory(self):
index 539af78..2c9c30b 100755 (executable)
@@ -47,7 +47,7 @@ def find_bin(name, extra_path = None):
             try:
                 os.stat(d + "/" + name)
                 return d + "/" + name
-            except OSError, e:
+            except OSError as e:
                 if e.errno != os.errno.ENOENT:
                     raise
     return None