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.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/contrib/tts/urlcheck.py b/bitbake/lib/toaster/contrib/tts/urlcheck.py
new file mode 100644
index 0000000000..a94af5000b
--- /dev/null
+++ b/bitbake/lib/toaster/contrib/tts/urlcheck.py
@@ -0,0 +1,44 @@
1from __future__ import print_function
2import sys
3
4import httplib2
5import time
6
7import config
8import urllist
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
23# TODO: turn to a test
24def validate_html(url):
25 h = httplib2.Http(".cache")
26 # TODO: the w3c-validator must be a configurable setting
27 urlrequest = "http://icarus.local/w3c-validator/check?doctype=HTML5&uri="+url
28 try:
29 resp, content = h.request(urlrequest, "HEAD")
30 if resp['x-w3c-validator-status'] == "Abort":
31 config.logger.error("FAILed call %s" % url)
32 else:
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))
34 except Exception as e:
35 config.logger.warn("Failed validation call: %s" % e.__str__())
36
37 print("done %s" % url)
38
39if __name__ == "__main__":
40 if len(sys.argv) > 1:
41 validate_html(sys.argv[1])
42 else:
43 for url in urllist.URLS:
44 validate_html(BASEURL+url)