Merge lp:~joshuascotton/entertainer/pluginsV2 into lp:entertainer

Proposed by Joshua Scotton
Status: Rejected
Rejected by: Paul Hummer
Proposed branch: lp:~joshuascotton/entertainer/pluginsV2
Merge into: lp:entertainer
To merge this branch: bzr merge lp:~joshuascotton/entertainer/pluginsV2
Reviewer Review Type Date Requested Status
Paul Hummer Needs Fixing
Entertainer Release Team preliminary Pending
Review via email: mp+1474@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Joshua Scotton (joshuascotton) wrote :
Download full text (5.6 KiB)

=== modified file 'entertainerlib/__init__.py'
--- entertainerlib/__init__.py 2008-06-22 05:08:20 +0000
+++ entertainerlib/__init__.py 2008-10-31 15:30:32 +0000
@@ -1,1 +1,3 @@
 '''Entertainer libraries'''
+
+__version__ = 0.2

=== modified file 'entertainerlib/frontend/frontend_client.py'
--- entertainerlib/frontend/frontend_client.py 2008-08-14 23:53:09 +0000
+++ entertainerlib/frontend/frontend_client.py 2008-10-31 15:16:15 +0000
@@ -7,6 +7,7 @@

 import sys

+from entertainerlib.utils.plugins import PluginManager
 from entertainerlib.utils.configuration import Configuration
 from entertainerlib.utils.logger import Logger
 from entertainerlib.frontend.backend_connection import BackendConnection
@@ -48,6 +49,15 @@

         self.config = Configuration()
         self.logger = Logger().getLogger('frontend.FrontendClient')
+
+ self.pm = PluginManager()
+
+ print "Starting plugins..."
+
+ for plugin in self.pm.get_plugins():
+ print 'Starting %s...' % (plugin)
+ plugin.load()
+
         self.backend_connection = None # Connection to the backend server
         self.feed_library = None # Feed library
         self.music_library = None # Music library

