Go to the documentation of this file.00001
00002 from time import time
00003 from random import randint
00004 from urllib2 import urlopen
00005 from re import search
00006
00007 class VersionChecker(object):
00008 def __init__(self, version):
00009 self.version = version
00010
00011 def check(self):
00012 version = self.version
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 utmac='UA-18071-1'
00023 utmhn='code.google.com'
00024 utmn=str(randint(1000000000,9999999999))
00025 cookie=str(randint(10000000,99999999))
00026 random=str(randint(1000000000,2147483647))
00027 today=str(int(time()))
00028 referer='0'
00029 uservar='-'
00030 utmp='%2Fp%2Fbrown-ros-pkg%2Fwiki%2FrosbridgeRecVer'
00031
00032 req = 'http://www.google-analytics.com/__utm.gif?utmwv=1&utmn='+ utmn + '&utmsr=-&utmsc=-&utmul=-&utmje=0&utmfl=-&utmdt=-&utmhn='+ utmhn + '&utmr='+ referer + '&utmp='+ utmp + '&utmac='+ utmac + '&utmcc=__utma%3D'+ cookie + '.'+ random + '.'+ today + '.'+ today + '.'+ today + '.2%3B%2B__utmb%3D'+ cookie + '%3B%2B__utmc%3D'+ cookie + '%3B%2B__utmz%3D'+ cookie + '.'+ today + '.2.2.utmccn%3D(direct)%7Cutmcsr%3D(direct)%7Cutmcmd%3D(none)%3B%2B__utmv%3D'+ cookie + '.'+ uservar + '%3B'
00033
00034 try:
00035 f = urlopen(req, timeout=5)
00036 f.readlines()
00037 f.close()
00038
00039 f = urlopen('http://code.google.com/p/brown-ros-pkg/wiki/rosbridgeRecVer', timeout=5)
00040 line = f.readline()
00041 while line:
00042 match = search(r'recommendation: ([0-9]+)',line)
00043 if match != None:
00044 recommendation = int(match.group(1))
00045 if (recommendation > version):
00046 print "This version of rosbridge is based on svn revision %s, revision %s or greater is highly recommended." % (version, recommendation)
00047 break
00048
00049 line = f.readline()
00050 f.close()
00051
00052 except:
00053 print "rosbridge may not have outside Internet connectivity."
00054
00055 print