fix processing of HTTP error code

This commit is contained in:
Bernhard Ehlers 2016-02-04 18:42:09 +01:00
parent c4dcbe1567
commit 380454b081

View File

@ -31,26 +31,30 @@ def check_url(url, appliance):
print(" " + url)
error = None
c = pycurl.Curl()
try:
c = pycurl.Curl()
c.setopt(c.URL, url)
c.setopt(c.USERAGENT, 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)')
c.setopt(c.HTTPHEADER, ['Accept-Language: en-us'])
c.setopt(c.FOLLOWLOCATION, True)
c.setopt(c.WRITEFUNCTION, data_abort)
c.perform()
http_status = c.getinfo(c.RESPONSE_CODE)
if http_status >= 400:
error = 'HTTP status {}'.format(http_status)
c.close()
except pycurl.error as err:
errno, errstr = err.args
if errno != pycurl.E_WRITE_ERROR:
error = errstr
if not error:
http_status = c.getinfo(c.RESPONSE_CODE)
if http_status >= 400:
error = 'HTTP status {}'.format(http_status)
if error:
print(" " + error)
err_list.append("{}: {} - {}".format(appliance, url, error))
c.close()
def check_urls(appliance):
try: