2011-05-26 03:40:30 -04:00
|
|
|
import urllib
|
2011-05-26 03:42:05 -04:00
|
|
|
import re
|
2011-05-29 14:02:10 -04:00
|
|
|
import time
|
2011-05-26 03:42:05 -04:00
|
|
|
|
|
|
|
USER_TYPE = "dev"
|
2011-05-26 03:40:30 -04:00
|
|
|
|
|
|
|
_pcMajor = "3.14"
|
|
|
|
_pcMinor = "2"
|
2011-05-27 01:53:45 -04:00
|
|
|
_pcStatus = "B" # A = alpha
|
|
|
|
# B = beta
|
|
|
|
# RC = release candidate
|
|
|
|
# None = public release
|
2011-05-26 03:40:30 -04:00
|
|
|
_pcRevision = "3"
|
|
|
|
_pcVersion = ""
|
|
|
|
|
|
|
|
def pcVerCalc():
|
|
|
|
global _pcVersion
|
2011-05-27 01:53:45 -04:00
|
|
|
if _pcStatus:
|
|
|
|
_pcVersion = "%s.%s-%s%s" % (_pcMajor, _pcMinor, _pcStatus, _pcRevision)
|
|
|
|
else:
|
|
|
|
_pcVersion = "%s.%s.%s" % (_pcMajor, _pcMinor, _pcRevision)
|
2011-05-26 03:42:05 -04:00
|
|
|
|
|
|
|
def verStrToNum(ver):
|
2011-05-27 01:53:45 -04:00
|
|
|
w = re.match("(\d+\.?\d+)\.(\d+)-?([A-Za-z]{0,2})\.?(\d*):(\S+)", ver)
|
2011-05-26 03:42:05 -04:00
|
|
|
if not w:
|
|
|
|
print "Update check Failure: 3"; return
|
|
|
|
full = ver[:ver.find(":")]
|
|
|
|
return full,w.group(1),w.group(2),w.group(3),w.group(4),w.group(5)
|
|
|
|
|
2011-05-29 14:02:10 -04:00
|
|
|
def updateCheck(q,num):
|
|
|
|
time.sleep(3)
|
2011-05-26 03:42:05 -04:00
|
|
|
data = urllib.urlencode({"type" : USER_TYPE})
|
|
|
|
try:
|
|
|
|
f = urllib.urlopen("http://distantsphere.com/pesterchum.php?" + data)
|
|
|
|
except:
|
2011-05-29 14:02:10 -04:00
|
|
|
print "Update check Failure: 1"; q.put((False,1))
|
2011-05-26 03:42:05 -04:00
|
|
|
newest = f.read()
|
|
|
|
f.close()
|
2011-05-27 01:53:45 -04:00
|
|
|
if not newest or newest[0] == "<":
|
2011-05-29 14:02:10 -04:00
|
|
|
print "Update check Failure: 2"; q.put((False,2))
|
2011-05-26 03:42:05 -04:00
|
|
|
try:
|
|
|
|
(full, major, minor, status, revision, url) = verStrToNum(newest)
|
|
|
|
except TypeError:
|
2011-05-29 14:02:10 -04:00
|
|
|
return q.put((False,3))
|
2011-05-26 03:42:05 -04:00
|
|
|
print full
|
2011-05-27 01:53:45 -04:00
|
|
|
if major <= _pcMajor:
|
|
|
|
if minor <= _pcMinor:
|
|
|
|
if status:
|
|
|
|
if status <= _pcStatus:
|
|
|
|
if revision <= _pcRevision:
|
2011-05-29 14:02:10 -04:00
|
|
|
return q.put((False,0))
|
2011-05-27 01:53:45 -04:00
|
|
|
else:
|
|
|
|
if not _pcStatus:
|
|
|
|
if revision <= _pcRevision:
|
2011-05-29 14:02:10 -04:00
|
|
|
return q.put((False,0))
|
2011-05-27 01:53:45 -04:00
|
|
|
print "A new version of Pesterchum is avaliable!"
|
2011-05-29 14:02:10 -04:00
|
|
|
q.put((full,url))
|