Ikke's Blog

Post details: One more status update

Jun 14
One more status update

I implemented Python plugin loading this afternoon. It's almost finished, only calling functions does not work yet (thats only like 10 lines or so, but my eyes start to hurt). It's using the Python plugin base class I blogged about yesterday.

The code is far from perfect, it might leak like hell etc, but hey, it's working ;-) You can't debug or clean code that is not working at all :-)

Here's the current output of the test loader I wrote:

** (process:19360): DEBUG: Loading all modules in .libs
** (process:19360): DEBUG: Suffix for .libs/libtestplugin1.so is valid, loading module
** (process:19360): DEBUG: [OPluginManagerPlugin] [test-plugin1] Got an init function
** (process:19360): DEBUG: [test-plugin1] Init with data "test-init-data"
** (process:19360): DEBUG: Module .libs/libtestplugin1.so is valid, adding
** (process:19360): DEBUG: Suffix for .libs/libtestplugin2.so is valid, loading module
** (process:19360): DEBUG: Module .libs/libtestplugin2.so is valid, adding
** (process:19360): DEBUG: Loading all modules in .
** (process:19360): DEBUG: Suffix for ./TestPlugin.py is valid, loading module
Creating new OPluginManagerPythonPlugin instance: PythonTest
** (process:19360): DEBUG: Module ./TestPlugin.py is valid, adding


Found 3 modules
** (process:19360): DEBUG: Dumping module 0:


================================================
Dumping data for: .libs/libtestplugin1.so, type is "native"
=================
* Name: test-plugin1
* Summary: A simple test plugin, full-featured
* Description: This is a sample test plugin, to test the OPluginManager functionality, giving sample usage of all possibilities
* Version: 0.1
* URI: http://www.eikke.com
* Authors:
        ikke
        -----------
                Email: eikke eikke com
                URI: http://www.eikke.com
* Module got an init function
* Module got a data free function
* Module got a configure function
================================================



** (process:19360): DEBUG: Dumping module 1:


================================================
Dumping data for: .libs/libtestplugin2.so, type is "native"
=================
* Name: test-plugin2
* Summary: A simple, small test plugin
* Description: This is a sample test plugin, to test the OPluginManager functionality. It only offers limited functionality
* Version: 0.1
* URI: http://www.eikke.com
* Authors:
        ikke
        -----------
                Email: eikke eikke com
                URI: http://www.eikke.com
        John Doe
        -----------
                Email: foo@bar.com
                URI: http://www.foobar.foo
* Module got no init function
* Module got no data free function
* Module got no configure function
================================================



** (process:19360): DEBUG: Dumping module 2:


================================================
Dumping data for: ./TestPlugin.py, type is "Python"
=================
* Name: PythonTest
* Summary: A little test plugin
* Description: Some longer description of this test plugin
* Version: 0.1
* URI: http://www.eikke.com
* Authors:
        Ikke
        -----------
                Email: eikke eikke com
                URI: http://www.eikke.com
* Module got no init function
* Module got no data free function
* Module got no configure function
================================================



** (process:19360): DEBUG: Deleting 3 modules
** (process:19360): DEBUG: [OPluginManagerPlugin] Freeing "test-plugin1" data
** (process:19360): DEBUG: [OPluginManagerPlugin] Running free function
** (process:19360): DEBUG: [test-plugin1] Freeing data "Test plugin 1 data"
** (process:19360): DEBUG: [OPluginManagerPlugin] Freeing "test-plugin2" data
** (process:19360): DEBUG: [OPluginManagerPlugin] No free function provided

As you can see, it loads 3 modules: 2 native (C) ones in .libs, one fully fledged, one minimal, and loads one Python plugin.
The Python plugin code is very simple, but can still offer almost the same flexibility as the C interface does:

from OPluginManagerPlugin import OPluginManagerPlugin, OPluginManagerPluginAuthor

class TestPlugin(OPluginManagerPlugin):
        def __init__(self):
                tmpauthor = OPluginManagerPluginAuthor("Ikke", "eikke eikke com", "http://www.eikke.com")
                OPluginManagerPlugin.__init__(self, "PythonTest", "A little test plugin", tmpauthor, "Some longer description of this test plugin", "0.1", "http://www.eikke.com", self.Init, self.FreeData, self.Configure)

        def Configure(self):
                print "Configuring"

        def Init(self, init_data):
                print "Initializing with data \"" + init_data + "\""
                return "testplugindata"

        def FreeData(self, data):
                print "Freeing \"" + data + "\""

def OPluginManagerPluginInit():
        return TestPlugin()

I should learn how to work with Python lists etc to be able to implement multi-author functionality etc though.

I updated CVS heavily, so you can find (and checkout) all current code here. Please play around with it and let me know what you think of it (as a comment here or on the live.gnome wiki page), so I know what I should enhance, add,...

Oh, I got one more terrible exam today (part 2 of the one I got yesterday). Life's great :-p

Comments:

Comment from: Joseph Smith [Visitor] · http://www.fiftiesweb.com/movies/gone-with-wind.htm
curious, astonishing, black nothing comparative to big: http://www.thearistocrats.com/ rape love steal - that is all that chips is capable of , standard, big, collective nothing compar
PermalinkPermalink 04/08/06 @ 15:42

Leave a comment:

Your email address will not be displayed on this site.
Your URL will be displayed.

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>
(Line breaks become <br />)
(Set cookies for name, email and url)
(Allow users to contact you through a message form (your email will NOT be displayed.))

Categories

Who's Online?

  • Guest Users: 464

Misc

XML Feeds

What is RSS?