Fixes to last merge request

This commit is contained in:
Tim Bentley 2009-10-12 05:43:02 +01:00
parent 7ee0549df2
commit d0b501bd2f
5 changed files with 25 additions and 63 deletions

View File

@ -33,8 +33,7 @@ from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \
from openlp.core.lib import translate, RenderManager, PluginConfig, \
OpenLPDockWidget, SettingsManager, PluginManager, Receiver, \
buildIcon
from openlp.core.utils import LatestVersion
from openlp.core.utils import check_latest_version
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
@ -529,7 +528,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
def versionCheck(self):
applicationVersion = self.generalConfig.get_config(u'Application version', u'1.9.0-595')
version = LatestVersion(self.generalConfig).checkVersion(applicationVersion)
version = check_latest_version(self.generalConfig, applicationVersion)
if applicationVersion != version:
QtGui.QMessageBox.question(None,
translate(u'mainWindow', u'OpenLP version Updated'),

View File

@ -21,9 +21,29 @@
# 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
from registry import Registry
from confighelper import ConfigHelper
from latestversion import LatestVersion
__all__ = ['Registry', 'ConfigHelper']
def check_latest_version(config, current_version):
version_string = current_version
lastTest = config.get_config(u'Application version Test', datetime.now().date())
thisTest = unicode(datetime.now().date())
config.set_config(u'Application version Test', thisTest)
if lastTest != thisTest:
version_string = u''
req = urllib2.Request(u'http://www.openlp.org/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

View File

@ -1,57 +0,0 @@
# -*- 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.org/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

View File

@ -34,7 +34,7 @@ class AuditDeleteForm(QtGui.QDialog, Ui_AuditDeleteDialog):
"""
Class documentation goes here.
"""
def __init__(self, auditmanager, parent = None):
def __init__(self, auditmanager, parent=None):
"""
Constructor
"""

View File

@ -32,7 +32,7 @@ class AuditDetailForm(QtGui.QDialog, Ui_AuditDetailDialog):
"""
Class documentation goes here.
"""
def __init__(self, parent = None):
def __init__(self, parent=None):
"""
Constructor
"""