comparison test-svn.py @ 14:28b1f4853968

Get the latest published version from /test.py/version.txt
author Oleg Oshmyan <chortos@inbox.lv>
date Sat, 13 Mar 2010 00:04:57 +0000
parents 7c6f02865bf6
children c0e925ae721e
comparison
equal deleted inserted replaced
13:a2c9f7cfa174 14:28b1f4853968
19 parser.destroy() 19 parser.destroy()
20 del parser 20 del parser
21 21
22 def update(): 22 def update():
23 import urllib 23 import urllib
24 homepage = urllib.urlopen('http://chortos.selfip.net/~astiob/test.py/').read() 24 latesttext = urllib.urlopen('http://chortos.selfip.net/~astiob/test.py/version.txt').read()
25 i = homepage.find("The latest version of test.py is <span style='font-weight: bold; font-size: larger'>") 25 latest = latesttext.split('.')
26 i += len("The latest version of test.py is <span style='font-weight: bold; font-size: larger'>")
27 j = homepage.find(".</span>", i)
28 latest = homepage[i:j].split('.')
29 installed = version.split('.') 26 installed = version.split('.')
30 update = '' 27 update = ''
31 if latest[0] > installed[0]: 28 if latest[0] > installed[0]:
32 update = 'major' 29 update = 'major'
33 elif latest[0] == installed[0]: 30 elif latest[0] == installed[0]:
42 if update == '': 39 if update == '':
43 print 'Your copy of test.py is newer than the publicly available version.' 40 print 'Your copy of test.py is newer than the publicly available version.'
44 return 41 return
45 print 'A ' + update + ' update to test.py is available. Downloading...' 42 print 'A ' + update + ' update to test.py is available. Downloading...'
46 urllib.urlretrieve('http://chortos.selfip.net/~astiob/test.py/test.py', 'test.py') 43 urllib.urlretrieve('http://chortos.selfip.net/~astiob/test.py/test.py', 'test.py')
47 print 'Downloaded and installed. Now you are using test.py ' + homepage[i:j] + '.' 44 print 'Downloaded and installed. Now you are using test.py ' + latesttext + '.'
48 45
49 if options.update: 46 if options.update:
50 update() 47 update()
51 sys.exit() 48 sys.exit()
52 49