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

Contents of /trunk/pygtk/versioncheck.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2486 - (show annotations) (download) (as text)
Sun Jul 24 13:40:55 2011 UTC (10 years, 11 months ago) by jpye
File MIME type: text/x-python
File size: 1265 byte(s)
Update 'About' box to new URL.
Update 'check for updates' to point to new server.
1 import urllib2, ConfigParser, platform
2 import socket
3
4 class VersionCheck:
5 def __init__(self):
6 self.url = "http://www.ascend4.org/versioncheck/version.ini"
7 self.download = None
8 self.latest = None
9 self.info = None
10 def check(self):
11 socket.setdefaulttimeout(1)
12 auth_handler = urllib2.HTTPBasicAuthHandler()
13 opener = urllib2.build_opener(auth_handler)
14 urllib2.install_opener(opener)
15 fp = urllib2.urlopen(self.url)
16
17 cp = ConfigParser.SafeConfigParser()
18 cp.readfp(fp,self.url)
19
20 opersys = platform.system()
21
22 if opersys=="Windows":
23 self.vertype = "Windows"
24 self.latest = cp.get('Windows','version').strip()
25 self.info = cp.get('Windows','info').strip()
26 try:
27 self.download = cp.get('Windows','download').strip()
28 except:
29 pass
30 return True
31 else:
32 self.vertype = "Source code"
33 self.latest = cp.get('Generic','version').strip()
34 self.info = cp.get('Generic','info').strip()
35 try:
36 self.download = cp.get('Generic','download').strip()
37 except:
38 pass
39 return True
40
41 raise RuntimeError("No version info available for this operating system")
42
43 if __name__=="__main__":
44 v = VersionCheck()
45 if v.check():
46 print v.latest
47 print "Info at %s" % v.info
48 if v.download:
49 print "Download from %s" % v.download

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