From 80ca4f00f82cd2f58fe5cda38c8cc5a719c887b6 Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Wed, 13 May 2015 13:21:33 +0100 Subject: bitbake: toaster/contrib: adding TTS squashed patch In order to move the Toaster Test System in Toaster itself, we create a contrib directory. The TTS is added as a squashed patch with no history. It contains code contributed by Ke Zou . (Bitbake rev: 7d24fea2b5dcaac6add738b6fb4700d698824286) Signed-off-by: Alexandru DAMIAN Signed-off-by: Richard Purdie --- bitbake/lib/toaster/contrib/tts/urlcheck.py | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 bitbake/lib/toaster/contrib/tts/urlcheck.py (limited to 'bitbake/lib/toaster/contrib/tts/urlcheck.py') 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 @@ +from __future__ import print_function +import sys + +import httplib2 +import time + +import config +import urllist + +# TODO: spawn server here +BASEURL="http://localhost:8000/" + +#def print_browserlog(url): +# driver = webdriver.Firefox() +# driver.get(url) +# body = driver.find_element_by_tag_name("body") +# body.send_keys(Keys.CONTROL + 't') +# for i in driver.get_log('browser'): +# print(i) +# driver.close() + + +# TODO: turn to a test +def validate_html(url): + h = httplib2.Http(".cache") + # TODO: the w3c-validator must be a configurable setting + urlrequest = "http://icarus.local/w3c-validator/check?doctype=HTML5&uri="+url + try: + resp, content = h.request(urlrequest, "HEAD") + if resp['x-w3c-validator-status'] == "Abort": + config.logger.error("FAILed call %s" % url) + else: + 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)) + except Exception as e: + config.logger.warn("Failed validation call: %s" % e.__str__()) + + print("done %s" % url) + +if __name__ == "__main__": + if len(sys.argv) > 1: + validate_html(sys.argv[1]) + else: + for url in urllist.URLS: + validate_html(BASEURL+url) -- cgit v1.2.3-54-g00ecf