forked from openlp/openlp
Latest Version checking added
This commit is contained in:
parent
268aadde4c
commit
f53a6fddeb
@ -49,6 +49,7 @@ class OpenLP(QtGui.QApplication):
|
|||||||
"""
|
"""
|
||||||
Run the OpenLP application.
|
Run the OpenLP application.
|
||||||
"""
|
"""
|
||||||
|
applicationVersion = u'1.9.0'
|
||||||
#set the default string encoding
|
#set the default string encoding
|
||||||
try:
|
try:
|
||||||
sys.setappdefaultencoding(u'utf-8')
|
sys.setappdefaultencoding(u'utf-8')
|
||||||
@ -58,7 +59,7 @@ class OpenLP(QtGui.QApplication):
|
|||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'process_events'), self.processEvents)
|
QtCore.SIGNAL(u'process_events'), self.processEvents)
|
||||||
self.setApplicationName(u'OpenLP')
|
self.setApplicationName(u'OpenLP')
|
||||||
self.setApplicationVersion(u'1.9.0')
|
self.setApplicationVersion(applicationVersion)
|
||||||
show_splash = str_to_bool(ConfigHelper.get_registry().get_value(
|
show_splash = str_to_bool(ConfigHelper.get_registry().get_value(
|
||||||
u'general', u'show splash', True))
|
u'general', u'show splash', True))
|
||||||
if show_splash:
|
if show_splash:
|
||||||
|
@ -33,6 +33,7 @@ from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \
|
|||||||
from openlp.core.lib import translate, RenderManager, PluginConfig, \
|
from openlp.core.lib import translate, RenderManager, PluginConfig, \
|
||||||
OpenLPDockWidget, SettingsManager, PluginManager, Receiver, \
|
OpenLPDockWidget, SettingsManager, PluginManager, Receiver, \
|
||||||
buildIcon
|
buildIcon
|
||||||
|
from openlp.core.utils import LatestVersion
|
||||||
|
|
||||||
|
|
||||||
class Ui_MainWindow(object):
|
class Ui_MainWindow(object):
|
||||||
@ -524,6 +525,21 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
self.ThemeManagerContents.loadThemes()
|
self.ThemeManagerContents.loadThemes()
|
||||||
log.info(u'Load data from Settings')
|
log.info(u'Load data from Settings')
|
||||||
self.settingsForm.postSetUp()
|
self.settingsForm.postSetUp()
|
||||||
|
self.versionCheck()
|
||||||
|
|
||||||
|
def versionCheck(self):
|
||||||
|
# We do not want this in development!
|
||||||
|
if log.isEnabledFor(logging.DEBUG):
|
||||||
|
applicationVersion = self.generalConfig.get_config(u'Application version', u'1.9.0')
|
||||||
|
version = LatestVersion(self.generalConfig).checkVersion(applicationVersion)
|
||||||
|
if applicationVersion != version:
|
||||||
|
QtGui.QMessageBox.question(None,
|
||||||
|
translate(u'mainWindow', u'OpenLP version Updated'),
|
||||||
|
translate(u'mainWindow', u'OpenLP version %s has been updated to version %s'
|
||||||
|
% (applicationVersion, version)),
|
||||||
|
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok),
|
||||||
|
QtGui.QMessageBox.Ok)
|
||||||
|
self.generalConfig.set_config(u'Application version', version)
|
||||||
|
|
||||||
|
|
||||||
def getMonitorNumber(self):
|
def getMonitorNumber(self):
|
||||||
|
@ -24,5 +24,6 @@
|
|||||||
|
|
||||||
from registry import Registry
|
from registry import Registry
|
||||||
from confighelper import ConfigHelper
|
from confighelper import ConfigHelper
|
||||||
|
from latestversion import LatestVersion
|
||||||
|
|
||||||
__all__ = ['Registry', 'ConfigHelper']
|
__all__ = ['Registry', 'ConfigHelper']
|
||||||
|
57
openlp/core/utils/latestversion.py
Normal file
57
openlp/core/utils/latestversion.py
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
|
# --------------------------------------------------------------------------- #
|
||||||
|
# Copyright (c) 2008-2009 Raoul Snyman #
|
||||||
|
# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten #
|
||||||
|
# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri #
|
||||||
|
# --------------------------------------------------------------------------- #
|
||||||
|
# This program is free software; you can redistribute it and/or modify it #
|
||||||
|
# under the terms of the GNU General Public License as published by the Free #
|
||||||
|
# Software Foundation; version 2 of the License. #
|
||||||
|
# #
|
||||||
|
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
||||||
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
||||||
|
# more details. #
|
||||||
|
# #
|
||||||
|
# You should have received a copy of the GNU General Public License along #
|
||||||
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||||
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import urllib2
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
class LatestVersion(object):
|
||||||
|
"""
|
||||||
|
"""
|
||||||
|
global log
|
||||||
|
log = logging.getLogger(u'LatestVersion')
|
||||||
|
log.info(u'Latest Version detector loaded')
|
||||||
|
|
||||||
|
def __init__(self, config):
|
||||||
|
self.config = config
|
||||||
|
|
||||||
|
def checkVersion(self, current_version):
|
||||||
|
version_string = current_version
|
||||||
|
lastTest = self.config.get_config(u'Application version Test', datetime.now().date())
|
||||||
|
thisTest = unicode(datetime.now().date())
|
||||||
|
self.config.set_config(u'Application version Test', thisTest)
|
||||||
|
if lastTest != thisTest:
|
||||||
|
print "Now check"
|
||||||
|
version_string = u''
|
||||||
|
req = urllib2.Request(u'http://www.openlp.oeg/files/version.txt')
|
||||||
|
req.add_header(u'User-Agent', u'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)')
|
||||||
|
try:
|
||||||
|
handle = urllib2.urlopen(req, None, 1)
|
||||||
|
html = handle.read()
|
||||||
|
version_string = unicode(html).rstrip()
|
||||||
|
except IOError, e:
|
||||||
|
if hasattr(e, u'reason'):
|
||||||
|
log.exception(u'Reason for failure: %s', e.reason)
|
||||||
|
return version_string
|
Loading…
Reference in New Issue
Block a user