Author: remi
Date: 2009-04-07 00:39:35 +0200 (Tue, 07 Apr 2009)
New Revision: 4372

Modified:
   
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/gadgets/Gadget.py
Log:
* added methods to schedule the gadget start and the gadget stop commands

Modified: 
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/gadgets/Gadget.py
===================================================================
--- 
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/gadgets/Gadget.py
  2009-04-06 22:38:08 UTC (rev 4371)
+++ 
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/gadgets/Gadget.py
  2009-04-06 22:39:35 UTC (rev 4372)
@@ -5,6 +5,7 @@
 
 from tuxisalive.api.base.ApiBaseChildResource import ApiBaseChildResource
 from tuxisalive.api.tuxdroid.const.ConstFramework import *
+from tuxisalive.api.scheduler.Task import Task
 from GadgetDescription import GadgetDescription
 from GadgetParameter import GadgetParameter
 from GadgetToken import GadgetToken
@@ -211,3 +212,85 @@
         }
         cmd = "gadget_framework/stop_gadget_by_uuid?"
         return self._sendCommandBooleanResult(cmd, argsToSend)
+
+    # 
--------------------------------------------------------------------------
+    # Schedule the start command of this gadget.
+    # 
--------------------------------------------------------------------------
+    def scheduleStart(self, command = None, parameters = {},
+        type = "ONCE DELAYED", name = None, weekMask = [True, True, True, True,
+        True, True, True], date = None, time = "00:00:10"):
+        """Schedule the start command of this gadget.
+        @param command: Command name to start the gadget.
+            if command is None, the first command is set.
+        @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 gadget name.
+        @param name: Task name.
+                     Default value is "Unamed task".
+        @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 start.
+        """
+        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
+        if not self._checkObjectType('parameters', parameters, 'dict'):
+            return False
+        args = ""
+        for key in parameters.keys():
+            args += "%s=%s|" % (key, parameters[key])
+        if len(args) > 0:
+            args = args[:-1]
+        if name == None:
+            name = self.getDescription().getName()
+        argsToSend = Task.formatRequestArguments(type, name, weekMask, date,
+            time)
+        if argsToSend == None:
+            return False
+        argsToSend['gadget_uuid'] = self.__description.getUuid()
+        argsToSend['gadget_command'] = command
+        argsToSend['gadget_parameters'] = args
+        cmd = "task_creation/start_gadget?"
+        return self._sendCommandBooleanResult(cmd, argsToSend)
+
+    # 
--------------------------------------------------------------------------
+    # Schedule the stop command of this gadget.
+    # 
--------------------------------------------------------------------------
+    def scheduleStop(self, type = "ONCE DELAYED", name = None,
+        weekMask = [True, True, True, True, True, True, True], date = None,
+        time = "00:00:10"):
+        """Schedule the stop command of this gadget.
+        @param type: <EVERY X|EVERY X FROM FULL HOUR|DAILY AT|ONCE AT|
+                      ONCE DELAYED>
+                     Default value is the gadget name.
+        @param name: Task name.
+                     Default value is "Unamed task".
+        @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 request.
+        """
+        if name == None:
+            name = self.getDescription().getName()
+        argsToSend = Task.formatRequestArguments(type, name, weekMask, date,
+            time)
+        if argsToSend == None:
+            return False
+        argsToSend['gadget_uuid'] = self.__description.getUuid()
+        cmd = "task_creation/stop_gadget?"
+        return self._sendCommandBooleanResult(cmd, argsToSend)


------------------------------------------------------------------------------
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