[tuxdroid-svn] r5921 - in software_suite_v3/software/plugin/plugin-merry-tuxmas/trunk: . executabl
Status: Beta
Brought to you by:
ks156
|
From: remi <c2m...@c2...> - 2009-12-02 11:35:57
|
Author: remi
Date: 2009-12-02 12:35:46 +0100 (Wed, 02 Dec 2009)
New Revision: 5921
Added:
software_suite_v3/software/plugin/plugin-merry-tuxmas/trunk/executables/plugin-merry-tuxmas.py
Removed:
software_suite_v3/software/plugin/plugin-merry-tuxmas/trunk/executables/plugin-marry-tuxmas.py
Modified:
software_suite_v3/software/plugin/plugin-merry-tuxmas/trunk/build.py
Log:
* Fixed plugin filename "Marry" -> "Merry" u_U
Modified: software_suite_v3/software/plugin/plugin-merry-tuxmas/trunk/build.py
===================================================================
--- software_suite_v3/software/plugin/plugin-merry-tuxmas/trunk/build.py 2009-12-02 11:34:01 UTC (rev 5920)
+++ software_suite_v3/software/plugin/plugin-merry-tuxmas/trunk/build.py 2009-12-02 11:35:46 UTC (rev 5921)
@@ -8,4 +8,4 @@
from builder.PluginPackager import PluginPackager
if __name__ == "__main__":
- PluginPackager().createScp("plugin-marry-tuxmas.scp")
+ PluginPackager().createScp("plugin-merry-tuxmas.scp")
Deleted: software_suite_v3/software/plugin/plugin-merry-tuxmas/trunk/executables/plugin-marry-tuxmas.py
===================================================================
--- software_suite_v3/software/plugin/plugin-merry-tuxmas/trunk/executables/plugin-marry-tuxmas.py 2009-12-02 11:34:01 UTC (rev 5920)
+++ software_suite_v3/software/plugin/plugin-merry-tuxmas/trunk/executables/plugin-marry-tuxmas.py 2009-12-02 11:35:46 UTC (rev 5921)
@@ -1,168 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Copyright (C) 2009 Kysoh Sa
-# Remi Jocaille <rem...@c2...>
-# Distributed under the terms of the GNU General Public License
-# http://www.gnu.org/copyleft/gpl.html
-
-__author__ = "Kysoh"
-__appname__ = "Merry Tuxmas"
-__version__ = "0.0.1"
-__date__ = "2009/12/02"
-__license__ = "GPL"
-
-import os
-import time
-import sys
-import threading
-import random
-
-sys.path.append(os.environ['TUXDROID_SERVER_PYTHON_UTIL'])
-
-from util.SimplePlugin.SimplePluginConfiguration import SimplePluginConfiguration
-from util.SimplePlugin.SimplePlugin import SimplePlugin
-
-ATTIUNE_NAMES_LIST = [
- "12_days",
- "Jingle_Bells",
- "Merry_Christmas_Song",
- "Hohoho",
- "Sleigh_bells",
- "Hohoho2",
- "God_Rest",
- "Hark",
- "O_Christmas_Tree",
- "Deck_The_Halls",
-]
-
-B_DELAY_RARELY = 2000
-B_DELAY_NORMAL = 500
-B_DELAY_OFTEN = 150
-B_DELAY_CRAZY = 30
-
-class Configuration(SimplePluginConfiguration):
- """This class make an access to the plugin parameters.
- Parameters are automatically filled by the SimplePlugin class at plugin
- starting.
- """
-
- def __init__(self):
- """Initialization of the class.
- It's necessary to initialize the values because the type of the python
- variables is set by value assignation. If we don't initialize the
- parameters the simple plugin class can't check and validate the values
- passed by the plugins server through the os environment variables.
- """
- # Call the super class
- SimplePluginConfiguration.__init__(self)
- # Initialize the parameters
- self.__frequency = ""
-
- def getFrequency(self):
- return self.__frequency
-
- def setFrequency(self, frequency):
- self.__frequency = frequency
-
-
-class MerryTuxmasPlugin(SimplePlugin):
- """This class override the SimplePlugin class to make easy
- the plugin coding.
- """
-
- def __init__(self):
- """Initialization of the class.
- """
- # Call the super class
- SimplePlugin.__init__(self)
- # Initialize some values ...
- self.__daemonRun = False
- self.__daemonRunMutex = threading.Lock()
- self.__bDelay = B_DELAY_NORMAL
- self.__iDelay = B_DELAY_NORMAL
- self.__iTimeBegin = time.time()
- self.__iDelayMutex = threading.Lock()
- random.seed()
-
- def start(self):
- """Plugin entry point.
- This method should be used to dispatch commands.
- """
- if self.getCommand() == "run":
- self.run()
- else:
- self.run()
-
- def __getDaemonRun(self):
- """
- """
- self.__daemonRunMutex.acquire()
- result = self.__daemonRun
- self.__daemonRunMutex.release()
- return result
-
- def __setDaemonRun(self, daemonRun):
- """
- """
- self.__daemonRunMutex.acquire()
- self.__daemonRun = daemonRun
- self.__daemonRunMutex.release()
-
- def __getIdleTimeBegin(self):
- """
- """
- self.__iDelayMutex.acquire()
- value = self.__iTimeBegin
- self.__iDelayMutex.release()
- return value
-
- def __resetIdleTimeBegin(self):
- """
- """
- self.__iDelayMutex.acquire()
- self.__iTimeBegin = time.time()
- tmp = random.randint(-(self.__bDelay / 3), (self.__bDelay / 3))
- self.__iDelay = self.__bDelay + tmp
- self.__iDelayMutex.release()
-
- def run(self):
- """Plugin entry point for the "run" command.
- """
- frequency = self.configuration().getFrequency()
- if frequency == "Rarely":
- self.__bDelay = B_DELAY_RARELY
- elif frequency == "Normal":
- self.__bDelay = B_DELAY_NORMAL
- elif frequency == "Often":
- self.__bDelay = B_DELAY_OFTEN
- else:
- self.__bDelay = B_DELAY_CRAZY
- self.__resetIdleTimeBegin()
- self.__setDaemonRun(True)
- while self.__getDaemonRun():
- if (time.time() - self.__getIdleTimeBegin()) >= self.__iDelay:
- self.__resetIdleTimeBegin()
- idx = random.randint(0, len(ATTIUNE_NAMES_LIST) - 1)
- self.throwNotification("start")
- self.throwActuation("playAttitune", ATTIUNE_NAMES_LIST[idx])
- self.throwNotification("stop")
- for i in range(10):
- if not self.__getDaemonRun():
- break
- time.sleep(0.25)
-
- def onPluginStop(self):
- """Callback on plugin stop.
- """
- self.__setDaemonRun(False)
-
- def onPluginEvent(self, eventName, eventValues):
- """Callback on plugin event.
- @param eventName: Event name.
- @param eventValues: Event values.
- """
- pass
-
-if __name__ == "__main__":
- plugin = MerryTuxmasPlugin()
- plugin.boot(sys.argv[1:], Configuration())
Copied: software_suite_v3/software/plugin/plugin-merry-tuxmas/trunk/executables/plugin-merry-tuxmas.py (from rev 5920, software_suite_v3/software/plugin/plugin-merry-tuxmas/trunk/executables/plugin-marry-tuxmas.py)
===================================================================
--- software_suite_v3/software/plugin/plugin-merry-tuxmas/trunk/executables/plugin-merry-tuxmas.py (rev 0)
+++ software_suite_v3/software/plugin/plugin-merry-tuxmas/trunk/executables/plugin-merry-tuxmas.py 2009-12-02 11:35:46 UTC (rev 5921)
@@ -0,0 +1,168 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2009 Kysoh Sa
+# Remi Jocaille <rem...@c2...>
+# Distributed under the terms of the GNU General Public License
+# http://www.gnu.org/copyleft/gpl.html
+
+__author__ = "Kysoh"
+__appname__ = "Merry Tuxmas"
+__version__ = "0.0.1"
+__date__ = "2009/12/02"
+__license__ = "GPL"
+
+import os
+import time
+import sys
+import threading
+import random
+
+sys.path.append(os.environ['TUXDROID_SERVER_PYTHON_UTIL'])
+
+from util.SimplePlugin.SimplePluginConfiguration import SimplePluginConfiguration
+from util.SimplePlugin.SimplePlugin import SimplePlugin
+
+ATTIUNE_NAMES_LIST = [
+ "12_days",
+ "Jingle_Bells",
+ "Merry_Christmas_Song",
+ "Hohoho",
+ "Sleigh_bells",
+ "Hohoho2",
+ "God_Rest",
+ "Hark",
+ "O_Christmas_Tree",
+ "Deck_The_Halls",
+]
+
+B_DELAY_RARELY = 2000
+B_DELAY_NORMAL = 500
+B_DELAY_OFTEN = 150
+B_DELAY_CRAZY = 30
+
+class Configuration(SimplePluginConfiguration):
+ """This class make an access to the plugin parameters.
+ Parameters are automatically filled by the SimplePlugin class at plugin
+ starting.
+ """
+
+ def __init__(self):
+ """Initialization of the class.
+ It's necessary to initialize the values because the type of the python
+ variables is set by value assignation. If we don't initialize the
+ parameters the simple plugin class can't check and validate the values
+ passed by the plugins server through the os environment variables.
+ """
+ # Call the super class
+ SimplePluginConfiguration.__init__(self)
+ # Initialize the parameters
+ self.__frequency = ""
+
+ def getFrequency(self):
+ return self.__frequency
+
+ def setFrequency(self, frequency):
+ self.__frequency = frequency
+
+
+class MerryTuxmasPlugin(SimplePlugin):
+ """This class override the SimplePlugin class to make easy
+ the plugin coding.
+ """
+
+ def __init__(self):
+ """Initialization of the class.
+ """
+ # Call the super class
+ SimplePlugin.__init__(self)
+ # Initialize some values ...
+ self.__daemonRun = False
+ self.__daemonRunMutex = threading.Lock()
+ self.__bDelay = B_DELAY_NORMAL
+ self.__iDelay = B_DELAY_NORMAL
+ self.__iTimeBegin = time.time()
+ self.__iDelayMutex = threading.Lock()
+ random.seed()
+
+ def start(self):
+ """Plugin entry point.
+ This method should be used to dispatch commands.
+ """
+ if self.getCommand() == "run":
+ self.run()
+ else:
+ self.run()
+
+ def __getDaemonRun(self):
+ """
+ """
+ self.__daemonRunMutex.acquire()
+ result = self.__daemonRun
+ self.__daemonRunMutex.release()
+ return result
+
+ def __setDaemonRun(self, daemonRun):
+ """
+ """
+ self.__daemonRunMutex.acquire()
+ self.__daemonRun = daemonRun
+ self.__daemonRunMutex.release()
+
+ def __getIdleTimeBegin(self):
+ """
+ """
+ self.__iDelayMutex.acquire()
+ value = self.__iTimeBegin
+ self.__iDelayMutex.release()
+ return value
+
+ def __resetIdleTimeBegin(self):
+ """
+ """
+ self.__iDelayMutex.acquire()
+ self.__iTimeBegin = time.time()
+ tmp = random.randint(-(self.__bDelay / 3), (self.__bDelay / 3))
+ self.__iDelay = self.__bDelay + tmp
+ self.__iDelayMutex.release()
+
+ def run(self):
+ """Plugin entry point for the "run" command.
+ """
+ frequency = self.configuration().getFrequency()
+ if frequency == "Rarely":
+ self.__bDelay = B_DELAY_RARELY
+ elif frequency == "Normal":
+ self.__bDelay = B_DELAY_NORMAL
+ elif frequency == "Often":
+ self.__bDelay = B_DELAY_OFTEN
+ else:
+ self.__bDelay = B_DELAY_CRAZY
+ self.__resetIdleTimeBegin()
+ self.__setDaemonRun(True)
+ while self.__getDaemonRun():
+ if (time.time() - self.__getIdleTimeBegin()) >= self.__iDelay:
+ self.__resetIdleTimeBegin()
+ idx = random.randint(0, len(ATTIUNE_NAMES_LIST) - 1)
+ self.throwNotification("start")
+ self.throwActuation("playAttitune", ATTIUNE_NAMES_LIST[idx])
+ self.throwNotification("stop")
+ for i in range(10):
+ if not self.__getDaemonRun():
+ break
+ time.sleep(0.25)
+
+ def onPluginStop(self):
+ """Callback on plugin stop.
+ """
+ self.__setDaemonRun(False)
+
+ def onPluginEvent(self, eventName, eventValues):
+ """Callback on plugin event.
+ @param eventName: Event name.
+ @param eventValues: Event values.
+ """
+ pass
+
+if __name__ == "__main__":
+ plugin = MerryTuxmasPlugin()
+ plugin.boot(sys.argv[1:], Configuration())
|