All pastes #985325 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-04-14 22:38 UTC
rendered paste body
if not testUri(ea.as['web url']): ea.as['web url']='Not provisioned.'

def testUri(uri, port=80, resource="/"):
    """
    tests urls for availability
    """
    uri = str(uri)
    try:
        conn = httplib.HTTPConnection(uri)
        conn.request("GET", resource)
        rr = conn.getresponse()
        print rr.status
    except socket.error, msg:
        ret = False
        print "ret is false: " + uri
    else:
        ret = rr.status
        print "ret is true: " + uri
        conn.close()
    
    return ret