...
[iramuteq] / checkversion.py
1 #!/bin/env python
2 # -*- coding: utf-8 -*-
3 #Author: Pierre Ratinaud
4 #Copyright (c) 2008-2009, Pierre Ratinaud
5 #License: GNU/GPL
6
7 import urllib2
8 import socket
9 import wx
10    
11 def NewVersion(parent):
12     version = parent.version.split(' ')
13     if len(version) == 3:
14         versionnb = float(version[0])
15         versionsub = int(version[2])
16     else:
17         versionnb = float(version[0])
18         versionsub = False
19     erreur = False
20     new = False
21     req = urllib2.Request("http://www.iramuteq.org/current_version")
22     try:
23         LastVersion = urllib2.urlopen(req,'',3)
24         lastversion = LastVersion.readlines()
25         lastversion = lastversion[0].replace('\n', '').split('-')
26         if len(lastversion) == 2 :
27             if (float(lastversion[0]) > versionnb) :
28                 new = True
29             elif float(lastversion[0]) == versionnb and versionsub :
30                 if versionsub < int(lastversion[1].replace('alpha', '')):
31                     new = True
32         elif len(lastversion) == 1 :
33             if (float(lastversion[0]) >= versionnb) and (versionsub) :
34                 new = True
35             elif (float(lastversion[0]) > versionnb) and not versionsub :
36                 new = True
37     except :
38         erreur = u"la page n'est pas accessible"
39     if not erreur and new :
40         msg = u"""
41 Une nouvelle version d'IRaMuTeQ (%s) est disponible.
42 Vous pouvez la télécharger à partir du site web iramuteq :
43 http://www.iramuteq.org""" % '-'.join(lastversion)
44         dlg = wx.MessageDialog(parent, msg, u"Nouvelle version disponible", wx.OK | wx.ICON_WARNING)
45         dlg.CenterOnParent()
46         if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
47              evt.Veto()
48
49 #print NewVersion('0.1-alpha18')