Author: duncan
Date: Fri Oct 19 03:53:56 2007
New Revision: 10001

Log:
Tidy up of the plug-in interfaces
audio.musicip has a multiple interfaces and the plugins helper does not handle 
this
Corrected OSD_OVERSCAN_X to OSD_OVERSCAN_LEFT for favoriteitem


Modified:
   branches/rel-1/freevo/src/audio/__init__.py
   branches/rel-1/freevo/src/audio/plugins/freevo_scrobbler.py
   branches/rel-1/freevo/src/audio/plugins/musicip.py
   branches/rel-1/freevo/src/games/__init__.py
   branches/rel-1/freevo/src/helpers/plugins.py
   branches/rel-1/freevo/src/image/__init__.py
   branches/rel-1/freevo/src/tv/__init__.py
   branches/rel-1/freevo/src/tv/favoriteitem.py
   branches/rel-1/freevo/src/video/__init__.py
   branches/rel-1/freevo/src/video/plugins/bilingual.py

Modified: branches/rel-1/freevo/src/audio/__init__.py
==============================================================================
--- branches/rel-1/freevo/src/audio/__init__.py (original)
+++ branches/rel-1/freevo/src/audio/__init__.py Fri Oct 19 03:53:56 2007
@@ -51,6 +51,7 @@
     """
     Plugin to handle all kinds of audio items
     """
+
     def __init__(self):
         plugin.MimetypePlugin.__init__(self)
         self.display_type = [ 'audio' ]

Modified: branches/rel-1/freevo/src/audio/plugins/freevo_scrobbler.py
==============================================================================
--- branches/rel-1/freevo/src/audio/plugins/freevo_scrobbler.py (original)
+++ branches/rel-1/freevo/src/audio/plugins/freevo_scrobbler.py Fri Oct 19 
03:53:56 2007
@@ -35,6 +35,7 @@
 
 
 class Scrobbler:
+
     def __init__(self):
         self.username = config.LASTFM_USER
         self.md5_pass = config.LASTFM_PASS
@@ -43,13 +44,7 @@
         self.password = hasher.hexdigest()
 
     def config(self):
-        '''config is called automatically,
-        freevo plugins -i video.bilingual returns the info
-        '''
-        return [
-            ('LASTFM_USER', 'None', 'User id for last fm'),
-            ('LASTFM_PASS', 'None', 'Password for last fm'),
-        ]
+        pass
 
     def send_handshake(self):
         url = URL + "&u=%s" % self.username

Modified: branches/rel-1/freevo/src/audio/plugins/musicip.py
==============================================================================
--- branches/rel-1/freevo/src/audio/plugins/musicip.py  (original)
+++ branches/rel-1/freevo/src/audio/plugins/musicip.py  Fri Oct 19 03:53:56 2007
@@ -48,6 +48,120 @@
 from urllib import urlencode
 from httplib import HTTPConnection
 