=== modified file 'entertainerlib/frontend/gui/user_interface.py'
--- entertainerlib/frontend/gui/user_interface.py 2008-10-07 23:23:12 +0000
+++ entertainerlib/frontend/gui/user_interface.py 2008-10-31 15:06:37 +0000
@@ -495,6 +495,10 @@
         @param event: UserEvent object, defines what action has been taken
         """
         type = event.get_type()
+
+ for plugin in self.frontend.pm.get_plugins_by_capability(
+ 'EventPlugin'):
+ plugin.on_event(event)

         if(type == UserEvent.PLAYER_PLAY_PAUSE):
             if self.current.is_interested_in_play_action():

=== added directory 'entertainerlib/plugins'
=== added file 'entertainerlib/plugins/__init__.py'
=== added file 'entertainerlib/utils/plugins.py'
--- entertainerlib/utils/plugins.py 1970-01-01 00:00:00 +0000
+++ entertainerlib/utils/plugins.py 2008-10-31 15:49:50 +0000
@@ -0,0 +1,87 @@
+"""Plugin Manager Class and Base Plugin Class"""
+
+__licence__ = "GPLv2"
+__copyright__ = "2008, Joshua Scotton"
+__author__ = "Joshua Scotton <email address hidden>"
+
+import os
+
+import entertainerlib
+from entertainerlib import plugins as mod_plugins
+
+
+class PluginManager:
+ """
+ @author Joshua Scotton
+ """
+
+ PLUGIN_DIRS = [ os.path.join(os.path.dirname(__file__), "../../plugins"),
+ #"/usr/share/entertainer/plugins",
+ os.path.expanduser("~/.config/entertainer/plugins") ]
+
+ plugins = {}
+
+ def __init__(self):
+ self.load_plugins()
+
+ def load_plugins(self):
+ #setup plugin paths
+ mod_plugins.__path__ = self.PLUGIN_DIRS
+
+ #load plugin names
+ plugin_names = []
+ for dir in self.PLUGIN_DIRS:
+ for name in os.listdir(dir):
+ path = os.path.join(dir, name)
+ if os.path.isdir(path) and self.is_plugin_module(path):
+ plugin_...

Read more...

Revision history for this message
Paul Hummer (rockstar) wrote :
Download full text (6.8 KiB)

Good work. It's coming along, which I'm excited about. There are still
a few niggling things still. When this gets completed, I'd like to see
if we can't port the Weather stuff to a plugin.

> === modified file 'entertainerlib/__init__.py'
> --- entertainerlib/__init__.py 2008-06-22 05:08:20 +0000
> +++ entertainerlib/__init__.py 2008-10-31 15:30:32 +0000
> @@ -1,1 +1,3 @@
> '''Entertainer libraries'''
> +
> +__version__ = 0.2
>
> === modified file 'entertainerlib/frontend/frontend_client.py'
> --- entertainerlib/frontend/frontend_client.py 2008-08-14 23:53:09 +0000
> +++ entertainerlib/frontend/frontend_client.py 2008-10-31 15:16:15 +0000
> @@ -7,6 +7,7 @@
>
> import sys
>
> +from entertainerlib.utils.plugins import PluginManager
> from entertainerlib.utils.configuration import Configuration
> from entertainerlib.utils.logger import Logger
> from entertainerlib.frontend.backend_connection import BackendConnection
> @@ -48,6 +49,15 @@
>
> self.config = Configuration()
> self.logger = Logger().getLogger('frontend.FrontendClient')
> +
> + self.pm = PluginManager()
> +
> + print "Starting plugins..."
> +
> + for plugin in self.pm.get_plugins():
> + print 'Starting %s...' % (plugin)
> + plugin.load()
> +
> self.backend_connection = None # Connection to the backend server
> self.feed_library = None # Feed library
> self.music_library = None # Music library
>

No print statements please. It's better to log them.

> === modified file 'entertainerlib/frontend/gui/user_interface.py'
> --- entertainerlib/frontend/gui/user_interface.py 2008-10-07 23:23:12 +0000
> +++ entertainerlib/frontend/gui/user_interface.py 2008-10-31 15:06:37 +0000
> @@ -495,6 +495,10 @@
> @param event: UserEvent object, defines what action has been taken
> """
> type = event.get_type()
> +
> + for plugin in self.frontend.pm.get_plugins_by_capability(
> + 'EventPlugin'):
> + plugin.on_event(event)
>
> if(type == UserEvent.PLAYER_PLAY_PAUSE):
> if self.current.is_interested_in_play_action():
>
> === added directory 'entertainerlib/plugins'
> === added file 'entertainerlib/plugins/__init__.py'
> === added file 'entertainerlib/utils/plugins.py'
> --- entertainerlib/utils/plugins.py 1970-01-01 00:00:00 +0000
> +++ entertainerlib/utils/plugins.py 2008-10-31 15:49:50 +0000
> @@ -0,0 +1,87 @@
> +"""Plugin Manager Class and Base Plugin Class"""
> +
> +__licence__ = "GPLv2"
> +__copyright__ = "2008, Joshua Scotton"
> +__author__ = "Joshua Scotton <email address hidden>"
> +
> +import os
> +
> +import entertainerlib
> +from entertainerlib import plugins as mod_plugins
> +
> +
> +class PluginManager:
> + """
> + @author Joshua Scotton
> + """
> +
> + PLUGIN_DIRS = [ os.path.join(os.path.dirname(__file__), "../../plugins"),
> + #"/usr/share/entertainer/plugins",
> + os.path.expanduser("~/.config/entertainer/plugins") ]
> +
> + plugins = {}
> +
> + def __init__(self):
> + self.load...

Read more...

Revision history for this message
Paul Hummer (rockstar) :
review: Needs Fixing

Unmerged revisions

293. By Joshua Scotton

initial work on plugin framework and demo HelloWorld plugin

Subscribers

People subscribed via source and target branches