applied the except and raise fixers to the master branch to close the gap with py3
[nepi.git] / src / nepi / resources / netns / netnsapplication.py
index 5ffff92..68d64ef 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
@@ -48,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]
 
@@ -57,7 +56,7 @@ class NetNSApplication(NetNSBase):
         return [self.node]
 
     def do_start(self):
-        if self.simulation.state < ResourceState.STARTED:
+        if self.emulation.state < ResourceState.STARTED:
             self.debug("---- RESCHEDULING START ----" )
             self.ec.schedule(self.reschedule_delay, self.start)
         else:
@@ -74,8 +73,8 @@ class NetNSApplication(NetNSBase):
             self._start_time = self.emulation.start_time
 
     def _configure_traces(self):
-        stdout = "%s/%d.stdout " % (self.emulation.run_home, self.pid)
-        stderr = "%s/%d.stderr " % (self.emulation.run_home, self.pid)
+        stdout = "%s/%d.stdout" % (self.emulation.run_home, self.guid)
+        stderr = "%s/%d.stderr" % (self.emulation.run_home, self.guid)
         self._trace_filename["stdout"] = stdout 
         self._trace_filename["stderr"] = stderr
         self._traces["stdout"] = self.emulation.create("open", stdout, "w")
@@ -86,8 +85,8 @@ class NetNSApplication(NetNSBase):
         if self._state == ResourceState.STARTED:
             retcode = self.emulation.invoke(self.uuid, "poll")
    
-            if retcode:
-                if ret == 0:
+            if retcode is not None:
+                if retcode == 0:
                     self.set_stopped()
                 else:
                     out = ""