From 8a8580f359b982dae79344998e4e9776af9ff054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Mon, 30 May 2011 22:58:30 +0200 Subject: [PATCH 01/12] Fix unicode bookname handling on Biblegateway --- openlp/plugins/bibles/lib/http.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 5fc742cce..891fd4a1b 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -72,9 +72,8 @@ class BGExtract(object): log.debug(u'BGExtract.get_bible_chapter("%s", "%s", "%s")', version, bookname, chapter) urlbookname = urllib.quote(bookname.encode("utf-8")) - url_params = urllib.urlencode( - {u'search': u'%s %s' % (urlbookname, chapter), - u'version': u'%s' % version}) + url_params = u'search=%s+%s&version=%s' % (urlbookname, chapter, + version) cleaner = [(re.compile(' |
|\'\+\''), lambda match: '')] soup = get_soup_for_bible_ref( u'http://www.biblegateway.com/passage/?%s' % url_params, @@ -97,7 +96,7 @@ class BGExtract(object): verse_list = {} # Cater for inconsistent mark up in the first verse of a chapter. first_verse = verses.find(u'versenum') - if first_verse: + if first_verse and 0 in first_verse.contents: verse_list[1] = unicode(first_verse.contents[0]) for verse in verses(u'sup', u'versenum'): raw_verse_num = verse.next From efc678d51883d99f2292637312964be04fc12246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Tue, 31 May 2011 09:26:44 +0200 Subject: [PATCH 02/12] bug fix --- openlp/plugins/bibles/lib/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 891fd4a1b..49728637d 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -96,7 +96,7 @@ class BGExtract(object): verse_list = {} # Cater for inconsistent mark up in the first verse of a chapter. first_verse = verses.find(u'versenum') - if first_verse and 0 in first_verse.contents: + if first_verse and len(first_verse.contents): verse_list[1] = unicode(first_verse.contents[0]) for verse in verses(u'sup', u'versenum'): raw_verse_num = verse.next From 63102855e8392fecfdca5c7aa72bccaf87945145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Tue, 31 May 2011 09:31:38 +0200 Subject: [PATCH 03/12] remove unnecessary whitespace --- openlp/plugins/bibles/lib/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 49728637d..edb111d93 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -99,7 +99,7 @@ class BGExtract(object): if first_verse and len(first_verse.contents): verse_list[1] = unicode(first_verse.contents[0]) for verse in verses(u'sup', u'versenum'): - raw_verse_num = verse.next + raw_verse_num = verse.next clean_verse_num = 0 # Not all verses exist in all translations and may or may not be # represented by a verse number. If they are not fine, if they are From 4ce960d0cc433a3c1165423313e56e3d546a3d64 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 1 Jun 2011 07:42:56 +0200 Subject: [PATCH 04/12] do not override the file class --- openlp/core/ui/exceptionform.py | 18 +++++++++--------- openlp/plugins/songs/forms/songimportform.py | 6 +++--- openlp/plugins/songs/lib/easislidesimport.py | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index ab61ef24d..2521ebaba 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -106,7 +106,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): """ Saving exception log and system informations to a file. """ - report = unicode(translate('OpenLP.ExceptionForm', + report_text = unicode(translate('OpenLP.ExceptionForm', '**OpenLP Bug Report**\n' 'Version: %s\n\n' '--- Details of the Exception. ---\n\n%s\n\n ' @@ -122,21 +122,21 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): filename = unicode(QtCore.QDir.toNativeSeparators(filename)) SettingsManager.set_last_dir(self.settingsSection, os.path.dirname( filename)) - report = report % self._createReport() + report_text = report_text % self._createReport() try: - file = open(filename, u'w') + report_file = open(filename, u'w') try: - file.write(report) + report_file.write(report_text) except UnicodeError: - file.close() - file = open(filename, u'wb') - file.write(report.encode(u'utf-8')) + report_file.close() + report_file = open(filename, u'wb') + report_file.write(report_text.encode(u'utf-8')) finally: - file.close() + report_file.close() except IOError: log.exception(u'Failed to write crash report') finally: - file.close() + report_file.close() def onSendReportButtonPressed(self): """ diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 61e9fc7c8..7ef494cf5 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -772,9 +772,9 @@ class SongImportForm(OpenLPWizard): SettingsManager.get_last_dir(self.plugin.settingsSection, 1)) if not filename: return - file = codecs.open(filename, u'w', u'utf-8') - file.write(self.errorReportTextEdit.toPlainText()) - file.close() + report_file = codecs.open(filename, u'w', u'utf-8') + report_file.write(self.errorReportTextEdit.toPlainText()) + report_file.close() def addFileSelectItem(self, prefix, obj_prefix=None, can_disable=False, single_select=False): diff --git a/openlp/plugins/songs/lib/easislidesimport.py b/openlp/plugins/songs/lib/easislidesimport.py index 7a370534d..373eb7c42 100644 --- a/openlp/plugins/songs/lib/easislidesimport.py +++ b/openlp/plugins/songs/lib/easislidesimport.py @@ -61,8 +61,8 @@ class EasiSlidesImport(SongImport): """ log.info(u'Importing EasiSlides XML file %s', self.import_source) parser = etree.XMLParser(remove_blank_text=True) - file = etree.parse(self.import_source, parser) - xml = unicode(etree.tostring(file)) + parsed_file = etree.parse(self.import_source, parser) + xml = unicode(etree.tostring(parsed_file)) song_xml = objectify.fromstring(xml) self.import_wizard.progressBar.setMaximum(len(song_xml.Item)) for song in song_xml.Item: From 9a81e8dbe60dc5d43c00a26c430f28706018e584 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 1 Jun 2011 07:46:34 +0200 Subject: [PATCH 05/12] added blank line --- openlp/plugins/songs/lib/importer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index ab92033c4..8fbbdbeaf 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -28,6 +28,7 @@ The :mod:`importer` modules provides the general song import functionality. """ import logging + from opensongimport import OpenSongImport from easislidesimport import EasiSlidesImport from olpimport import OpenLPSongImport From d7ebb73fd1a2a6d12395aaa614ee3f08cb11d30d Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 1 Jun 2011 08:24:35 +0200 Subject: [PATCH 06/12] - do not show an error message when the directory does not exist, instead create items - trivial clean ups --- .../plugins/bibles/forms/bibleupgradeform.py | 43 +++++++++---------- openlp/plugins/bibles/forms/booknameform.py | 8 ++-- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 0fdcdfd11..9ba7e36d3 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -33,7 +33,8 @@ import shutil from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, SettingsManager, translate +from openlp.core.lib import Receiver, SettingsManager, translate, \ + check_directory_exists from openlp.core.lib.db import delete_database from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings @@ -94,7 +95,7 @@ class BibleUpgradeForm(OpenLPWizard): def onCheckBoxIndexChanged(self, index): """ - Show/ Hide warnings if CheckBox state has changed + Show/Hide warnings if CheckBox state has changed """ for number, filename in enumerate(self.files): if not self.checkBox[number].checkState() == QtCore.Qt.Checked: @@ -154,17 +155,19 @@ class BibleUpgradeForm(OpenLPWizard): self.backupDirectoryEdit.setEnabled(not checked) self.backupBrowseButton.setEnabled(not checked) - def backupOldBibles(self, backupdirectory): + def backupOldBibles(self, backup_directory): """ Backup old bible databases in a given folder. """ + check_directory_exists(backup_directory) + success = True for filename in self.files: try: - shutil.copy(os.path.join(self.path, filename[0]), - backupdirectory) + shutil.copy(os.path.join(self.path, filename[0]), + backup_directory) except: - return False - return True + success = False + return success def customInit(self): """ @@ -318,7 +321,7 @@ class BibleUpgradeForm(OpenLPWizard): QtGui.QFormLayout.FieldRole, self.versionNameEdit[number]) self.versionNameEdit[number].setText(bible.get_name()) self.formLayout.addWidget(self.formWidget[number]) - #Set up the Signal for the checkbox + # Set up the Signal for the checkbox. QtCore.QObject.connect(self.checkBox[number], QtCore.SIGNAL(u'stateChanged(int)'), self.onCheckBoxIndexChanged) @@ -414,29 +417,23 @@ class BibleUpgradeForm(OpenLPWizard): return True elif self.currentPage() == self.backupPage: if not self.noBackupCheckBox.checkState() == QtCore.Qt.Checked: - if not unicode(self.backupDirectoryEdit.text()): + backup_path = unicode(self.backupDirectoryEdit.text()) + if not backup_path: critical_error_message_box(UiStrings().EmptyField, translate('BiblesPlugin.UpgradeWizardForm', 'You need to specify a Backup Directory for your ' 'Bibles.')) self.backupDirectoryEdit.setFocus() return False - elif not os.path.exists(unicode( - self.backupDirectoryEdit.text())): - critical_error_message_box(UiStrings().Error, - translate('BiblesPlugin.UpgradeWizardForm', - 'The given path is not an existing directory.')) - self.backupDirectoryEdit.setFocus() - return False else: - if not self.backupOldBibles(unicode( - self.backupDirectoryEdit.text())): + if not self.backupOldBibles(backup_path): critical_error_message_box(UiStrings().Error, - translate('BiblesPlugin.UpgradeWizardForm', - 'The backup was not successfull.\nTo backup your ' - 'Bibles you need the permission to write in the given ' - 'directory. If you have a permissions to write and ' - 'this error still occurs, please report a bug.')) + translate('BiblesPlugin.UpgradeWizardForm', + 'The backup was not successfull.\nTo backup your ' + 'Bibles you need the permission to write in the ' + 'given directory. If you have a permissions to ' + 'write and this error still occurs, please report ' + 'a bug.')) return False return True elif self.currentPage() == self.selectPage: diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index 28e4c9df1..b07f28bf1 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -70,15 +70,15 @@ class BookNameForm(QDialog, Ui_BookNameDialog): self.onCheckBoxIndexChanged) def onCheckBoxIndexChanged(self, index): - ''' + """ Reload Combobox if CheckBox state has changed - ''' + """ self.reloadComboBox() def reloadComboBox(self): - ''' + """ Reload the Combobox items - ''' + """ self.correspondingComboBox.clear() items = BiblesResourcesDB.get_books() for item in items: From 5494b20805c6d26261571443853ee5d9a15506fe Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 1 Jun 2011 08:31:22 +0200 Subject: [PATCH 07/12] added more debug --- openlp/core/ui/screen.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/screen.py b/openlp/core/ui/screen.py index 2b6e10644..68d4c37ae 100644 --- a/openlp/core/ui/screen.py +++ b/openlp/core/ui/screen.py @@ -79,7 +79,7 @@ class ScreenList(object): ``number`` The number of the screen, which size has changed. """ - log.info(u'screenResolutionChanged %d' % number) + log.info(u'screen_resolution_changed %d' % number) for screen in self.screen_list: if number == screen[u'number']: newScreen = { @@ -104,6 +104,9 @@ class ScreenList(object): ``changed_screen`` The screen's number which has been (un)plugged. """ + # Do not log at start up. + if changed_screen != -1: + log.info(u'screen_count_changed %d' % number) # Remove unplugged screens. for screen in copy.deepcopy(self.screen_list): if screen[u'number'] == self.desktop.numScreens(): @@ -116,8 +119,7 @@ class ScreenList(object): u'size': self.desktop.screenGeometry(number), u'primary': (self.desktop.primaryScreen() == number) }) - # We do not want to send this message, when the method is called the - # first time. + # We do not want to send this message at start up. if changed_screen != -1: # Reload setting tabs to apply possible changes. Receiver.send_message(u'config_screen_changed') From 91718326ea28865305cf1b788f40019351ebddaf Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 1 Jun 2011 08:47:19 +0200 Subject: [PATCH 08/12] removed dangling list --- openlp/plugins/bibles/lib/mediaitem.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 8158465c7..15f5e7bee 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -845,7 +845,8 @@ class BibleMediaItem(MediaManagerItem): service_item.theme = None else: service_item.theme = self.settings.bible_theme - [service_item.add_from_text(slide[:30], slide) for slide in raw_slides] + for slide in raw_slides: + service_item.add_from_text(slide[:30], slide) return True def formatTitle(self, start_bitem, old_bitem): From c7a90102a2cd09a6fd2369d4f8935c9badcff8db Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Wed, 1 Jun 2011 08:38:19 +0100 Subject: [PATCH 09/12] Fix some startup blank/hide problems --- openlp.pyw | 1 + openlp/core/lib/renderer.py | 2 +- openlp/core/ui/maindisplay.py | 1 - openlp/core/ui/mainwindow.py | 5 ++--- openlp/core/ui/screen.py | 1 + openlp/core/ui/slidecontroller.py | 4 +++- openlp/core/utils/__init__.py | 1 - 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index afd0b01f8..0bd7c940d 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -133,6 +133,7 @@ class OpenLP(QtGui.QApplication): u'general/update check', QtCore.QVariant(True)).toBool() if update_check: VersionThread(self.mainWindow).start() + Receiver.send_message(u'maindisplay_blank_check') self.mainWindow.appStartup() DelayStartThread(self.mainWindow).start() return self.exec_() diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 4acf88202..c6e729be8 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -67,7 +67,7 @@ class Renderer(object): ``theme_manager`` The ThemeManager instance, used to get the current theme details. """ - log.debug(u'Initilisation started') + log.debug(u'Initialisation started') self.theme_manager = theme_manager self.image_manager = image_manager self.screens = ScreenList.get_instance() diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 715bb3b5b..e2117cc10 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -148,7 +148,6 @@ class MainDisplay(QtGui.QGraphicsView): self.__hideMouse() # To display or not to display? if not self.screen[u'primary']: - self.show() self.primary = False else: self.primary = True diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 6a5a753f3..7f41027a3 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -678,13 +678,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def blankCheck(self): """ Check and display message if screen blank on setup. - Triggered by delay thread. """ settings = QtCore.QSettings() + self.liveController.mainDisplaySetBackground() if settings.value(u'%s/screen blank' % self.generalSettingsSection, QtCore.QVariant(False)).toBool(): - self.liveController.mainDisplaySetBackground() - if settings.value(u'blank warning', + if settings.value(u'%s/blank warning' % self.generalSettingsSection, QtCore.QVariant(False)).toBool(): QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', diff --git a/openlp/core/ui/screen.py b/openlp/core/ui/screen.py index 2b6e10644..1e24c8681 100644 --- a/openlp/core/ui/screen.py +++ b/openlp/core/ui/screen.py @@ -241,6 +241,7 @@ class ScreenList(object): height = settings.value(u'height', QtCore.QVariant(self.current[u'size'].height())).toInt()[0] self.override[u'size'] = QtCore.QRect(x, y, width, height) + self.override[u'primary'] = False settings.endGroup() if override_display: self.set_override_display() diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index a59f00f21..5b6212cf8 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -742,8 +742,10 @@ class SlideController(QtGui.QWidget): self.onThemeDisplay(True) elif display_type == u'hidden': self.onHideDisplay(True) - else: + elif display_type == u'blanked': self.onBlankDisplay(True) + else: + Receiver.send_message(u'maindisplay_show') def onSlideBlank(self): """ diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 4ef445e36..ec20346d8 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -69,7 +69,6 @@ class VersionThread(QtCore.QThread): Run the thread. """ time.sleep(1) - Receiver.send_message(u'maindisplay_blank_check') app_version = get_application_version() version = check_latest_version(app_version) remote_version = {} From 6b1f8f36f2623b47a37a14e07a38311becb28cb7 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 1 Jun 2011 11:35:08 +0200 Subject: [PATCH 10/12] fixed spelling --- openlp/plugins/bibles/forms/bibleupgradeform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 9ba7e36d3..a60fbec8f 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -429,7 +429,7 @@ class BibleUpgradeForm(OpenLPWizard): if not self.backupOldBibles(backup_path): critical_error_message_box(UiStrings().Error, translate('BiblesPlugin.UpgradeWizardForm', - 'The backup was not successfull.\nTo backup your ' + 'The backup was not successful.\nTo backup your ' 'Bibles you need the permission to write in the ' 'given directory. If you have a permissions to ' 'write and this error still occurs, please report ' From b9dfd1f7d22510855782c6c0fcaf6926b4511030 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 1 Jun 2011 14:08:40 +0200 Subject: [PATCH 11/12] more spelling fixes --- openlp/plugins/bibles/forms/bibleupgradeform.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index a60fbec8f..a29ef25d0 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -430,10 +430,9 @@ class BibleUpgradeForm(OpenLPWizard): critical_error_message_box(UiStrings().Error, translate('BiblesPlugin.UpgradeWizardForm', 'The backup was not successful.\nTo backup your ' - 'Bibles you need the permission to write in the ' - 'given directory. If you have a permissions to ' - 'write and this error still occurs, please report ' - 'a bug.')) + 'Bibles you need permission to write to the given ' + 'directory. If you have write permissions and this ' + 'error still occurs, please report a bug.')) return False return True elif self.currentPage() == self.selectPage: From 40f2b4d1381d668554ca2af5e9f02a5524ae023f Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Wed, 1 Jun 2011 19:58:27 +0100 Subject: [PATCH 12/12] Fix unhidden toolbox that appears in the media manager --- openlp/core/lib/mediamanageritem.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 602b3c55b..374617664 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -91,6 +91,7 @@ class MediaManagerItem(QtGui.QWidget): Constructor to create the media manager item. """ QtGui.QWidget.__init__(self, parent) + self.hide() self.whitespace = re.compile(r'\W+', re.UNICODE) self.plugin = plugin visible_title = self.plugin.getString(StringContent.VisibleName)