diff options
Diffstat (limited to 'bitbake/lib/toaster/contrib/tts/urlcheck.py')
-rw-r--r-- | bitbake/lib/toaster/contrib/tts/urlcheck.py | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/bitbake/lib/toaster/contrib/tts/urlcheck.py b/bitbake/lib/toaster/contrib/tts/urlcheck.py deleted file mode 100644 index 001fcee96a..0000000000 --- a/bitbake/lib/toaster/contrib/tts/urlcheck.py +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | from __future__ import print_function | ||
2 | import sys | ||
3 | |||
4 | import httplib2 | ||
5 | import config | ||
6 | import urllist | ||
7 | |||
8 | |||
9 | config.logger.info("Testing %s with %s", config.TOASTER_BASEURL, config.W3C_VALIDATOR) | ||
10 | |||
11 | def validate_html5(url): | ||
12 | http_client = httplib2.Http(None) | ||
13 | status = "Failed" | ||
14 | errors = -1 | ||
15 | warnings = -1 | ||
16 | |||
17 | urlrequest = config.W3C_VALIDATOR+url | ||
18 | |||
19 | # pylint: disable=broad-except | ||
20 | # we disable the broad-except because we want to actually catch all possible exceptions | ||
21 | try: | ||
22 | resp, _ = http_client.request(urlrequest, "HEAD") | ||
23 | if resp['x-w3c-validator-status'] != "Abort": | ||
24 | status = resp['x-w3c-validator-status'] | ||
25 | errors = int(resp['x-w3c-validator-errors']) | ||
26 | warnings = int(resp['x-w3c-validator-warnings']) | ||
27 | |||
28 | if status == 'Invalid': | ||
29 | config.logger.warning("Failed %s is %s\terrors %s warnings %s (check at %s)", url, status, errors, warnings, urlrequest) | ||
30 | else: | ||
31 | config.logger.debug("OK! %s", url) | ||
32 | |||
33 | except Exception as exc: | ||
34 | config.logger.warning("Failed validation call: %s", exc) | ||
35 | return (status, errors, warnings) | ||
36 | |||
37 | |||
38 | def print_validation(url): | ||
39 | status, errors, warnings = validate_html5(url) | ||
40 | config.logger.error("url %s is %s\terrors %s warnings %s (check at %s)", url, status, errors, warnings, config.W3C_VALIDATOR+url) | ||
41 | |||
42 | |||
43 | def main(): | ||
44 | print("Testing %s with %s" % (config.TOASTER_BASEURL, config.W3C_VALIDATOR)) | ||
45 | |||
46 | if len(sys.argv) > 1: | ||
47 | print_validation(sys.argv[1]) | ||
48 | else: | ||
49 | for url in urllist.URLS: | ||
50 | print_validation(config.TOASTER_BASEURL+url) | ||
51 | |||
52 | if __name__ == "__main__": | ||
53 | main() | ||