bug 548320 (winnt 5.1/6.1 have trouble pinging the graph server) use HTTP instead of HTTPConnection p=anodelman r=bhearsum
git-svn-id: svn://10.0.0.236/trunk@259818 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
0c83972816
commit
91e2c1c29f
@ -6,24 +6,33 @@
|
|||||||
# This recipe is covered under the Python license: http://www.python.org/license
|
# This recipe is covered under the Python license: http://www.python.org/license
|
||||||
|
|
||||||
import httplib, mimetypes, urllib2
|
import httplib, mimetypes, urllib2
|
||||||
|
import socket
|
||||||
from socket import error, herror, gaierror, timeout
|
from socket import error, herror, gaierror, timeout
|
||||||
|
socket.setdefaulttimeout(None)
|
||||||
|
import urlparse
|
||||||
|
|
||||||
def link_exists(host, selector):
|
def link_exists(host, selector):
|
||||||
"""
|
url = "http://" + host + selector
|
||||||
Check to see if the given host exists and is reachable
|
host, path = urlparse.urlsplit(url)[1:3]
|
||||||
"""
|
found = 0
|
||||||
|
msg = "ping"
|
||||||
try:
|
try:
|
||||||
site = urllib2.urlopen("http://" + host + selector)
|
h = httplib.HTTP(host) ## Make HTTPConnection Object
|
||||||
meta = site.info()
|
h.putrequest('HEAD', selector)
|
||||||
except urllib2.HTTPError, e:
|
h.putheader('content-type', "text/plain")
|
||||||
print "FAIL: graph server HTTPError"
|
h.putheader('content-length', str(len(msg)))
|
||||||
print "FAIL: " + str(e)
|
h.putheader('Host', host)
|
||||||
return 0
|
h.endheaders()
|
||||||
except urllib2.URLError, e:
|
h.send(msg)
|
||||||
print "FAIL: graph server URLError"
|
|
||||||
print "FAIL: " + str(e)
|
errcode, errmsg, headers = h.getreply()
|
||||||
return 0
|
if errcode == 200:
|
||||||
return 1
|
found = 1
|
||||||
|
else:
|
||||||
|
print "FAIL: graph server Status %d %s : %s" % (errcode, errmsg, url)
|
||||||
|
except Exception, e:
|
||||||
|
print "FAIL: graph server ", e.__class__, e, url
|
||||||
|
return found
|
||||||
|
|
||||||
def post_multipart(host, selector, fields, files):
|
def post_multipart(host, selector, fields, files):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -45,7 +45,7 @@ import urllib
|
|||||||
import os
|
import os
|
||||||
import string
|
import string
|
||||||
import socket
|
import socket
|
||||||
socket.setdefaulttimeout(480)
|
#socket.setdefaulttimeout(480)
|
||||||
import getopt
|
import getopt
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user