From f12949eb0ca70727e8728eba2048c576c6ac3cf5 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 8 Jul 2009 07:12:16 +0200 Subject: [PATCH] Fixed up a few logging things, a few bits of indentation, and resolved some conflicts from the last update. bzr-revno: 484 --- openlp/core/lib/pluginconfig.py | 2 +- openlp/core/lib/pluginmanager.py | 25 ++++++++++++++----- .../presentations/presentationplugin.py | 5 ++-- openlp/plugins/songs/lib/manager.py | 11 +++++--- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/openlp/core/lib/pluginconfig.py b/openlp/core/lib/pluginconfig.py index e966fb2ed..519e4e255 100644 --- a/openlp/core/lib/pluginconfig.py +++ b/openlp/core/lib/pluginconfig.py @@ -51,7 +51,7 @@ class PluginConfig(object): return ConfigHelper.set_config(self.section, key, value) def get_data_path(self): - app_data = ConfigHelper.get_data_path() + #app_data = ConfigHelper.get_data_path() app_data = ConfigHelper.get_data_path() safe_name = self.section.replace(u' ',u'-') plugin_data = self.get_config(u'data path', safe_name) diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 38cb9b477..b557400b9 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -53,7 +53,7 @@ class PluginManager(object): """ self.plugin_helpers = plugin_helpers startdepth = len(os.path.abspath(dir).split(os.sep)) - log.debug(u'find plugins %s at depth %d' %( unicode(dir), startdepth)) + log.debug(u'find plugins %s at depth %d', unicode(dir), startdepth) for root, dirs, files in os.walk(dir): for name in files: @@ -69,34 +69,46 @@ class PluginManager(object): modulename = modulename[len(prefix) + 1:] modulename = modulename.replace(os.path.sep, '.') # import the modules - log.debug(u'Importing %s from %s. Depth %d' % (modulename, path, thisdepth)) + log.debug(u'Importing %s from %s. Depth %d', modulename, path, thisdepth) try: __import__(modulename, globals(), locals(), []) except ImportError, e: - log.error(u'Failed to import module %s on path %s for reason %s', modulename, path, sys.exc_info()[1]) + log.error(u'Failed to import module %s on path %s for reason %s', modulename, path, e.args[0]) self.plugin_classes = Plugin.__subclasses__() self.plugins = [] plugin_objects = [] for p in self.plugin_classes: try: plugin = p(self.plugin_helpers) - log.debug(u'loaded plugin %s with helpers'%unicode(p)) + log.debug(u'loaded plugin %s with helpers', unicode(p)) log.debug(u'Plugin: %s', unicode(p)) if plugin.check_pre_conditions(): - log.debug(u'Appending %s ', unicode(p)) + log.debug(u'Appending %s ', unicode(p)) plugin_objects.append(plugin) eventmanager.register(plugin) except TypeError: - log.error(u'loaded plugin %s has no helpers'%unicode(p)) + log.error(u'loaded plugin %s has no helpers', unicode(p)) self.plugins = sorted(plugin_objects, self.order_by_weight) def order_by_weight(self, x, y): + """ + Sort two plugins and order them by their weight. + + ``x`` + The first plugin. + + ``y`` + The second plugin. + """ return cmp(x.weight, y.weight) def hook_media_manager(self, mediatoolbox): """ Loop through all the plugins. If a plugin has a valid media manager item, add it to the media manager. + + ``mediatoolbox`` + The Media Manager itself. """ for plugin in self.plugins: media_manager_item = plugin.get_media_manager_item() @@ -140,3 +152,4 @@ class PluginManager(object): """ for plugin in self.plugins: plugin.initialise() + diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 1bc95ef26..42f5930bf 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -42,8 +42,8 @@ class PresentationPlugin(Plugin): QtGui.QIcon.Normal, QtGui.QIcon.Off) def get_settings_tab(self): - self.presentation_tab = PresentationTab() - return self.presentation_tab + #self.presentation_tab = PresentationTab() + return None #self.presentation_tab def get_media_manager_item(self): # Create the MediaManagerItem object @@ -54,3 +54,4 @@ class PresentationPlugin(Plugin): log.debug('check_pre_conditions') self.openoffice = Openoffice() return self.openoffice.checkOoPid() + diff --git a/openlp/plugins/songs/lib/manager.py b/openlp/plugins/songs/lib/manager.py index c4c7a1fa6..bfe795f6e 100644 --- a/openlp/plugins/songs/lib/manager.py +++ b/openlp/plugins/songs/lib/manager.py @@ -47,8 +47,7 @@ class SongManager(): self.db_url = u'' db_type = self.config.get_config(u'db type', u'sqlite') if db_type == u'sqlite': - self.db_url = u'sqlite:///' + self.config.get_data_path() + \ - u'/songs.sqlite' + self.db_url = u'sqlite:///%s/songs.sqlite' % self.config.get_data_path() else: self.db_url = db_type + 'u://' + \ self.config.get_config(u'db username') + u':' + \ @@ -73,13 +72,17 @@ class SongManager(): """ Searches the song title for keywords. """ - return self.session.query(Song).filter(Song.search_title.like(u'%' + keywords + u'%')).order_by(Song.search_title.asc()).all() + return self.session.query(Song).filter( + Song.search_title.like(u'%' + keywords + u'%')).order_by( + Song.search_title.asc()).all() def search_song_lyrics(self, keywords): """ Searches the song lyrics for keywords. """ - return self.session.query(Song).filter(Song.search_lyrics.like(u'%' + keywords + u'%')).order_by(Song.search_lyrics.asc()).all() + return self.session.query(Song).filter( + Song.search_lyrics.like(u'%' + keywords + u'%')).order_by( + Song.search_lyrics.asc()).all() def get_song_from_author(self, keywords): """