openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #20889
[Merge] lp:~trb143/openlp/junefixes into lp:openlp
Tim Bentley has proposed merging lp:~trb143/openlp/junefixes into lp:openlp.
Requested reviews:
Jonathan Corwin (j-corwin)
Andreas Preikschat (googol)
For more details, see:
https://code.launchpad.net/~trb143/openlp/junefixes/+merge/172247
Correct the application code so windows can invalidate application on exit.
Removed in Registry migration.
Migrate formatting tags to json from cpickle
--
https://code.launchpad.net/~trb143/openlp/junefixes/+merge/172247
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/formattingtags.py'
--- openlp/core/lib/formattingtags.py 2013-02-14 14:54:45 +0000
+++ openlp/core/lib/formattingtags.py 2013-06-30 18:40:35 +0000
@@ -29,7 +29,7 @@
"""
Provide HTML Tag management and Formatting Tag access class
"""
-import cPickle
+import json
from openlp.core.lib import Settings, translate
@@ -66,7 +66,7 @@
if isinstance(tag[element], unicode):
tag[element] = tag[element].encode('utf8')
# Formatting Tags were also known as display tags.
- Settings().setValue(u'displayTags/html_tags', cPickle.dumps(tags) if tags else u'')
+ Settings().setValue(u'formattingTags/html_tags', json.dumps(tags) if tags else u'')
@staticmethod
def load_tags():
@@ -156,13 +156,10 @@
u'end html': u'', u'protected': True, u'temporary': False})
FormattingTags.add_html_tags(base_tags)
FormattingTags.add_html_tags(temporary_tags)
-
# Formatting Tags were also known as display tags.
- user_expands = Settings().value(u'displayTags/html_tags')
- # cPickle only accepts str not unicode strings
- user_expands_string = str(user_expands)
+ user_expands_string = str(Settings().value(u'formattingTags/html_tags'))
if user_expands_string:
- user_tags = cPickle.loads(user_expands_string)
+ user_tags = json.loads(user_expands_string)
for tag in user_tags:
for element in tag:
if isinstance(tag[element], str):
=== modified file 'openlp/core/lib/imagemanager.py'
--- openlp/core/lib/imagemanager.py 2013-03-17 09:21:18 +0000
+++ openlp/core/lib/imagemanager.py 2013-06-30 18:40:35 +0000
@@ -1,3 +1,4 @@
+
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py 2013-05-23 07:31:12 +0000
+++ openlp/core/lib/mediamanageritem.py 2013-06-30 18:40:35 +0000
@@ -728,10 +728,14 @@
def _get_application(self):
"""
- Adds the openlp to the class dynamically
+ Adds the openlp to the class dynamically.
+ Windows needs to access the application in a dynamic manner.
"""
- if not hasattr(self, u'_application'):
- self._application = Registry().get(u'application')
- return self._application
+ if os.name == u'nt':
+ return Registry().get(u'application')
+ else:
+ if not hasattr(self, u'_application'):
+ self._application = Registry().get(u'application')
+ return self._application
application = property(_get_application)
=== modified file 'openlp/core/lib/plugin.py'
--- openlp/core/lib/plugin.py 2013-04-05 19:37:15 +0000
+++ openlp/core/lib/plugin.py 2013-06-30 18:40:35 +0000
@@ -30,6 +30,7 @@
Provide the generic plugin functionality for OpenLP plugins.
"""
import logging
+import os
from PyQt4 import QtCore
@@ -424,8 +425,11 @@
"""
Adds the openlp to the class dynamically
"""
- if not hasattr(self, u'_application'):
- self._application = Registry().get(u'application')
- return self._application
+ if os.name == u'nt':
+ return Registry().get(u'application')
+ else:
+ if not hasattr(self, u'_application'):
+ self._application = Registry().get(u'application')
+ return self._application
application = property(_get_application)
=== modified file 'openlp/core/lib/registry.py'
--- openlp/core/lib/registry.py 2013-03-17 09:21:18 +0000
+++ openlp/core/lib/registry.py 2013-06-30 18:40:35 +0000
@@ -103,9 +103,6 @@
``key``
The service to be deleted.
"""
- if self.running_under_test is False:
- log.error(u'Invalid Method call for key %s' % key)
- raise KeyError(u'Invalid Method call for key %s' % key)
if key in self.service_list:
del self.service_list[key]
=== modified file 'openlp/core/lib/settings.py'
--- openlp/core/lib/settings.py 2013-04-29 18:23:06 +0000
+++ openlp/core/lib/settings.py 2013-06-30 18:40:35 +0000
@@ -115,7 +115,7 @@
u'advanced/single click preview': False,
u'advanced/x11 bypass wm': X11_BYPASS_DEFAULT,
u'crashreport/last directory': u'',
- u'displayTags/html_tags': u'',
+ u'formattingTags/html_tags': u'',
u'core/audio repeat list': False,
u'core/auto open': False,
u'core/auto preview': False,
=== modified file 'openlp/core/ui/firsttimeform.py'
--- openlp/core/ui/firsttimeform.py 2013-03-26 11:35:29 +0000
+++ openlp/core/ui/firsttimeform.py 2013-06-30 18:40:35 +0000
@@ -484,10 +484,14 @@
def _get_application(self):
"""
- Adds the openlp to the class dynamically
+ Adds the openlp to the class dynamically.
+ Windows needs to access the application in a dynamic manner.
"""
- if not hasattr(self, u'_application'):
- self._application = Registry().get(u'application')
- return self._application
+ if os.name == u'nt':
+ return Registry().get(u'application')
+ else:
+ if not hasattr(self, u'_application'):
+ self._application = Registry().get(u'application')
+ return self._application
application = property(_get_application)
=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py 2013-06-16 07:54:16 +0000
+++ openlp/core/ui/maindisplay.py 2013-06-30 18:40:35 +0000
@@ -38,6 +38,7 @@
from __future__ import division
import cgi
import logging
+import os
import sys
from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL
@@ -494,11 +495,15 @@
def _get_application(self):
"""
- Adds the openlp to the class dynamically
+ Adds the openlp to the class dynamically.
+ Windows needs to access the application in a dynamic manner.
"""
- if not hasattr(self, u'_application'):
- self._application = Registry().get(u'application')
- return self._application
+ if os.name == u'nt':
+ return Registry().get(u'application')
+ else:
+ if not hasattr(self, u'_application'):
+ self._application = Registry().get(u'application')
+ return self._application
application = property(_get_application)
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2013-06-16 07:54:16 +0000
+++ openlp/core/ui/mainwindow.py 2013-06-30 18:40:35 +0000
@@ -1064,6 +1064,9 @@
if self.live_controller.display:
self.live_controller.display.close()
self.live_controller.display = None
+ if os.name == u'nt':
+ # Needed for Windows to stop crashes on exit
+ Registry().remove(u'application')
def service_changed(self, reset=False, serviceName=None):
"""
@@ -1374,10 +1377,14 @@
def _get_application(self):
"""
- Adds the openlp to the class dynamically
+ Adds the openlp to the class dynamically.
+ Windows needs to access the application in a dynamic manner.
"""
- if not hasattr(self, u'_application'):
- self._application = Registry().get(u'application')
- return self._application
+ if os.name == u'nt':
+ return Registry().get(u'application')
+ else:
+ if not hasattr(self, u'_application'):
+ self._application = Registry().get(u'application')
+ return self._application
application = property(_get_application)
=== modified file 'openlp/core/ui/media/mediaplayer.py'
--- openlp/core/ui/media/mediaplayer.py 2013-03-23 07:28:24 +0000
+++ openlp/core/ui/media/mediaplayer.py 2013-06-30 18:40:35 +0000
@@ -29,6 +29,8 @@
"""
The :mod:`~openlp.core.ui.media.mediaplayer` module contains the MediaPlayer class.
"""
+import os
+
from openlp.core.lib import Registry
from openlp.core.ui.media import MediaState
@@ -153,10 +155,14 @@
def _get_application(self):
"""
- Adds the openlp to the class dynamically
+ Adds the openlp to the class dynamically.
+ Windows needs to access the application in a dynamic manner.
"""
- if not hasattr(self, u'_application'):
- self._application = Registry().get(u'application')
- return self._application
+ if os.name == u'nt':
+ return Registry().get(u'application')
+ else:
+ if not hasattr(self, u'_application'):
+ self._application = Registry().get(u'application')
+ return self._application
application = property(_get_application)
\ No newline at end of file
=== modified file 'openlp/core/ui/pluginform.py'
--- openlp/core/ui/pluginform.py 2013-06-18 09:09:54 +0000
+++ openlp/core/ui/pluginform.py 2013-06-30 18:40:35 +0000
@@ -30,6 +30,7 @@
The actual plugin view form
"""
import logging
+import os
from PyQt4 import QtGui
@@ -166,10 +167,14 @@
def _get_application(self):
"""
- Adds the openlp to the class dynamically
+ Adds the openlp to the class dynamically.
+ Windows needs to access the application in a dynamic manner.
"""
- if not hasattr(self, u'_application'):
- self._application = Registry().get(u'application')
- return self._application
+ if os.name == u'nt':
+ return Registry().get(u'application')
+ else:
+ if not hasattr(self, u'_application'):
+ self._application = Registry().get(u'application')
+ return self._application
application = property(_get_application)
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py 2013-06-16 07:54:16 +0000
+++ openlp/core/ui/servicemanager.py 2013-06-30 18:40:35 +0000
@@ -1588,10 +1588,14 @@
def _get_application(self):
"""
- Adds the openlp to the class dynamically
+ Adds the openlp to the class dynamically.
+ Windows needs to access the application in a dynamic manner.
"""
- if not hasattr(self, u'_application'):
- self._application = Registry().get(u'application')
- return self._application
+ if os.name == u'nt':
+ return Registry().get(u'application')
+ else:
+ if not hasattr(self, u'_application'):
+ self._application = Registry().get(u'application')
+ return self._application
application = property(_get_application)
=== modified file 'openlp/core/ui/thememanager.py'
--- openlp/core/ui/thememanager.py 2013-04-05 17:41:01 +0000
+++ openlp/core/ui/thememanager.py 2013-06-30 18:40:35 +0000
@@ -836,10 +836,14 @@
def _get_application(self):
"""
- Adds the openlp to the class dynamically
+ Adds the openlp to the class dynamically.
+ Windows needs to access the application in a dynamic manner.
"""
- if not hasattr(self, u'_application'):
- self._application = Registry().get(u'application')
- return self._application
+ if os.name == u'nt':
+ return Registry().get(u'application')
+ else:
+ if not hasattr(self, u'_application'):
+ self._application = Registry().get(u'application')
+ return self._application
application = property(_get_application)
=== modified file 'openlp/core/ui/wizard.py'
--- openlp/core/ui/wizard.py 2013-04-29 18:23:06 +0000
+++ openlp/core/ui/wizard.py 2013-06-30 18:40:35 +0000
@@ -320,10 +320,14 @@
def _get_application(self):
"""
- Adds the openlp to the class dynamically
+ Adds the openlp to the class dynamically.
+ Windows needs to access the application in a dynamic manner.
"""
- if not hasattr(self, u'_application'):
- self._application = Registry().get(u'application')
- return self._application
+ if os.name == u'nt':
+ return Registry().get(u'application')
+ else:
+ if not hasattr(self, u'_application'):
+ self._application = Registry().get(u'application')
+ return self._application
application = property(_get_application)
=== modified file 'openlp/plugins/bibles/forms/editbibleform.py'
--- openlp/plugins/bibles/forms/editbibleform.py 2013-04-18 17:45:14 +0000
+++ openlp/plugins/bibles/forms/editbibleform.py 2013-06-30 18:40:35 +0000
@@ -28,6 +28,7 @@
###############################################################################
import logging
+import os
import re
from PyQt4 import QtGui
@@ -191,10 +192,14 @@
def _get_application(self):
"""
- Adds the openlp to the class dynamically
+ Adds the openlp to the class dynamically.
+ Windows needs to access the application in a dynamic manner.
"""
- if not hasattr(self, u'_application'):
- self._application = Registry().get(u'application')
- return self._application
+ if os.name == u'nt':
+ return Registry().get(u'application')
+ else:
+ if not hasattr(self, u'_application'):
+ self._application = Registry().get(u'application')
+ return self._application
application = property(_get_application)
=== modified file 'openlp/plugins/bibles/lib/db.py'
--- openlp/plugins/bibles/lib/db.py 2013-04-18 17:45:14 +0000
+++ openlp/plugins/bibles/lib/db.py 2013-06-30 18:40:35 +0000
@@ -544,11 +544,15 @@
def _get_application(self):
"""
- Adds the openlp to the class dynamically
+ Adds the openlp to the class dynamically.
+ Windows needs to access the application in a dynamic manner.
"""
- if not hasattr(self, u'_application'):
- self._application = Registry().get(u'application')
- return self._application
+ if os.name == u'nt':
+ return Registry().get(u'application')
+ else:
+ if not hasattr(self, u'_application'):
+ self._application = Registry().get(u'application')
+ return self._application
application = property(_get_application)
=== modified file 'openlp/plugins/bibles/lib/http.py'
--- openlp/plugins/bibles/lib/http.py 2013-04-23 21:46:07 +0000
+++ openlp/plugins/bibles/lib/http.py 2013-06-30 18:40:35 +0000
@@ -29,6 +29,7 @@
"""
The :mod:`http` module enables OpenLP to retrieve scripture from bible websites.
"""
+import os
import logging
import re
import socket
@@ -301,11 +302,15 @@
def _get_application(self):
"""
- Adds the openlp to the class dynamically
+ Adds the openlp to the class dynamically.
+ Windows needs to access the application in a dynamic manner.
"""
- if not hasattr(self, u'_application'):
- self._application = Registry().get(u'application')
- return self._application
+ if os.name == u'nt':
+ return Registry().get(u'application')
+ else:
+ if not hasattr(self, u'_application'):
+ self._application = Registry().get(u'application')
+ return self._application
application = property(_get_application)
@@ -362,8 +367,8 @@
The version of the Bible like NIV for New International Version
"""
log.debug(u'BSExtract.get_books_from_http("%s")', version)
- urlversion = urllib.quote(version.encode("utf-8"))
- chapter_url = u'http://m.bibleserver.com/overlay/selectBook?translation=%s' % (urlversion)
+ url_version = urllib.quote(version.encode("utf-8"))
+ chapter_url = u'http://m.bibleserver.com/overlay/selectBook?translation=%s' % (url_version)
soup = get_soup_for_bible_ref(chapter_url)
if not soup:
return None
@@ -377,11 +382,15 @@
def _get_application(self):
"""
- Adds the openlp to the class dynamically
+ Adds the openlp to the class dynamically.
+ Windows needs to access the application in a dynamic manner.
"""
- if not hasattr(self, u'_application'):
- self._application = Registry().get(u'application')
- return self._application
+ if os.name == u'nt':
+ return Registry().get(u'application')
+ else:
+ if not hasattr(self, u'_application'):
+ self._application = Registry().get(u'application')
+ return self._application
application = property(_get_application)
@@ -477,11 +486,15 @@
def _get_application(self):
"""
- Adds the openlp to the class dynamically
+ Adds the openlp to the class dynamically.
+ Windows needs to access the application in a dynamic manner.
"""
- if not hasattr(self, u'_application'):
- self._application = Registry().get(u'application')
- return self._application
+ if os.name == u'nt':
+ return Registry().get(u'application')
+ else:
+ if not hasattr(self, u'_application'):
+ self._application = Registry().get(u'application')
+ return self._application
application = property(_get_application)
@@ -598,9 +611,8 @@
if show_error:
critical_error_message_box(
translate('BiblesPlugin', 'No Book Found'),
- translate('BiblesPlugin', 'No matching '
- 'book could be found in this Bible. Check that you '
- 'have spelled the name of the book correctly.'))
+ translate('BiblesPlugin', 'No matching book could be found in this Bible. Check that you have '
+ 'spelled the name of the book correctly.'))
return []
book = db_book.name
if BibleDB.get_verse_count(self, book_id, reference[1]) == 0:
@@ -667,14 +679,19 @@
def _get_application(self):
"""
- Adds the openlp to the class dynamically
+ Adds the openlp to the class dynamically.
+ Windows needs to access the application in a dynamic manner.
"""
- if not hasattr(self, u'_application'):
- self._application = Registry().get(u'application')
- return self._application
+ if os.name == u'nt':
+ return Registry().get(u'application')
+ else:
+ if not hasattr(self, u'_application'):
+ self._application = Registry().get(u'application')
+ return self._application
application = property(_get_application)
+
def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None, pre_parse_substitute=None):
"""
Gets a webpage and returns a parsed and optionally cleaned soup or None.
@@ -724,13 +741,10 @@
if error_type == u'download':
critical_error_message_box(
translate('BiblesPlugin.HTTPBible', 'Download Error'),
- translate('BiblesPlugin.HTTPBible', 'There was a '
- 'problem downloading your verse selection. Please check your '
- 'Internet connection, and if this error continues to occur '
- 'please consider reporting a bug.'))
+ translate('BiblesPlugin.HTTPBible', 'There was a problem downloading your verse selection. Please check '
+ 'your Internet connection, and if this error continues to occur please consider reporting a bug.'))
elif error_type == u'parse':
critical_error_message_box(
translate('BiblesPlugin.HTTPBible', 'Parse Error'),
- translate('BiblesPlugin.HTTPBible', 'There was a '
- 'problem extracting your verse selection. If this error continues '
- 'to occur please consider reporting a bug.'))
+ translate('BiblesPlugin.HTTPBible', 'There was a problem extracting your verse selection. If this error '
+ 'continues to occur please consider reporting a bug.'))
=== modified file 'openlp/plugins/songs/forms/duplicatesongremovalform.py'
--- openlp/plugins/songs/forms/duplicatesongremovalform.py 2013-06-15 10:46:00 +0000
+++ openlp/plugins/songs/forms/duplicatesongremovalform.py 2013-06-30 18:40:35 +0000
@@ -349,10 +349,14 @@
def _get_application(self):
"""
- Adds the openlp to the class dynamically
+ Adds the openlp to the class dynamically.
+ Windows needs to access the application in a dynamic manner.
"""
- if not hasattr(self, u'_application'):
- self._application = Registry().get(u'application')
- return self._application
+ if os.name == u'nt':
+ return Registry().get(u'application')
+ else:
+ if not hasattr(self, u'_application'):
+ self._application = Registry().get(u'application')
+ return self._application
application = property(_get_application)
\ No newline at end of file
=== modified file 'openlp/plugins/songs/forms/songmaintenanceform.py'
--- openlp/plugins/songs/forms/songmaintenanceform.py 2013-03-14 22:22:18 +0000
+++ openlp/plugins/songs/forms/songmaintenanceform.py 2013-06-30 18:40:35 +0000
@@ -27,6 +27,7 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
import logging
+import os
from PyQt4 import QtGui, QtCore
from sqlalchemy.sql import and_
@@ -525,10 +526,14 @@
def _get_application(self):
"""
- Adds the application to the class dynamically
+ Adds the openlp to the class dynamically.
+ Windows needs to access the application in a dynamic manner.
"""
- if not hasattr(self, u'_application'):
- self._application = Registry().get(u'application')
- return self._application
+ if os.name == u'nt':
+ return Registry().get(u'application')
+ else:
+ if not hasattr(self, u'_application'):
+ self._application = Registry().get(u'application')
+ return self._application
application = property(_get_application)
=== modified file 'openlp/plugins/songs/lib/openlyricsexport.py'
--- openlp/plugins/songs/lib/openlyricsexport.py 2013-03-08 08:14:39 +0000
+++ openlp/plugins/songs/lib/openlyricsexport.py 2013-06-30 18:40:35 +0000
@@ -84,10 +84,14 @@
def _get_application(self):
"""
- Adds the openlp to the class dynamically
+ Adds the openlp to the class dynamically.
+ Windows needs to access the application in a dynamic manner.
"""
- if not hasattr(self, u'_application'):
- self._application = Registry().get(u'application')
- return self._application
+ if os.name == u'nt':
+ return Registry().get(u'application')
+ else:
+ if not hasattr(self, u'_application'):
+ self._application = Registry().get(u'application')
+ return self._application
application = property(_get_application)
=== modified file 'tests/functional/openlp_core_lib/test_formattingtags.py'
--- tests/functional/openlp_core_lib/test_formattingtags.py 2013-02-27 21:40:55 +0000
+++ tests/functional/openlp_core_lib/test_formattingtags.py 2013-06-30 18:40:35 +0000
@@ -33,11 +33,11 @@
"""
with patch(u'openlp.core.lib.translate') as mocked_translate, \
patch(u'openlp.core.lib.settings') as mocked_settings, \
- patch(u'openlp.core.lib.formattingtags.cPickle') as mocked_cPickle:
+ patch(u'openlp.core.lib.formattingtags.json') as mocked_json:
# GIVEN: Our mocked modules and functions.
mocked_translate.side_effect = lambda module, string_to_translate, comment: string_to_translate
mocked_settings.value.return_value = u''
- mocked_cPickle.load.return_value = []
+ mocked_json.load.return_value = []
# WHEN: Get the display tags.
FormattingTags.load_tags()
@@ -54,11 +54,11 @@
"""
with patch(u'openlp.core.lib.translate') as mocked_translate, \
patch(u'openlp.core.lib.settings') as mocked_settings, \
- patch(u'openlp.core.lib.formattingtags.cPickle') as mocked_cPickle:
+ patch(u'openlp.core.lib.formattingtags.json') as mocked_json:
# GIVEN: Our mocked modules and functions.
mocked_translate.side_effect = lambda module, string_to_translate: string_to_translate
mocked_settings.value.return_value = u''
- mocked_cPickle.loads.side_effect = [[], [TAG]]
+ mocked_json.loads.side_effect = [[], [TAG]]
# WHEN: Get the display tags.
FormattingTags.load_tags()
Follow ups