multisplit
[iramuteq] / checkversion.py
1 # -*- coding: utf-8 -*-
2 #Author: Pierre Ratinaud
3 #Copyright (c) 2008-2020 Pierre Ratinaud
4 #modification pour python 3 : Laurent Mérat, 6x7 - mai 2020
5 #License: GNU/GPL
6
7 #------------------------------------
8 # import des modules python
9 #------------------------------------
10 import urllib.request, urllib.error, urllib.parse #migration de module PY3
11 import socket
12
13 #------------------------------------
14 # import des modules wx
15 #------------------------------------
16 import wx
17
18 #------------------------------------
19 # import des fichiers du projet
20 #------------------------------------
21
22
23 # utilisé seulement depuis iramuteq.py
24
25
26 def NewVersion(parent):
27     version = parent.version.split(' ')
28     if len(version) == 3:
29         versionnb = float(version[0])
30         versionsub = int(version[2])
31     else:
32         versionnb = float(version[0])
33         versionsub = False
34     erreur = False
35     new = False
36     req = urllib.request.Request("http://www.iramuteq.org/current_version")
37     try:
38         LastVersion = urllib.request.urlopen(req,'',3)
39         lastversion = LastVersion.readlines()
40         lastversion = lastversion[0].replace('\n', '').split('-')
41         if len(lastversion) == 2 :
42             if (float(lastversion[0]) > versionnb) :
43                 new = True
44             elif float(lastversion[0]) == versionnb and versionsub :
45                 if versionsub < int(lastversion[1].replace('alpha', '')):
46                     new = True
47         elif len(lastversion) == 1 :
48             if (float(lastversion[0]) >= versionnb) and (versionsub) :
49                 new = True
50             elif (float(lastversion[0]) > versionnb) and not versionsub :
51                 new = True
52     except :
53         erreur = "la page n'est pas accessible"
54     if not erreur and new :
55         msg = """
56 Une nouvelle version d'IRaMuTeQ (%s) est disponible.
57 Vous pouvez la télécharger à partir du site web iramuteq :
58 http://www.iramuteq.org""" % '-'.join(lastversion)
59         dlg = wx.MessageDialog(parent, msg, "Nouvelle version disponible", wx.OK | wx.ICON_WARNING)
60         dlg.CenterOnParent()
61         if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
62              evt.Veto()