Author: remi
Date: 2009-06-03 09:44:32 +0200 (Wed, 03 Jun 2009)
New Revision: 4726

Modified:
   
software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimplePlugin.py
   
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/interpreters/PluginInterpreter.py
Log:
* added handling of the events from the server to the pyhton SimplePlugin call
* fixed event header name (uppercase to lowercase)

Modified: 
software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimplePlugin.py
===================================================================
--- 
software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimplePlugin.py
   2009-06-02 14:35:56 UTC (rev 4725)
+++ 
software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimplePlugin.py
   2009-06-03 07:44:32 UTC (rev 4726)
@@ -53,6 +53,14 @@
         pass
 
     # 
--------------------------------------------------------------------------
+    # On plugin event. Must be overrided
+    # 
--------------------------------------------------------------------------
+    def onPluginEvent(self, eventName, eventValues):
+        """On plugin event. Must be overrided
+        """
+        pass
+
+    # 
--------------------------------------------------------------------------
     # Stop the plugin.
     # 
--------------------------------------------------------------------------
     def stop(self):
@@ -98,6 +106,20 @@
             if line.lower().find("stop") == 0:
                 self.onPluginStop()
                 self.__setRun(False)
+            elif line.lower().find("event") == 0:
+                sltLine = line.split(":")
+                # Get event name
+                if len(sltLine) > 1:
+                    eventName = sltLine[1]
+                    # Get event values
+                    eventValues = []
+                    if len(sltLine) > 2:
+                        for value in sltLine[2:]:
+                            eventValues.append(value)
+                    # Callback
+                    t = threading.Thread(target = self.onPluginEvent,
+                        args = (eventName, eventValues))
+                    t.start()
             time.sleep(0.1)
 
     # 
--------------------------------------------------------------------------

Modified: 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/interpreters/PluginInterpreter.py
===================================================================
--- 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/interpreters/PluginInterpreter.py
     2009-06-02 14:35:56 UTC (rev 4725)
+++ 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/interpreters/PluginInterpreter.py
     2009-06-03 07:44:32 UTC (rev 4726)
@@ -234,7 +234,7 @@
             return
         if not self.__daemon:
             return
-        eventString = "EVENT:"
+        eventString = "event:"
         eventString += eventName
         for value in eventValues:
             eventString += ":" + str(value)


------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to