openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #15429
[Merge] lp:~googol/openlp/trivial into lp:openlp
Andreas Preikschat has proposed merging lp:~googol/openlp/trivial into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~googol/openlp/trivial/+merge/103981
Hello,
- removed dead code
- refactor version comparison code
--
https://code.launchpad.net/~googol/openlp/trivial/+merge/103981
Your team OpenLP Core is requested to review the proposed merge of lp:~googol/openlp/trivial into lp:openlp.
=== modified file 'openlp/.version'
--- openlp/.version 2011-03-25 18:49:53 +0000
+++ openlp/.version 2012-04-28 13:53:23 +0000
@@ -1,1 +1,1 @@
-1.9.5-bzr1421
\ No newline at end of file
+1.9.9-bzr1956
=== modified file 'openlp/core/__init__.py'
--- openlp/core/__init__.py 2011-12-27 10:33:55 +0000
+++ openlp/core/__init__.py 2012-04-28 13:53:23 +0000
@@ -49,7 +49,7 @@
from openlp.core.ui.exceptionform import ExceptionForm
from openlp.core.ui import SplashScreen, ScreenList
from openlp.core.utils import AppLocation, LanguageManager, VersionThread, \
- get_application_version, DelayStartThread
+ get_application_version
__all__ = [u'OpenLP', u'main']
@@ -145,7 +145,6 @@
VersionThread(self.mainWindow).start()
Receiver.send_message(u'live_display_blank_check')
self.mainWindow.appStartup()
- DelayStartThread(self.mainWindow).start()
# Skip exec_() for gui tests
if not testing:
return self.exec_()
=== modified file 'openlp/core/utils/__init__.py'
--- openlp/core/utils/__init__.py 2012-03-23 06:36:24 +0000
+++ openlp/core/utils/__init__.py 2012-04-28 13:53:23 +0000
@@ -27,14 +27,15 @@
"""
The :mod:`openlp.core.utils` module provides the utility libraries for OpenLP.
"""
+from datetime import datetime
+from distutils.version import LooseVersion
import logging
import os
import re
+from subprocess import Popen, PIPE
import sys
import time
import urllib2
-from datetime import datetime
-from subprocess import Popen, PIPE
from PyQt4 import QtGui, QtCore
@@ -55,7 +56,6 @@
#UNO_CONNECTION_TYPE = u'socket'
CONTROL_CHARS = re.compile(r'[\x00-\x1F\x7F-\x9F]', re.UNICODE)
INVALID_FILE_CHARS = re.compile(r'[\\/:\*\?"<>\|\+\[\]%]', re.UNICODE)
-VERSION_SPLITTER = re.compile(r'([0-9]+).([0-9]+).([0-9]+)(?:-bzr([0-9]+))?')
class VersionThread(QtCore.QThread):
"""
@@ -72,48 +72,8 @@
time.sleep(1)
app_version = get_application_version()
version = check_latest_version(app_version)
- remote_version = {}
- local_version = {}
- match = VERSION_SPLITTER.match(version)
- if match:
- remote_version[u'major'] = int(match.group(1))
- remote_version[u'minor'] = int(match.group(2))
- remote_version[u'release'] = int(match.group(3))
- if len(match.groups()) > 3 and match.group(4):
- remote_version[u'revision'] = int(match.group(4))
- else:
- return
- match = VERSION_SPLITTER.match(app_version[u'full'])
- if match:
- local_version[u'major'] = int(match.group(1))
- local_version[u'minor'] = int(match.group(2))
- local_version[u'release'] = int(match.group(3))
- if len(match.groups()) > 3 and match.group(4):
- local_version[u'revision'] = int(match.group(4))
- else:
- return
- if remote_version[u'major'] > local_version[u'major'] or \
- remote_version[u'minor'] > local_version[u'minor'] or \
- remote_version[u'release'] > local_version[u'release']:
- Receiver.send_message(u'openlp_version_check', u'%s' % version)
- elif remote_version.get(u'revision') and \
- local_version.get(u'revision') and \
- remote_version[u'revision'] > local_version[u'revision']:
- Receiver.send_message(u'openlp_version_check', u'%s' % version)
-
-
-class DelayStartThread(QtCore.QThread):
- """
- A special Qt thread class to build things after OpenLP has started
- """
- def __init__(self, parent):
- QtCore.QThread.__init__(self, parent)
-
- def run(self):
- """
- Run the thread.
- """
- Receiver.send_message(u'openlp_phonon_creation')
+ if LooseVersion(str(version)) > str(app_version[u'full']):
+ Receiver.send_message(u'openlp_version_check', u'%s' % version)
class AppLocation(object):
@@ -181,6 +141,7 @@
check_directory_exists(path)
return path
+
def _get_os_dir_path(dir_type):
"""
Return a path based on which OS and environment we are running in.
@@ -220,6 +181,7 @@
u'.openlp', u'data')
return os.path.join(unicode(os.getenv(u'HOME'), encoding), u'.openlp')
+
def _get_frozen_path(frozen_option, non_frozen_option):
"""
Return a path based on the system status.
@@ -228,6 +190,7 @@
return frozen_option
return non_frozen_option
+
def get_application_version():
"""
Returns the application version of the running instance of OpenLP::
@@ -307,6 +270,7 @@
log.info(u'Openlp version %s' % APPLICATION_VERSION[u'version'])
return APPLICATION_VERSION
+
def check_latest_version(current_version):
"""
Check the latest version of OpenLP against the version file on the OpenLP
@@ -340,6 +304,7 @@
version_string = remote_version
return version_string
+
def add_actions(target, actions):
"""
Adds multiple actions to a menu or toolbar in one command.
@@ -357,6 +322,7 @@
else:
target.addAction(action)
+
def get_filesystem_encoding():
"""
Returns the name of the encoding used to convert Unicode filenames into
@@ -367,6 +333,7 @@
encoding = sys.getdefaultencoding()
return encoding
+
def get_images_filter():
"""
Returns a filter string for a file dialog containing all the supported
@@ -383,6 +350,7 @@
visible_formats, actual_formats)
return IMAGES_FILTER
+
def split_filename(path):
"""
Return a list of the parts in a given path.
@@ -393,6 +361,7 @@
else:
return os.path.split(path)
+
def clean_filename(filename):
"""
Removes invalid characters from the given ``filename``.
@@ -404,6 +373,7 @@
filename = unicode(filename, u'utf-8')
return INVALID_FILE_CHARS.sub(u'_', CONTROL_CHARS.sub(u'', filename))
+
def delete_file(file_path_name):
"""
Deletes a file from the system.
@@ -421,6 +391,7 @@
log.exception("Unable to delete file %s" % file_path_name)
return False
+
def get_web_page(url, header=None, update_openlp=False):
"""
Attempts to download the webpage at url and returns that page or None.
@@ -457,6 +428,7 @@
log.debug(page)
return page
+
def get_uno_command():
"""
Returns the UNO command to launch an openoffice.org instance.
@@ -469,6 +441,7 @@
CONNECTION = u'"-accept=socket,host=localhost,port=2002;urp;"'
return u'%s %s %s' % (COMMAND, OPTIONS, CONNECTION)
+
def get_uno_instance(resolver):
"""
Returns a running openoffice.org instance.
Follow ups