diff --git a/openlp/core/lib/rendermanager.py b/openlp/core/lib/rendermanager.py index 36ff6a61a..324ffcb08 100644 --- a/openlp/core/lib/rendermanager.py +++ b/openlp/core/lib/rendermanager.py @@ -234,7 +234,7 @@ class RenderManager(object): realh = preview.height() # and move it to the centre of the preview space newImage = QtGui.QImage(w, h, QtGui.QImage.Format_ARGB32_Premultiplied) - newImage.fill(QtCore.Qt.transparent) + newImage.fill(QtCore.Qt.black) painter = QtGui.QPainter(newImage) painter.drawImage((w-realw) / 2, (h-realh) / 2, preview) return newImage diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index ab112e758..db7c286cc 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -437,7 +437,7 @@ class ServiceManager(QtGui.QWidget): #if not present do not worry pass except: - log.error(u'Problem processing oos load %s', sys.exc_info()[0]) + log.exception(u'Problem loading a service file') pass self.serviceName = name[len(name) - 1] self.parent.OosChanged(True, self.serviceName) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index ca320fa6e..684034fba 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -192,7 +192,8 @@ class BibleManager(object): nbible.save_meta(u'proxypass', proxypass) return True else: - log.debug(u'register_http_file_bible %s not created already exists', biblename) + log.debug(u'register_http_file_bible %s not created already exists', + biblename) return False def register_csv_file_bible(self, biblename, booksfile, versefile): @@ -201,34 +202,46 @@ class BibleManager(object): If the database exists it is deleted and the database is reloaded from scratch. """ - log.debug(u'register_CSV_file_bible %s,%s,%s', biblename, booksfile, versefile) + log.debug(u'register_CSV_file_bible %s,%s,%s', + biblename, booksfile, versefile) if self._is_new_bible(biblename): - nbible = BibleDBImpl(self.biblePath, biblename, self.config) # Create new Bible - nbible.create_tables() # Create Database - self.bible_db_cache[biblename] = nbible # cache the database for use later - bcsv = BibleCSVImpl(nbible) # create the loader and pass in the database + # Create new Bible + nbible = BibleDBImpl(self.biblePath, biblename, self.config) + # Create database + nbible.create_tables() + # Cache the database for use later + self.bible_db_cache[biblename] = nbible + # Create the loader and pass in the database + bcsv = BibleCSVImpl(nbible) bcsv.load_data(booksfile, versefile, self.dialogobject) return True else: - log.debug(u'register_csv_file_bible %s not created already exists', biblename) + log.debug(u'register_csv_file_bible %s not created already exists', + biblename) return False def register_osis_file_bible(self, biblename, osisfile): """ - Method to load a bible from a osis xml file extracted from Sword bible viewer. - If the database exists it is deleted and the database is reloaded - from scratch. + Method to load a bible from a osis xml file extracted from Sword bible + viewer. If the database exists it is deleted and the database is + reloaded from scratch. """ log.debug(u'register_OSIS_file_bible %s , %s', biblename, osisfile) if self._is_new_bible(biblename): - nbible = BibleDBImpl(self.biblePath, biblename, self.config) # Create new Bible - nbible.create_tables() # Create Database - self.bible_db_cache[biblename] = nbible # cache the database for use later - bcsv = BibleOSISImpl(self.biblePath, nbible) # create the loader and pass in the database + # Create new Bible + nbible = BibleDBImpl(self.biblePath, biblename, self.config) + # Create Database + nbible.create_tables() + # Cache the database for use later + self.bible_db_cache[biblename] = nbible + # Create the loader and pass in the database + bcsv = BibleOSISImpl(self.biblePath, nbible) bcsv.load_data(osisfile, self.dialogobject) return True else: - log.debug(u'register_OSIS_file_bible %s , %s not created already exists', biblename, osisfile) + log.debug( + u'register_OSIS_file_bible %s , %s not created already exists', + biblename, osisfile) return False def get_bibles(self, mode=BibleMode.Full): @@ -271,7 +284,8 @@ c book and chapterMaxBibleBookVerses """ log.debug(u'get_book_verse_count %s,%s,%s', bible, book, chapter) - return self.bible_db_cache[bible].get_max_bible_book_verses(book, chapter) + return self.bible_db_cache[bible].get_max_bible_book_verses( + book, chapter) def get_verse_from_text(self, bible, versetext): """ @@ -285,7 +299,8 @@ c """ Saves the bibles meta data """ - log.debug(u'save_meta data %s,%s, %s,%s', bible, version, copyright, permissions) + log.debug(u'save_meta data %s,%s, %s,%s', + bible, version, copyright, permissions) self.bible_db_cache[bible].save_meta(u'Version', version) self.bible_db_cache[bible].save_meta(u'Copyright', copyright) self.bible_db_cache[bible].save_meta(u'Permissions', permissions) @@ -297,7 +312,8 @@ c log.debug(u'get_meta %s,%s', bible, key) return self.bible_db_cache[bible].get_meta(key) - def get_verse_text(self, bible, bookname, schapter, echapter, sverse, everse=0): + def get_verse_text(self, bible, bookname, schapter, echapter, sverse, + everse=0): """ Returns a list of verses for a given Book, Chapter and ranges of verses. If the end verse(everse) is less then the start verse(sverse) @@ -311,8 +327,10 @@ c text = [] self.media.setQuickMsg1(u'') self.media.setQuickMsg2(u'') - log.debug(u'get_verse_text %s,%s,%s,%s,%s,%s', bible, bookname, schapter, echapter, sverse, everse) - # check to see if book/chapter exists fow HTTP bibles and load cache if necessary + log.debug(u'get_verse_text %s,%s,%s,%s,%s,%s', + bible, bookname, schapter, echapter, sverse, everse) + # check to see if book/chapter exists fow HTTP bibles and load cache + # if necessary if self.bible_http_cache[bible] is not None: book= self.bible_db_cache[bible].get_bible_book(bookname) if book == None: @@ -320,49 +338,61 @@ c log.debug(u'get_verse_text : new book') for chapter in range(schapter, echapter + 1): self.media.setQuickMsg2(u'%s: %s'% (bookname, chapter)) - search_results = self.bible_http_cache [bible].get_bible_chapter(bible, 0, bookname, chapter) + search_results = \ + self.bible_http_cache[bible].get_bible_chapter( + bible, 0, bookname, chapter) if search_results.has_verselist() : - ## We have found a book of the bible lets check to see if it was there. - ## By reusing the returned book name we get a correct book. - ## For example it is possible to request ac and get Acts back. + ## We have found a book of the bible lets check to see + ## if it was there. By reusing the returned book name + ## we get a correct book. For example it is possible + ## to request ac and get Acts back. bookname = search_results.get_book() # check to see if book/chapter exists - book= self.bible_db_cache[bible].get_bible_book(bookname) + book = self.bible_db_cache[bible].get_bible_book( + bookname) if book == None: ## Then create book, chapter and text - book = self.bible_db_cache[bible].create_book(bookname, \ - self.book_abbreviations[bookname], \ - self.book_testaments[bookname]) - log.debug(u'New http book %s , %s, %s', book, book.id, book.name) - self.bible_db_cache[bible].create_chapter(book.id, \ - search_results.get_chapter(),\ - search_results.get_verselist()) + book = self.bible_db_cache[bible].create_book( + bookname, self.book_abbreviations[bookname], + self.book_testaments[bookname]) + log.debug(u'New http book %s , %s, %s', + book, book.id, book.name) + self.bible_db_cache[bible].create_chapter( + book.id, search_results.get_chapter(), + search_results.get_verselist()) else: ## Book exists check chapter and texts only. - v = self.bible_db_cache[bible].get_bible_chapter(book.id, chapter) + v = self.bible_db_cache[bible].get_bible_chapter( + book.id, chapter) if v == None: - self.media.setQuickMsg2(u'%s: %s'%(bookname, chapter)) - self.bible_db_cache[bible].create_chapter(book.id, \ - chapter, \ - search_results.get_verselist()) + self.media.setQuickMsg2(u'%s: %s'% ( + bookname, chapter)) + self.bible_db_cache[bible].create_chapter( + book.id, chapter, + search_results.get_verselist()) else: log.debug(u'get_verse_text : old book') for chapter in range(schapter, echapter + 1): - v = self.bible_db_cache[bible].get_bible_chapter(book.id, chapter) + v = self.bible_db_cache[bible].get_bible_chapter( + book.id, chapter) if v == None: try: self.media.setQuickMsg1(u'Downloading') - self.media.setQuickMsg2(u'%s: %s'% (bookname, chapter)) - search_results = self.bible_http_cache [bible].get_bible_chapter(bible, book.id, bookname, chapter) + self.media.setQuickMsg2(u'%s: %s'% \ + (bookname, chapter)) + search_results = \ + self.bible_http_cache[bible].get_bible_chapter( + bible, book.id, bookname, chapter) if search_results.has_verselist(): - self.bible_db_cache[bible].create_chapter(book.id, \ - search_results.get_chapter(),\ - search_results.get_verselist()) - except : - log.error(u'Errow thrown %s', sys.exc_info()[1]) + self.bible_db_cache[bible].create_chapter( + book.id, search_results.get_chapter(), + search_results.get_verselist()) + except: + log.exception(u'Problem getting scripture online') #Now get verses from database if schapter == echapter: - text = self.bible_db_cache[bible].get_bible_text(bookname, schapter, sverse, everse) + text = self.bible_db_cache[bible].get_bible_text(bookname, + schapter, sverse, everse) else: for i in range (schapter, echapter + 1): if i == schapter: @@ -375,7 +405,8 @@ c start = 1 end = self.get_book_verse_count(bible, bookname, i) - txt = self.bible_db_cache[bible].get_bible_text(bookname, i, start, end) + txt = self.bible_db_cache[bible].get_bible_text( + bookname, i, start, end) text.extend(txt) return text diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 905b62def..a8650df00 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -23,8 +23,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA # http://www.oooforum.org/forum/viewtopic.phtml?t=5252 # http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Working_with_Presentations # http://mail.python.org/pipermail/python-win32/2008-January/006676.html -#http://www.linuxjournal.com/content/starting-stopping-and-connecting-openoffice-python -#http://nxsy.org/comparing-documents-with-openoffice-and-python +# http://www.linuxjournal.com/content/starting-stopping-and-connecting-openoffice-python +# http://nxsy.org/comparing-documents-with-openoffice-and-python import logging import os , subprocess @@ -80,8 +80,9 @@ class ImpressController(object): """ Called when a presentation is added to the SlideController. It builds the environment, starts communcations with the background - OpenOffice task started earlier. If OpenOffice is not present is ts started. - Once the environment is available the presentation is loaded and started. + OpenOffice task started earlier. If OpenOffice is not present is is + started. Once the environment is available the presentation is loaded + and started. ``presentation`` The file name of the presentatios to the run. @@ -98,19 +99,22 @@ class ImpressController(object): try: properties = [] properties = tuple(properties) - self.document = desktop.loadComponentFromURL(url, "_blank", 0, properties) + self.document = desktop.loadComponentFromURL( + url, "_blank", 0, properties) self.presentation = self.document.getPresentation() self.presentation.start() - self.xSlideShowController = desktop.getCurrentComponent().Presentation.getController() + self.xSlideShowController = \ + desktop.getCurrentComponent().Presentation.getController() except: - log.error(u'Failed reason %s' % sys.exc_info()) + log.exception(u'Failed to load presentation') def getUNODesktop(self): log.debug(u'getUNODesktop') ctx = None loop = 0 context = uno.getComponentContext() - resolver = context.ServiceManager.createInstanceWithContext(u'com.sun.star.bridge.UnoUrlResolver', context) + resolver = context.ServiceManager.createInstanceWithContext( + u'com.sun.star.bridge.UnoUrlResolver', context) while ctx == None and loop < 3: try: ctx = resolver.resolve(u'uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext') @@ -119,10 +123,11 @@ class ImpressController(object): loop += 1 try: smgr = ctx.ServiceManager - desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop", ctx ) + desktop = smgr.createInstanceWithContext( + "com.sun.star.frame.Desktop", ctx ) return desktop except: - log.error(u'Failed reason %s' % sys.exc_info()) + log.exception(u'Failed to get UNO desktop') return None def getCOMDesktop(self): @@ -132,7 +137,7 @@ class ImpressController(object): desktop = smgr.createInstance( "com.sun.star.frame.Desktop") return desktop except: - log.error(u'Failed reason %s' % sys.exc_info()) + log.exception(u'Failed to get COM desktop') return None def closePresentation(self): diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 5c2c07d3d..d76e9a493 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -29,8 +29,8 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, MediaManagerItem -from openlp.plugins.presentations.lib import PresentationMediaItem, PresentationTab, \ - ImpressController +from openlp.plugins.presentations.lib import PresentationMediaItem, \ + PresentationTab, ImpressController try: from openlp.plugins.presentations.lib import PowerpointController except: @@ -64,7 +64,8 @@ class PresentationPlugin(Plugin): """ Create the Media Manager List """ - self.media_item = PresentationMediaItem(self, self.icon, u'Presentations', self.controllers) + self.media_item = PresentationMediaItem( + self, self.icon, u'Presentations', self.controllers) return self.media_item def registerControllers(self, handle, controller): @@ -77,7 +78,8 @@ class PresentationPlugin(Plugin): """ log.debug('check_pre_conditions') #Lets see if Impress is required (Default is Not wanted) - if int(self.config.get_config(u'Impress', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: + if int(self.config.get_config( + u'Impress', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: try: if os.name == u'nt': #Check to see if we are Win32 @@ -88,25 +90,27 @@ class PresentationPlugin(Plugin): openoffice = ImpressController() self.registerControllers(u'Impress', openoffice) except: - log.error(u'Reason : %s', sys.exc_info()) + log.exception(u'Failed to set up plugin for Impress') #Lets see if Powerpoint is required (Default is Not wanted) - if int(self.config.get_config(u'Powerpoint', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: + if int(self.config.get_config( + u'Powerpoint', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: try: #Check to see if we are Win32 from win32com.client import Dispatch powerpoint = PowerpointController() self.registerControllers(u'Powerpoint', powerpoint) except: - log.error(u'Reason : %s', sys.exc_info()) + log.exception(u'Failed to set up plugin for Powerpoint') #Lets see if Powerpoint Viewer is required (Default is Not wanted) - if int(self.config.get_config(u'Powerpoint Viewer', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: + if int(self.config.get_config( + u'Powerpoint Viewer', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: try: #Check to see if we are Win32 from win32com.client import Dispatch powerpoint = PowerpointController() self.registerControllers(u'Powerpoint Viewer', powerpoint) except: - log.error(u'Reason : %s', sys.exc_info()) + log.exception(u'Failed to set up plugin for Powerpoint Viewer') #If we have no available controllers disable plugin if len(self.controllers) > 0: return True diff --git a/openlp/plugins/songs/lib/manager.py b/openlp/plugins/songs/lib/manager.py index b4f89ec18..53a6c6af8 100644 --- a/openlp/plugins/songs/lib/manager.py +++ b/openlp/plugins/songs/lib/manager.py @@ -51,7 +51,8 @@ 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:///%s/songs.sqlite' % self.config.get_data_path() + 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':' + \ @@ -88,7 +89,8 @@ class SongManager(): """ Searches the song authors for keywords. """ - return self.session.query(Author).filter(Author.display_name.like(u'%' + keywords + u'%')).order_by(Author.display_name.asc()).all() + return self.session.query(Author).filter(Author.display_name.like( + u'%' + keywords + u'%')).order_by(Author.display_name.asc()).all() def get_song(self, id=None): """ @@ -109,7 +111,7 @@ class SongManager(): return True except: self.session.rollback() - log.error(u'Errow thrown %s', sys.exc_info()[1]) + log.exception(u'Could not save song to song database') return False def delete_song(self, songid): @@ -120,8 +122,7 @@ class SongManager(): return True except: self.session.rollback() - log.error(u'Errow thrown %s', sys.exc_info()[1]) - print u'Errow thrown ', sys.exc_info()[1] + log.exception(u'Could not delete song from song database') return False def get_authors(self): @@ -146,7 +147,7 @@ class SongManager(): return True except: self.session.rollback() - log.error(u'Errow thrown %s', sys.exc_info()[1]) + log.exception(u'Could not save author to song database') return False def delete_author(self, authorid): @@ -160,7 +161,7 @@ class SongManager(): return True except: self.session.rollback() - log.error(u'Errow thrown %s', sys.exc_info()[1]) + log.exception(u'Could not delete author from song database') return False def get_topics(self): @@ -185,7 +186,7 @@ class SongManager(): return True except: self.session.rollback() - log.error(u'Errow thrown %s', sys.exc_info()[1]) + log.exception(u'Could not save topic to song database') return False def delete_topic(self, topicid): @@ -199,7 +200,7 @@ class SongManager(): return True except: self.session.rollback() - log.error(u'Errow thrown %s', sys.exc_info()[1]) + log.exception(u'Could not delete topic from song database') return False def get_books(self): @@ -224,7 +225,7 @@ class SongManager(): return True except Exception, e: self.session.rollback() - log.error(u'Errow thrown %s', e.args[0]) + log.exception(u'Could not save book to song database') return False def delete_book(self, bookid): @@ -238,5 +239,6 @@ class SongManager(): return True except: self.session.rollback() - log.error(u'Errow thrown %s', sys.exc_info()[1]) + log.exception(u'Could not delete book from song database') return False +