summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/contrib/tts/urlcheck.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/contrib/tts/urlcheck.py')
-rw-r--r--bitbake/lib/toaster/contrib/tts/urlcheck.py41
1 files changed, 19 insertions, 22 deletions
diff --git a/bitbake/lib/toaster/contrib/tts/urlcheck.py b/bitbake/lib/toaster/contrib/tts/urlcheck.py
index a94af5000b..86d7caac2a 100644
--- a/bitbake/lib/toaster/contrib/tts/urlcheck.py
+++ b/bitbake/lib/toaster/contrib/tts/urlcheck.py
@@ -7,38 +7,35 @@ import time
7import config 7import config
8import urllist 8import urllist
9 9
10# TODO: spawn server here
11BASEURL="http://localhost:8000/"
12
13#def print_browserlog(url):
14# driver = webdriver.Firefox()
15# driver.get(url)
16# body = driver.find_element_by_tag_name("body")
17# body.send_keys(Keys.CONTROL + 't')
18# for i in driver.get_log('browser'):
19# print(i)
20# driver.close()
21
22 10
23# TODO: turn to a test 11# TODO: turn to a test
24def validate_html(url): 12def validate_html5(url):
25 h = httplib2.Http(".cache") 13 h = httplib2.Http(".cache")
14 status = "Failed"
15 errors = -1
16 warnings = -1
17
26 # TODO: the w3c-validator must be a configurable setting 18 # TODO: the w3c-validator must be a configurable setting
27 urlrequest = "http://icarus.local/w3c-validator/check?doctype=HTML5&uri="+url 19 urlrequest = config.W3C_VALIDATOR+url
28 try: 20 try:
29 resp, content = h.request(urlrequest, "HEAD") 21 resp, content = h.request(urlrequest, "HEAD")
30 if resp['x-w3c-validator-status'] == "Abort": 22 if resp['x-w3c-validator-status'] != "Abort":
31 config.logger.error("FAILed call %s" % url) 23 status = resp['x-w3c-validator-status']
32 else: 24 errors = int(resp['x-w3c-validator-errors'])
33 config.logger.error("url %s is %s\terrors %s warnings %s (check at %s)" % (url, resp['x-w3c-validator-status'], resp['x-w3c-validator-errors'], resp['x-w3c-validator-warnings'], urlrequest)) 25 warnings = int(resp['x-w3c-validator-warnings'])
34 except Exception as e: 26 except Exception as e:
35 config.logger.warn("Failed validation call: %s" % e.__str__()) 27 config.logger.warn("Failed validation call: %s" % e.__str__())
36 28 return (status, errors, warnings)
37 print("done %s" % url)
38 29
39if __name__ == "__main__": 30if __name__ == "__main__":
31 print("Testing %s with %s" % (config.TOASTER_BASEURL, config.W3C_VALIDATOR))
32
33 def print_validation(url):
34 status, errors, warnings = validate_html5(url)
35 config.logger.error("url %s is %s\terrors %s warnings %s (check at %s)" % (url, status, errors, warnings, config.W3C_VALIDATOR+url))
36
40 if len(sys.argv) > 1: 37 if len(sys.argv) > 1:
41 validate_html(sys.argv[1]) 38 print_validation(sys.argv[1])
42 else: 39 else:
43 for url in urllist.URLS: 40 for url in urllist.URLS:
44 validate_html(BASEURL+url) 41 print_validation(config.TOASTER_BASEURL+url)