forked from openlp/openlp
removed dead code, refactor version comparison code
This commit is contained in:
parent
38e5635901
commit
69affcc059
@ -1 +1 @@
|
||||
1.9.5-bzr1421
|
||||
1.9.9-bzr1956
|
||||
|
@ -49,7 +49,7 @@ from openlp.core.ui.firsttimeform import FirstTimeForm
|
||||
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 @@ class OpenLP(QtGui.QApplication):
|
||||
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_()
|
||||
|
@ -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'pipe'
|
||||
#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,49 +72,8 @@ class VersionThread(QtCore.QThread):
|
||||
time.sleep(1)
|
||||
app_version = get_application_version()
|
||||
version = check_latest_version(app_version)
|
||||
print app_version, 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']:
|
||||
if LooseVersion(str(version)) > str(app_version[u'full']):
|
||||
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')
|
||||
|
||||
|
||||
class AppLocation(object):
|
||||
@ -182,6 +141,7 @@ class AppLocation(object):
|
||||
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.
|
||||
@ -221,6 +181,7 @@ def _get_os_dir_path(dir_type):
|
||||
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.
|
||||
@ -229,6 +190,7 @@ def _get_frozen_path(frozen_option, non_frozen_option):
|
||||
return frozen_option
|
||||
return non_frozen_option
|
||||
|
||||
|
||||
def get_application_version():
|
||||
"""
|
||||
Returns the application version of the running instance of OpenLP::
|
||||
@ -308,6 +270,7 @@ def get_application_version():
|
||||
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
|
||||
@ -341,6 +304,7 @@ def check_latest_version(current_version):
|
||||
version_string = remote_version
|
||||
return version_string
|
||||
|
||||
|
||||
def add_actions(target, actions):
|
||||
"""
|
||||
Adds multiple actions to a menu or toolbar in one command.
|
||||
@ -358,6 +322,7 @@ def add_actions(target, actions):
|
||||
else:
|
||||
target.addAction(action)
|
||||
|
||||
|
||||
def get_filesystem_encoding():
|
||||
"""
|
||||
Returns the name of the encoding used to convert Unicode filenames into
|
||||
@ -368,6 +333,7 @@ def get_filesystem_encoding():
|
||||
encoding = sys.getdefaultencoding()
|
||||
return encoding
|
||||
|
||||
|
||||
def get_images_filter():
|
||||
"""
|
||||
Returns a filter string for a file dialog containing all the supported
|
||||
@ -384,6 +350,7 @@ def get_images_filter():
|
||||
visible_formats, actual_formats)
|
||||
return IMAGES_FILTER
|
||||
|
||||
|
||||
def split_filename(path):
|
||||
"""
|
||||
Return a list of the parts in a given path.
|
||||
@ -394,6 +361,7 @@ def split_filename(path):
|
||||
else:
|
||||
return os.path.split(path)
|
||||
|
||||
|
||||
def clean_filename(filename):
|
||||
"""
|
||||
Removes invalid characters from the given ``filename``.
|
||||
@ -405,6 +373,7 @@ def clean_filename(filename):
|
||||
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.
|
||||
@ -422,6 +391,7 @@ def delete_file(file_path_name):
|
||||
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.
|
||||
@ -458,6 +428,7 @@ def get_web_page(url, header=None, update_openlp=False):
|
||||
log.debug(page)
|
||||
return page
|
||||
|
||||
|
||||
def get_uno_command():
|
||||
"""
|
||||
Returns the UNO command to launch an openoffice.org instance.
|
||||
@ -470,6 +441,7 @@ def get_uno_command():
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user