applied the except and raise fixers to the master branch to close the gap with py3
[nepi.git] / src / nepi / resources / linux / udptest.py
index 1b7ac9c..4ef2b2b 100644 (file)
@@ -3,9 +3,8 @@
 #    Copyright (C) 2013 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
@@ -18,9 +17,7 @@
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
 from nepi.execution.attribute import Attribute, Flags, Types
-from nepi.execution.resource import clsinit_copy, ResourceState, \
-        reschedule_delay
-from nepi.execution.resource import clsinit_copy 
+from nepi.execution.resource import clsinit_copy, ResourceState
 from nepi.resources.linux.application import LinuxApplication
 from nepi.util.timefuncs import tnow
 
@@ -33,7 +30,7 @@ class LinuxUdpTest(LinuxApplication):
 
     http://hpcbench.sourceforge.net/
     """
-    _rtype = "LinuxUdpTest"
+    _rtype = "linux::UdpTest"
 
     @classmethod
     def _register_attributes(cls):
@@ -41,103 +38,103 @@ class LinuxUdpTest(LinuxApplication):
             "Runs in server mode. ",
             type = Types.Bool,
             default = False,
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         p = Attribute("p",
             "Port to listen to in server mode, or to connect to in client mode. "
             "Defaults to 5678. ",
             type = Types.Integer,
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         a = Attribute("a",
             "Client option. Perform UDP Round Trip Time (latency) ",
             type = Types.Bool,
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         A = Attribute("A",
             "Client option. "
             "Message size for UDP RTT test. "
             "UDP RTT (latency) test with specified message size.",
             type = Types.Integer,
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         b = Attribute("b",
             "Client option. "
             "Client UDP buffer size in bytes. Using system default "
             "value if not defined.",
             type = Types.Integer,
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         B = Attribute("B",
             "Client option. "
             "Server UDP buffer size in bytes. The same as cleint's by default.",
             type = Types.Integer,
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         c = Attribute("c",
             "Client option. "
             "CPU log option. Tracing system info during the test. "
             "Only available when output is defined. ",
             type = Types.Bool,
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         d = Attribute("d",
             "Client option. "
             "Data size of each read/write in bytes. The same as packet size "
             "by default.",
             type = Types.Integer,
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         e = Attribute("e",
             "Client option. "
             "Exponential test (data size of each sending increasing from 1 "
             "byte to packet size). ",
             type = Types.Bool,
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         g = Attribute("g",
             "Client option. "
             "UDP traffic generator (Keep sending data to a host). "
             "Work without server's support.",
             type = Types.Bool,
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         target = Attribute("target",
             "Client option. "
             "Hostname or IP address of UDP server. Must be specified.",
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         i = Attribute("i",
             "Client option. "
             "Bidirectional UDP throuhgput test. Default is unidirection "
             "stream test. ",
             type = Types.Bool,
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         l = Attribute("l",
             "Client option. "
             "UDP datagram (packet) size in bytes ( < udp-buffer-szie ). "
             "1460 by default.",
             type = Types.Integer,
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         m = Attribute("m",
             "Client option. "
             "Total message size in bytes. 1048576 by default.",
             type = Types.Integer,
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         o = Attribute("o",
             "Client option. "
             "Output file name. ",
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         P = Attribute("P",
             "Client option. "
             "Write the plot file for gnuplot. Only enable when the output "
             "is specified. ",
             type = Types.Bool,
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         q = Attribute("q",
             "Client option. "
@@ -153,38 +150,38 @@ class LinuxUdpTest(LinuxApplication):
             "is specified. ",
             type = Types.Enumerate,
             allowed = ["1", "2", "3", "4", "5", "6"],
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         r = Attribute("r",
             "Client option. "
             "Repetition of tests. 10 by default. ",
             type = Types.Integer,
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         t = Attribute("t",
             "Client option. "
             "Test time constraint in seconds. 5 by default. ",
             type = Types.Integer,
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         T = Attribute("T",
             "Client option. "
             "Throughput constraint for UDP generator or throughput "
             "test. Unlimited by default. ",
             type = Types.Integer,
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         continuous = Attribute("continuous",
             "Run nping in a while loop",
             type = Types.Bool,
             default = False,
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         print_timestamp = Attribute("printTimestamp",
             "Print timestamp before running nping",
             type = Types.Bool,
             default = False,
-            flags = Flags.ExecReadOnly)
+            flags = Flags.Design)
 
         cls._register_attribute(s)
         cls._register_attribute(p)
@@ -214,7 +211,7 @@ class LinuxUdpTest(LinuxApplication):
         super(LinuxUdpTest, self).__init__(ec, guid)
         self._home = "udptest-%s" % self.guid
 
-    def deploy(self):
+    def do_deploy(self):
         if not self.get("command"):
             self.set("command", self._start_command)
 
@@ -233,10 +230,9 @@ class LinuxUdpTest(LinuxApplication):
         if not self.get("depends"):
             self.set("depends", self._depends)
 
-        super(LinuxUdpTest, self).deploy()
+        super(LinuxUdpTest, self).do_deploy()
 
     def upload_start_command(self):
-
         super(LinuxUdpTest, self).upload_start_command()
 
         if self.get("s") == True:
@@ -247,7 +243,7 @@ class LinuxUdpTest(LinuxApplication):
             # finished to continue )
             self._run_in_background()
     
-    def start(self):
+    def do_start(self):
         if self.get("s") == True:
             # Server is already running
             if self.state == ResourceState.READY:
@@ -258,9 +254,9 @@ class LinuxUdpTest(LinuxApplication):
             else:
                 msg = " Failed to execute command '%s'" % command
                 self.error(msg, out, err)
-                self.fail()
+                raise RuntimeError(err)
         else:
-            super(LinuxUdpTest, self).start()
+            super(LinuxUdpTest, self).do_start()
  
     @property
     def _start_command(self):