Merge pull request #92 from ehlers/check_url

use GET requests instead of HEAD for checking URLs
This commit is contained in:
Julien Duponchelle 2016-02-05 09:30:51 +01:00
commit a14cd6de65
2 changed files with 17 additions and 6 deletions

View File

@ -3,7 +3,7 @@
"category": "guest",
"description": "Microsoft Windows (or simply Windows) is a graphical operating system developed, marketed, and sold by Microsoft.\n\nMicrosoft releases time limited VMs for testing Internet Explorer.\n\nOn the download site select the VM, as platform select VirtualBox, then download the zip file, afterwards unzip it.",
"vendor_name": "Microsoft",
"vendor_url": "https://dev.microsoft.com/",
"vendor_url": "http://www.microsoft.com",
"product_name": "Windows",
"registry_version": 1,
"status": "experimental",

View File

@ -22,28 +22,39 @@ import pycurl
err_list = []
def data_abort(data):
return -1
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.NOBODY, True)
c.setopt(c.HTTPHEADER, ['Accept-Language: en-us'])
c.setopt(c.FOLLOWLOCATION, True)
c.setopt(c.WRITEFUNCTION, data_abort)
c.perform()
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)
c.close()
except pycurl.error:
error = c.errstr()
if error:
print(" " + error)
err_list.append("{}: {} - {}".format(appliance, url, error))
c.close()
def check_urls(appliance):
try: