Started work on update notification. Successfully prints out alert to stdout if version from GitHub is not the same as internal version.

This commit is contained in:
blitzmann
2014-02-13 22:28:56 -05:00
parent d7b7d127b8
commit 6ee474a8ff
3 changed files with 60 additions and 0 deletions

View File

@@ -161,6 +161,10 @@ class MainFrame(wx.Frame):
#Show ourselves #Show ourselves
self.Show() self.Show()
#Check for updates
self.sUpdate = service.Update.getInstance()
self.sUpdate.CheckUpdate()
def LoadMainFrameAttribs(self): def LoadMainFrameAttribs(self):
mainFrameDefaultAttribs = {"wnd_width":1000, "wnd_height": 700, "wnd_maximized": False} mainFrameDefaultAttribs = {"wnd_width":1000, "wnd_height": 700, "wnd_maximized": False}

View File

@@ -5,3 +5,4 @@ from service.character import Character
from service.damagePattern import DamagePattern from service.damagePattern import DamagePattern
from service.settings import SettingsProvider from service.settings import SettingsProvider
from service.fleet import Fleet from service.fleet import Fleet
from service.update import Update

55
service/update.py Normal file
View File

@@ -0,0 +1,55 @@
#===============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
#
# pyfa 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 3 of the License, or
# (at your option) any later version.
#
# pyfa 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 pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
import threading
import wx
import urllib2
import json
import config
from service.settings import SettingsProvider
class Update():
instance = None
def __init__(self):
pass
def CheckUpdate(self):
print "Checking for Updates"
t=threading.Thread(target=self.__CheckUpdate)
t.start()
def __CheckUpdate(self):
print "In the thread"
try:
response = urllib2.urlopen('https://api.github.com/repos/DarkFenX/Pyfa/releases')
jsonResponse = json.loads(response.read());
responseVersion = jsonResponse[0]['tag_name'].replace('v', '', 1)
if responseVersion != config.version:
print "New version!"
except:
pass
@classmethod
def getInstance(cls):
if cls.instance == None:
cls.instance = Update()
return cls.instance