From f9441e367639181c23678afc414d9285145cf1d7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 5 Dec 2007 21:06:38 +0000 Subject: [PATCH] Fix #368 --- src/libprs500/gui2/update.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/libprs500/gui2/update.py diff --git a/src/libprs500/gui2/update.py b/src/libprs500/gui2/update.py new file mode 100644 index 0000000000..5df5eae663 --- /dev/null +++ b/src/libprs500/gui2/update.py @@ -0,0 +1,36 @@ +## Copyright (C) 2007 Kovid Goyal kovid@kovidgoyal.net +## 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; either version 2 of the License, or +## (at your option) any later version. +## +## 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., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +import urllib, re + +from PyQt4.QtCore import QThread, SIGNAL + +from libprs500 import __version__ +from libprs500.ebooks.BeautifulSoup import BeautifulSoup + +class CheckForUpdates(QThread): + + def run(self): + src = urllib.urlopen('http://pypi.python.org/pypi/libprs500').read() + soup = BeautifulSoup(src) + meta = soup.find('link', rel='meta', title='DOAP') + if meta: + src = meta['href'] + match = re.search(r'version=(\S+)', src) + if match: + version = match.group(1) + if version != __version__: + self.emit(SIGNAL('update_found(PyQt_PyObject)'), version) + \ No newline at end of file