This repository has been archived by the owner on Mar 18, 2020. It is now read-only.
/
dzik.py
58 lines (47 loc) · 2.07 KB
/
dzik.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# -*- coding: latin-1 -*-
### App By : Redouane ###
### E-MAIL : unrealdz@gmail.com ###
### BLOG : redouanezait.com ###
### LICENSE : GNU GPL v3 ###
from main import gui
from PyQt4.QtGui import QApplication, QMessageBox
from PyQt4.QtCore import QThread, SIGNAL
import urllib
import re
import sys
if hasattr(sys,"setdefaultencoding"):
sys.setdefaultencoding("latin-1")
currentversion = '1.3'
def main():
class App(QApplication):
def __init__(self, argv):
super(App, self).__init__(argv)
css = open('style.qss', 'r').read()
self.main = gui.Mainwindow()
self.urlbar = gui.urlgroup(self.main)
self.setStyleSheet(css)
self.thread = checkforUpdate()
self.connect(self.thread, SIGNAL('updateinfos(PyQt_PyObject)'), self.update)
self.thread.start()
def update(self, updateinfos):
self.updatebox = QMessageBox()
self.updatebox.about(self.main, 'Mise �� jour', 'Une nouvelle Mise �� jour est disponible : <br \> <b> Version : </b>' + updateinfos['version'] + '<br /> <b> Lien : </b>' + updateinfos['link'] + '<br /> <b>Nouveaut�s : </b>' + updateinfos['whatsnew'])
class checkforUpdate(QThread):
def run(self):
xml = 'http://dl.dropbox.com/u/6858914/DZik/DZik.xml'
try:
xml = urllib.urlopen(xml).read()
latestversion = re.findall('<version>(.+)</version>', xml)[0]
if float(latestversion) <= float(currentversion):
return
else:
link = re.findall('<link>(.+)</link>', xml)[0]
whatsnew = re.findall('<whatsnew>(.+)</whatsnew>', xml)[0]
updateinfos = {'version':latestversion, 'link':link , 'whatsnew':whatsnew}
self.emit(SIGNAL('updateinfos(PyQt_PyObject)'), updateinfos)
except IOError:
return
dzik = App(sys.argv)
dzik.exec_()
if __name__ == '__main__':
main()