merge trunk

This commit is contained in:
Tomas Groth 2018-10-30 20:46:55 +01:00
commit e7526f1e59
94 changed files with 254 additions and 314 deletions

View File

@ -11,7 +11,7 @@ recursive-include openlp *.ttf
recursive-include documentation * recursive-include documentation *
recursive-include resources * recursive-include resources *
recursive-include scripts * recursive-include scripts *
recursive-include tests/resources * recursive-include tests *
include copyright.txt include copyright.txt
include LICENSE include LICENSE
include README.txt include README.txt

View File

@ -19,10 +19,3 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
from openlp.core.api.http import register_endpoint, requires_auth
from openlp.core.api.http.endpoint import Endpoint
from openlp.core.api.poll import Poller
from openlp.core.api.tab import ApiTab
__all__ = ['Endpoint', 'ApiTab', 'register_endpoint', 'requires_auth']

View File

@ -22,4 +22,3 @@
""" """
The Endpoint class, which provides plugins with a way to serve their own portion of the API The Endpoint class, which provides plugins with a way to serve their own portion of the API
""" """
from .pluginhelpers import search, live, service

View File

@ -27,7 +27,6 @@ from webob import Response
from openlp.core.api.http.wsgiapp import WSGIApplication from openlp.core.api.http.wsgiapp import WSGIApplication
from openlp.core.common.settings import Settings from openlp.core.common.settings import Settings
from .errors import NotFound, ServerError, HttpError
application = WSGIApplication('api') application = WSGIApplication('api')

View File

@ -90,7 +90,7 @@ class Poller(RegistryProperties):
if self.stage_cache is None: if self.stage_cache is None:
try: try:
page = get_web_page("http://localhost:4316/stage") page = get_web_page("http://localhost:4316/stage")
except: except Exception:
page = None page = None
if page: if page:
self.stage_cache = True self.stage_cache = True
@ -106,7 +106,7 @@ class Poller(RegistryProperties):
if self.live_cache is None: if self.live_cache is None:
try: try:
page = get_web_page("http://localhost:4316/main") page = get_web_page("http://localhost:4316/main")
except: except Exception:
page = None page = None
if page: if page:
self.live_cache = True self.live_cache = True
@ -122,7 +122,7 @@ class Poller(RegistryProperties):
if self.chords_cache is None: if self.chords_cache is None:
try: try:
page = get_web_page("http://localhost:4316/chords") page = get_web_page("http://localhost:4316/chords")
except: except Exception:
page = None page = None
if page: if page:
self.chords_cache = True self.chords_cache = True

View File

