forked from openlp/openlp
refactor version comparison code; removed dead code
bzr-revno: 1959
This commit is contained in:
commit
99314e762d
@ -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.exceptionform import ExceptionForm
|
||||||
from openlp.core.ui import SplashScreen, ScreenList
|
from openlp.core.ui import SplashScreen, ScreenList
|
||||||
from openlp.core.utils import AppLocation, LanguageManager, VersionThread, \
|
from openlp.core.utils import AppLocation, LanguageManager, VersionThread, \
|
||||||
get_application_version, DelayStartThread
|
get_application_version
|
||||||
|
|
||||||
|
|
||||||
__all__ = [u'OpenLP', u'main']
|
__all__ = [u'OpenLP', u'main']
|
||||||
@ -145,7 +145,6 @@ class OpenLP(QtGui.QApplication):
|
|||||||
VersionThread(self.mainWindow).start()
|
VersionThread(self.mainWindow).start()
|
||||||
Receiver.send_message(u'live_display_blank_check')
|
Receiver.send_message(u'live_display_blank_check')
|
||||||
self.mainWindow.appStartup()
|
self.mainWindow.appStartup()
|
||||||
DelayStartThread(self.mainWindow).start()
|
|
||||||
# Skip exec_() for gui tests
|
# Skip exec_() for gui tests
|
||||||
if not testing:
|
if not testing:
|
||||||
return self.exec_()
|
return self.exec_()
|
||||||
|
@ -27,14 +27,15 @@
|
|||||||
"""
|
"""
|
||||||
The :mod:`openlp.core.utils` module provides the utility libraries for OpenLP.
|
The :mod:`openlp.core.utils` module provides the utility libraries for OpenLP.
|
||||||
"""
|
"""
|
||||||
|
from datetime import datetime
|
||||||
|
from distutils.version import LooseVersion
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
from subprocess import Popen, PIPE
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import urllib2
|
import urllib2
|
||||||
from datetime import datetime
|
|
||||||
from subprocess import Popen, PIPE
|
|
||||||
|
|
||||||
from PyQt4 import QtGui, QtCore
|
from PyQt4 import QtGui, QtCore
|
||||||
|
|
||||||
@ -55,7 +56,6 @@ UNO_CONNECTION_TYPE = u'pipe'
|
|||||||
#UNO_CONNECTION_TYPE = u'socket'
|
#UNO_CONNECTION_TYPE = u'socket'
|
||||||
CONTROL_CHARS = re.compile(r'[\x00-\x1F\x7F-\x9F]', re.UNICODE)
|
CONTROL_CHARS = re.compile(r'[\x00-\x1F\x7F-\x9F]', re.UNICODE)
|
||||||
INVALID_FILE_CHARS = re.compile(r'[\\/:\*\?"<>\|\+\[\]%]', 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):
|
class VersionThread(QtCore.QThread):
|
||||||
"""
|
"""
|
||||||
@ -72,48 +72,8 @@ class VersionThread(QtCore.QThread):
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
app_version = get_application_version()
|
app_version = get_application_version()
|
||||||
version = check_latest_version(app_version)
|
version = check_latest_version(app_version)
|
||||||
remote_version = {}
|
if LooseVersion(str(version)) > LooseVersion(str(app_version[u'full'])):
|
||||||
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)
|
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):
|
class AppLocation(object):
|
||||||
@ -181,6 +141,7 @@ class AppLocation(object):
|
|||||||
check_directory_exists(path)
|
check_directory_exists(path)
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
def _get_os_dir_path(dir_type):
|
def _get_os_dir_path(dir_type):
|
||||||
"""
|
"""
|
||||||
Return a path based on which OS and environment we are running in.
|
Return a path based on which OS and environment we are running in.
|
||||||
@ -220,6 +181,7 @@ def _get_os_dir_path(dir_type):
|
|||||||
u'.openlp', u'data')
|
u'.openlp', u'data')
|
||||||
return os.path.join(unicode(os.getenv(u'HOME'), encoding), u'.openlp')
|
return os.path.join(unicode(os.getenv(u'HOME'), encoding), u'.openlp')
|
||||||
|
|
||||||
|
|
||||||
def _get_frozen_path(frozen_option, non_frozen_option):
|
def _get_frozen_path(frozen_option, non_frozen_option):
|
||||||
"""
|
"""
|
||||||
Return a path based on the system status.
|
Return a path based on the system status.
|
||||||
@ -228,6 +190,7 @@ def _get_frozen_path(frozen_option, non_frozen_option):
|
|||||||
return frozen_option
|
return frozen_option
|
||||||
return non_frozen_option
|
return non_frozen_option
|
||||||
|
|
||||||
|
|
||||||
def get_application_version():
|
def get_application_version():
|
||||||
"""
|
"""
|
||||||
Returns the application version of the running instance of OpenLP::
|
Returns the application version of the running instance of OpenLP::
|
||||||
@ -307,6 +270,7 @@ def get_application_version():
|
|||||||
log.info(u'Openlp version %s' % APPLICATION_VERSION[u'version'])
|
log.info(u'Openlp version %s' % APPLICATION_VERSION[u'version'])
|
||||||
return APPLICATION_VERSION
|
return APPLICATION_VERSION
|
||||||
|
|
||||||
|
|
||||||
def check_latest_version(current_version):
|
def check_latest_version(current_version):
|
||||||
"""
|
"""
|
||||||
Check the latest version of OpenLP against the version file on the OpenLP
|
Check the latest version of OpenLP against the version file on the OpenLP
|
||||||
@ -340,6 +304,7 @@ def check_latest_version(current_version):
|
|||||||
version_string = remote_version
|
version_string = remote_version
|
||||||
return version_string
|
return version_string
|
||||||
|
|
||||||
|
|
||||||
def add_actions(target, actions):
|
def add_actions(target, actions):
|
||||||
"""
|
"""
|
||||||
Adds multiple actions to a menu or toolbar in one command.
|
Adds multiple actions to a menu or toolbar in one command.
|
||||||
@ -357,6 +322,7 @@ def add_actions(target, actions):
|
|||||||
else:
|
else:
|
||||||
target.addAction(action)
|
target.addAction(action)
|
||||||
|
|
||||||
|
|
||||||
def get_filesystem_encoding():
|
def get_filesystem_encoding():
|
||||||
"""
|
"""
|
||||||
Returns the name of the encoding used to convert Unicode filenames into
|
Returns the name of the encoding used to convert Unicode filenames into
|
||||||
@ -367,6 +333,7 @@ def get_filesystem_encoding():
|
|||||||
encoding = sys.getdefaultencoding()
|
encoding = sys.getdefaultencoding()
|
||||||
return encoding
|
return encoding
|
||||||
|
|
||||||
|
|
||||||
def get_images_filter():
|
def get_images_filter():
|
||||||
"""
|
"""
|
||||||
Returns a filter string for a file dialog containing all the supported
|
Returns a filter string for a file dialog containing all the supported
|
||||||
@ -383,6 +350,7 @@ def get_images_filter():
|
|||||||
visible_formats, actual_formats)
|
visible_formats, actual_formats)
|
||||||
return IMAGES_FILTER
|
return IMAGES_FILTER
|
||||||
|
|
||||||
|
|
||||||
def split_filename(path):
|
def split_filename(path):
|
||||||
"""
|
"""
|
||||||
Return a list of the parts in a given path.
|
Return a list of the parts in a given path.
|
||||||
@ -393,6 +361,7 @@ def split_filename(path):
|
|||||||
else:
|
else:
|
||||||
return os.path.split(path)
|
return os.path.split(path)
|
||||||
|
|
||||||
|
|
||||||
def clean_filename(filename):
|
def clean_filename(filename):
|
||||||
"""
|
"""
|
||||||
Removes invalid characters from the given ``filename``.
|
Removes invalid characters from the given ``filename``.
|
||||||
@ -404,6 +373,7 @@ def clean_filename(filename):
|
|||||||
filename = unicode(filename, u'utf-8')
|
filename = unicode(filename, u'utf-8')
|
||||||
return INVALID_FILE_CHARS.sub(u'_', CONTROL_CHARS.sub(u'', filename))
|
return INVALID_FILE_CHARS.sub(u'_', CONTROL_CHARS.sub(u'', filename))
|
||||||
|
|
||||||
|
|
||||||
def delete_file(file_path_name):
|
def delete_file(file_path_name):
|
||||||
"""
|
"""
|
||||||
Deletes a file from the system.
|
Deletes a file from the system.
|
||||||
@ -421,6 +391,7 @@ def delete_file(file_path_name):
|
|||||||
log.exception("Unable to delete file %s" % file_path_name)
|
log.exception("Unable to delete file %s" % file_path_name)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_web_page(url, header=None, update_openlp=False):
|
def get_web_page(url, header=None, update_openlp=False):
|
||||||
"""
|
"""
|
||||||
Attempts to download the webpage at url and returns that page or None.
|
Attempts to download the webpage at url and returns that page or None.
|
||||||
@ -457,6 +428,7 @@ def get_web_page(url, header=None, update_openlp=False):
|
|||||||
log.debug(page)
|
log.debug(page)
|
||||||
return page
|
return page
|
||||||
|
|
||||||
|
|
||||||
def get_uno_command():
|
def get_uno_command():
|
||||||
"""
|
"""
|
||||||
Returns the UNO command to launch an openoffice.org instance.
|
Returns the UNO command to launch an openoffice.org instance.
|
||||||
@ -469,6 +441,7 @@ def get_uno_command():
|
|||||||
CONNECTION = u'"-accept=socket,host=localhost,port=2002;urp;"'
|
CONNECTION = u'"-accept=socket,host=localhost,port=2002;urp;"'
|
||||||
return u'%s %s %s' % (COMMAND, OPTIONS, CONNECTION)
|
return u'%s %s %s' % (COMMAND, OPTIONS, CONNECTION)
|
||||||
|
|
||||||
|
|
||||||
def get_uno_instance(resolver):
|
def get_uno_instance(resolver):
|
||||||
"""
|
"""
|
||||||
Returns a running openoffice.org instance.
|
Returns a running openoffice.org instance.
|
||||||
|
Loading…
Reference in New Issue
Block a user