Hi,
After much research and help from forums, i have the following. Using HTMLParser to parse thru html pages and then finally reaching a webpage where i have to check all the checkboxes and then click the 'Deploy' button. Used ClientForm to do this. But i am getting some HTTP version error

URL = "http://10.47.42.27:8080/cruisecontrol"

#from urllib2 import urlopen
from HTMLParser import HTMLParser

import re
import ClientForm
import urllib2

# Fetching links using HTMLParser
def get_links(url):
    parser = MyHTMLParser()
    parser.feed(urlopen(url).read())
    parser.close()
    return parser.links

# Build url for Deploy page
def get_deploy_url():
    url = URL + "/buildresults/Poker-TTM_%s_nightly_build" % branch
    print url
    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 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"]
        print link["href"]

# 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

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 "Cannot deploy here"
    else:
        print final_url
        request = urllib2.Request("%s" % final_url)
        response = urllib2.urlopen(request)
        forms = ClientForm.ParseResponse(response, backwards_compat = False)
        response.close()
        form = forms[0]
        print form
        form.find_control("all_top").items[0].selected = True
        form.find_control("client.POK_code").items[0].selected = True
        form.find_control("client.SVS_code").items[0].selected = True
        form.find_control("client.PAT_code").items[0].selected = True
        form.find_control("client.POK_code_gms").items[0].selected = True
        form.find_control("client.POK_code_gms_cpn").items[0].selected = True
        form.find_control("client.POK_code_mini").items[0].selected = True
        form.find_control("client.LTM_code").items[0].selected = True
        form.find_control("client.LTM_tot_code").items[0].selected = True
        form.find_control("client.POK_code_paradise").items[0].selected = True
        form.find_control("client.POK_code_forfun").items[0].selected = True
        form.find_control("client.POK_code_pokerheaven").items[0].selected = True
        form.find_control("client.POK_code_totalpoker").items[0].selected = True
        form.find_control("client.POK_code_las").items[0].selected = True
        form.find_control("client.POK_code_italian").items[0].selected = True
        form.find_control("client.POK_code_bulgarian").items[0].selected = True
        form.find_control("client.POK_code_finnish").items[0].selected = True
        form.find_control("client.POK_code_danish").items[0].selected = True
        form.find_control("client.POK_code_french").items[0].selected = True
        form.find_control("client.POK_code_greek").items[0].selected = True
        form.find_control("client.POK_code_german").items[0].selected = True
        form.find_control("client.POK_code_croatian").items[0].selected = True
        form.find_control("client.POK_code_polish").items[0].selected = True
        form.find_control("client.POK_code_portuguese").items[0].selected = True
        form.find_control("client.POK_code_romanian").items[0].selected = True
        form.find_control("client.POK_code_russian").items[0].selected = True
        form.find_control("client.POK_code_slovak").items[0].selected = True
        form.find_control("client.POK_code_spanish").items[0].selected = True
        form.find_control("client.POK_code_czech").items[0].selected = True
        form.find_control("client.POK_code_swedish").items[0].selected = True
        form.find_control("client.POK_code_hungarian").items[0].selected = True
        form.find_control("client.POK_code_turkish").items[0].selected = True
        form.find_control("client.POK_code_albanian").items[0].selected = True
        form.find_control("client.POK_code_austrian").items[0].selected = True
        form.find_control("client.POK_code_brazilian").items[0].selected = True
        form.find_control("all").items[0].selected = True
        print form

        ##request2 = form.click()
        try:
            response2 = urllib2.urlopen(request2)
        except urllib2.HTTPError, response2:
            pass

        print response2.geturl()
        print response2.read()
        response2.close()

Below is the error

Traceback (most recent call last):
  File "C:\deploy_input_clientform.py", line 65, in <module>
    response = urllib2.urlopen(request)
  File "C:\Python26\lib\urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "C:\Python26\lib\urllib2.py", line 397, in open
    response = meth(req, response)
  File "C:\Python26\lib\urllib2.py", line 510, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Python26\lib\urllib2.py", line 435, in error
    return self._call_chain(*args)
  File "C:\Python26\lib\urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "C:\Python26\lib\urllib2.py", line 518, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 505: HTTP Version Not Supported

Please help!

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
10.5.6 505 HTTP Version Not Supported

The server does not support, or refuses to support, the HTTP protocol version that was used in the request message. The server is indicating that it is unable or unwilling to complete the request using the same major version as the client, as described in section 3.1, other than with this error message. The response SHOULD contain an entity describing why that version is not supported and what other protocols are supported by that server.

I read that too. But i could not figure out what the workaround to this problem was. Anybody has any ideas??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.