@ -23,7 +23,6 @@
The :mod:`languages` module provides a list of language names with utility functions. The :mod:`languages` module provides a list of language names with utility functions.
""" """
import itertools import itertools
import locale
import logging import logging
import re import re
from collections import namedtuple from collections import namedtuple
@ -53,8 +52,7 @@ def translate(context, text, comment=None, qt_translate=QtCore.QCoreApplication.
Language = namedtuple('Language', ['id', 'name', 'code']) Language = namedtuple('Language', ['id', 'name', 'code'])
ICU_COLLATOR = None COLLATOR = None
DIGITS_OR_NONDIGITS = re.compile(r'\d+|\D+')
LANGUAGES = sorted([ LANGUAGES = sorted([
Language(1, translate('common.languages', '(Afan) Oromo', 'Language code: om'), 'om'), Language(1, translate('common.languages', '(Afan) Oromo', 'Language code: om'), 'om'),
Language(2, translate('common.languages', 'Abkhazian', 'Language code: ab'), 'ab'), Language(2, translate('common.languages', 'Abkhazian', 'Language code: ab'), 'ab'),
@ -507,24 +505,19 @@ def format_time(text, local_time):
return re.sub(r'\%[a-zA-Z]', match_formatting, text) return re.sub(r'\%[a-zA-Z]', match_formatting, text)
def get_locale_key(string): def get_locale_key(string, numeric=False):
""" """
Creates a key for case insensitive, locale aware string sorting. Creates a key for case insensitive, locale aware string sorting.
:param string: The corresponding string. :param string: The corresponding string.
""" """
string = string.lower() string = string.lower()
# ICU is the prefered way to handle locale sort key, we fallback to locale.strxfrm which will work in most cases. global COLLATOR
global ICU_COLLATOR if COLLATOR is None:
try: language = LanguageManager.get_language()
if ICU_COLLATOR is None: COLLATOR = QtCore.QCollator(QtCore.QLocale(language))
import icu COLLATOR.setNumericMode(numeric)
language = LanguageManager.get_language() return COLLATOR.sortKey(string)
icu_locale = icu.Locale(language)
ICU_COLLATOR = icu.Collator.createInstance(icu_locale)
return ICU_COLLATOR.getSortKey(string)
except:
return locale.strxfrm(string).encode()
def get_natural_key(string): def get_natural_key(string):
@ -534,13 +527,7 @@ def get_natural_key(string):
:param string: string to be sorted by :param string: string to be sorted by
Returns a list of string compare keys and integers. Returns a list of string compare keys and integers.
""" """
key = DIGITS_OR_NONDIGITS.findall(string) return get_locale_key(string, True)
key = [int(part) if part.isdigit() else get_locale_key(part) for part in key]
# Python 3 does not support comparison of different types anymore. So make sure, that we do not compare str
# and int.
if string and string[0].isdigit():
return [b''] + key
return key
def get_language(name): def get_language(name):

View File

@ -409,7 +409,7 @@ class Manager(object):
self.session.rollback() self.session.rollback()
log.exception('Object list save failed') log.exception('Object list save failed')
return False return False
except: except Exception:
self.session.rollback() self.session.rollback()
raise raise
@ -439,7 +439,7 @@ class Manager(object):
self.session.rollback() self.session.rollback()
log.exception('Object list save failed') log.exception('Object list save failed')
return False return False
except: except Exception:
self.session.rollback() self.session.rollback()
raise raise
@ -556,7 +556,7 @@ class Manager(object):
self.session.rollback() self.session.rollback()
log.exception('Failed to delete object') log.exception('Failed to delete object')
return False return False
except: except Exception:
self.session.rollback() self.session.rollback()
raise raise
else: else:
@ -591,7 +591,7 @@ class Manager(object):
self.session.rollback() self.session.rollback()
log.exception('Failed to delete {name} records'.format(name=object_class.__name__)) log.exception('Failed to delete {name} records'.format(name=object_class.__name__))
return False return False
except: except Exception:
self.session.rollback() self.session.rollback()
raise raise

View File

@ -471,7 +471,7 @@ class ProjectorManager(QtWidgets.QWidget, RegistryBase, UiProjectorManager, LogM
projector = list_item.data(QtCore.Qt.UserRole) projector = list_item.data(QtCore.Qt.UserRole)
try: try:
projector.link.set_shutter_closed() projector.link.set_shutter_closed()
except: except Exception:
continue continue
def on_doubleclick_item(self, item, opt=None): def on_doubleclick_item(self, item, opt=None):
@ -486,7 +486,7 @@ class ProjectorManager(QtWidgets.QWidget, RegistryBase, UiProjectorManager, LogM
try: try:
log.debug('ProjectorManager: Calling connect_to_host() on "{ip}"'.format(ip=projector.link.ip)) log.debug('ProjectorManager: Calling connect_to_host() on "{ip}"'.format(ip=projector.link.ip))
projector.link.connect_to_host() projector.link.connect_to_host()
except: except Exception:
log.debug('ProjectorManager: "{ip}" already connected - skipping'.format(ip=projector.link.ip)) log.debug('ProjectorManager: "{ip}" already connected - skipping'.format(ip=projector.link.ip))
return return
@ -505,7 +505,7 @@ class ProjectorManager(QtWidgets.QWidget, RegistryBase, UiProjectorManager, LogM
projector = list_item.data(QtCore.Qt.UserRole) projector = list_item.data(QtCore.Qt.UserRole)
try: try:
projector.link.connect_to_host() projector.link.connect_to_host()
except: except Exception:
continue continue
def on_delete_projector(self, opt=None): def on_delete_projector(self, opt=None):
@ -587,7 +587,7 @@ class ProjectorManager(QtWidgets.QWidget, RegistryBase, UiProjectorManager, LogM
projector = list_item.data(QtCore.Qt.UserRole) projector = list_item.data(QtCore.Qt.UserRole)
try: try:
projector.link.disconnect_from_host() projector.link.disconnect_from_host()
except: except Exception:
continue continue
def on_edit_projector(self, opt=None): def on_edit_projector(self, opt=None):
@ -620,7 +620,7 @@ class ProjectorManager(QtWidgets.QWidget, RegistryBase, UiProjectorManager, LogM
projector = list_item.data(QtCore.Qt.UserRole) projector = list_item.data(QtCore.Qt.UserRole)
try: try:
projector.link.set_power_off() projector.link.set_power_off()
except: except Exception:
continue continue
def on_poweron_projector(self, opt=None): def on_poweron_projector(self, opt=None):
@ -638,7 +638,7 @@ class ProjectorManager(QtWidgets.QWidget, RegistryBase, UiProjectorManager, LogM
projector = list_item.data(QtCore.Qt.UserRole) projector = list_item.data(QtCore.Qt.UserRole)
try: try:
projector.link.set_power_on() projector.link.set_power_on()
except: except Exception:
continue continue
def on_show_projector(self, opt=None): def on_show_projector(self, opt=None):
@ -656,7 +656,7 @@ class ProjectorManager(QtWidgets.QWidget, RegistryBase, UiProjectorManager, LogM
projector = list_item.data(QtCore.Qt.UserRole) projector = list_item.data(QtCore.Qt.UserRole)
try: try:
projector.link.set_shutter_open() projector.link.set_shutter_open()
except: except Exception:
continue continue
def on_status_projector(self, opt=None): def on_status_projector(self, opt=None):

View File

@ -23,7 +23,7 @@
The GUI widgets of the exception dialog. The GUI widgets of the exception dialog.
""" """
from PyQt5 import QtGui, QtWidgets from PyQt5 import QtWidgets
from openlp.core.common.i18n import translate from openlp.core.common.i18n import translate
from openlp.core.lib.ui import create_button, create_button_box from openlp.core.lib.ui import create_button, create_button_box

View File

@ -26,8 +26,36 @@ import logging
import os import os
import platform import platform
import re import re
import bs4
import sqlalchemy
from PyQt5 import Qt, QtCore, QtGui, QtWebKit, QtWidgets
from lxml import etree
from PyQt5 import QtCore, QtGui, QtWidgets try:
import migrate
MIGRATE_VERSION = getattr(migrate, '__version__', '< 0.7')
except ImportError:
MIGRATE_VERSION = '-'
try:
import chardet
CHARDET_VERSION = chardet.__version__
except ImportError:
CHARDET_VERSION = '-'
try:
import enchant
ENCHANT_VERSION = enchant.__version__
except ImportError:
ENCHANT_VERSION = '-'
try:
import mako
MAKO_VERSION = mako.__version__
except ImportError:
MAKO_VERSION = '-'
try:
from openlp.core.ui.media.vlcplayer import VERSION
VLC_VERSION = VERSION
except ImportError:
VLC_VERSION = '-'
from openlp.core.common import is_linux from openlp.core.common import is_linux
from openlp.core.common.i18n import UiStrings, translate from openlp.core.common.i18n import UiStrings, translate
@ -76,9 +104,15 @@ class ExceptionForm(QtWidgets.QDialog, Ui_ExceptionDialog, RegistryProperties):
description = self.description_text_edit.toPlainText() description = self.description_text_edit.toPlainText()
traceback = self.exception_text_edit.toPlainText() traceback = self.exception_text_edit.toPlainText()
system = translate('OpenLP.ExceptionForm', 'Platform: {platform}\n').format(platform=platform.platform()) system = translate('OpenLP.ExceptionForm', 'Platform: {platform}\n').format(platform=platform.platform())
library_versions = get_library_versions() libraries = ('Python: {python}\nQt5: {qt5}\nPyQt5: {pyqt5}\nSQLAlchemy: {sqalchemy}\n'
library_versions['PyUNO'] = self._get_pyuno_version() 'SQLAlchemy Migrate: {migrate}\nBeautifulSoup: {soup}\nlxml: {etree}\nChardet: {chardet}\n'
libraries = '\n'.join(['{}: {}'.format(library, version) for library, version in library_versions.items()]) 'PyEnchant: {enchant}\nMako: {mako}\npyUNO bridge: {uno}\n'
'VLC: {vlc}\n').format(python=platform.python_version(), qt5=Qt.qVersion(),
pyqt5=Qt.PYQT_VERSION_STR,
sqalchemy=sqlalchemy.__version__, migrate=MIGRATE_VERSION,
soup=bs4.__version__, etree=etree.__version__, chardet=CHARDET_VERSION,
enchant=ENCHANT_VERSION, mako=MAKO_VERSION,
uno=self._pyuno_import(), vlc=VLC_VERSION)
if is_linux(): if is_linux():
if os.environ.get('KDE_FULL_SESSION') == 'true': if os.environ.get('KDE_FULL_SESSION') == 'true':
@ -194,5 +228,5 @@ class ExceptionForm(QtWidgets.QDialog, Ui_ExceptionDialog, RegistryProperties):
return node.getByName('ooSetupVersion') return node.getByName('ooSetupVersion')
except ImportError: except ImportError:
return '-' return '-'
except: except Exception:
return '- (Possible non-standard UNO installation)' return '- (Possible non-standard UNO installation)'

View File

@ -174,9 +174,9 @@ class UiIcons(object):
setattr(self, key, qta.icon(icon)) setattr(self, key, qta.icon(icon))
except Exception: except Exception:
import sys import sys
log.error("Unexpected error: %s" % sys.exc_info()) log.error('Unexpected error: %s' % sys.exc_info())
setattr(self, key, qta.icon('fa.plus-circle', color='red')) setattr(self, key, qta.icon('fa.plus-circle', color='red'))
except: except Exception:
setattr(self, key, qta.icon('fa.plus-circle', color='red')) setattr(self, key, qta.icon('fa.plus-circle', color='red'))
self.main_icon = build_icon(':/icon/openlp-logo.svg') self.main_icon = build_icon(':/icon/openlp-logo.svg')

View File

@ -51,7 +51,7 @@ from openlp.core.ui.aboutform import AboutForm
from openlp.core.ui.firsttimeform import FirstTimeForm from openlp.core.ui.firsttimeform import FirstTimeForm
from openlp.core.ui.formattingtagform import FormattingTagForm from openlp.core.ui.formattingtagform import FormattingTagForm
from openlp.core.ui.icons import UiIcons from openlp.core.ui.icons import UiIcons
from openlp.core.ui.media import MediaController from openlp.core.ui.media.mediacontroller import MediaController
from openlp.core.ui.pluginform import PluginForm from openlp.core.ui.pluginform import PluginForm
from openlp.core.ui.printserviceform import PrintServiceForm from openlp.core.ui.printserviceform import PrintServiceForm
from openlp.core.ui.servicemanager import ServiceManager from openlp.core.ui.servicemanager import ServiceManager

View File

@ -142,10 +142,3 @@ def format_milliseconds(milliseconds):
minutes=minutes, minutes=minutes,
seconds=seconds, seconds=seconds,
millis=millis) millis=millis)
from .mediacontroller import MediaController
from .playertab import PlayerTab
from .endpoint import media_endpoint
__all__ = ['MediaController', 'PlayerTab']

View File

@ -38,7 +38,7 @@ class Track(object):
def __getattribute__(self, name): def __getattribute__(self, name):
try: try:
return object.__getattribute__(self, name) return object.__getattribute__(self, name)
except: except Exception:
pass pass
return None return None
@ -64,14 +64,14 @@ class Track(object):
try: try:
primary = o.replace('other_', '') primary = o.replace('other_', '')
setattr(self, primary, int(getattr(self, primary))) setattr(self, primary, int(getattr(self, primary)))
except: except Exception:
for v in getattr(self, o): for v in getattr(self, o):
try: try:
current = getattr(self, primary) current = getattr(self, primary)
setattr(self, primary, int(v)) setattr(self, primary, int(v))
getattr(self, o).append(current) getattr(self, o).append(current)
break break
except: except Exception:
pass pass
def __repr__(self): def __repr__(self):

View File

@ -70,7 +70,7 @@ def get_vlc():
is_vlc_available = False is_vlc_available = False
try: try:
is_vlc_available = bool(sys.modules['openlp.core.ui.media.vendor.vlc'].get_default_instance()) is_vlc_available = bool(sys.modules['openlp.core.ui.media.vendor.vlc'].get_default_instance())
except: except Exception:
pass pass
if is_vlc_available: if is_vlc_available:
return sys.modules['openlp.core.ui.media.vendor.vlc'] return sys.modules['openlp.core.ui.media.vendor.vlc']
@ -107,7 +107,7 @@ def get_vlc():
if is_vlc_available: if is_vlc_available:
try: try:
VERSION = vlc.libvlc_get_version().decode('UTF-8') VERSION = vlc.libvlc_get_version().decode('UTF-8')
except: except Exception:
VERSION = '0.0.0' VERSION = '0.0.0'
# LooseVersion does not work when a string contains letter and digits (e. g. 2.0.5 Twoflower). # LooseVersion does not work when a string contains letter and digits (e. g. 2.0.5 Twoflower).
# http://bugs.python.org/issue14894 # http://bugs.python.org/issue14894
@ -131,7 +131,7 @@ if is_linux() and 'nose' not in sys.argv[0] and get_vlc():
# If libx11.so.6 was not found, fallback to more generic libx11.so # If libx11.so.6 was not found, fallback to more generic libx11.so
x11 = ctypes.cdll.LoadLibrary('libX11.so') x11 = ctypes.cdll.LoadLibrary('libX11.so')
x11.XInitThreads() x11.XInitThreads()
except: except Exception:
log.exception('Failed to run XInitThreads(), VLC might not work properly!') log.exception('Failed to run XInitThreads(), VLC might not work properly!')

View File

@ -704,7 +704,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
Settings().setValue('servicemanager/last file', file_path) Settings().setValue('servicemanager/last file', file_path)
else: else:
raise ValidationError(msg='No service data found') raise ValidationError(msg='No service data found')
except (NameError, OSError, ValidationError, zipfile.BadZipFile) as e: except (NameError, OSError, ValidationError, zipfile.BadZipFile):
self.log_exception('Problem loading service file {name}'.format(name=file_path)) self.log_exception('Problem loading service file {name}'.format(name=file_path))
critical_error_message_box( critical_error_message_box(
message=translate('OpenLP.ServiceManager', message=translate('OpenLP.ServiceManager',

View File

@ -33,8 +33,9 @@ from openlp.core.lib import build_icon
from openlp.core.projectors.tab import ProjectorTab from openlp.core.projectors.tab import ProjectorTab
from openlp.core.ui.advancedtab import AdvancedTab from openlp.core.ui.advancedtab import AdvancedTab
from openlp.core.ui.generaltab import GeneralTab from openlp.core.ui.generaltab import GeneralTab
from openlp.core.ui.media import PlayerTab
from openlp.core.ui.screenstab import ScreensTab from openlp.core.ui.screenstab import ScreensTab
from openlp.core.ui.themestab import ThemesTab
from openlp.core.ui.media.playertab import PlayerTab
from openlp.core.ui.settingsdialog import Ui_SettingsDialog from openlp.core.ui.settingsdialog import Ui_SettingsDialog
from openlp.core.ui.themestab import ThemesTab from openlp.core.ui.themestab import ThemesTab

View File

@ -25,11 +25,9 @@ The :mod:`openlp.core.version` module downloads the version details for OpenLP.
import logging import logging
import platform import platform
import sys import sys
import time
from collections import OrderedDict from collections import OrderedDict
from datetime import date from datetime import date
from distutils.version import LooseVersion from distutils.version import LooseVersion
from subprocess import PIPE, Popen
import requests import requests
from PyQt5 import QtCore from PyQt5 import QtCore

View File

@ -31,7 +31,6 @@ from openlp.core.common import CONTROL_CHARS
from openlp.core.common.i18n import UiStrings, translate from openlp.core.common.i18n import UiStrings, translate
from openlp.core.common.path import Path, path_to_str, str_to_path from openlp.core.common.path import Path, path_to_str, str_to_path
from openlp.core.common.settings import Settings from openlp.core.common.settings import Settings
from openlp.core.lib import build_icon
from openlp.core.lib.formattingtags import FormattingTags from openlp.core.lib.formattingtags import FormattingTags
from openlp.core.lib.ui import create_action, create_widget_action from openlp.core.lib.ui import create_action, create_widget_action
from openlp.core.ui.icons import UiIcons from openlp.core.ui.icons import UiIcons

View File

@ -146,7 +146,6 @@ class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties):
try: try:
self.cellWidget(row, 0).children()[1].setMaximumWidth(new_height * self.screen_ratio) self.cellWidget(row, 0).children()[1].setMaximumWidth(new_height * self.screen_ratio)
except Exception: except Exception:
# TODO: Figure out what sort of exceptions are thrown
return return
def screen_size_changed(self, screen_ratio): def screen_size_changed(self, screen_ratio):

View File

@ -31,7 +31,6 @@ from openlp.core.common.i18n import UiStrings, translate
from openlp.core.common.mixins import RegistryProperties from openlp.core.common.mixins import RegistryProperties
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings from openlp.core.common.settings import Settings
from openlp.core.lib import build_icon
from openlp.core.lib.ui import add_welcome_page from openlp.core.lib.ui import add_welcome_page
from openlp.core.ui.icons import UiIcons from openlp.core.ui.icons import UiIcons
from openlp.core.widgets.dialogs import FileDialog from openlp.core.widgets.dialogs import FileDialog

View File

@ -34,9 +34,10 @@ from openlp.core.lib.theme import VerticalType
from openlp.core.lib.ui import create_action from openlp.core.lib.ui import create_action
from openlp.core.ui import AlertLocation from openlp.core.ui import AlertLocation
from openlp.core.ui.icons import UiIcons from openlp.core.ui.icons import UiIcons
from openlp.plugins.alerts.endpoint import alerts_endpoint, api_alerts_endpoint from openlp.plugins.alerts.endpoint import api_alerts_endpoint, alerts_endpoint
from openlp.plugins.alerts.forms import AlertForm from openlp.plugins.alerts.forms.alertform import AlertForm
from openlp.plugins.alerts.lib import AlertsManager, AlertsTab from openlp.plugins.alerts.lib.alertsmanager import AlertsManager
from openlp.plugins.alerts.lib.alertstab import AlertsTab
from openlp.plugins.alerts.lib.db import init_schema from openlp.plugins.alerts.lib.db import init_schema

View File

@ -22,7 +22,6 @@
import json import json
import logging import logging
import urllib import urllib
from urllib.parse import urlparse
from openlp.core.api.http import requires_auth from openlp.core.api.http import requires_auth
from openlp.core.api.http.endpoint import Endpoint from openlp.core.api.http.endpoint import Endpoint

View File

@ -40,5 +40,3 @@ mentioned above, like so::
This allows OpenLP to use ``self.object`` for all the GUI elements while keeping them separate from the functionality, This allows OpenLP to use ``self.object`` for all the GUI elements while keeping them separate from the functionality,
so that it is easier to recreate the GUI from the .ui files later if necessary. so that it is easier to recreate the GUI from the .ui files later if necessary.
""" """
from .alertform import AlertForm

View File

@ -19,6 +19,3 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
from .alertsmanager import AlertsManager
from .alertstab import AlertsTab

View File

@ -25,14 +25,14 @@ import logging
from openlp.core.api.http import register_endpoint from openlp.core.api.http import register_endpoint
from openlp.core.common.actions import ActionList from openlp.core.common.actions import ActionList
from openlp.core.common.i18n import UiStrings, translate from openlp.core.common.i18n import UiStrings, translate
from openlp.core.lib import build_icon from openlp.core.ui.icons import UiIcons
from openlp.core.lib.plugin import Plugin, StringContent from openlp.core.lib.plugin import Plugin, StringContent
from openlp.core.lib.ui import create_action from openlp.core.lib.ui import create_action
from openlp.core.ui.icons import UiIcons
from openlp.plugins.bibles.endpoint import api_bibles_endpoint, bibles_endpoint from openlp.plugins.bibles.endpoint import api_bibles_endpoint, bibles_endpoint
from openlp.plugins.bibles.lib import BibleManager, BibleMediaItem, BiblesTab, DisplayStyle, LanguageSelection, \ from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, LanguageSelection
LayoutStyle from openlp.plugins.bibles.lib.biblestab import BiblesTab
from openlp.plugins.bibles.lib.mediaitem import BibleSearch from openlp.plugins.bibles.lib.manager import BibleManager
from openlp.plugins.bibles.lib.mediaitem import BibleMediaItem, BibleSearch
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View File

@ -28,6 +28,12 @@ import urllib.error
from lxml import etree from lxml import etree
from PyQt5 import QtWidgets from PyQt5 import QtWidgets
try:
from pysword import modules
PYSWORD_AVAILABLE = True
except ImportError:
PYSWORD_AVAILABLE = False
from openlp.core.common import trace_error_handler from openlp.core.common import trace_error_handler
from openlp.core.common.applocation import AppLocation from openlp.core.common.applocation import AppLocation
from openlp.core.common.i18n import UiStrings, get_locale_key, translate from openlp.core.common.i18n import UiStrings, get_locale_key, translate
@ -42,13 +48,6 @@ from openlp.plugins.bibles.lib.importers.http import BGExtract, BSExtract, CWExt
from openlp.plugins.bibles.lib.manager import BibleFormat from openlp.plugins.bibles.lib.manager import BibleFormat
try:
from pysword import modules
PYSWORD_AVAILABLE = True
except:
PYSWORD_AVAILABLE = False
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -585,7 +584,7 @@ class BibleImportForm(OpenLPWizard):
(WebDownload.Bibleserver, BSExtract())): (WebDownload.Bibleserver, BSExtract())):
try: try:
bibles = extractor.get_bibles_from_http() bibles = extractor.get_bibles_from_http()
except (urllib.error.URLError, ConnectionError) as err: except (urllib.error.URLError, ConnectionError):
critical_error_message_box(translate('BiblesPlugin.ImportWizardForm', 'Error during download'), critical_error_message_box(translate('BiblesPlugin.ImportWizardForm', 'Error during download'),
translate('BiblesPlugin.ImportWizardForm', translate('BiblesPlugin.ImportWizardForm',
'An error occurred while downloading the list of bibles from %s.')) 'An error occurred while downloading the list of bibles from %s.'))
@ -615,7 +614,7 @@ class BibleImportForm(OpenLPWizard):
self.sword_bible_combo_box.clear() self.sword_bible_combo_box.clear()
for key in bible_keys: for key in bible_keys:
self.sword_bible_combo_box.addItem(self.pysword_folder_modules_json[key]['description'], key) self.sword_bible_combo_box.addItem(self.pysword_folder_modules_json[key]['description'], key)
except: except Exception:
self.sword_bible_combo_box.clear() self.sword_bible_combo_box.clear()
def on_sword_zipfile_path_edit_path_changed(self, new_path): def on_sword_zipfile_path_edit_path_changed(self, new_path):
@ -630,7 +629,7 @@ class BibleImportForm(OpenLPWizard):
self.sword_zipbible_combo_box.clear() self.sword_zipbible_combo_box.clear()
for key in bible_keys: for key in bible_keys:
self.sword_zipbible_combo_box.addItem(self.pysword_zip_modules_json[key]['description'], key) self.sword_zipbible_combo_box.addItem(self.pysword_zip_modules_json[key]['description'], key)
except: except Exception:
self.sword_zipbible_combo_box.clear() self.sword_zipbible_combo_box.clear()
def register_fields(self): def register_fields(self):

View File

@ -424,9 +424,3 @@ class SearchResults(object):
Returns whether or not the verse list contains verses. Returns whether or not the verse list contains verses.
""" """
return len(self.verse_list) > 0 return len(self.verse_list) > 0
from .versereferencelist import VerseReferenceList
from .manager import BibleManager
from .biblestab import BiblesTab
from .mediaitem import BibleMediaItem

View File

@ -54,7 +54,6 @@ from collections import namedtuple
from openlp.core.common import get_file_encoding from openlp.core.common import get_file_encoding
from openlp.core.common.i18n import translate from openlp.core.common.i18n import translate
from openlp.core.common.path import Path
from openlp.core.lib.exceptions import ValidationError from openlp.core.lib.exceptions import ValidationError
from openlp.plugins.bibles.lib.bibleimport import BibleImport from openlp.plugins.bibles.lib.bibleimport import BibleImport

View File

@ -750,7 +750,7 @@ def get_soup_for_bible_ref(reference_url, headers=None, pre_parse_regex=None, pr
return None return None
try: try:
page_source = get_web_page(reference_url, headers, update_openlp=True) page_source = get_web_page(reference_url, headers, update_openlp=True)
except Exception as e: except Exception:
log.exception('Unable to download Bible %s, unknown exception occurred', reference_url) log.exception('Unable to download Bible %s, unknown exception occurred', reference_url)
page_source = None page_source = None
if not page_source: if not page_source:

View File

@ -40,7 +40,7 @@ from .importers.zefania import ZefaniaBible
try: try:
from .importers.sword import SwordBible from .importers.sword import SwordBible
except: except ImportError:
pass pass
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View File

@ -38,9 +38,9 @@ from openlp.core.ui.icons import UiIcons
from openlp.core.widgets.edits import SearchEdit from openlp.core.widgets.edits import SearchEdit
from openlp.plugins.bibles.forms.bibleimportform import BibleImportForm from openlp.plugins.bibles.forms.bibleimportform import BibleImportForm
from openlp.plugins.bibles.forms.editbibleform import EditBibleForm from openlp.plugins.bibles.forms.editbibleform import EditBibleForm
from openlp.plugins.bibles.lib import DisplayStyle, LayoutStyle, VerseReferenceList, get_reference_match, \ from openlp.plugins.bibles.lib import DisplayStyle, LayoutStyle, get_reference_match, \
get_reference_separator get_reference_separator
from openlp.plugins.bibles.lib.versereferencelist import VerseReferenceList
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View File

@ -33,9 +33,9 @@ from openlp.core.lib.db import Manager
from openlp.core.lib.plugin import Plugin, StringContent from openlp.core.lib.plugin import Plugin, StringContent
from openlp.core.ui.icons import UiIcons from openlp.core.ui.icons import UiIcons
from openlp.plugins.custom.endpoint import api_custom_endpoint, custom_endpoint from openlp.plugins.custom.endpoint import api_custom_endpoint, custom_endpoint
from openlp.plugins.custom.lib import CustomMediaItem, CustomTab
from openlp.plugins.custom.lib.db import CustomSlide, init_schema from openlp.plugins.custom.lib.db import CustomSlide, init_schema
from openlp.plugins.custom.lib.mediaitem import CustomSearch from openlp.plugins.custom.lib.mediaitem import CustomMediaItem, CustomSearch
from openlp.plugins.custom.lib.customtab import CustomTab
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View File

@ -27,13 +27,11 @@ from PyQt5 import QtCore, QtWidgets
from openlp.core.common.i18n import translate from openlp.core.common.i18n import translate
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
from openlp.core.lib.ui import critical_error_message_box, find_and_set_in_combo_box from openlp.core.lib.ui import critical_error_message_box, find_and_set_in_combo_box
from openlp.plugins.custom.lib import CustomXMLBuilder, CustomXMLParser from openlp.plugins.custom.forms.editcustomdialog import Ui_CustomEditDialog
from openlp.plugins.custom.forms.editcustomslideform import EditCustomSlideForm
from openlp.plugins.custom.lib.customxmlhandler import CustomXMLBuilder, CustomXMLParser
from openlp.plugins.custom.lib.db import CustomSlide from openlp.plugins.custom.lib.db import CustomSlide
from .editcustomdialog import Ui_CustomEditDialog
from .editcustomslideform import EditCustomSlideForm
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View File

@ -19,7 +19,3 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
from .customtab import CustomTab
from .customxmlhandler import CustomXMLBuilder, CustomXMLParser
from .mediaitem import CustomMediaItem

View File

@ -35,7 +35,7 @@ from openlp.core.lib.serviceitem import ItemCapabilities
from openlp.core.lib.ui import create_widget_action from openlp.core.lib.ui import create_widget_action
from openlp.core.ui.icons import UiIcons from openlp.core.ui.icons import UiIcons
from openlp.plugins.custom.forms.editcustomform import EditCustomForm from openlp.plugins.custom.forms.editcustomform import EditCustomForm
from openlp.plugins.custom.lib import CustomXMLBuilder, CustomXMLParser from openlp.plugins.custom.lib.customxmlhandler import CustomXMLBuilder, CustomXMLParser
from openlp.plugins.custom.lib.db import CustomSlide from openlp.plugins.custom.lib.db import CustomSlide

View File

@ -40,6 +40,3 @@ mentioned above, like so::
This allows OpenLP to use ``self.object`` for all the GUI elements while keeping them separate from the functionality, This allows OpenLP to use ``self.object`` for all the GUI elements while keeping them separate from the functionality,
so that it is easier to recreate the GUI from the .ui files later if necessary. so that it is easier to recreate the GUI from the .ui files later if necessary.
""" """
from .addgroupform import AddGroupForm
from .choosegroupform import ChooseGroupForm

View File

@ -32,7 +32,9 @@ from openlp.core.lib.db import Manager
from openlp.core.lib.plugin import Plugin, StringContent from openlp.core.lib.plugin import Plugin, StringContent
from openlp.core.ui.icons import UiIcons from openlp.core.ui.icons import UiIcons
from openlp.plugins.images.endpoint import api_images_endpoint, images_endpoint from openlp.plugins.images.endpoint import api_images_endpoint, images_endpoint
from openlp.plugins.images.lib import ImageMediaItem, ImageTab, upgrade from openlp.plugins.images.lib import upgrade
from openlp.plugins.images.lib.mediaitem import ImageMediaItem
from openlp.plugins.images.lib.imagetab import ImageTab
from openlp.plugins.images.lib.db import init_schema from openlp.plugins.images.lib.db import init_schema

View File

@ -19,6 +19,3 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
from .imagetab import ImageTab
from .mediaitem import ImageMediaItem

View File

@ -37,7 +37,8 @@ from openlp.core.lib.serviceitem import ItemCapabilities
from openlp.core.lib.ui import create_widget_action, critical_error_message_box from openlp.core.lib.ui import create_widget_action, critical_error_message_box
from openlp.core.ui.icons import UiIcons from openlp.core.ui.icons import UiIcons
from openlp.core.widgets.views import TreeWidgetWithDnD from openlp.core.widgets.views import TreeWidgetWithDnD
from openlp.plugins.images.forms import AddGroupForm, ChooseGroupForm from openlp.plugins.images.forms.addgroupform import AddGroupForm
from openlp.plugins.images.forms.choosegroupform import ChooseGroupForm
from openlp.plugins.images.lib.db import ImageFilenames, ImageGroups from openlp.plugins.images.lib.db import ImageFilenames, ImageGroups

View File

@ -19,8 +19,3 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
from .mediaitem import MediaMediaItem
from .mediatab import MediaTab
__all__ = ['MediaMediaItem']

View File

@ -36,7 +36,8 @@ from openlp.core.lib import build_icon
from openlp.core.lib.plugin import Plugin, StringContent from openlp.core.lib.plugin import Plugin, StringContent
from openlp.core.ui.icons import UiIcons from openlp.core.ui.icons import UiIcons
from openlp.plugins.media.endpoint import api_media_endpoint, media_endpoint from openlp.plugins.media.endpoint import api_media_endpoint, media_endpoint
from openlp.plugins.media.lib import MediaMediaItem, MediaTab from openlp.plugins.media.lib.mediaitem import MediaMediaItem
from openlp.plugins.media.lib.mediatab import MediaTab
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View File

@ -19,8 +19,3 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
from .presentationcontroller import PresentationController
from .messagelistener import MessageListener
from .mediaitem import PresentationMediaItem
from .presentationtab import PresentationTab

View File

@ -122,7 +122,7 @@ class ImpressController(PresentationController):
while uno_instance is None and loop < 3: while uno_instance is None and loop < 3:
try: try:
uno_instance = get_uno_instance(resolver) uno_instance = get_uno_instance(resolver)
except: except Exception:
log.warning('Unable to find running instance ') log.warning('Unable to find running instance ')
self.start_process() self.start_process()
loop += 1 loop += 1
@ -131,7 +131,7 @@ class ImpressController(PresentationController):
log.debug('get UNO Desktop Openoffice - createInstanceWithContext - Desktop') log.debug('get UNO Desktop Openoffice - createInstanceWithContext - Desktop')
desktop = self.manager.createInstanceWithContext("com.sun.star.frame.Desktop", uno_instance) desktop = self.manager.createInstanceWithContext("com.sun.star.frame.Desktop", uno_instance)
return desktop return desktop
except: except Exception:
log.warning('Failed to get UNO desktop') log.warning('Failed to get UNO desktop')
return None return None
@ -173,7 +173,7 @@ class ImpressController(PresentationController):
desktop = self.get_uno_desktop() desktop = self.get_uno_desktop()
else: else:
desktop = self.get_com_desktop() desktop = self.get_com_desktop()
except: except Exception:
log.warning('Failed to find an OpenOffice desktop to terminate') log.warning('Failed to find an OpenOffice desktop to terminate')
if not desktop: if not desktop:
return return
@ -191,7 +191,7 @@ class ImpressController(PresentationController):
try: try:
desktop.terminate() desktop.terminate()
log.debug('OpenOffice killed') log.debug('OpenOffice killed')
except: except Exception:
log.warning('Failed to terminate OpenOffice') log.warning('Failed to terminate OpenOffice')
@ -236,7 +236,7 @@ class ImpressDocument(PresentationDocument):
properties = tuple(properties) properties = tuple(properties)
try: try:
self.document = desktop.loadComponentFromURL(url, '_blank', 0, properties) self.document = desktop.loadComponentFromURL(url, '_blank', 0, properties)
except: except Exception:
log.warning('Failed to load presentation {url}'.format(url=url)) log.warning('Failed to load presentation {url}'.format(url=url))
return False return False
self.presentation = self.document.getPresentation() self.presentation = self.document.getPresentation()
@ -275,7 +275,7 @@ class ImpressDocument(PresentationDocument):
delete_file(path) delete_file(path)
except ErrorCodeIOException as exception: except ErrorCodeIOException as exception:
log.exception('ERROR! ErrorCodeIOException {error:d}'.format(error=exception.ErrCode)) log.exception('ERROR! ErrorCodeIOException {error:d}'.format(error=exception.ErrCode))
except: except Exception:
log.exception('{path} - Unable to store openoffice preview'.format(path=path)) log.exception('{path} - Unable to store openoffice preview'.format(path=path))
def create_property(self, name, value): def create_property(self, name, value):
@ -303,7 +303,7 @@ class ImpressDocument(PresentationDocument):
self.presentation.end() self.presentation.end()
self.presentation = None self.presentation = None
self.document.dispose() self.document.dispose()
except: except Exception:
log.warning("Closing presentation failed") log.warning("Closing presentation failed")
self.document = None self.document = None
self.controller.remove_doc(self) self.controller.remove_doc(self)
@ -320,7 +320,7 @@ class ImpressDocument(PresentationDocument):
if self.document.getPresentation() is None: if self.document.getPresentation() is None:
log.debug("getPresentation failed to find a presentation") log.debug("getPresentation failed to find a presentation")
return False return False
except: except Exception:
log.warning("getPresentation failed to find a presentation") log.warning("getPresentation failed to find a presentation")
return False return False
return True return True

View File

@ -21,7 +21,7 @@
############################################################################### ###############################################################################
import logging import logging
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5 import QtCore, QtWidgets
from openlp.core.common.i18n import UiStrings, get_natural_key, translate from openlp.core.common.i18n import UiStrings, get_natural_key, translate
from openlp.core.common.path import path_to_str, str_to_path from openlp.core.common.path import path_to_str, str_to_path
@ -32,7 +32,7 @@ from openlp.core.lib.mediamanageritem import MediaManagerItem
from openlp.core.lib.serviceitem import ItemCapabilities from openlp.core.lib.serviceitem import ItemCapabilities
from openlp.core.lib.ui import create_horizontal_adjusting_combo_box, critical_error_message_box from openlp.core.lib.ui import create_horizontal_adjusting_combo_box, critical_error_message_box
from openlp.core.ui.icons import UiIcons from openlp.core.ui.icons import UiIcons
from openlp.plugins.presentations.lib import MessageListener from openlp.plugins.presentations.lib.messagelistener import MessageListener
from openlp.plugins.presentations.lib.pdfcontroller import PDF_CONTROLLER_FILETYPES from openlp.plugins.presentations.lib.pdfcontroller import PDF_CONTROLLER_FILETYPES

View File

@ -280,7 +280,7 @@ class PdfDocument(PresentationDocument):
for image_path in created_files: for image_path in created_files:
if image_path.is_file(): if image_path.is_file():
self.image_files.append(image_path) self.image_files.append(image_path)
except Exception as e: except Exception:
log.exception(runlog) log.exception(runlog)
return False return False
self.num_pages = len(self.image_files) self.num_pages = len(self.image_files)

View File

@ -327,14 +327,14 @@ class PresentationDocument(object):
titles_path = self.get_thumbnail_folder() / 'titles.txt' titles_path = self.get_thumbnail_folder() / 'titles.txt'
try: try:
titles = titles_path.read_text().splitlines() titles = titles_path.read_text().splitlines()
except: except Exception:
log.exception('Failed to open/read existing titles file') log.exception('Failed to open/read existing titles file')
titles = [] titles = []
for slide_no, title in enumerate(titles, 1): for slide_no, title in enumerate(titles, 1):
notes_path = self.get_thumbnail_folder() / 'slideNotes{number:d}.txt'.format(number=slide_no) notes_path = self.get_thumbnail_folder() / 'slideNotes{number:d}.txt'.format(number=slide_no)
try: try:
note = notes_path.read_text() note = notes_path.read_text()
except: except Exception:
log.exception('Failed to open/read notes file') log.exception('Failed to open/read notes file')
note = '' note = ''
notes.append(note) notes.append(note)

View File

@ -36,7 +36,9 @@ from openlp.core.lib import build_icon
from openlp.core.lib.plugin import Plugin, StringContent from openlp.core.lib.plugin import Plugin, StringContent
from openlp.core.ui.icons import UiIcons from openlp.core.ui.icons import UiIcons
from openlp.plugins.presentations.endpoint import api_presentations_endpoint, presentations_endpoint from openlp.plugins.presentations.endpoint import api_presentations_endpoint, presentations_endpoint
from openlp.plugins.presentations.lib import PresentationController, PresentationMediaItem, PresentationTab from openlp.plugins.presentations.lib.presentationcontroller import PresentationController
from openlp.plugins.presentations.lib.mediaitem import PresentationMediaItem
from openlp.plugins.presentations.lib.presentationtab import PresentationTab
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View File

@ -45,4 +45,3 @@ This allows OpenLP to use ``self.object`` for all the GUI elements while keeping
them separate from the functionality, so that it is easier to recreate the GUI them separate from the functionality, so that it is easier to recreate the GUI
from the .ui files later if necessary. from the .ui files later if necessary.
""" """
from .editsongform import EditSongForm

View File

@ -320,7 +320,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
for verse in multiple: for verse in multiple:
self.song.verse_order = re.sub(r'([' + verse.upper() + verse.lower() + r'])(\W|$)', self.song.verse_order = re.sub(r'([' + verse.upper() + verse.lower() + r'])(\W|$)',
r'\g<1>1\2', self.song.verse_order) r'\g<1>1\2', self.song.verse_order)
except: except Exception:
log.exception('Problem processing song Lyrics \n{xml}'.format(xml=sxml.dump_xml())) log.exception('Problem processing song Lyrics \n{xml}'.format(xml=sxml.dump_xml()))
raise raise
@ -1088,7 +1088,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
if audio_path not in file_paths: if audio_path not in file_paths:
try: try:
audio_path.unlink() audio_path.unlink()
except: except Exception:
log.exception('Could not remove file: {audio}'.format(audio=audio_path)) log.exception('Could not remove file: {audio}'.format(audio=audio_path))
if not file_paths: if not file_paths:
try: try:

View File

@ -32,8 +32,7 @@ from openlp.core.common import CONTROL_CHARS
from openlp.core.common.applocation import AppLocation from openlp.core.common.applocation import AppLocation
from openlp.core.common.i18n import translate from openlp.core.common.i18n import translate
from openlp.core.common.settings import Settings from openlp.core.common.settings import Settings
from openlp.core.display.render import remove_tags from openlp.plugins.songs.lib.db import Author, MediaFile, Song
from openlp.plugins.songs.lib.db import Author, MediaFile, Song, Topic
from openlp.plugins.songs.lib.ui import SongStrings from openlp.plugins.songs.lib.ui import SongStrings
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View File

@ -291,10 +291,8 @@ class CCLIFileImport(SongImport):
# verse type, so set flag # verse type, so set flag
verse_type = VerseType.tags[VerseType.Other] verse_type = VerseType.tags[VerseType.Other]
check_first_verse_line = True check_first_verse_line = True
verse_number = verse_desc_parts[1]
else: else:
verse_type = VerseType.tags[VerseType.Other] verse_type = VerseType.tags[VerseType.Other]
verse_number = 1
verse_start = True verse_start = True
else: else:
# check first line for verse type # check first line for verse type

View File

@ -108,7 +108,7 @@ class EasySlidesImport(SongImport):
def _add_authors(self, writer): def _add_authors(self, writer):
try: try:
self.parse_author(str(writer)) self.parse_author(str(writer))
except UnicodeDecodeError as e: except UnicodeDecodeError:
log.exception('Unicode decode error while decoding Writer') log.exception('Unicode decode error while decoding Writer')
self._success = False self._success = False

View File

@ -136,7 +136,7 @@ class OpenOfficeImport(SongImport):
process = QtCore.QProcess() process = QtCore.QProcess()
process.startDetached(cmd) process.startDetached(cmd)
self.process_started = True self.process_started = True
except: except Exception:
log.exception("start_ooo_process failed") log.exception("start_ooo_process failed")
def open_ooo_file(self, file_path): def open_ooo_file(self, file_path):
@ -178,7 +178,7 @@ class OpenOfficeImport(SongImport):
""" """
try: try:
self.document.close(True) self.document.close(True)
except: except Exception:
log.exception('Exception in close_ooo_file - trying to ignore it.') log.exception('Exception in close_ooo_file - trying to ignore it.')
self.document = None self.document = None
@ -189,7 +189,7 @@ class OpenOfficeImport(SongImport):
if self.process_started: if self.process_started:
try: try:
self.desktop.terminate() self.desktop.terminate()
except: except Exception:
log.exception('Exception in close_ooo - trying to ignore it.') log.exception('Exception in close_ooo - trying to ignore it.')
def process_presentation(self): def process_presentation(self):

View File

@ -224,5 +224,5 @@ class SongShowPlusImport(SongImport):
try: try:
# Don't question this, it works... # Don't question this, it works...
return data.decode('utf-8').encode('cp1251').decode('cp1251') return data.decode('utf-8').encode('cp1251').decode('cp1251')
except: except Exception:
return data.decode(retrieve_windows_encoding()) return data.decode(retrieve_windows_encoding())

View File

@ -194,7 +194,7 @@ class SundayPlusImport(SongImport):
while True: while True:
try: try:
return blob.decode(self.encoding) return blob.decode(self.encoding)
except Exception as e: except Exception:
self.encoding = retrieve_windows_encoding() self.encoding = retrieve_windows_encoding()
def unescape(self, text): def unescape(self, text):

View File

@ -325,12 +325,12 @@ class SongMediaItem(MediaManagerItem):
:param search_results: A tuple containing (songbook entry, book name, song title, song id) :param search_results: A tuple containing (songbook entry, book name, song title, song id)
:return: None :return: None
""" """
def get_songbook_key(text_array): def get_songbook_key(text):
""" """
Get the key to sort by Get the key to sort by
:param text_array: the result text to be processed. :param text: the text tuple to be processed.
""" """
return get_natural_key(text_array[1]), get_natural_key(text_array[0]), get_natural_key(text_array[2]) return get_natural_key('{0} {1} {2}'.format(text[1], text[0], text[2]))
log.debug('display results Book') log.debug('display results Book')
self.list_view.clear() self.list_view.clear()

View File

@ -34,7 +34,7 @@ from urllib.request import HTTPCookieProcessor, URLError, build_opener
from bs4 import BeautifulSoup, NavigableString from bs4 import BeautifulSoup, NavigableString
from openlp.plugins.songs.lib import VerseType, clean_song from openlp.plugins.songs.lib import VerseType, clean_song
from openlp.plugins.songs.lib.db import Author, Song, Topic from openlp.plugins.songs.lib.db import Song, Author, Topic
from openlp.plugins.songs.lib.openlyricsxml import SongXML from openlp.plugins.songs.lib.openlyricsxml import SongXML

View File

@ -19,6 +19,3 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
from .songusagedeleteform import SongUsageDeleteForm
from .songusagedetailform import SongUsageDetailForm

View File

@ -33,7 +33,8 @@ from openlp.core.lib.db import Manager
from openlp.core.lib.plugin import Plugin, StringContent from openlp.core.lib.plugin import Plugin, StringContent
from openlp.core.lib.ui import create_action from openlp.core.lib.ui import create_action
from openlp.core.ui.icons import UiIcons from openlp.core.ui.icons import UiIcons
from openlp.plugins.songusage.forms import SongUsageDeleteForm, SongUsageDetailForm from openlp.plugins.songusage.forms.songusagedetailform import SongUsageDetailForm
from openlp.plugins.songusage.forms.songusagedeleteform import SongUsageDeleteForm
from openlp.plugins.songusage.lib import upgrade from openlp.plugins.songusage.lib import upgrade
from openlp.plugins.songusage.lib.db import SongUsageItem, init_schema from openlp.plugins.songusage.lib.db import SongUsageItem, init_schema

View File

@ -48,7 +48,6 @@ def start():
""" """
Instantiate and run the application. Instantiate and run the application.
""" """
faulthandler.enable()
set_up_fault_handling() set_up_fault_handling()
# Add support for using multiprocessing from frozen Windows executable (built using PyInstaller), # Add support for using multiprocessing from frozen Windows executable (built using PyInstaller),
# see https://docs.python.org/3/library/multiprocessing.html#multiprocessing.freeze_support # see https://docs.python.org/3/library/multiprocessing.html#multiprocessing.freeze_support

View File

@ -11,17 +11,15 @@ environment:
install: install:
# Install dependencies from pypi # Install dependencies from pypi
- "%PYTHON%\\python.exe -m pip install sqlalchemy alembic appdirs chardet beautifulsoup4 lxml Mako mysql-connector-python nose mock pyodbc psycopg2 pypiwin32 websockets asyncio waitress six webob requests QtAwesome PyQt5" - "%PYTHON%\\python.exe -m pip install sqlalchemy alembic appdirs chardet beautifulsoup4 lxml Mako mysql-connector-python nose mock pyodbc psycopg2 pypiwin32 websockets asyncio waitress six webob requests QtAwesome PyQt5 pymediainfo"
# Download and install pyicu (originally from http://www.lfd.uci.edu/~gohlke/pythonlibs/)
- "%PYTHON%\\python.exe -m pip install https://get.openlp.org/win-sdk/PyICU-2.1-cp37-cp37m-win_amd64.whl"
# Download and unpack mupdf # Download and unpack mupdf
- appveyor DownloadFile http://mupdf.com/downloads/archive/mupdf-1.9a-windows.zip - appveyor DownloadFile https://mupdf.com/downloads/archive/mupdf-1.14.0-windows.zip
- 7z x mupdf-1.9a-windows.zip - 7z x mupdf-1.14.0-windows.zip
- cp mupdf-1.9a-windows/mupdf.exe openlp-branch/mupdf.exe - cp mupdf-1.14.0-windows/mupdf.exe openlp-branch/mupdf.exe
# Download and unpack mediainfo # Download and unpack mediainfo
- appveyor DownloadFile https://mediaarea.net/download/binary/mediainfo/0.7.90/MediaInfo_CLI_0.7.90_Windows_i386.zip - appveyor DownloadFile https://mediaarea.net/download/binary/mediainfo/18.08.1/MediaInfo_CLI_18.08.1_Windows_i386.zip
- mkdir MediaInfo - mkdir MediaInfo
- 7z x -oMediaInfo MediaInfo_CLI_0.7.90_Windows_i386.zip - 7z x -oMediaInfo MediaInfo_CLI_18.08.1_Windows_i386.zip
- cp MediaInfo\\MediaInfo.exe openlp-branch\\MediaInfo.exe - cp MediaInfo\\MediaInfo.exe openlp-branch\\MediaInfo.exe
build: off build: off

View File

@ -40,8 +40,8 @@ IS_MAC = sys.platform.startswith('dar')
VERS = { VERS = {
'Python': '3.6', 'Python': '3.6',
'PyQt5': '5.0', 'PyQt5': '5.5',
'Qt5': '5.0', 'Qt5': '5.5',
'pymediainfo': '2.2', 'pymediainfo': '2.2',
'sqlalchemy': '0.5', 'sqlalchemy': '0.5',
'enchant': '1.6' 'enchant': '1.6'
@ -52,7 +52,6 @@ WIN32_MODULES = [
'win32com', 'win32com',
'win32ui', 'win32ui',
'pywintypes', 'pywintypes',
'icu',
] ]
LINUX_MODULES = [ LINUX_MODULES = [

View File

@ -60,7 +60,6 @@ from getpass import getpass
from lxml import etree, objectify from lxml import etree, objectify
from PyQt5 import QtCore from PyQt5 import QtCore
SERVER_URL = 'http://www.transifex.com/api/2/project/openlp/resource/openlp-26x/' SERVER_URL = 'http://www.transifex.com/api/2/project/openlp/resource/openlp-26x/'
IGNORED_PATHS = ['scripts'] IGNORED_PATHS = ['scripts']
IGNORED_FILES = ['setup.py'] IGNORED_FILES = ['setup.py']

View File

@ -9,16 +9,13 @@ ignore = E402,E722,W503,W504
[flake8] [flake8]
exclude=resources.py,vlc.py exclude=resources.py,vlc.py
max-line-length = 120 ignore = E402,W503,W504,D
ignore = E402,E722,W503,W504
[pycodestyle] [pycodestyle]
exclude = resources.py,vlc.py exclude = resources.py,vlc.py
max-line-length = 120 max-line-length = 120
# Ignoring: # Ignoring:
# E402... # E402...
# E722 do not use bare 'except'
# W503 line break before binary operator # W503 line break before binary operator
# W504 line break after binary operator # W504 line break after binary operator
ignore = E402,E722,W503,W504 ignore = E402,W503,W504

View File

@ -119,7 +119,8 @@ requires = [
'chardet', 'chardet',
'lxml', 'lxml',
'Mako', 'Mako',
'PyQt5', 'pymediainfo >= 2.2',
'PyQt5 >= 5.5',
'QtAwesome', 'QtAwesome',
'requests', 'requests',
'SQLAlchemy >= 0.5', 'SQLAlchemy >= 0.5',
@ -128,10 +129,7 @@ requires = [
'websockets' 'websockets'
] ]
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
requires.extend([ requires.append('pywin32')
'PyICU',
'pywin32'
])
elif sys.platform.startswith('darwin'): elif sys.platform.startswith('darwin'):
requires.extend([ requires.extend([
'pyobjc', 'pyobjc',
@ -188,7 +186,7 @@ using a computer and a data projector.""",
author_email='raoulsnyman@openlp.org', author_email='raoulsnyman@openlp.org',
url='https://openlp.org/', url='https://openlp.org/',
license='GNU General Public License', license='GNU General Public License',
packages=find_packages(exclude=['ez_setup', 'tests']), packages=find_packages(exclude=['ez_setup', 'tests*']),
py_modules=['run_openlp'], py_modules=['run_openlp'],
include_package_data=True, include_package_data=True,
zip_safe=False, zip_safe=False,
@ -204,7 +202,7 @@ using a computer and a data projector.""",
'jenkins': ['python-jenkins'], 'jenkins': ['python-jenkins'],
'launchpad': ['launchpadlib'] 'launchpad': ['launchpadlib']
}, },
tests_require=['nose2', 'PyICU', 'pylint', 'pyodbc', 'pysword'], tests_require=['nose2', 'pylint', 'pyodbc', 'pysword'],
test_suite='nose2.collector.collector', test_suite='nose2.collector.collector',
entry_points={'gui_scripts': ['openlp = run_openlp:start']} entry_points={'gui_scripts': ['openlp = run_openlp:start']}
) )

View File

@ -26,8 +26,9 @@ import os
from unittest import TestCase from unittest import TestCase
from unittest.mock import MagicMock from unittest.mock import MagicMock
from openlp.core.api.http import NotFound, application, register_endpoint from openlp.core.api.http import register_endpoint, application
from openlp.core.api.http.endpoint import Endpoint from openlp.core.api.http.endpoint import Endpoint
from openlp.core.api.http.errors import NotFound
ROOT_DIR = os.path.dirname(os.path.realpath(__file__)) ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
@ -69,7 +70,9 @@ class TestRouting(TestCase):
rqst.method = 'GET' rqst.method = 'GET'
application.dispatch(rqst) application.dispatch(rqst)
# THEN: the not found id called # THEN: the not found id called
assert 1 == application.route_map['^\\/test\\/image$']['GET'].call_count, \ route_key = next(iter(application.route_map))
assert '/image' in route_key
assert 1 == application.route_map[route_key]['GET'].call_count, \
'main_index function should have been called' 'main_index function should have been called'

View File

@ -24,7 +24,6 @@ This module contains tests for the lib submodule of the Remotes plugin.
""" """
import re import re
from unittest import TestCase from unittest import TestCase
from unittest.mock import patch
from PyQt5 import QtWidgets from PyQt5 import QtWidgets

View File

@ -63,7 +63,7 @@ class TestUtilsDBFunctions(TestCase):
if os.path.exists(self.tmp_folder): if os.path.exists(self.tmp_folder):
shutil.rmtree(self.tmp_folder) shutil.rmtree(self.tmp_folder)
break break
except: except Exception:
time.sleep(1) time.sleep(1)
retries += 1 retries += 1

View File

@ -22,12 +22,10 @@
""" """
Package to test the openlp.core.lib.languages package. Package to test the openlp.core.lib.languages package.
""" """
from unittest import skipIf
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
from openlp.core.common import is_macosx from openlp.core.common.i18n import LANGUAGES, Language, UiStrings, get_language, get_locale_key, get_natural_key, \
from openlp.core.common.i18n import LANGUAGES, Language, LanguageManager, UiStrings, get_language, get_locale_key, \ translate, LanguageManager
get_natural_key, translate
from openlp.core.common.settings import Settings from openlp.core.common.settings import Settings
@ -113,7 +111,6 @@ def test_get_language_invalid_with_none():
assert language is None assert language is None
@skipIf(is_macosx(), 'This test doesn\'t work on macOS currently')
def test_get_locale_key(): def test_get_locale_key():
""" """
Test the get_locale_key(string) function Test the get_locale_key(string) function

View File

@ -397,7 +397,7 @@ class TestPath(TestCase):
try: try:
create_paths(mocked_path) create_paths(mocked_path)
assert False, 'create_paths should have thrown an exception' assert False, 'create_paths should have thrown an exception'
except: except Exception:
# THEN: `create_paths` raises an exception # THEN: `create_paths` raises an exception
pass pass

View File

@ -279,7 +279,7 @@ class TestLib(TestCase):
# last test. # last test.
try: try:
thumb_path.unlink() thumb_path.unlink()
except: except Exception:
pass pass
# Only continue when the thumb does not exist. # Only continue when the thumb does not exist.
@ -297,7 +297,7 @@ class TestLib(TestCase):
# Remove the thumb so that the test actually tests if the thumb will be created. # Remove the thumb so that the test actually tests if the thumb will be created.
try: try:
thumb_path.unlink() thumb_path.unlink()
except: except Exception:
pass pass
def test_create_thumb_no_size(self): def test_create_thumb_no_size(self):
@ -313,7 +313,7 @@ class TestLib(TestCase):
# last test. # last test.
try: try:
thumb_path.unlink() thumb_path.unlink()
except: except Exception:
pass pass
# Only continue when the thumb does not exist. # Only continue when the thumb does not exist.
@ -331,7 +331,7 @@ class TestLib(TestCase):
# Remove the thumb so that the test actually tests if the thumb will be created. # Remove the thumb so that the test actually tests if the thumb will be created.
try: try:
thumb_path.unlink() thumb_path.unlink()
except: except Exception:
pass pass
def test_create_thumb_invalid_size(self): def test_create_thumb_invalid_size(self):
@ -348,7 +348,7 @@ class TestLib(TestCase):
# last test. # last test.
try: try:
thumb_path.unlink() thumb_path.unlink()
except: except Exception:
pass pass
# Only continue when the thumb does not exist. # Only continue when the thumb does not exist.
@ -366,7 +366,7 @@ class TestLib(TestCase):
# Remove the thumb so that the test actually tests if the thumb will be created. # Remove the thumb so that the test actually tests if the thumb will be created.
try: try:
thumb_path.unlink() thumb_path.unlink()
except: except Exception:
pass pass
def test_create_thumb_width_only(self): def test_create_thumb_width_only(self):
@ -383,7 +383,7 @@ class TestLib(TestCase):
# last test. # last test.
try: try:
thumb_path.unlink() thumb_path.unlink()
except: except Exception:
pass pass
# Only continue when the thumb does not exist. # Only continue when the thumb does not exist.
@ -401,7 +401,7 @@ class TestLib(TestCase):
# Remove the thumb so that the test actually tests if the thumb will be created. # Remove the thumb so that the test actually tests if the thumb will be created.
try: try:
thumb_path.unlink() thumb_path.unlink()
except: except Exception:
pass pass
def test_create_thumb_height_only(self): def test_create_thumb_height_only(self):
@ -418,7 +418,7 @@ class TestLib(TestCase):
# last test. # last test.
try: try:
thumb_path.unlink() thumb_path.unlink()
except: except Exception:
pass pass
# Only continue when the thumb does not exist. # Only continue when the thumb does not exist.
@ -436,7 +436,7 @@ class TestLib(TestCase):
# Remove the thumb so that the test actually tests if the thumb will be created. # Remove the thumb so that the test actually tests if the thumb will be created.
try: try:
thumb_path.unlink() thumb_path.unlink()
except: except Exception:
pass pass
def test_create_thumb_empty_img(self): def test_create_thumb_empty_img(self):
@ -454,7 +454,7 @@ class TestLib(TestCase):
# last test. # last test.
try: try:
thumb_path.unlink() thumb_path.unlink()
except: except Exception:
pass pass
# Only continue when the thumb does not exist. # Only continue when the thumb does not exist.
@ -484,7 +484,7 @@ class TestLib(TestCase):
# Remove the thumb so that the test actually tests if the thumb will be created. # Remove the thumb so that the test actually tests if the thumb will be created.
try: try:
thumb_path.unlink() thumb_path.unlink()
except: except Exception:
pass pass
@patch('openlp.core.lib.QtWidgets', MagicMock()) @patch('openlp.core.lib.QtWidgets', MagicMock())

View File

@ -412,7 +412,7 @@ class TestVLCPlayer(TestCase, TestMixin):
# WHEN: An audio CD is loaded into VLC # WHEN: An audio CD is loaded into VLC
with patch.object(vlc_player, 'volume') as mocked_volume, \ with patch.object(vlc_player, 'volume') as mocked_volume, \
patch.object(vlc_player, 'media_state_wait') as mocked_media_state_wait: patch.object(vlc_player, 'media_state_wait'):
result = vlc_player.load(mocked_display) result = vlc_player.load(mocked_display)
# THEN: The video should be loaded # THEN: The video should be loaded
@ -457,7 +457,7 @@ class TestVLCPlayer(TestCase, TestMixin):
# WHEN: An audio CD is loaded into VLC # WHEN: An audio CD is loaded into VLC
with patch.object(vlc_player, 'volume') as mocked_volume, \ with patch.object(vlc_player, 'volume') as mocked_volume, \
patch.object(vlc_player, 'media_state_wait') as mocked_media_state_wait: patch.object(vlc_player, 'media_state_wait'):
result = vlc_player.load(mocked_display) result = vlc_player.load(mocked_display)
# THEN: The video should be loaded # THEN: The video should be loaded
@ -501,8 +501,7 @@ class TestVLCPlayer(TestCase, TestMixin):
vlc_player = VlcPlayer(None) vlc_player = VlcPlayer(None)
# WHEN: An audio CD is loaded into VLC # WHEN: An audio CD is loaded into VLC
with patch.object(vlc_player, 'volume') as mocked_volume, \ with patch.object(vlc_player, 'volume'), patch.object(vlc_player, 'media_state_wait'):
patch.object(vlc_player, 'media_state_wait') as mocked_media_state_wait:
result = vlc_player.load(mocked_display) result = vlc_player.load(mocked_display)
# THEN: The video should be loaded # THEN: The video should be loaded
@ -657,7 +656,7 @@ class TestVLCPlayer(TestCase, TestMixin):
# WHEN: play() is called # WHEN: play() is called
with patch.object(vlc_player, 'media_state_wait') as mocked_media_state_wait, \ with patch.object(vlc_player, 'media_state_wait') as mocked_media_state_wait, \
patch.object(vlc_player, 'volume') as mocked_volume: patch.object(vlc_player, 'volume'):
mocked_media_state_wait.return_value = False mocked_media_state_wait.return_value = False
result = vlc_player.play(mocked_display) result = vlc_player.play(mocked_display)
@ -690,7 +689,7 @@ class TestVLCPlayer(TestCase, TestMixin):
vlc_player.set_state(MediaState.Paused, mocked_display) vlc_player.set_state(MediaState.Paused, mocked_display)
# WHEN: play() is called # WHEN: play() is called
with patch.object(vlc_player, 'media_state_wait', return_value=True) as mocked_media_state_wait, \ with patch.object(vlc_player, 'media_state_wait', return_value=True), \
patch.object(vlc_player, 'volume') as mocked_volume, \ patch.object(vlc_player, 'volume') as mocked_volume, \
patch.object(vlc_player, 'get_live_state', return_value=MediaState.Loaded): patch.object(vlc_player, 'get_live_state', return_value=MediaState.Loaded):
result = vlc_player.play(mocked_display) result = vlc_player.play(mocked_display)

View File

@ -34,42 +34,30 @@ from openlp.core.ui import exceptionform
from tests.helpers.testmixin import TestMixin from tests.helpers.testmixin import TestMixin
exceptionform.WEBKIT_VERSION = 'Webkit Test'
exceptionform.MIGRATE_VERSION = 'Migrate Test' exceptionform.MIGRATE_VERSION = 'Migrate Test'
exceptionform.CHARDET_VERSION = 'CHARDET Test' exceptionform.CHARDET_VERSION = 'CHARDET Test'
exceptionform.ENCHANT_VERSION = 'Enchant Test' exceptionform.ENCHANT_VERSION = 'Enchant Test'
exceptionform.MAKO_VERSION = 'Mako Test' exceptionform.MAKO_VERSION = 'Mako Test'
exceptionform.ICU_VERSION = 'ICU Test'
exceptionform.VLC_VERSION = 'VLC Test' exceptionform.VLC_VERSION = 'VLC Test'
MAIL_ITEM_TEXT = ('**OpenLP Bug Report**\nVersion: Trunk Test\n\n--- Details of the Exception. ---\n\n' MAIL_ITEM_TEXT = ('**OpenLP Bug Report**\nVersion: Trunk Test\n\n--- Details of the Exception. ---\n\n'
'Description Test\n\n --- Exception Traceback ---\nopenlp: Traceback Test\n' 'Description Test\n\n --- Exception Traceback ---\nopenlp: Traceback Test\n'
'--- System information ---\nPlatform: Nose Test\n\n--- Library Versions ---\n' '--- System information ---\nPlatform: Nose Test\n\n--- Library Versions ---\n'
'Python: Python Test\nQt5: Qt5 Test\nPyQt5: PyQt5 Test\n' 'Python: Python Test\nQt5: Qt5 test\nPyQt5: PyQt5 Test\n'
'SQLAlchemy: SQLAlchemy Test\nAlembic: Alembic Test\nBeautifulSoup: BeautifulSoup Test\n' 'SQLAlchemy: SqlAlchemy Test\nSQLAlchemy Migrate: Migrate Test\nBeautifulSoup: BeautifulSoup Test\n'
'lxml: ETree Test\nChardet: Chardet Test\nPyEnchant: PyEnchant Test\nMako: Mako Test\n' 'lxml: ETree Test\nChardet: CHARDET Test\nPyEnchant: Enchant Test\nMako: Mako Test\n'
'pyICU: pyICU Test\nVLC: VLC Test\nPyUNO: UNO Bridge Test\n') 'pyUNO bridge: UNO Bridge Test\nVLC: VLC Test\n\n')
LIBRARY_VERSIONS = OrderedDict([
('Python', 'Python Test'),
('Qt5', 'Qt5 Test'),
('PyQt5', 'PyQt5 Test'),
('SQLAlchemy', 'SQLAlchemy Test'),
('Alembic', 'Alembic Test'),
('BeautifulSoup', 'BeautifulSoup Test'),
('lxml', 'ETree Test'),
('Chardet', 'Chardet Test'),
('PyEnchant', 'PyEnchant Test'),
('Mako', 'Mako Test'),
('pyICU', 'pyICU Test'),
('VLC', 'VLC Test')
])
@patch('openlp.core.ui.exceptionform.QtGui.QDesktopServices.openUrl') @patch("openlp.core.ui.exceptionform.Qt.qVersion")
@patch('openlp.core.ui.exceptionform.get_version') @patch("openlp.core.ui.exceptionform.QtGui.QDesktopServices.openUrl")
@patch('openlp.core.ui.exceptionform.get_library_versions') @patch("openlp.core.ui.exceptionform.get_version")
@patch('openlp.core.ui.exceptionform.is_linux') @patch("openlp.core.ui.exceptionform.sqlalchemy")
@patch('openlp.core.ui.exceptionform.platform.platform') @patch("openlp.core.ui.exceptionform.bs4")
@patch("openlp.core.ui.exceptionform.etree")
@patch("openlp.core.ui.exceptionform.is_linux")
@patch("openlp.core.ui.exceptionform.platform.platform")
@patch("openlp.core.ui.exceptionform.platform.python_version")
class TestExceptionForm(TestMixin, TestCase): class TestExceptionForm(TestMixin, TestCase):
""" """
Test functionality of exception form functions Test functionality of exception form functions

View File

@ -22,8 +22,8 @@
""" """
Package to test the openlp.core.ui.icons package. Package to test the openlp.core.ui.icons package.
""" """
from unittest import TestCase, skipUnless from unittest import TestCase
from unittest.mock import MagicMock, patch from unittest.mock import patch
from PyQt5 import QtGui from PyQt5 import QtGui

View File

@ -22,7 +22,6 @@
""" """
Package to test the openlp.core.ui.slidecontroller package. Package to test the openlp.core.ui.slidecontroller package.
""" """
import os
from unittest import TestCase from unittest import TestCase
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch

View File

@ -25,7 +25,7 @@ This module contains tests for the CSV Bible importer.
import csv import csv
from collections import namedtuple from collections import namedtuple
from unittest import TestCase from unittest import TestCase
from unittest.mock import ANY, MagicMock, PropertyMock, call, patch from unittest.mock import MagicMock, PropertyMock, call, patch
from openlp.core.common.path import Path from openlp.core.common.path import Path
from openlp.core.lib.exceptions import ValidationError from openlp.core.lib.exceptions import ValidationError
@ -132,35 +132,40 @@ class TestCSVImport(TestCase):
# GIVEN: A mocked csv.reader which returns an iterator with test data # GIVEN: A mocked csv.reader which returns an iterator with test data
test_data = [['1', 'Line 1', 'Data 1'], ['2', 'Line 2', 'Data 2'], ['3', 'Line 3', 'Data 3']] test_data = [['1', 'Line 1', 'Data 1'], ['2', 'Line 2', 'Data 2'], ['3', 'Line 3', 'Data 3']]
TestTuple = namedtuple('TestTuple', 'line_no line_description line_data') TestTuple = namedtuple('TestTuple', 'line_no line_description line_data')
mocked_csv_file = MagicMock()
mocked_enter_file = MagicMock()
mocked_csv_file.open.return_value.__enter__.return_value = mocked_enter_file
with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding', with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding',
return_value={'encoding': 'utf-8', 'confidence': 0.99}),\ return_value={'encoding': 'utf-8', 'confidence': 0.99}), \
patch('openlp.plugins.bibles.lib.importers.csvbible.Path.open', create=True) as mocked_open,\
patch('openlp.plugins.bibles.lib.importers.csvbible.csv.reader', patch('openlp.plugins.bibles.lib.importers.csvbible.csv.reader',
return_value=iter(test_data)) as mocked_reader: return_value=iter(test_data)) as mocked_reader:
# WHEN: Calling the CSVBible parse_csv_file method with a file name and TestTuple # WHEN: Calling the CSVBible parse_csv_file method with a file name and TestTuple
result = CSVBible.parse_csv_file(Path('file.csv'), TestTuple) result = CSVBible.parse_csv_file(mocked_csv_file, TestTuple)
# THEN: A list of TestTuple instances with the parsed data should be returned # THEN: A list of TestTuple instances with the parsed data should be returned
assert result == [TestTuple('1', 'Line 1', 'Data 1'), TestTuple('2', 'Line 2', 'Data 2'), assert result == [TestTuple('1', 'Line 1', 'Data 1'), TestTuple('2', 'Line 2', 'Data 2'),
TestTuple('3', 'Line 3', 'Data 3')] TestTuple('3', 'Line 3', 'Data 3')]
mocked_open.assert_called_once_with('r', encoding='utf-8', newline='') mocked_csv_file.open.assert_called_once_with('r', encoding='utf-8', newline='')
mocked_reader.assert_called_once_with(ANY, delimiter=',', quotechar='"') mocked_reader.assert_called_once_with(mocked_enter_file, delimiter=',', quotechar='"')
def test_parse_csv_file_oserror(self): def test_parse_csv_file_oserror(self):
""" """
Test the parse_csv_file() handles an OSError correctly Test the parse_csv_file() handles an OSError correctly
""" """
# GIVEN: Mocked a mocked open object which raises an OSError # GIVEN: Mocked a mocked open object which raises an OSError
mocked_csv_file = MagicMock()
mocked_csv_file.__str__.return_value = 'file.csv'
mocked_csv_file.open.side_effect = OSError()
with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding', with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding',
return_value={'encoding': 'utf-8', 'confidence': 0.99}),\ return_value={'encoding': 'utf-8', 'confidence': 0.99}):
patch('openlp.plugins.bibles.lib.importers.csvbible.Path.open', side_effect=OSError, create=True):
# WHEN: Calling CSVBible.parse_csv_file # WHEN: Calling CSVBible.parse_csv_file
# THEN: A ValidationError should be raised # THEN: A ValidationError should be raised
with self.assertRaises(ValidationError) as context: with self.assertRaises(ValidationError) as context:
CSVBible.parse_csv_file(Path('file.csv'), None) CSVBible.parse_csv_file(mocked_csv_file, None)
assert context.exception.msg == 'Parsing "file.csv" failed' assert context.exception.msg == 'Parsing "file.csv" failed'
def test_parse_csv_file_csverror(self): def test_parse_csv_file_csverror(self):
@ -168,15 +173,17 @@ class TestCSVImport(TestCase):
Test the parse_csv_file() handles an csv.Error correctly Test the parse_csv_file() handles an csv.Error correctly
""" """
# GIVEN: Mocked a csv.reader which raises an csv.Error # GIVEN: Mocked a csv.reader which raises an csv.Error
mocked_csv_file = MagicMock()
mocked_csv_file.__str__.return_value = 'file.csv'
with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding', with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding',
return_value={'encoding': 'utf-8', 'confidence': 0.99}),\ return_value={'encoding': 'utf-8', 'confidence': 0.99}),\
patch('openlp.plugins.bibles.lib.importers.csvbible.Path.open', create=True),\
patch('openlp.plugins.bibles.lib.importers.csvbible.csv.reader', side_effect=csv.Error): patch('openlp.plugins.bibles.lib.importers.csvbible.csv.reader', side_effect=csv.Error):
# WHEN: Calling CSVBible.parse_csv_file # WHEN: Calling CSVBible.parse_csv_file
# THEN: A ValidationError should be raised # THEN: A ValidationError should be raised
with self.assertRaises(ValidationError) as context: with self.assertRaises(ValidationError) as context:
CSVBible.parse_csv_file(Path('file.csv'), None) CSVBible.parse_csv_file(mocked_csv_file, None)
assert context.exception.msg == 'Parsing "file.csv" failed' assert context.exception.msg == 'Parsing "file.csv" failed'
def test_process_books_stopped_import(self): def test_process_books_stopped_import(self):

View File

@ -55,7 +55,7 @@ class TestLib(TestCase, TestMixin):
# WHEN: Calling get_reference_separator # WHEN: Calling get_reference_separator
for key, value in separators.items(): for key, value in separators.items():
_ = lib.get_reference_separator(key) lib.get_reference_separator(key)
# THEN: get_reference_separator should return the correct separator # THEN: get_reference_separator should return the correct separator
assert separators[key] == value assert separators[key] == value

View File

@ -756,7 +756,7 @@ class TestMediaItem(TestCase, TestMixin):
# GIVEN: An instance of :class:`MediaManagerItem` and mocked media_item.settings and select_book_combo_box # GIVEN: An instance of :class:`MediaManagerItem` and mocked media_item.settings and select_book_combo_box
self.media_item.version_combo_box = MagicMock(**{'currentData.return_value': None}) self.media_item.version_combo_box = MagicMock(**{'currentData.return_value': None})
self.media_item.select_book_combo_box = MagicMock() self.media_item.select_book_combo_box = MagicMock()
with patch.object(self.media_item, 'initialise_advanced_bible') as mocked_initialise_advanced_bible: with patch.object(self.media_item, 'initialise_advanced_bible'):
# WHEN: Calling on_version_combo_box_index_changed # WHEN: Calling on_version_combo_box_index_changed
self.media_item.on_version_combo_box_index_changed() self.media_item.on_version_combo_box_index_changed()
@ -774,7 +774,7 @@ class TestMediaItem(TestCase, TestMixin):
mocked_bible_db.name = 'ABC' mocked_bible_db.name = 'ABC'
self.media_item.version_combo_box = MagicMock(**{'currentData.return_value': mocked_bible_db}) self.media_item.version_combo_box = MagicMock(**{'currentData.return_value': mocked_bible_db})
self.media_item.select_book_combo_box = MagicMock() self.media_item.select_book_combo_box = MagicMock()
with patch.object(self.media_item, 'initialise_advanced_bible') as mocked_initialise_advanced_bible: with patch.object(self.media_item, 'initialise_advanced_bible'):
# WHEN: Calling on_version_combo_box_index_changed # WHEN: Calling on_version_combo_box_index_changed
self.media_item.on_version_combo_box_index_changed() self.media_item.on_version_combo_box_index_changed()
@ -792,7 +792,7 @@ class TestMediaItem(TestCase, TestMixin):
self.media_item.list_view = MagicMock(**{'count.return_value': 5}) self.media_item.list_view = MagicMock(**{'count.return_value': 5})
self.media_item.style_combo_box = MagicMock() self.media_item.style_combo_box = MagicMock()
self.media_item.select_book_combo_box = MagicMock() self.media_item.select_book_combo_box = MagicMock()
with patch.object(self.media_item, 'initialise_advanced_bible') as mocked_initialise_advanced_bible, \ with patch.object(self.media_item, 'initialise_advanced_bible'), \
patch('openlp.plugins.bibles.lib.mediaitem.critical_error_message_box') \ patch('openlp.plugins.bibles.lib.mediaitem.critical_error_message_box') \
as mocked_critical_error_message_box: as mocked_critical_error_message_box:
@ -815,7 +815,7 @@ class TestMediaItem(TestCase, TestMixin):
self.media_item.list_view = MagicMock(**{'count.return_value': 5}) self.media_item.list_view = MagicMock(**{'count.return_value': 5})
self.media_item.style_combo_box = MagicMock() self.media_item.style_combo_box = MagicMock()
self.media_item.select_book_combo_box = MagicMock() self.media_item.select_book_combo_box = MagicMock()
with patch.object(self.media_item, 'initialise_advanced_bible') as mocked_initialise_advanced_bible, \ with patch.object(self.media_item, 'initialise_advanced_bible'), \
patch('openlp.plugins.bibles.lib.mediaitem.critical_error_message_box', patch('openlp.plugins.bibles.lib.mediaitem.critical_error_message_box',
return_value=QtWidgets.QMessageBox.No) as mocked_critical_error_message_box: return_value=QtWidgets.QMessageBox.No) as mocked_critical_error_message_box:

View File

@ -22,14 +22,12 @@
""" """
This module contains tests for the upgrade submodule of the Bibles plugin. This module contains tests for the upgrade submodule of the Bibles plugin.
""" """
import os
import shutil import shutil
from pathlib import Path from pathlib import Path
from tempfile import mkdtemp from tempfile import mkdtemp
from unittest import TestCase from unittest import TestCase
from unittest.mock import MagicMock, call, patch from unittest.mock import MagicMock, call, patch
from PyQt5 import QtWidgets
from sqlalchemy import create_engine from sqlalchemy import create_engine
from openlp.core.common.settings import ProxyMode from openlp.core.common.settings import ProxyMode

View File

@ -30,7 +30,7 @@ from PyQt5 import QtCore
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
from openlp.core.lib.plugin import PluginStatus from openlp.core.lib.plugin import PluginStatus
from openlp.core.lib.serviceitem import ServiceItem from openlp.core.lib.serviceitem import ServiceItem
from openlp.plugins.custom.lib import CustomMediaItem from openlp.plugins.custom.lib.mediaitem import CustomMediaItem
from tests.helpers.testmixin import TestMixin from tests.helpers.testmixin import TestMixin

View File

@ -29,7 +29,7 @@ from PyQt5 import QtWidgets
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings from openlp.core.common.settings import Settings
from openlp.plugins.images.lib import ImageTab from openlp.plugins.images.lib.imagetab import ImageTab
from tests.helpers.testmixin import TestMixin from tests.helpers.testmixin import TestMixin

View File

@ -27,7 +27,6 @@ from tempfile import mkdtemp
from unittest import TestCase from unittest import TestCase
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
from openlp.core.common.path import Path
from openlp.core.common.settings import Settings from openlp.core.common.settings import Settings
from openlp.plugins.presentations.lib.impresscontroller import ImpressController, ImpressDocument, TextType from openlp.plugins.presentations.lib.impresscontroller import ImpressController, ImpressDocument, TextType
from openlp.plugins.presentations.presentationplugin import __default_settings__ from openlp.plugins.presentations.presentationplugin import __default_settings__

View File

@ -313,7 +313,7 @@ class TestLib(TestCase):
# WHEN: Transposing it 1 down # WHEN: Transposing it 1 down
# THEN: An exception should be raised # THEN: An exception should be raised
with self.assertRaises(ValueError) as err: with self.assertRaises(ValueError) as err:
new_chord = transpose_chord(chord, -1, 'english') transpose_chord(chord, -1, 'english')
assert err.exception.args[0] == '\'T\' is not in list', \ assert err.exception.args[0] == '\'T\' is not in list', \
'ValueError exception should have been thrown for invalid chord' 'ValueError exception should have been thrown for invalid chord'

View File

@ -23,7 +23,7 @@
This module contains tests for the lib submodule of the Songs plugin. This module contains tests for the lib submodule of the Songs plugin.
""" """
from unittest import TestCase from unittest import TestCase
from unittest.mock import MagicMock, call, patch from unittest.mock import MagicMock, patch
from PyQt5 import QtCore from PyQt5 import QtCore
@ -170,27 +170,23 @@ class TestMediaItem(TestCase, TestMixin):
""" """
Test that songbooks are sorted naturally Test that songbooks are sorted naturally
""" """
# GIVEN: Search results grouped by book and entry, plus a mocked QtListWidgetItem # GIVEN: Search results grouped by book and entry
with patch('openlp.core.lib.QtWidgets.QListWidgetItem') as MockedQListWidgetItem: search_results = [('2', 'Thy Book', 'Thy Song', 50),
mock_search_results = [('2', 'Thy Book', 'Thy Song', 50), ('2', 'My Book', 'Your Song', 7),
('2', 'My Book', 'Your Song', 7), ('10', 'My Book', 'Our Song', 12),
('10', 'My Book', 'Our Song', 12), ('1', 'My Book', 'My Song', 1),
('1', 'My Book', 'My Song', 1), ('2', 'Thy Book', 'A Song', 8)]
('2', 'Thy Book', 'A Song', 8)]
mock_qlist_widget = MagicMock()
MockedQListWidgetItem.return_value = mock_qlist_widget
# WHEN: I display song search results grouped by book # WHEN: I display song search results grouped by book
self.media_item.display_results_book(mock_search_results) self.media_item.display_results_book(search_results)
# THEN: The songbooks are inserted in the right (natural) order, # THEN: The songbooks are sorted inplace in the right (natural) order,
# grouped first by book, then by number, then by song title # grouped first by book, then by number, then by song title
calls = [call('My Book #1: My Song'), call().setData(QtCore.Qt.UserRole, 1), assert search_results == [('1', 'My Book', 'My Song', 1),
call('My Book #2: Your Song'), call().setData(QtCore.Qt.UserRole, 7), ('2', 'My Book', 'Your Song', 7),
call('My Book #10: Our Song'), call().setData(QtCore.Qt.UserRole, 12), ('10', 'My Book', 'Our Song', 12),
call('Thy Book #2: A Song'), call().setData(QtCore.Qt.UserRole, 8), ('2', 'Thy Book', 'A Song', 8),
call('Thy Book #2: Thy Song'), call().setData(QtCore.Qt.UserRole, 50)] ('2', 'Thy Book', 'Thy Song', 50)]
MockedQListWidgetItem.assert_has_calls(calls)
def test_display_results_topic(self): def test_display_results_topic(self):
""" """

View File

@ -100,7 +100,7 @@ class TestMediaShoutImport(TestCase):
mocked_pyodbc.connect.return_value = mocked_connection mocked_pyodbc.connect.return_value = mocked_connection
# WHEN: do_import is called # WHEN: do_import is called
with patch.object(importer, 'import_wizard') as mocked_import_wizard, \ with patch.object(importer, 'import_wizard'), \
patch.object(importer, 'process_song') as mocked_process_song: patch.object(importer, 'process_song') as mocked_process_song:
importer.do_import() importer.do_import()
@ -134,7 +134,7 @@ class TestMediaShoutImport(TestCase):
mocked_pyodbc.connect.return_value = mocked_connection mocked_pyodbc.connect.return_value = mocked_connection
# WHEN: do_import is called, but cancelled # WHEN: do_import is called, but cancelled
with patch.object(importer, 'import_wizard') as mocked_import_wizard, \ with patch.object(importer, 'import_wizard'), \
patch.object(importer, 'process_song') as mocked_process_song: patch.object(importer, 'process_song') as mocked_process_song:
importer.stop_import_flag = True importer.stop_import_flag = True
importer.do_import() importer.do_import()

View File

@ -25,8 +25,6 @@ Functional tests to test the AppLocation class and related methods.
from unittest import TestCase from unittest import TestCase
from openlp.core.common import is_not_image_file from openlp.core.common import is_not_image_file
from openlp.core.common.path import Path
from tests.helpers.testmixin import TestMixin
from tests.utils.constants import RESOURCE_PATH from tests.utils.constants import RESOURCE_PATH

View File

@ -46,7 +46,6 @@ class TestBibleImportForm(TestCase, TestMixin):
self.setup_application() self.setup_application()
self.main_window = QtWidgets.QMainWindow() self.main_window = QtWidgets.QMainWindow()
Registry().register('main_window', self.main_window) Registry().register('main_window', self.main_window)
PYSWORD_AVAILABLE = False
self.mocked_manager = MagicMock() self.mocked_manager = MagicMock()
self.form = BibleImportForm(self.main_window, self.mocked_manager, MagicMock()) self.form = BibleImportForm(self.main_window, self.mocked_manager, MagicMock())

View File

@ -27,7 +27,8 @@ from unittest.mock import MagicMock, patch
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings from openlp.core.common.settings import Settings
from openlp.plugins.bibles.lib import BibleManager, LanguageSelection from openlp.plugins.bibles.lib import LanguageSelection
from openlp.plugins.bibles.lib.manager import BibleManager
from tests.helpers.testmixin import TestMixin from tests.helpers.testmixin import TestMixin
from tests.utils.constants import TEST_RESOURCES_PATH from tests.utils.constants import TEST_RESOURCES_PATH

View File

@ -27,7 +27,8 @@ from unittest.mock import MagicMock, patch
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings from openlp.core.common.settings import Settings
from openlp.plugins.bibles.lib import BibleManager, LanguageSelection, parse_reference from openlp.plugins.bibles.lib import LanguageSelection, parse_reference
from openlp.plugins.bibles.lib.manager import BibleManager
from tests.helpers.testmixin import TestMixin from tests.helpers.testmixin import TestMixin
from tests.utils.constants import TEST_RESOURCES_PATH from tests.utils.constants import TEST_RESOURCES_PATH

View File

@ -84,7 +84,7 @@ class TestEditCustomForm(TestCase, TestMixin):
Test the on_add_button_clicked_test method / add_button button. Test the on_add_button_clicked_test method / add_button button.
""" """
# GIVEN: A mocked QDialog.exec() method # GIVEN: A mocked QDialog.exec() method
with patch('PyQt5.QtWidgets.QDialog.exec') as mocked_exec: with patch('PyQt5.QtWidgets.QDialog.exec'):
# WHEN: Add a new slide. # WHEN: Add a new slide.
QtTest.QTest.mouseClick(self.form.add_button, QtCore.Qt.LeftButton) QtTest.QTest.mouseClick(self.form.add_button, QtCore.Qt.LeftButton)

View File

@ -58,7 +58,7 @@ class TestEditCustomSlideForm(TestCase, TestMixin):
Test if the dialog is correctly set up. Test if the dialog is correctly set up.
""" """
# GIVEN: A mocked QDialog.exec() method # GIVEN: A mocked QDialog.exec() method
with patch('PyQt5.QtWidgets.QDialog.exec') as mocked_exec: with patch('PyQt5.QtWidgets.QDialog.exec'):
# WHEN: Show the dialog. # WHEN: Show the dialog.
self.form.exec() self.form.exec()
@ -70,7 +70,7 @@ class TestEditCustomSlideForm(TestCase, TestMixin):
Test the set_text() method. Test the set_text() method.
""" """
# GIVEN: A mocked QDialog.exec() method # GIVEN: A mocked QDialog.exec() method
with patch('PyQt5.QtWidgets.QDialog.exec') as mocked_exec: with patch('PyQt5.QtWidgets.QDialog.exec'):
mocked_set_focus = MagicMock() mocked_set_focus = MagicMock()
self.form.slide_text_edit.setFocus = mocked_set_focus self.form.slide_text_edit.setFocus = mocked_set_focus
wanted_text = 'THIS TEXT SHOULD BE SHOWN.' wanted_text = 'THIS TEXT SHOULD BE SHOWN.'

View File

@ -81,7 +81,7 @@ class TestMediaClipSelectorForm(TestCase, TestMixin):
Test if the dialog is correctly set up. Test if the dialog is correctly set up.
""" """
# GIVEN: A mocked QDialog.exec() method # GIVEN: A mocked QDialog.exec() method
with patch('PyQt5.QtWidgets.QDialog.exec') as mocked_exec: with patch('PyQt5.QtWidgets.QDialog.exec'):
# WHEN: Show the dialog. # WHEN: Show the dialog.
self.form.exec() self.form.exec()
@ -96,7 +96,7 @@ class TestMediaClipSelectorForm(TestCase, TestMixin):
with patch('openlp.plugins.media.forms.mediaclipselectorform.critical_error_message_box') as \ with patch('openlp.plugins.media.forms.mediaclipselectorform.critical_error_message_box') as \
mocked_critical_error_message_box,\ mocked_critical_error_message_box,\
patch('openlp.plugins.media.forms.mediaclipselectorform.os.path.exists') as mocked_os_path_exists,\ patch('openlp.plugins.media.forms.mediaclipselectorform.os.path.exists') as mocked_os_path_exists,\
patch('PyQt5.QtWidgets.QDialog.exec') as mocked_exec: patch('PyQt5.QtWidgets.QDialog.exec'):
self.form.exec() self.form.exec()
# WHEN: The load button is clicked with no path set # WHEN: The load button is clicked with no path set
@ -134,7 +134,7 @@ class TestMediaClipSelectorForm(TestCase, TestMixin):
Test the behavior when the title combobox is updated Test the behavior when the title combobox is updated
""" """
# GIVEN: Mocked methods and some entries in the title combobox. # GIVEN: Mocked methods and some entries in the title combobox.
with patch('PyQt5.QtWidgets.QDialog.exec') as mocked_exec: with patch('PyQt5.QtWidgets.QDialog.exec'):
self.form.exec() self.form.exec()
self.form.vlc_media_player.get_length.return_value = 1000 self.form.vlc_media_player.get_length.return_value = 1000
self.form.audio_tracks_combobox.itemData = MagicMock() self.form.audio_tracks_combobox.itemData = MagicMock()
@ -163,7 +163,7 @@ class TestMediaClipSelectorForm(TestCase, TestMixin):
# GIVEN: Mocked methods. # GIVEN: Mocked methods.
with patch('openlp.plugins.media.forms.mediaclipselectorform.critical_error_message_box') as \ with patch('openlp.plugins.media.forms.mediaclipselectorform.critical_error_message_box') as \
mocked_critical_error_message_box,\ mocked_critical_error_message_box,\
patch('PyQt5.QtWidgets.QDialog.exec') as mocked_exec: patch('PyQt5.QtWidgets.QDialog.exec'):
self.form.exec() self.form.exec()
# WHEN: The save button is clicked with a NoneType in start_time_ms or end_time_ms # WHEN: The save button is clicked with a NoneType in start_time_ms or end_time_ms

View File

@ -91,7 +91,7 @@ class ProjectorSourceFormTest(TestCase, TestMixin):
if os.path.exists(TEST_DB): if os.path.exists(TEST_DB):
os.unlink(TEST_DB) os.unlink(TEST_DB)
break break
except: except Exception:
time.sleep(1) time.sleep(1)
retries += 1 retries += 1
self.destroy_settings() self.destroy_settings()