+
+class PluginInterface(plugin.ItemPlugin, plugin.MainMenuPlugin):
+    """
+    This plugin allows you to create a new mix based on MusicIP's automatic 
mixing
+    feature.  It also allows browsing by Genre, Album, or Artist.
+    """
+
+    def __init__(self):
+        server = config.MUSICIP_SERVER
+        self.service = MusicIPClient(server)
+        plugin.ItemPlugin.__init__(self)
+        plugin.MainMenuPlugin.__init__(self)
+
+
+    def config(self):
+        '''config is called automatically, for default settings run:
+        freevo plugins -i audio.musicip
+        '''
+        return [
+            ('MUSICIP_SERVER', '127.0.0.1:10002', 'IP address and port of the 
music ip server'),
+        ]
+
+
+    def items(self, parent):
+        return [GenresItem(parent, self.service),
+        ArtistsItem(parent, self.service),
+        AlbumsItem(parent, self.service)]
+
+
+    def actions(self, item):
+        self.item = item
+        #print 'actions called for item', item
+        items = []
+        if item.type in ('audio', 'playlist'):
+            items.append((self.file_mix, _('MusicIP Mix'), 'musicip_file_mix'))
+        if item.type == 'audio':
+            items.append((self.file_play_album, _('Songs From Same Album'), 
'musicip_file_play_album'))
+            items.append((self.file_play_all_by_artist, _('Songs From Same 
Artist'), 'musicip_file_play_all_by_artist'))
+
+        return items
+
+
+    def file_mix(self, arg=None, menuw=None):
+        kwargs = {}
+        try:
+            if self.item.type == 'playlist':
+                filenames = self.service.getMix(playlist=self.item.filename)
+            elif self.item.type == 'audio':
+                filenames = self.service.getMix(song=self.item.filename)
+            else:
+                print 'Bad file type', self.item.type, self.item.filename, 
'for MusicIP mix'
+        except MusicIPException, x:
+            pop = PopupBox(text=_(str(x)))
+            pop.show()
+            time.sleep(2)
+            pop.destroy()
+            return
+
+        #file = NamedTemporaryFile(prefix="freevo-musicip-playlist", 
suffix=".tmp")
+        #file.write(m3u)
+        #print '\n'.join(filenames)
+        #items = [kaa.beacon.query(filename=f) for f in filenames]
+        playlist = Playlist('MusicIP Mix', playlist=filenames, 
display_type="audio", autoplay=True)
+        playlist.browse(arg=arg, menuw=menuw)
+
+
+    def file_play_album(self, arg=None, menuw=None):
+        kwargs = {}
+        try:
+            if self.item.type == 'audio':
+                songInfo = self.service.getSongInfo(file=self.item.filename)
+                filenames = 
self.service.getSongs(album=songInfo['artist']+'@@'+songInfo['album'])
+            else:
+                print 'Bad file type', self.item.type, self.item.filename, 
'for MusicIP mix'
+        except MusicIPException, x:
+            pop = PopupBox(text=_(str(x)))
+            pop.show()
+            time.sleep(2)
+            pop.destroy()
+            return
+
+        #file = NamedTemporaryFile(prefix="freevo-musicip-playlist", 
suffix=".tmp")
+        #file.write(m3u)
+        #print '\n'.join(filenames)
+        #items = [kaa.beacon.query(filename=f) for f in filenames]
+        playlist = Playlist('%s - %s' % (songInfo['artist'], 
songInfo['album']), \
+            playlist=filenames, display_type="audio", autoplay=True)
+        playlist.browse(arg=arg, menuw=menuw)
+
+
+    def file_play_all_by_artist(self, arg=None, menuw=None):
+        kwargs = {}
+        try:
+            if self.item.type == 'audio':
+                songInfo = self.service.getSongInfo(file=self.item.filename)
+                filenames = self.service.getSongs(artist=songInfo['artist'])
+            else:
+                print 'Bad file type', self.item.type, self.item.filename, 
'for MusicIP mix'
+        except MusicIPException, x:
+            pop = PopupBox(text=_(str(x)))
+            pop.show()
+            time.sleep(2)
+            pop.destroy()
+            return
+
+        #file = NamedTemporaryFile(prefix="freevo-musicip-playlist", 
suffix=".tmp")
+        #file.write(m3u)
+        #print '\n'.join(filenames)
+        #items = [kaa.beacon.query(filename=f) for f in filenames]
+        playlist = Playlist(songInfo['artist'], playlist=filenames, 
display_type="audio", autoplay=True)
+        playlist.browse(arg=arg, menuw=menuw)
+
+
+
 class MusicIPException(Exception):
     pass
 
@@ -384,115 +498,3 @@
             time.sleep(2)
             pop.destroy()
             return
-
-
-
-class PluginInterface(plugin.ItemPlugin, plugin.MainMenuPlugin):
-    """
-    This plugin allows you to create a new mix based on MusicIP's automatic 
mixing
-    feature.  It also allows browsing by Genre, Album, or Artist.
-    """
-
-    def __init__(self):
-        server = config.MUSICIP_SERVER
-        self.service = MusicIPClient(server)
-        plugin.ItemPlugin.__init__(self)
-        plugin.MainMenuPlugin.__init__(self)
-
-
-    def config(self):
-        '''config is called automatically, for default settings run:
-        freevo plugins -i audio.musicip
-        '''
-        return [
-            ('MUSICIP_SERVER', '127.0.0.1:10002', 'IP address and port of the 
music ip server'),
-        ]
-
-
-    def items(self, parent):
-        return [GenresItem(parent, self.service),
-        ArtistsItem(parent, self.service),
-        AlbumsItem(parent, self.service)]
-
-
-    def actions(self, item):
-        self.item = item
-        #print 'actions called for item', item
-        items = []
-        if item.type in ('audio', 'playlist'):
-            items.append((self.file_mix, _('MusicIP Mix'), 'musicip_file_mix'))
-        if item.type == 'audio':
-            items.append((self.file_play_album, _('Songs From Same Album'), 
'musicip_file_play_album'))
-            items.append((self.file_play_all_by_artist, _('Songs From Same 
Artist'), 'musicip_file_play_all_by_artist'))
-
-        return items
-
-
-    def file_mix(self, arg=None, menuw=None):
-        kwargs = {}
-        try:
-            if self.item.type == 'playlist':
-                filenames = self.service.getMix(playlist=self.item.filename)
-            elif self.item.type == 'audio':
-                filenames = self.service.getMix(song=self.item.filename)
-            else:
-                print 'Bad file type', self.item.type, self.item.filename, 
'for MusicIP mix'
-        except MusicIPException, x:
-            pop = PopupBox(text=_(str(x)))
-            pop.show()
-            time.sleep(2)
-            pop.destroy()
-            return
-
-        #file = NamedTemporaryFile(prefix="freevo-musicip-playlist", 
suffix=".tmp")
-        #file.write(m3u)
-        #print '\n'.join(filenames)
-        #items = [kaa.beacon.query(filename=f) for f in filenames]
-        playlist = Playlist('MusicIP Mix', playlist=filenames, 
display_type="audio", autoplay=True)
-        playlist.browse(arg=arg, menuw=menuw)
-
-
-    def file_play_album(self, arg=None, menuw=None):
-        kwargs = {}
-        try:
-            if self.item.type == 'audio':
-                songInfo = self.service.getSongInfo(file=self.item.filename)
-                filenames = 
self.service.getSongs(album=songInfo['artist']+'@@'+songInfo['album'])
-            else:
-                print 'Bad file type', self.item.type, self.item.filename, 
'for MusicIP mix'
-        except MusicIPException, x:
-            pop = PopupBox(text=_(str(x)))
-            pop.show()
-            time.sleep(2)
-            pop.destroy()
-            return
-
-        #file = NamedTemporaryFile(prefix="freevo-musicip-playlist", 
suffix=".tmp")
-        #file.write(m3u)
-        #print '\n'.join(filenames)
-        #items = [kaa.beacon.query(filename=f) for f in filenames]
-        playlist = Playlist('%s - %s'%(songInfo['artist'], songInfo['album']), 
playlist=filenames, display_type="audio", autoplay=True)
-        playlist.browse(arg=arg, menuw=menuw)
-
-
-    def file_play_all_by_artist(self, arg=None, menuw=None):
-        kwargs = {}
-        try:
-            if self.item.type == 'audio':
-                songInfo = self.service.getSongInfo(file=self.item.filename)
-                filenames = self.service.getSongs(artist=songInfo['artist'])
-            else:
-                print 'Bad file type', self.item.type, self.item.filename, 
'for MusicIP mix'
-        except MusicIPException, x:
-            pop = PopupBox(text=_(str(x)))
-            pop.show()
-            time.sleep(2)
-            pop.destroy()
-            return
-
-        #file = NamedTemporaryFile(prefix="freevo-musicip-playlist", 
suffix=".tmp")
-        #file.write(m3u)
-        #print '\n'.join(filenames)
-        #items = [kaa.beacon.query(filename=f) for f in filenames]
-        playlist = Playlist(songInfo['artist'], playlist=filenames, 
display_type="audio", autoplay=True)
-        playlist.browse(arg=arg, menuw=menuw)

Modified: branches/rel-1/freevo/src/games/__init__.py
==============================================================================
--- branches/rel-1/freevo/src/games/__init__.py (original)
+++ branches/rel-1/freevo/src/games/__init__.py Fri Oct 19 03:53:56 2007
@@ -49,6 +49,7 @@
     """
     Plugin to handle all kinds of games items
     """
+
     def __init__(self):
         plugin.MimetypePlugin.__init__(self)
         self.display_type = [ 'games' ]

Modified: branches/rel-1/freevo/src/helpers/plugins.py
==============================================================================
--- branches/rel-1/freevo/src/helpers/plugins.py        (original)
+++ branches/rel-1/freevo/src/helpers/plugins.py        Fri Oct 19 03:53:56 2007
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: iso-8859-1 -*-
 # -----------------------------------------------------------------------
 # plugins.py - list all plugins and prints help about them
@@ -39,6 +38,92 @@
 import re
 import os
 import sys
+import imp
+
+
+def find_plugin_interface(data):
+    """
+    Search a source file for the PluginInterface classes
+    @returns a list of classes source code as a string
+    """
+
+    has_classes = re.compile('\n\s*(class[^\n]*:.*?)((\n\s*class)|($))', 
re.DOTALL)
+    has_plugin = re.compile('\n *class PluginInterface *(.*) *:')
+    classes = []
+    while 1:
+        res = has_classes.search(data)
+        if not res:
+            break
+        begin, end = res.span()
+        length = len(res.groups()[1])
+        classes.append(data[begin:end-length])
+        data = data[end-length:]
+
+    class_srcs = []
+    for class_src in classes:
+        if has_plugin.search(class_src):
+            class_srcs.append(class_src)
+
+    return class_srcs
+
+
+def parse_plugins2():
+    """
+    The idea is to extract the PluginInterface class or classes from the 
source module
+    and then to import it and extract the __doc__ string from the Class and 
the 
+    config() from the class instance.
+
+    This does't quite work, neither does import PluginInterface from <m> as <a>
+    nor do any of the import methods that I've tried. I've left this code in to
+    remind any that this techique does work in all cases, it does work in come
+    cases and from the freevo prompt.
+    """
+
+    import time
+    import pygame
+    from screensaver import ScreenSaverPlugin
+    from idlebar import IdleBarPlugin
+    from util import Rendezvous
+    import osd
+    osd = osd.get_singleton()
+
+    all_plugins = []
+    print 'FREEVO_PYTHON', os.environ['FREEVO_PYTHON']
+    print 'PYTHONPATH', os.environ['PYTHONPATH']
+    for file in util.recursefolders(os.environ['FREEVO_PYTHON'], 1, '*.py', 1):
+        if file.find('plugin.py') > 0:
+            continue
+
+        data = open(file, 'r').read()
+        for plugin_interface in find_plugin_interface(data):
+            if not plugin_interface:
+                print 'Can\'t find interface in %s' % file
+                continue
+
+            try:
+                exec plugin_interface
+            except Exception, e:
+                print 'Error:1:%s: %s' % (file, e)
+                break
+
+            print '<<<%s>>>' % file
+            print PluginInterface.__bases__
+            for base in PluginInterface.__bases__:
+                print base.__name__
+            print PluginInterface.__doc__
+
+            try:
+                interface = PluginInterface()
+                print interface.config()
+            except Exception, e:
+                print 'Error:2:%s: %s' % (file, e)
+                continue
+
+            interface = None
+            PluginInterface = None
+
+    return ''
+
 
 def parse_plugins():
     start = re.compile('^class *(.*)\((.*Plugin\s*).:')
@@ -420,7 +505,7 @@
             modules = sys.argv[2:]
     all_plugins = parse_plugins()
 
-    # This is a bit horrid
+    # This is a bit horrid, should do this cleaner
     if mode == 'trac':
         print '[[TOC(depth=2)]]'
     else:

Modified: branches/rel-1/freevo/src/image/__init__.py
==============================================================================
--- branches/rel-1/freevo/src/image/__init__.py (original)
+++ branches/rel-1/freevo/src/image/__init__.py Fri Oct 19 03:53:56 2007
@@ -45,6 +45,7 @@
     """
     Plugin to handle all kinds of image items
     """
+
     def __init__(self):
         plugin.MimetypePlugin.__init__(self)
         self.display_type = [ 'image' ]

Modified: branches/rel-1/freevo/src/tv/__init__.py
==============================================================================
--- branches/rel-1/freevo/src/tv/__init__.py    (original)
+++ branches/rel-1/freevo/src/tv/__init__.py    Fri Oct 19 03:53:56 2007
@@ -35,6 +35,9 @@
 # Plugin interface to integrate the tv module into Freevo
 #
 class PluginInterface(plugin.MainMenuPlugin):
+    """
+    TV main menu option
+    """
 
     def items(self, parent):
         import tvmenu

Modified: branches/rel-1/freevo/src/tv/favoriteitem.py
==============================================================================
--- branches/rel-1/freevo/src/tv/favoriteitem.py        (original)
+++ branches/rel-1/freevo/src/tv/favoriteitem.py        Fri Oct 19 03:53:56 2007
@@ -167,7 +167,7 @@
         """
         self.menuw = menuw
         InputBox(text=_('Alter Name'), handler=self.alter_name,
-                 width = osd.get_singleton().width - config.OSD_OVERSCAN_X - 
20,
+                 width = osd.get_singleton().width - config.OSD_OVERSCAN_LEFT 
- 20,
                  input_text=self.name).show()
 
 

Modified: branches/rel-1/freevo/src/video/__init__.py
==============================================================================
--- branches/rel-1/freevo/src/video/__init__.py (original)
+++ branches/rel-1/freevo/src/video/__init__.py Fri Oct 19 03:53:56 2007
@@ -51,6 +51,7 @@
     """
     Plugin to handle all kinds of video items
     """
+
     def __init__(self):
         plugin.MimetypePlugin.__init__(self)
         self.display_type = [ 'video' ]

Modified: branches/rel-1/freevo/src/video/plugins/bilingual.py
==============================================================================
--- branches/rel-1/freevo/src/video/plugins/bilingual.py        (original)
+++ branches/rel-1/freevo/src/video/plugins/bilingual.py        Fri Oct 19 
03:53:56 2007
@@ -5,8 +5,6 @@
 # $Id$
 #
 # Notes:
-#    To activate, put the following line in local_conf.py:
-#       plugin.activate('video.bilingual')
 # ToDo:
 #
 # -----------------------------------------------------------------------
@@ -44,6 +42,9 @@
 class PluginInterface(plugin.ItemPlugin):
     """
     Plug-in to play tv recordings which have bilingual audio
+
+    To activate, put the following line in local_conf.py:
+    | plugin.activate('video.bilingual')
     """
 
     def __init__(self):

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to