chk new version commit: fixing a bug introduced by tab when he changed the names of the var in config and adding a timeout

This commit is contained in:
Nikos Kouremenos 2005-05-08 15:06:24 +00:00
parent 58e7da6d54
commit 4a90f80cfa
2 changed files with 41 additions and 37 deletions

View File

@ -33,10 +33,7 @@ GTKGUI_GLADE='gtkgui.glade'
class Check_for_new_version_dialog: class Check_for_new_version_dialog:
def __init__(self, plugin): def __init__(self, plugin):
self.plugin = plugin self.plugin = plugin
try: self.check_for_new_version()
self.check_for_new_version()
except:
pass
def parse_glade(self): def parse_glade(self):
xml = gtk.glade.XML(GTKGUI_GLADE, 'new_version_available_dialog', APP) xml = gtk.glade.XML(GTKGUI_GLADE, 'new_version_available_dialog', APP)
@ -56,37 +53,44 @@ class Check_for_new_version_dialog:
def check_for_new_version(self): def check_for_new_version(self):
'''parse online Changelog to find out last version '''parse online Changelog to find out last version
and the changes for that latest version''' and the changes for that latest version'''
check_for_new_version_available = True # Why that ? import urllib2
if check_for_new_version_available: import socket
import urllib dto = socket.getdefaulttimeout()
socket.setdefaulttimeout(5)
url = 'http://trac.gajim.org/file/trunk/Changelog?rev=latest&format=txt' url = 'http://trac.gajim.org/file/trunk/Changelog?rev=latest&format=txt'
changelog = urllib.urlopen(url) try:
# format is Gajim version (date) changelog = urllib2.urlopen(url)
first_line = changelog.readline() except:
finish_version = first_line.find(' ', 6) # start search after 'Gajim' pass
latest_version = first_line[6:finish_version]
if latest_version > gajim.version:
start_date = finish_version + 2 # one space and one (
date = first_line[start_date:-2] # remove the last ) and \n
info = 'Gajim ' + latest_version + ' was released in ' + date + '!'
changes = ''
while True:
line = changelog.readline().lstrip()
if line.startswith('Gajim'):
break
else:
if line != '\n' or line !='': # line has some content
if not line.startswith('*'):
# the is not a new *real* line
# but a continuation from previous line.
# So remove \n from previous 'line' beforing adding it
changes = changes[:-1]
changes += line socket.setdefaulttimeout(dto)
self.parse_glade() # format is 'Gajim version (date)'
self.information_label.set_text(info) first_line = changelog.readline()
buf = self.changes_textview.get_buffer() finish_version = first_line.find(' ', 6) # start search after 'Gajim'
buf.set_text(changes) latest_version = first_line[6:finish_version]
self.window.show_all() if latest_version > gajim.version:
start_date = finish_version + 2 # one space and one (
date = first_line[start_date:-2] # remove the last ) and \n
info = 'Gajim ' + latest_version + ' was released in ' + date + '!'
changes = ''
while True:
line = changelog.readline().lstrip()
if line.startswith('Gajim'):
break
else:
if line != '\n' or line !='': # line has some content
if not line.startswith('*'):
# the is not a new *real* line
# but a continuation from previous line.
# So remove \n from previous 'line' beforing adding it
changes = changes[:-1]
changes += line
self.parse_glade()
self.information_label.set_text(info)
buf = self.changes_textview.get_buffer()
buf.set_text(changes)
self.window.show_all()

View File

@ -696,7 +696,7 @@ class Interface:
if self.systray_capabilities: if self.systray_capabilities:
self.show_systray() self.show_systray()
if not gajim.config.get('check_for_new_version'): if gajim.config.get('check_for_new_version'):
check_for_new_version.Check_for_new_version_dialog(self) check_for_new_version.Check_for_new_version_dialog(self)
self.init_regexp() self.init_regexp()