Author: remi
Date: 2009-04-15 15:08:06 +0200 (Wed, 15 Apr 2009)
New Revision: 4522

Modified:
   
softwares_suite_v3/kysoh/tuxware/api/python/trunk/tuxisalive/api/gadgets/Gadget.py
   
softwares_suite_v3/kysoh/tuxware/api/python/trunk/tuxisalive/api/gadgets/GadgetDescription.py
Log:
* added methods to get the default name of check and run commands
* added run(), check(), scheduleRun() and scheduleCheck() methods

Modified: 
softwares_suite_v3/kysoh/tuxware/api/python/trunk/tuxisalive/api/gadgets/Gadget.py
===================================================================
--- 
softwares_suite_v3/kysoh/tuxware/api/python/trunk/tuxisalive/api/gadgets/Gadget.py
  2009-04-15 13:07:15 UTC (rev 4521)
+++ 
softwares_suite_v3/kysoh/tuxware/api/python/trunk/tuxisalive/api/gadgets/Gadget.py
  2009-04-15 13:08:06 UTC (rev 4522)
@@ -40,6 +40,8 @@
         for key in infosStructure['commands'].keys():
             self.__commands.append(GadgetToken(self,
                 infosStructure['commands'][key]))
+        self.__defaultRunCommandName = infosStructure['default_run_command']
+        self.__defaultCheckCommandName = 
infosStructure['default_check_command']
 
     # 
--------------------------------------------------------------------------
     # Get the parent gadgets container.
@@ -110,6 +112,24 @@
         return result
 
     # 
--------------------------------------------------------------------------
+    # Get the default check command name.
+    # 
--------------------------------------------------------------------------
+    def getDefaultCheckCommandName(self):
+        """Get the default check command name.
+        @return: A string.
+        """
+        return self.__defaultCheckCommandName
+
+    # 
--------------------------------------------------------------------------
+    # Get the default run command name.
+    # 
--------------------------------------------------------------------------
+    def getDefaultRunCommandName(self):
+        """Get the default run command name.
+        @return: A string.
+        """
+        return self.__defaultRunCommandName
+
+    # 
--------------------------------------------------------------------------
     # Get the parameter objects list.
     # 
--------------------------------------------------------------------------
     def getParameters(self):
@@ -197,6 +217,30 @@
         return self._sendCommandBooleanResult(cmd, argsToSend)
 
     # 
--------------------------------------------------------------------------
+    # Execute the run command of this gadget.
+    # 
--------------------------------------------------------------------------
+    def runAsync(self, parameters = {}):
+        """Execute the run command of this gadget.
+        @param parameters: Parameters of the gadget as dictionary.
+            if no parameter is defined the default ones are set.
+            if a parameter is wrong or missing the default one is set.
+        @return: The success of the command.
+        """
+        return self.startAsync(self.getDefaultRunCommandName(), parameters)
+
+    # 
--------------------------------------------------------------------------
+    # Execute the check command of this gadget.
+    # 
--------------------------------------------------------------------------
+    def checkAsync(self, parameters = {}):
+        """Execute the check command of this gadget.
+        @param parameters: Parameters of the gadget as dictionary.
+            if no parameter is defined the default ones are set.
+            if a parameter is wrong or missing the default one is set.
+        @return: The success of the command.
+        """
+        return self.startAsync(self.getDefaultCheckCommandName(), parameters)
+
+    # 
--------------------------------------------------------------------------
     # Start this gadget.
     # 
--------------------------------------------------------------------------
     def start(self, command = None, parameters = {}):
@@ -215,6 +259,30 @@
         return True
 
     # 
--------------------------------------------------------------------------
+    # Execute the run command of this gadget.
+    # 
--------------------------------------------------------------------------
+    def run(self, parameters = {}):
+        """Execute the run command of this gadget.
+        @param parameters: Parameters of the gadget as dictionary.
+            if no parameter is defined the default ones are set.
+            if a parameter is wrong or missing the default one is set.
+        @return: The success of the command.
+        """
+        return self.start(self.getDefaultRunCommandName(), parameters)
+
+    # 
--------------------------------------------------------------------------
+    # Execute the check command of this gadget.
+    # 
--------------------------------------------------------------------------
+    def check(self, parameters = {}):
+        """Execute the check command of this gadget.
+        @param parameters: Parameters of the gadget as dictionary.
+            if no parameter is defined the default ones are set.
+            if a parameter is wrong or missing the default one is set.
+        @return: The success of the command.
+        """
+        return self.start(self.getDefaultCheckCommandName(), parameters)
+
+    # 
--------------------------------------------------------------------------
     # Stop the gadget.
     # 
--------------------------------------------------------------------------
     def stop(self):
