Fix uno import noise in python 3

This commit is contained in:
Tim Bentley 2013-07-19 21:56:31 +01:00
parent 7d081b866a
commit 50f3b2b563
2 changed files with 32 additions and 18 deletions

View File

@ -185,7 +185,7 @@ class OpenLP(QtGui.QApplication):
""" """
log.exception(''.join(format_exception(exctype, value, traceback))) log.exception(''.join(format_exception(exctype, value, traceback)))
if not hasattr(self, u'exception_form'): 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.exception_form.exception_text_edit.setPlainText(''.join(format_exception(exctype, value, traceback)))
self.set_normal_cursor() self.set_normal_cursor()
self.exception_form.exec_() self.exception_form.exec_()

View File

@ -37,6 +37,8 @@ import platform
import bs4 import bs4
import sqlalchemy import sqlalchemy
from lxml import etree from lxml import etree
from openlp.core.lib import Registry
from PyQt4 import Qt, QtCore, QtGui, QtWebKit from PyQt4 import Qt, QtCore, QtGui, QtWebKit
try: try:
@ -77,19 +79,7 @@ try:
CHERRYPY_VERSION = cherrypy.__version__ CHERRYPY_VERSION = cherrypy.__version__
except ImportError: except ImportError:
CHERRYPY_VERSION = u'-' 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: try:
WEBKIT_VERSION = QtWebKit.qWebKitVersion() WEBKIT_VERSION = QtWebKit.qWebKitVersion()
except AttributeError: except AttributeError:
@ -100,7 +90,6 @@ try:
except ImportError: except ImportError:
VLC_VERSION = u'-' VLC_VERSION = u'-'
from openlp.core.lib import UiStrings, Settings, translate from openlp.core.lib import UiStrings, Settings, translate
from openlp.core.utils import get_application_version from openlp.core.utils import get_application_version
@ -113,11 +102,11 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
""" """
The exception dialog The exception dialog
""" """
def __init__(self, parent): def __init__(self):
""" """
Constructor. Constructor.
""" """
QtGui.QDialog.__init__(self, parent) QtGui.QDialog.__init__(self, self.main_window)
self.setupUi(self) self.setupUi(self)
self.settings_section = u'crashreport' self.settings_section = u'crashreport'
@ -152,7 +141,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
u'Mako: %s\n' % MAKO_VERSION + \ u'Mako: %s\n' % MAKO_VERSION + \
u'CherryPy: %s\n' % CHERRYPY_VERSION + \ u'CherryPy: %s\n' % CHERRYPY_VERSION + \
u'pyICU: %s\n' % ICU_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 u'VLC: %s\n' % VLC_VERSION
if platform.system() == u'Linux': if platform.system() == u'Linux':
if os.environ.get(u'KDE_FULL_SESSION') == u'true': 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.save_report_button.setEnabled(state)
self.send_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)