From d0b501bd2fc16410e3c9528ba4e82ce158292960 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 12 Oct 2009 05:43:02 +0100 Subject: [PATCH] Fixes to last merge request --- openlp/core/ui/mainwindow.py | 5 +- openlp/core/utils/__init__.py | 22 ++++++- openlp/core/utils/latestversion.py | 57 ------------------- openlp/plugins/audit/forms/auditdeleteform.py | 2 +- openlp/plugins/audit/forms/auditdetailform.py | 2 +- 5 files changed, 25 insertions(+), 63 deletions(-) delete mode 100644 openlp/core/utils/latestversion.py diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 3a4193f01..67b9bcd3d 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -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'), diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 17a4f5785..de12084ea 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -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 diff --git a/openlp/core/utils/latestversion.py b/openlp/core/utils/latestversion.py deleted file mode 100644 index cd1ea1083..000000000 --- a/openlp/core/utils/latestversion.py +++ /dev/null @@ -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 diff --git a/openlp/plugins/audit/forms/auditdeleteform.py b/openlp/plugins/audit/forms/auditdeleteform.py index e91545433..fbe07d142 100644 --- a/openlp/plugins/audit/forms/auditdeleteform.py +++ b/openlp/plugins/audit/forms/auditdeleteform.py @@ -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 """ diff --git a/openlp/plugins/audit/forms/auditdetailform.py b/openlp/plugins/audit/forms/auditdetailform.py index 42834b378..74e28f394 100644 --- a/openlp/plugins/audit/forms/auditdetailform.py +++ b/openlp/plugins/audit/forms/auditdetailform.py @@ -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 """