Author: remi
Date: 2009-04-06 19:16:14 +0200 (Mon, 06 Apr 2009)
New Revision: 4363
Added:
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/scheduler/TaskDescription.py
Log:
* added TaskDescription class
Added:
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/scheduler/TaskDescription.py
===================================================================
---
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/scheduler/TaskDescription.py
(rev 0)
+++
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/scheduler/TaskDescription.py
2009-04-06 17:16:14 UTC (rev 4363)
@@ -0,0 +1,177 @@
+# Copyright (C) 2009 C2ME Sa
+# Remi Jocaille <[email protected]>
+# Distributed under the terms of the GNU General Public License
+# http://www.gnu.org/copyleft/gpl.html
+
+from tuxisalive.api.base.lib.Helper import Helper
+
+#
------------------------------------------------------------------------------
+# Task description class.
+#
------------------------------------------------------------------------------
+class TaskDescription(Helper):
+ """Task description class.
+ """
+
+ #
--------------------------------------------------------------------------
+ # Constructor of the class.
+ #
--------------------------------------------------------------------------
+ def __init__(self, parent, dictionary):
+ """Constructor of the class.
+ @param parent: Parent Task.
+ @param dictionary: Description as dictionary.
+ """
+ Helper.__init__(self)
+ self.__parent = parent
+ self.__dictionary = dictionary
+
+ #
--------------------------------------------------------------------------
+ # Get the parent task.
+ #
--------------------------------------------------------------------------
+ def getParent(self):
+ """Get the parent task.
+ @return: A Task object.
+ """
+ return self.__parent
+
+ #
--------------------------------------------------------------------------
+ # Get the task name.
+ #
--------------------------------------------------------------------------
+ def getName(self):
+ """Get the task name.
+ @return: A string.
+ """
+ return self.__dictionary['name']
+
+ #
--------------------------------------------------------------------------
+ # Get the task identifier.
+ #
--------------------------------------------------------------------------
+ def getId(self):
+ """Get the task identifier.
+ @return: A string.
+ """
+ return self.__dictionary['id']
+
+ #
--------------------------------------------------------------------------
+ # Get the task type.
+ #
--------------------------------------------------------------------------
+ def getType(self):
+ """Get the task type.
+ @return: <SCH_LOOP_ABS|SCH_LOOP_REL|SCH_ONCE_ABS|SCH_ONCE_REL>.
+ """
+ return self.__dictionary['type']
+
+ #
--------------------------------------------------------------------------
+ # Get the task configuration to string.
+ #
--------------------------------------------------------------------------
+ def toString(self):
+ """Get the task configuration to string.
+ @return: A string
+ """
+ return self.__dictionary['taskDesc']
+
+ #
--------------------------------------------------------------------------
+ # Get the week mask.
+ #
--------------------------------------------------------------------------
+ def getWeekMask(self):
+ """Get the week mask.
+ @return: Week mask. [True, True, True, True, True, True, True]
+ """
+ result = [True, True, True, True, True, True, True]
+ try:
+ splitedStr = self.__dictionary['weekMaskString'].split(",")
+ if len(splitedStr) == 7:
+ for i, value in enumerate(splitedStr):
+ if value == "1":
+ result[i] = True
+ else:
+ result[i] = False
+ except:
+ pass
+ return result
+
+ #
--------------------------------------------------------------------------
+ # Get the week mask.
+ #
--------------------------------------------------------------------------
+ def getWeekMaskString(self):
+ """Get the week mask.
+ @return: A string.
+ """
+ return self.__dictionary['weekMaskString']:
+
+ #
--------------------------------------------------------------------------
+ # Get the year value.
+ #
--------------------------------------------------------------------------
+ def getYear(self):
+ """Get the year value.
+ @return: An integer or -1.
+ """
+ return self.__dictionary['year']
+
+ #
--------------------------------------------------------------------------
+ # Get the month value.
+ #
--------------------------------------------------------------------------
+ def getMonth(self):
+ """Get the month value.
+ @return: An integer or -1.
+ """
+ return self.__dictionary['month']
+
+ #
--------------------------------------------------------------------------
+ # Get the day value.
+ #
--------------------------------------------------------------------------
+ def getDay(self):
+ """Get the day value.
+ @return: An integer or -1.
+ """
+ return self.__dictionary['day']
+
+ #
--------------------------------------------------------------------------
+ # Get the hour value.
+ #
--------------------------------------------------------------------------
+ def getHour(self):
+ """Get the hour value.
+ @return: An integer.
+ """
+ return self.__dictionary['hour']
+
+ #
--------------------------------------------------------------------------
+ # Get the minute value.
+ #
--------------------------------------------------------------------------
+ def getMinute(self):
+ """Get the minute value.
+ @return: An integer.
+ """
+ return self.__dictionary['minute']
+
+ #
--------------------------------------------------------------------------
+ # Get the second value.
+ #
--------------------------------------------------------------------------
+ def getSecond(self):
+ """Get the second value.
+ @return: An integer.
+ """
+ return self.__dictionary['second']
+
+ #
--------------------------------------------------------------------------
+ # Get the user data.
+ #
--------------------------------------------------------------------------
+ def getData(self):
+ """Get the user data.
+ @return: A dictionary.
+ """
+ return self.__dictionary['data']
+
+ #
--------------------------------------------------------------------------
+ # Show the description in the console.
+ #
--------------------------------------------------------------------------
+ def show(self):
+ """Show the description in the console.
+ """
+ descList = []
+ descList.append("%s = %s" % ('Name', self.getName()))
+ descList.append("%s = %s" % ('Id', self.getId()))
+ descList.append("%s = %s" % ('Command type',
+ self.getData()['commandType']))
+ descList.append("%s = %s" % ('Scheduling', self.toString()))
+ descList.append("%s = %s" % ('Week mask', self.getWeekMaskString()))
+ self._showStringList("Task description :", descList)
Property changes on:
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/scheduler/TaskDescription.py
___________________________________________________________________
Name: svn:keywords
+ Id
------------------------------------------------------------------------------
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