Author: remi
Date: 2009-04-06 19:32:39 +0200 (Mon, 06 Apr 2009)
New Revision: 4365
Modified:
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceScheduler.py
Log:
* added a method and a service to execute the action of a scheduled task
Modified:
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceScheduler.py
===================================================================
---
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceScheduler.py
2009-04-06 17:16:46 UTC (rev 4364)
+++
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceScheduler.py
2009-04-06 17:32:39 UTC (rev 4365)
@@ -232,6 +232,18 @@
second, command, arguments, data)
return None, None
+ def executeTask(self, taskId):
+ """Execute the action of a scheduled task.
+ @param taskId: Task id.
+ @return: A boolean.
+ """
+ tasks = self.__scheduler.getTasks()
+ for task in tasks:
+ if task.getDescription().getId() == taskId:
+ task.execute(globals())
+ return True
+ return False
+
def removeTask(self, taskId):
"""Remove a task from the scheduler.
@param taskId: Task id.
@@ -319,3 +331,28 @@
# Register the service into the resource
resourceScheduler.addService(TDSServiceSchedulerRemoveTask)
+
+#
------------------------------------------------------------------------------
+# Declaration of the service "execute_task".
+#
------------------------------------------------------------------------------
+class TDSServiceSchedulerExecuteTask(TDSService):
+
+ def configure(self):
+ self.parametersDict = {
+ 'task_id' : 'string',
+ }
+ self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
+ self.exclusiveExecution = False
+ self.name = "execute_task"
+ self.comment = "Execute the action of a scheduled task."
+
+ def execute(self, id, parameters):
+ headersStruct = self.getDefaultHeadersStruct()
+ contentStruct = self.getDefaultContentStruct()
+ contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
+ if not resourceScheduler.executeTask(parameters['task_id']):
+ contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
+ return headersStruct, contentStruct
+
+# Register the service into the resource
+resourceScheduler.addService(TDSServiceSchedulerExecuteTask)
------------------------------------------------------------------------------
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