/[ascend]/trunk/pygtk/versioncheck.py
ViewVC logotype

Contents of /trunk/pygtk/versioncheck.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 905 - (show annotations) (download) (as text)
Thu Oct 26 00:58:49 2006 UTC (16 years, 3 months ago) by johnpye
File MIME type: text/x-python
File size: 1221 byte(s)
Improved check-for-updates a little bit
1 import urllib2, ConfigParser, platform
2
3
4 class VersionCheck:
5 def __init__(self):
6 self.url = "http://ascend.cruncher2.dyndns.org/version.ini"
7 self.download = None
8 self.latest = None
9 self.info = None
10 def check(self):
11 auth_handler = urllib2.HTTPBasicAuthHandler()
12 opener = urllib2.build_opener(auth_handler)
13 urllib2.install_opener(opener)
14 fp = urllib2.urlopen(self.url)
15
16 cp = ConfigParser.SafeConfigParser()
17 cp.readfp(fp,self.url)
18
19 opersys = platform.system()
20
21 if opersys=="Windows":
22 self.vertype = "Windows"
23 self.latest = cp.get('Windows','version').strip()
24 self.info = cp.get('Windows','info').strip()
25 try:
26 self.download = cp.get('Windows','download').strip()
27 except:
28 pass
29 return True
30 else:
31 self.vertype = "Source code"
32 self.latest = cp.get('Generic','version').strip()
33 self.info = cp.get('Generic','info').strip()
34 try:
35 self.download = cp.get('Generic','download').strip()
36 except:
37 pass
38 return True
39
40 raise RuntimeError("No version info available for this operating system")
41
42 if __name__=="__main__":
43 v = VersionCheck()
44 if v.check():
45 print v.latest
46 print "Info at %s" % v.info
47 if v.download:
48 print "Download from %s" % v.download

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22