diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 436ea82de..e097983eb 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -33,7 +33,8 @@ from urllib import quote_plus as urlquote from PyQt4 import QtCore from sqlalchemy import Table, MetaData, Column, types, create_engine -from sqlalchemy.exc import SQLAlchemyError, InvalidRequestError, DBAPIError +from sqlalchemy.exc import SQLAlchemyError, InvalidRequestError, DBAPIError, \ + OperationalError from sqlalchemy.orm import scoped_session, sessionmaker, mapper from sqlalchemy.pool import NullPool diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index 8fa2127ad..0139cd001 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -166,7 +166,7 @@ class ImageManager(QtCore.QObject): self.height = current_screen[u'size'].height() # Mark the images as dirty for a rebuild by setting the image and byte # stream to None. - for key, image in self._cache.iteritems(): + for image in self._cache.values(): self._reset_image(image) def update_images(self, image_type, background): @@ -176,7 +176,7 @@ class ImageManager(QtCore.QObject): log.debug(u'update_images') # Mark the images as dirty for a rebuild by setting the image and byte # stream to None. - for key, image in self._cache.iteritems(): + for image in self._cache.values(): if image.source == image_type: image.background = background self._reset_image(image) @@ -188,7 +188,7 @@ class ImageManager(QtCore.QObject): log.debug(u'update_images') # Mark the images as dirty for a rebuild by setting the image and byte # stream to None. - for key, image in self._cache.iteritems(): + for image in self._cache.values(): if image.source == image_type and image.name == name: image.background = background self._reset_image(image) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 42e140381..a82941341 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -300,6 +300,7 @@ class ServiceItem(object): ``path`` Defaults to *None*. Any path data, usually for images. """ + log.debug(u'set_from_service called with path %s' % path) header = serviceitem[u'serviceitem'][u'header'] self.title = header[u'title'] self.name = header[u'name'] diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 7c1156078..b4d424b10 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -295,7 +295,8 @@ class GeneralTab(SettingsTab): QtCore.QVariant(False)).toBool()) self.timeoutSpinBox.setValue(settings.value(u'loop delay', QtCore.QVariant(5)).toInt()[0]) - self.monitorRadioButton.setChecked(not settings.value(u'override position', + self.monitorRadioButton.setChecked( + not settings.value(u'override position', QtCore.QVariant(False)).toBool()) self.overrideRadioButton.setChecked(settings.value(u'override position', QtCore.QVariant(False)).toBool()) @@ -313,11 +314,14 @@ class GeneralTab(SettingsTab): u'audio repeat list', QtCore.QVariant(False)).toBool()) settings.endGroup() self.monitorComboBox.setDisabled(self.overrideRadioButton.isChecked()) - self.displayOnMonitorCheck.setDisabled(self.overrideRadioButton.isChecked()) + self.displayOnMonitorCheck.setDisabled( + self.overrideRadioButton.isChecked()) self.customXValueEdit.setEnabled(self.overrideRadioButton.isChecked()) self.customYValueEdit.setEnabled(self.overrideRadioButton.isChecked()) - self.customHeightValueEdit.setEnabled(self.overrideRadioButton.isChecked()) - self.customWidthValueEdit.setEnabled(self.overrideRadioButton.isChecked()) + self.customHeightValueEdit.setEnabled( + self.overrideRadioButton.isChecked()) + self.customWidthValueEdit.setEnabled( + self.overrideRadioButton.isChecked()) self.display_changed = False settings.beginGroup(self.settingsSection) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 228809042..9c3baf9bf 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -286,7 +286,8 @@ class MediaController(object): controller.mediabar.setVisible(value) if controller.isLive and controller.display: if self.curDisplayMediaPlayer and value: - if self.curDisplayMediaPlayer[controller.display] != self.mediaPlayers[u'webkit']: + if self.curDisplayMediaPlayer[controller.display] != \ + self.mediaPlayers[u'webkit']: controller.display.setTransparency(False) # Special controls: Here media type specific Controls will be enabled # (e.g. for DVD control, ...) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 3e650765d..943f8daff 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -405,7 +405,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): # Only continue when we include the song's text. if not self.slideTextCheckBox.isChecked(): return - for index, item in enumerate(self.serviceManager.serviceItems): + for item in self.serviceManager.serviceItems: # Trigger Audit requests Receiver.send_message(u'print_service_started', [item[u'service_item']]) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index c4ac122dc..bc075c3e1 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -461,7 +461,7 @@ class ServiceManager(QtGui.QWidget): log.debug(temp_file_name) path_file_name = unicode(self.fileName()) path, file_name = os.path.split(path_file_name) - basename, extension = os.path.splitext(file_name) + basename = os.path.splitext(file_name)[0] service_file_name = '%s.osd' % basename log.debug(u'ServiceManager.saveFile - %s', path_file_name) SettingsManager.set_last_dir( @@ -483,8 +483,7 @@ class ServiceManager(QtGui.QWidget): for i, filename in \ enumerate(service_item[u'header'][u'background_audio']): new_file = os.path.join(u'audio', - item[u'service_item']._uuid, - os.path.split(filename)[1]) + item[u'service_item']._uuid, filename) audio_files.append((filename, new_file)) service_item[u'header'][u'background_audio'][i] = new_file # Add the service item to the service. @@ -1354,15 +1353,15 @@ class ServiceManager(QtGui.QWidget): Handle of the event pint passed """ link = event.mimeData() - if event.mimeData().hasUrls(): + if link.hasUrls(): event.setDropAction(QtCore.Qt.CopyAction) event.accept() - for url in event.mimeData().urls(): + for url in link.urls(): filename = unicode(url.toLocalFile()) if filename.endswith(u'.osz'): self.onLoadServiceClicked(filename) - elif event.mimeData().hasText(): - plugin = unicode(event.mimeData().text()) + elif link.hasText(): + plugin = unicode(link.text()) item = self.serviceManagerList.itemAt(event.pos()) # ServiceManager started the drag and drop if plugin == u'ServiceManager': diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 0aa5d44d0..b2e09e809 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -57,7 +57,7 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): def exec_(self): # load all the settings self.settingListWidget.clear() - for tabIndex in range(0, self.stackedLayout.count() + 1): + while self.stackedLayout.count(): # take at 0 and the rest shuffle up. self.stackedLayout.takeAt(0) self.insertTab(self.generalTab, 0, PluginStatus.Active) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 41965903a..99d0d1bc4 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -563,7 +563,8 @@ class SlideController(Controller): Receiver.send_message('servicemanager_previous_item') elif keypressCommand == ServiceItemAction.PreviousLastSlide: # Go to the last slide of the previous item - Receiver.send_message('servicemanager_previous_item', u'last slide') + Receiver.send_message('servicemanager_previous_item', + u'last slide') else: Receiver.send_message('servicemanager_next_item') self.keypress_loop = False @@ -1190,7 +1191,8 @@ class SlideController(Controller): if self.slide_limits == SlideLimits.Wrap: row = self.previewListWidget.rowCount() - 1 elif self.isLive and self.slide_limits == SlideLimits.Next: - self.keypress_queue.append(ServiceItemAction.PreviousLastSlide) + self.keypress_queue.append( + ServiceItemAction.PreviousLastSlide) self._process_queue() return else: diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 430a1b3a3..72a8b7e3b 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -153,7 +153,6 @@ class ThemeManager(QtGui.QWidget): Import new themes downloaded by the first time wizard """ Receiver.send_message(u'cursor_busy') - encoding = get_filesystem_encoding() files = SettingsManager.get_files(self.settingsSection, u'.otz') for file in files: file = os.path.join(self.path, file) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index be20cf154..b7df84d92 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -27,7 +27,7 @@ import logging -from PyQt4 import QtCore, QtGui +from PyQt4 import QtGui from openlp.core.lib import Plugin, StringContent, build_icon, translate from openlp.core.lib.ui import create_action, UiStrings diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 75ace5d6f..053f4d689 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -189,7 +189,7 @@ class ImageMediaItem(MediaManagerItem): # Continue with the existing images. for bitem in items: filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) - (path, name) = os.path.split(filename) + name = os.path.split(filename)[1] service_item.add_from_image(filename, name, background) return True @@ -220,7 +220,7 @@ class ImageMediaItem(MediaManagerItem): bitem = self.listView.item(item.row()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) if os.path.exists(filename): - (path, name) = os.path.split(filename) + name = os.path.split(filename)[1] if self.plugin.liveController.display.directImage(name, filename, background): self.resetAction.setVisible(True) diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index e4f258cd3..bae2a7090 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -87,7 +87,8 @@ class RemoteTab(SettingsTab): self.qrLayout = QtGui.QVBoxLayout(self.androidAppGroupBox) self.qrLayout.setObjectName(u'qrLayout') self.qrCodeLabel = QtGui.QLabel(self.androidAppGroupBox) - self.qrCodeLabel.setPixmap(QtGui.QPixmap(u':/remotes/android_app_qr.png')) + self.qrCodeLabel.setPixmap(QtGui.QPixmap( + u':/remotes/android_app_qr.png')) self.qrCodeLabel.setAlignment(QtCore.Qt.AlignCenter) self.qrCodeLabel.setObjectName(u'qrCodeLabel') self.qrLayout.addWidget(self.qrCodeLabel) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 02b464497..91fff151b 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -589,7 +589,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): verse_names.append(u'%s%s' % ( VerseType.translated_tag(verse[0]), verse[1:])) verses_not_used = [] - for count, verse in enumerate(verses): + for verse in verses: if not verse in order: verses_not_used.append(verse) self.warningLabel.setVisible(len(verses_not_used) > 0) @@ -680,7 +680,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.verseListWidget.rowCount()) if not result: return False - item = int(self.songBookComboBox.currentIndex()) text = unicode(self.songBookComboBox.currentText()) if self.songBookComboBox.findText(text, QtCore.Qt.MatchExactly) < 0: if QtGui.QMessageBox.question(self, diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 8ad9b33ab..c2e14a999 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -36,7 +36,7 @@ from sqlalchemy.sql import or_ from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \ translate, check_item_selected, PluginStatus, create_separated_list -from openlp.core.lib.ui import UiStrings, create_action, create_widget_action +from openlp.core.lib.ui import UiStrings, create_widget_action from openlp.core.utils import AppLocation from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \ SongImportForm, SongExportForm