[tuxdroid-svn] r4683 - software_suite_v3/smart-core/smart-server/trunk/resources/03_content_servers
Status: Beta
Brought to you by:
ks156
|
From: remi <c2m...@c2...> - 2009-05-27 08:29:14
|
Author: remi
Date: 2009-05-27 10:29:03 +0200 (Wed, 27 May 2009)
New Revision: 4683
Modified:
software_suite_v3/smart-core/smart-server/trunk/resources/03_content_servers/01_resourcePluginsServer.py
Log:
* linked plugin/gadget message to the TTS stack
* removed useless events
Modified: software_suite_v3/smart-core/smart-server/trunk/resources/03_content_servers/01_resourcePluginsServer.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/resources/03_content_servers/01_resourcePluginsServer.py 2009-05-26 17:16:12 UTC (rev 4682)
+++ software_suite_v3/smart-core/smart-server/trunk/resources/03_content_servers/01_resourcePluginsServer.py 2009-05-27 08:29:03 UTC (rev 4683)
@@ -14,28 +14,14 @@
ST_NAME_PS_CONTAINER_ERROR = "plugins_server_container_error"
ST_NAME_PS_PLUGIN_LOADED = "plugins_server_plugin_loaded"
ST_NAME_PS_PLUGIN_UNLOADED = "plugins_server_plugin_unloaded"
-ST_NAME_PS_PLUGIN_MESSAGE = "plugins_server_plugin_message"
-ST_NAME_PS_PLUGIN_ERROR = "plugins_server_plugin_error"
-ST_NAME_PS_PLUGIN_TRACE = "plugins_server_plugin_trace"
-ST_NAME_PS_PLUGIN_RESULT = "plugins_server_plugin_result"
-ST_NAME_PS_PLUGIN_NOTIFICATION = "plugins_server_plugin_notification"
-ST_NAME_PS_PLUGIN_STARTING = "plugins_server_plugin_starting"
-ST_NAME_PS_PLUGIN_STOPPED = "plugins_server_plugin_stopped"
# Framework events/statuses list
SW_NAME_PLUGINS_SERVER = [
ST_NAME_PS_RUN, # Is sent to clients
ST_NAME_PS_CONTAINER_DEPLOYED, # Is sent to clients
- ST_NAME_PS_PLUGIN_STARTING, # Is sent to clients
- ST_NAME_PS_PLUGIN_STOPPED, # Is sent to clients
ST_NAME_PS_CONTAINER_ERROR, # Is not sent to clients
ST_NAME_PS_PLUGIN_LOADED, # Is not sent to clients
ST_NAME_PS_PLUGIN_UNLOADED, # Is not sent to clients
- ST_NAME_PS_PLUGIN_MESSAGE, # Is not sent to clients
- ST_NAME_PS_PLUGIN_ERROR, # Is not sent to clients
- ST_NAME_PS_PLUGIN_TRACE, # Is not sent to clients
- ST_NAME_PS_PLUGIN_RESULT, # Is not sent to clients
- ST_NAME_PS_PLUGIN_NOTIFICATION, # Is not sent to clients
]
# ------------------------------------------------------------------------------
@@ -164,8 +150,6 @@
pitch = instanceParameters['pitch']
self.logger.logDebug("Plugin NOTIFICATION [%s] (%s : %s)" % (
plugin.getDescription().getName(), messageId, messageStr))
- self.__publishEvents(False, ST_NAME_PS_PLUGIN_NOTIFICATION, [uuid, "0",
- locutor, pitch, messageId, messageStr])
def __onPluginMessage(self, plugin, instanceParameters, message):
uuid = plugin.getDescription().getUuid()
@@ -173,8 +157,7 @@
pitch = instanceParameters['pitch']
self.logger.logDebug("Plugin MESSAGE [%s] (%s)" % (
plugin.getDescription().getName(), message))
- self.__publishEvents(False, ST_NAME_PS_PLUGIN_MESSAGE, [uuid, "0",
- locutor, pitch, message])
+ self.__pushPluginMessageInTtsStack(uuid, message, locutor, int(pitch))
def __onPluginError(self, plugin, instanceParameters, *messagesList):
messageStr = ""
@@ -182,8 +165,6 @@
messageStr += message
self.logger.logError("Plugin ERROR [%s] (%s)" % (
plugin.getDescription().getName(), messageStr))
- self.__publishEvents(False, ST_NAME_PS_PLUGIN_ERROR, [
- plugin.getDescription().getUuid(), "0", messageStr])
def __onPluginTrace(self, plugin, instanceParameters, *messagesList):
messageStr = ""
@@ -191,21 +172,17 @@
messageStr += message
self.logger.logDebug("Plugin TRACE [%s] (%s)" % (
plugin.getDescription().getName(), messageStr))
- self.__publishEvents(False, ST_NAME_PS_PLUGIN_TRACE, [
- plugin.getDescription().getUuid(), "0", messageStr])
def __onPluginResult(self, plugin, instanceParameters, pluginResult):
self.logger.logDebug("Plugin RESULT [%s] (%s)" % (
plugin.getDescription().getName(), str(pluginResult)))
- self.__publishEvents(False, ST_NAME_PS_PLUGIN_RESULT, [
- plugin.getDescription().getUuid(), "0", str(pluginResult)])
def __onPluginStarting(self, plugin, instanceParameters, instanceCommand,
instanceIsDaemon):
uuid = plugin.getDescription().getUuid()
self.logger.logInfo("Plugin starting [%s] (%s)" % (
plugin.getDescription().getName(), str(instanceParameters)))
- self.__publishEvents(True, ST_NAME_PS_PLUGIN_STARTING, [uuid, "PS"])
+ self.__pluginStopEventFromStartEvent(uuid)
def __onPluginStopped(self, plugin, instanceParameters, instanceCommand,
instanceIsDaemon):
@@ -213,15 +190,39 @@
if instanceIsDaemon:
self.logger.logInfo("Plugin stopped [%s]" % (
plugin.getDescription().getName()))
- self.__publishEvents(True, ST_NAME_PS_PLUGIN_STOPPED, [uuid, "PS"])
- self.__publishEvents(True, ST_NAME_PS_PLUGIN_STOPPED, [uuid, "TTS"])
else:
- self.__publishEvents(True, ST_NAME_PS_PLUGIN_STOPPED, [uuid, "PS"])
+ pass
# --------------------------------------------------------------------------
# Private methods
# --------------------------------------------------------------------------
+ def __pushPluginMessageInTtsStack(self, uuid, message, locutor, pitch):
+ resourceTTS.stackPush(message, locutor, pitch, uuid)
+
+ def __pluginStopEventFromStartEvent(self, uuid):
+ plugin = self.__pluginsContainer.getPluginByUuid(uuid)
+ if plugin == None:
+ return
+ if plugin.instanceIsDaemon():
+ return
+ def async():
+ pluginName = plugin.getDescription().getName()
+ if not resourceTTS.stackIsFilled(uuid):
+ time.sleep(0.5)
+ if not resourceTTS.stackIsFilled(uuid):
+ if not eventsHandler.waitCondition(ST_NAME_TTS_STACK_FILLING,
+ (uuid, None), 10.0):
+ self.logger.logInfo("Plugin stopped [%s]" % pluginName)
+ # Event plugin stop
+ return
+ eventsHandler.waitCondition(ST_NAME_TTS_STACK_EMPTY, (uuid, None),
+ 600.0)
+ self.logger.logInfo("Plugin stopped [%s]" % pluginName)
+ # Event plugin stop
+ t = threading.Thread(target = async)
+ t.start()
+
def __publishEvents(self, sendToClients, eventName, eventValues = []):
def async():
values = ""
|