Hi Tony,
Sorry i am unable to understand you :(
Below is what i have now
URL = "http://10.47.42.27:8080/cruisecontrol"
from urllib2 import urlopen
from HTMLParser import HTMLParser
import re
# Parsing HTML pages
class MyHTMLParser(HTMLParser):
def __init__(self, *args, **kwd):
HTMLParser.__init__(self, *args, **kwd)
self.links = []
def handle_starttag(self, tag, attrs):
if tag == "a":
attrs = dict(attrs)
if "href" in attrs:
self.links.append(dict(attrs))
def handle_endtag(self, tag):
pass
# Fetching links using HTMLParser
def get_links(url):
parser = MyHTMLParser()
parser.feed(urlopen(url).read())
parser.close()
return parser.links
# To find all text in the HTML table
class DataParser():
def __init__(self):
self.find = "COMPLETE"
self.found = False
self.data = urlopen(url).read()
if self.data:
if self.find in self.data:
self.found=True
print "FOUND"
else:
print "NOT FOUND"
else: print "NO DATA"
def build_check():
parser = DataParser()
return parser.found
# Build url for Deploy page
def get_deploy_url():
url = URL + "/buildresults/Poker-TTM_%s_nightly_build" % branch
print url
if build_check():
print "BUILD COMPLETE found"
for link in get_links(url):
if link["href"].startswith("Deploy"):
return "%s/%s" % (URL, link["href"])
# Build url for Destination page
def get_destination_url():
url = get_deploy_url()
print "Deploy URL is: %s" % url
destination_re = re.compile(r"%s" % destination)
for link in get_links(url):
if destination_re.search(link["href"]):
return "http://10.47.42.27:8080/cruisecontrol/" + link["href"]
if __name__ == "__main__":
# Read the branch name and the test destination to deploy on
lines = [x.split(':') for x in open("branch_dest.txt")]
print lines
branch = "%s" % lines[0][1].strip()
print branch
destination = "%s" % lines[1][1].strip()
print destination
final_url = get_destination_url()
if final_url is None:
print "Could not find a destination to deploy"
else:
print "Destination URL is: %s" % final_url