Merge lp:~trb143/openlp/junefixes into lp:openlp

Proposed by Tim Bentley
Status: Merged
Merged at revision: 2282
Proposed branch: lp:~trb143/openlp/junefixes
Merge into: lp:openlp
Diff against target: 127 lines (+40/-19)
3 files modified
openlp/core/__init__.py (+1/-1)
openlp/core/ui/exceptionform.py (+38/-17)
openlp/core/ui/formattingtagform.py (+1/-1)
To merge this branch: bzr merge lp:~trb143/openlp/junefixes
Reviewer Review Type Date Requested Status
Andreas Preikschat (community) Approve
Review via email: mp+176059@code.launchpad.net

This proposal supersedes a proposal from 2013-07-19.

Description of the change

In testing python3 there is alot of import noise with uno.
This is caused by the exceptionform so only request the uno details if the form is being displayed. This removes all the import noise!

To post a comment you must log in.
Revision history for this message
Andreas Preikschat (googol-deactivatedaccount) wrote : Posted in a previous version of this proposal

Missing line (line 22/23).

Could you add a doc string to the method (it should be clear, why this method exits)

review: Needs Fixing
Revision history for this message
Andreas Preikschat (googol-deactivatedaccount) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/__init__.py'
2--- openlp/core/__init__.py 2013-03-26 11:45:18 +0000
3+++ openlp/core/__init__.py 2013-07-21 14:15:33 +0000
4@@ -185,7 +185,7 @@
5 """
6 log.exception(''.join(format_exception(exctype, value, traceback)))
7 if not hasattr(self, u'exception_form'):
8- self.exception_form = ExceptionForm(self.main_window)
9+ self.exception_form = ExceptionForm()
10 self.exception_form.exception_text_edit.setPlainText(''.join(format_exception(exctype, value, traceback)))
11 self.set_normal_cursor()
12 self.exception_form.exec_()
13
14=== modified file 'openlp/core/ui/exceptionform.py'
15--- openlp/core/ui/exceptionform.py 2013-06-26 18:54:21 +0000
16+++ openlp/core/ui/exceptionform.py 2013-07-21 14:15:33 +0000
17@@ -37,6 +37,9 @@
18 import bs4
19 import sqlalchemy
20 from lxml import etree
21+
22+from openlp.core.lib import Registry
23+
24 from PyQt4 import Qt, QtCore, QtGui, QtWebKit
25
26 try:
27@@ -77,19 +80,7 @@
28 CHERRYPY_VERSION = cherrypy.__version__
29 except ImportError:
30 CHERRYPY_VERSION = u'-'
31-try:
32- import uno
33- arg = uno.createUnoStruct(u'com.sun.star.beans.PropertyValue')
34- arg.Name = u'nodepath'
35- arg.Value = u'/org.openoffice.Setup/Product'
36- context = uno.getComponentContext()
37- provider = context.ServiceManager.createInstance(u'com.sun.star.configuration.ConfigurationProvider')
38- node = provider.createInstanceWithArguments(u'com.sun.star.configuration.ConfigurationAccess', (arg,))
39- UNO_VERSION = node.getByName(u'ooSetupVersion')
40-except ImportError:
41- UNO_VERSION = u'-'
42-except:
43- UNO_VERSION = u'- (Possible non-standard UNO installation)'
44+
45 try:
46 WEBKIT_VERSION = QtWebKit.qWebKitVersion()
47 except AttributeError:
48@@ -100,7 +91,6 @@
49 except ImportError:
50 VLC_VERSION = u'-'
51
52-
53 from openlp.core.lib import UiStrings, Settings, translate
54 from openlp.core.utils import get_application_version
55
56@@ -113,11 +103,11 @@
57 """
58 The exception dialog
59 """
60- def __init__(self, parent):
61+ def __init__(self):
62 """
63 Constructor.
64 """
65- QtGui.QDialog.__init__(self, parent)
66+ QtGui.QDialog.__init__(self, self.main_window)
67 self.setupUi(self)
68 self.settings_section = u'crashreport'
69
70@@ -152,7 +142,7 @@
71 u'Mako: %s\n' % MAKO_VERSION + \
72 u'CherryPy: %s\n' % CHERRYPY_VERSION + \
73 u'pyICU: %s\n' % ICU_VERSION + \
74- u'pyUNO bridge: %s\n' % UNO_VERSION + \
75+ u'pyUNO bridge: %s\n' % self._pyuno_import() + \
76 u'VLC: %s\n' % VLC_VERSION
77 if platform.system() == u'Linux':
78 if os.environ.get(u'KDE_FULL_SESSION') == u'true':
79@@ -256,3 +246,34 @@
80 """
81 self.save_report_button.setEnabled(state)
82 self.send_report_button.setEnabled(state)
83+
84+ def _pyuno_import(self):
85+ """
86+ Added here to define only when the form is actioned. The uno interface spits out lots of exception messages
87+ if the import is at a file level. If uno import is changed this could be reverted.
88+ This happens in other classes but there it is localised here it is across the whole system and hides real
89+ errors.
90+ """
91+ try:
92+ import uno
93+ arg = uno.createUnoStruct(u'com.sun.star.beans.PropertyValue')
94+ arg.Name = u'nodepath'
95+ arg.Value = u'/org.openoffice.Setup/Product'
96+ context = uno.getComponentContext()
97+ provider = context.ServiceManager.createInstance(u'com.sun.star.configuration.ConfigurationProvider')
98+ node = provider.createInstanceWithArguments(u'com.sun.star.configuration.ConfigurationAccess', (arg,))
99+ return node.getByName(u'ooSetupVersion')
100+ except ImportError:
101+ return u'-'
102+ except:
103+ return u'- (Possible non-standard UNO installation)'
104+
105+ def _get_main_window(self):
106+ """
107+ Adds the main window to the class dynamically
108+ """
109+ if not hasattr(self, u'_main_window'):
110+ self._main_window = Registry().get(u'main_window')
111+ return self._main_window
112+
113+ main_window = property(_get_main_window)
114\ No newline at end of file
115
116=== modified file 'openlp/core/ui/formattingtagform.py'
117--- openlp/core/ui/formattingtagform.py 2013-03-06 22:42:52 +0000
118+++ openlp/core/ui/formattingtagform.py 2013-07-21 14:15:33 +0000
119@@ -31,7 +31,7 @@
120 Custom tags can be defined and saved. The Custom Tag arrays are saved in a pickle so QSettings works on them. Base Tags
121 cannot be changed.
122 """
123-from PyQt4 import QtCore, QtGui
124+from PyQt4 import QtGui
125
126 from openlp.core.lib import FormattingTags, translate
127 from openlp.core.lib.ui import critical_error_message_box