From dc7cb85574810717888f97ca6e6cfa864b9cf18e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 19 Jul 2013 16:51:47 +0100 Subject: [PATCH 1/4] Uneeded import --- openlp/core/ui/formattingtagform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/formattingtagform.py b/openlp/core/ui/formattingtagform.py index d2390c2f9..30ab0902d 100644 --- a/openlp/core/ui/formattingtagform.py +++ b/openlp/core/ui/formattingtagform.py @@ -31,7 +31,7 @@ The :mod:`formattingtagform` provides an Tag Edit facility. The Base set are pro Custom tags can be defined and saved. The Custom Tag arrays are saved in a pickle so QSettings works on them. Base Tags cannot be changed. """ -from PyQt4 import QtCore, QtGui +from PyQt4 import QtGui from openlp.core.lib import FormattingTags, translate from openlp.core.lib.ui import critical_error_message_box From 50f3b2b563b938a0665b94240636a991c4d974cf Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 19 Jul 2013 21:56:31 +0100 Subject: [PATCH 2/4] Fix uno import noise in python 3 --- openlp/core/__init__.py | 2 +- openlp/core/ui/exceptionform.py | 48 +++++++++++++++++++++------------ 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 23986ffc4..16987df5d 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -185,7 +185,7 @@ class OpenLP(QtGui.QApplication): """ log.exception(''.join(format_exception(exctype, value, traceback))) if not hasattr(self, u'exception_form'): - self.exception_form = ExceptionForm(self.main_window) + self.exception_form = ExceptionForm() self.exception_form.exception_text_edit.setPlainText(''.join(format_exception(exctype, value, traceback))) self.set_normal_cursor() self.exception_form.exec_() diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index 49d6b0bef..bbd76446b 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -37,6 +37,8 @@ import platform import bs4 import sqlalchemy from lxml import etree + +from openlp.core.lib import Registry from PyQt4 import Qt, QtCore, QtGui, QtWebKit try: @@ -77,19 +79,7 @@ try: CHERRYPY_VERSION = cherrypy.__version__ except ImportError: CHERRYPY_VERSION = u'-' -try: - import uno - arg = uno.createUnoStruct(u'com.sun.star.beans.PropertyValue') - arg.Name = u'nodepath' - arg.Value = u'/org.openoffice.Setup/Product' - context = uno.getComponentContext() - provider = context.ServiceManager.createInstance(u'com.sun.star.configuration.ConfigurationProvider') - node = provider.createInstanceWithArguments(u'com.sun.star.configuration.ConfigurationAccess', (arg,)) - UNO_VERSION = node.getByName(u'ooSetupVersion') -except ImportError: - UNO_VERSION = u'-' -except: - UNO_VERSION = u'- (Possible non-standard UNO installation)' + try: WEBKIT_VERSION = QtWebKit.qWebKitVersion() except AttributeError: @@ -100,7 +90,6 @@ try: except ImportError: VLC_VERSION = u'-' - from openlp.core.lib import UiStrings, Settings, translate from openlp.core.utils import get_application_version @@ -113,11 +102,11 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): """ The exception dialog """ - def __init__(self, parent): + def __init__(self): """ Constructor. """ - QtGui.QDialog.__init__(self, parent) + QtGui.QDialog.__init__(self, self.main_window) self.setupUi(self) self.settings_section = u'crashreport' @@ -152,7 +141,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): u'Mako: %s\n' % MAKO_VERSION + \ u'CherryPy: %s\n' % CHERRYPY_VERSION + \ u'pyICU: %s\n' % ICU_VERSION + \ - u'pyUNO bridge: %s\n' % UNO_VERSION + \ + u'pyUNO bridge: %s\n' % self._pyuno_import() + \ u'VLC: %s\n' % VLC_VERSION if platform.system() == u'Linux': if os.environ.get(u'KDE_FULL_SESSION') == u'true': @@ -256,3 +245,28 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): """ self.save_report_button.setEnabled(state) self.send_report_button.setEnabled(state) + + def _pyuno_import(self): + try: + import uno + arg = uno.createUnoStruct(u'com.sun.star.beans.PropertyValue') + arg.Name = u'nodepath' + arg.Value = u'/org.openoffice.Setup/Product' + context = uno.getComponentContext() + provider = context.ServiceManager.createInstance(u'com.sun.star.configuration.ConfigurationProvider') + node = provider.createInstanceWithArguments(u'com.sun.star.configuration.ConfigurationAccess', (arg,)) + return node.getByName(u'ooSetupVersion') + except ImportError: + return u'-' + except: + return u'- (Possible non-standard UNO installation)' + + def _get_main_window(self): + """ + Adds the main window to the class dynamically + """ + if not hasattr(self, u'_main_window'): + self._main_window = Registry().get(u'main_window') + return self._main_window + + main_window = property(_get_main_window) \ No newline at end of file From 790c9ae4f6440a6830156d2d42118593cc5a94a6 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 21 Jul 2013 15:10:21 +0100 Subject: [PATCH 3/4] Add doc string --- openlp/core/ui/exceptionform.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index bbd76446b..62f8fae71 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -247,6 +247,12 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): self.send_report_button.setEnabled(state) def _pyuno_import(self): + """ + Added here to define only when the form is actioned. The uno interface spits out lots of exception messages + if the import is at a file level. If uno import is changed this could be reverted. + This happens in other classes but there it is localised here it is across the whole system and hides real + errors. + """ try: import uno arg = uno.createUnoStruct(u'com.sun.star.beans.PropertyValue') From 72c83d444bff9f2ef76e38a6d52047979fcf25a8 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 21 Jul 2013 15:13:44 +0100 Subject: [PATCH 4/4] missing blank line --- openlp/core/ui/exceptionform.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index 62f8fae71..d89a9fef9 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -39,6 +39,7 @@ import sqlalchemy from lxml import etree from openlp.core.lib import Registry + from PyQt4 import Qt, QtCore, QtGui, QtWebKit try: