@@ -0,0 +1,1365 @@
+from subprocess import Popen%0Aimport sys%0Aimport urllib2%0Aimport time%0A# Find hostname to use for passing to webdriver%0Aresp=urllib2.urlopen('http://169.254.169.254/latest/meta-data/public-hostname')%0APHOST=resp.read()%0APHOST='localhost'%0A%0A# Poll Hub interface to determine free/busy status of resources%0Adef freeCheck():%0A        try:%0A                response=urllib2.urlopen('http://localhost:4200/grid/console')%0A                time.sleep(2)%0A%09%09html=response.read()%0A                exit%0A        except urllib2.URLError:%0A                pass%0A%0A        count = html.count(%22platform=%22)%0A        busy = html.count('busy')%0A        %0A        return %5Bcount,busy%5D%0A%09#return busy%0A%0A# If resources available (first condition) add more requests%0A#   - rename whatever test you want to run to the 'sdtest.py' value%0A# Otherwise, exit and wait a while%0A#if 'type=WebDriver' in html:%0AfreeCount=freeCheck()%0Aprint 'count:'+str(freeCount%5B0%5D)%0Aprint 'busy:'+str(freeCount%5B1%5D)%0A%0A%0A%0A%22%22%22%0Awhile freeCount%3E0:%0A        #Popen('python gridExecute.py 2 0 sdtest.py 40000 '+PHOST+'&',shell=True,close_fds=True)%0A%09#url2Send = urllib2.urlopen('http://cert-pa.elsevier.com/perfTest?perfTest.cpc=SD&perfTest.cpc.newScripts=2')        %0A        time.sleep(30)%0A        try:%0A                freeCount=freeCheck()%0A%09%09time.sleep(2)%0A                #print('fc:'+str(freeCount))%0A        except:%0A                exit%0A%0A%22%22%22%0A%0A%0A%09%09%0A

add cleanup script