version.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
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     # note:
00015     # The following code for producing the proper Google Analytics request is
00016     # based off of that provided for PHP in a blog post by Peter van Der Graaf:
00017     # http://www.vdgraaf.info/google-analytics-without-javascript.html
00018     # http://www.vdgraaf.info/wp-content/uploads/urchin-image.txt
00019     #
00020     # Any bugs are likely due to me and not Peter. -tjay
00021 
00022     utmac='UA-18071-1' #enter the new urchin code
00023     utmhn='code.google.com' #enter your domain
00024     utmn=str(randint(1000000000,9999999999)) #random request number
00025     cookie=str(randint(10000000,99999999)) #random cookie number
00026     random=str(randint(1000000000,2147483647)) #number under 2147483647
00027     today=str(int(time())) #today
00028     referer='0'
00029     uservar='-' #enter your own user defined variable
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 


rosbridge
Author(s): Graylin Trevor Jay
autogenerated on Fri Jan 3 2014 11:11:38