applied the except and raise fixers to the master branch to close the gap with py3
[nepi.git] / src / nepi / resources / ns3 / ns3pipechanel.py
index c74b24d..40b3ab5 100644 (file)
@@ -3,9 +3,8 @@
 #    Copyright (C) 2014 INRIA
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 2 as
+#    published by the Free Software Foundation;
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -41,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
         
@@ -58,14 +57,9 @@ class NS3BasePipeChannel(NS3Base):
 
     def _instantiate_object(self):
         """ The pipe channel does not really exists as an ns-3 object.
-        Do nothing, just validate that the simulator is in real time
-        mode, otherwise it is not going to work.
+        Do nothing.
         """
-        mode = self.simulator.get("simulatorImplementationType")
-        if mode != "ns3::RealtimeSimulatorImpl":
-            msg = "The simulation must run in real time!!"
-                self.error(msg)
-                raise RuntimeError, msg
+        pass
 
     def _connect_object(self):
         dev1 = self.devices[0]
@@ -73,17 +67,15 @@ class NS3BasePipeChannel(NS3Base):
 
         if dev1.uuid not in self.connected and dev2.uuid not in self.connected:
             (s0, s1) = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM, 0)
-            self._send_fd(dev1, s0)
-            self._send_fd(dev2, s1)
+            
+            dev1.send_fd(s0)
 
-    def _send_fd(self, dev, fd):
-        import passfd
-        
-        address = self.simulation.invoke(dev.uuid, "recvFD")
-        sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
-        sock.connect(address)
-        passfd.sendfd(sock, fd, '0')
+            self._connected.add(dev1.uuid)
+            dev1._connected.add(self.uuid)
+
+            dev2.send_fd(s1)
+
+            self._connected.add(dev2.uuid)
+            dev2._connected.add(self.uuid)
 
-        self._connected.add(dev.uuid)
-        dev._connected.add(self.uuid)