use print() - import print_function - should be fine for both py2 and py3
[nepi.git] / test / resources / omf / set_hook.py
index 08abb00..f515f1e 100755 (executable)
@@ -4,9 +4,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
 #
 # Author: Julien Tribino <julien.tribino@inria.fr>
 
+from __future__ import print_function
 
-from nepi.execution.resource import ResourceFactory, clsinit_copy, ResourceManager, ResourceAction, ResourceState
+from nepi.execution.resource import (ResourceFactory, clsinit_copy,
+                                     ResourceManager, ResourceAction, ResourceState)
 from nepi.execution.ec import ExperimentController
 from nepi.execution.attribute import Attribute, Flags 
 
@@ -35,8 +36,8 @@ class DummyEC(ExperimentController):
     pass
 
 @clsinit_copy
-class DummyOMFApplication(OMFApplication):
-    _rtype = "DummyOMFApplication"
+class OMFDummyApplication(OMFApplication):
+    _rtype = "omf::DummyApplication"
 
     @classmethod
     def _register_attributes(cls):
@@ -46,7 +47,7 @@ class DummyOMFApplication(OMFApplication):
     @classmethod
     def test_hook(cls, old_value, new_value):
         new_value *= 10
-        print "Change the value of test from "+ str(old_value) +" to : " + str(new_value)
+        print("Change the value of test from "+ str(old_value) +" to : " + str(new_value))
         return new_value
 
 
@@ -55,16 +56,16 @@ class OMFTestSet(unittest.TestCase):
     def test_set_hook(self):
         self.ec = DummyEC(exp_id = "30")
 
-        ResourceFactory.register_type(DummyOMFApplication)
+        ResourceFactory.register_type(OMFDummyApplication)
 
-        self.node1 = self.ec.register_resource("OMFNode")
+        self.node1 = self.ec.register_resource("omf::Node")
         self.ec.set(self.node1, 'hostname', 'omf.plexus.wlab17')
         self.ec.set(self.node1, 'xmppSlice', "nepi")
         self.ec.set(self.node1, 'xmppHost', "xmpp-plexus.onelab.eu")
         self.ec.set(self.node1, 'xmppPort', "5222")
         self.ec.set(self.node1, 'xmppPassword', "1234")
 
-        self.app1 = self.ec.register_resource("DummyOMFApplication")
+        self.app1 = self.ec.register_resource("omf::DummyApplication")
         self.ec.set(self.app1, 'appid', 'Test#1')
         self.ec.set(self.app1, 'path', "/usr/bin/ping")
         self.ec.set(self.app1, 'args', "")
@@ -81,13 +82,13 @@ class OMFTestSet(unittest.TestCase):
         self.ec.deploy()
 
         time.sleep(3)
-        print "First try to change the STDIN"
+        print("First try to change the STDIN")
         self.ec.set(self.app1, 'test', 3)
 
         self.assertEquals(self.ec.get(self.app1, 'test'), 30)
 
         time.sleep(3)
-        print "Second try to change the STDIN"
+        print("Second try to change the STDIN")
         self.ec.set(self.app1, 'test', 101)
         self.assertEquals(self.ec.get(self.app1, 'test'), 1010)