@@ -249,16 +317,10 @@
                     Default is None (no date defined)
         @param time: Task time as string "HH:MM:SS".
                     Default is "00:00:10".
-        @return: The success of the gadget start.
+        @return: The success of the gadget task adding.
         """
         if command == None:
-            if len(self.__commands) > 0:
-                command = self.__commands[0].getName()
-            else:
-                return False
-        else:
-            if command not in self.getCommandsName():
-                return False
+            command = self.getDefaultCheckCommandName()
         if not self._checkObjectType('parameters', parameters, 'dict'):
             return False
         args = ""
@@ -279,6 +341,58 @@
         return self._sendCommandBooleanResult(cmd, argsToSend)
 
     # 
--------------------------------------------------------------------------
+    # Schedule the run command of this gadget.
+    # 
--------------------------------------------------------------------------
+    def scheduleRun(self, parameters = {}, type = "ONCE DELAYED", name = None,
+        weekMask = [True, True, True, True, True, True, True], date = None,
+        time = "00:00:10"):
+        """Schedule the run command of this gadget.
+        @param parameters: Parameters of the gadget as dictionary.
+            if no parameter is defined the default ones are set.
+            if a parameter is wrong or missing the default one is set.
+        @param type: <EVERY X|EVERY X FROM FULL HOUR|DAILY AT|ONCE AT|
+                      ONCE DELAYED>
+                     Default value is the "ONCE DELAYED".
+        @param name: Task name.
+                     Default value is gadget name.
+        @param weekMask: Week mask as list of 7 booleans.
+                    Default is [True, True, True, True, True, True, True]
+        @param date: Task date as string "YYYY/MM/DD".
+                    Default is None (no date defined)
+        @param time: Task time as string "HH:MM:SS".
+                    Default is "00:00:10".
+        @return: The success of the gadget task adding.
+        """
+        return self.scheduleStart(self.getDefaultRunCommandName(), parameters,
+            type, name, weekMask, date, time)
+
+    # 
--------------------------------------------------------------------------
+    # Schedule the check command of this gadget.
+    # 
--------------------------------------------------------------------------
+    def scheduleCheck(self, parameters = {}, type = "ONCE DELAYED", name = 
None,
+        weekMask = [True, True, True, True, True, True, True], date = None,
+        time = "00:00:10"):
+        """Schedule the check command of this gadget.
+        @param parameters: Parameters of the gadget as dictionary.
+            if no parameter is defined the default ones are set.
+            if a parameter is wrong or missing the default one is set.
+        @param type: <EVERY X|EVERY X FROM FULL HOUR|DAILY AT|ONCE AT|
+                      ONCE DELAYED>
+                     Default value is the "ONCE DELAYED".
+        @param name: Task name.
+                     Default value is gadget name.
+        @param weekMask: Week mask as list of 7 booleans.
+                    Default is [True, True, True, True, True, True, True]
+        @param date: Task date as string "YYYY/MM/DD".
+                    Default is None (no date defined)
+        @param time: Task time as string "HH:MM:SS".
+                    Default is "00:00:10".
+        @return: The success of the gadget task adding.
+        """
+        return self.scheduleStart(self.getDefaultCheckCommandName(), 
parameters,
+            type, name, weekMask, date, time)
+
+    # 
--------------------------------------------------------------------------
     # Schedule the stop command of this gadget.
     # 
--------------------------------------------------------------------------
     def scheduleStop(self, type = "ONCE DELAYED", name = None,

Modified: 
softwares_suite_v3/kysoh/tuxware/api/python/trunk/tuxisalive/api/gadgets/GadgetDescription.py
===================================================================
--- 
softwares_suite_v3/kysoh/tuxware/api/python/trunk/tuxisalive/api/gadgets/GadgetDescription.py
       2009-04-15 13:07:15 UTC (rev 4521)
+++ 
softwares_suite_v3/kysoh/tuxware/api/python/trunk/tuxisalive/api/gadgets/GadgetDescription.py
       2009-04-15 13:08:06 UTC (rev 4522)
@@ -141,6 +141,10 @@
         descList.append("%s = %s" % ('Description', self.getDescription()))
         descList.append("%s = %s" % ('Author', self.getAuthor()))
         descList.append("%s = %s" % ('Version', self.getVersion()))
+        descList.append("%s = %s" % ('Default run command',
+            self.getParent().getDefaultRunCommandName()))
+        descList.append("%s = %s" % ('Default check command',
+            self.getParent().getDefaultCheckCommandName()))
         str = "%s = %s" % ('Icon file', self.getIconFile())
         if len(str) >= 70:
             str = "%s = ...%s" % ('Icon file',


------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to