diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2015-05-13 13:21:33 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-05-14 18:04:10 +0100 |
commit | 80ca4f00f82cd2f58fe5cda38c8cc5a719c887b6 (patch) | |
tree | f2d5a130213c37b8aed1fb07fecf46eb9e5e1a13 /bitbake/lib/toaster/contrib/tts/urlcheck.py | |
parent | 23f5b009e0ebf59cfcc9ae90a1084468fc88e42f (diff) | |
download | poky-80ca4f00f82cd2f58fe5cda38c8cc5a719c887b6.tar.gz |
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 <ke.zou@windriver.com>.
(Bitbake rev: 7d24fea2b5dcaac6add738b6fb4700d698824286)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/contrib/tts/urlcheck.py')
-rw-r--r-- | bitbake/lib/toaster/contrib/tts/urlcheck.py | 44 |
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 @@ | |||
1 | from __future__ import print_function | ||
2 | import sys | ||
3 | |||
4 | import httplib2 | ||
5 | import time | ||
6 | |||
7 | import config | ||
8 | import urllist | ||
9 | |||
10 | # TODO: spawn server here | ||
11 | BASEURL="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 | ||
24 | def 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 | |||
39 | if __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) | ||