diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2015-07-30 19:25:09 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-08-01 11:26:13 +0100 |
commit | 1640a65091c56eeed0f6bb1020fd156cdc279a6e (patch) | |
tree | ee36a0a10c1fea4d5e10e645b9077f80d6d67567 /bitbake/lib/toaster/contrib/tts/urlcheck.py | |
parent | 160d610604fff0b119de2b70a9da8a5f73d93715 (diff) | |
download | poky-1640a65091c56eeed0f6bb1020fd156cdc279a6e.tar.gz |
bitbake: toaster: tts: fix pylint warnings
This patch brings TTS to the pylint coding standards.
Pylint was run with some disables:
disable=logging-too-many-args,line-too-long,missing-docstring
and achieved
Your code has been rated at 10.00/10
There are no functional changes.
(Bitbake rev: 2b40b412ff6a7e3fd4cc32707bd3cd713bc09ddb)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.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 | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/bitbake/lib/toaster/contrib/tts/urlcheck.py b/bitbake/lib/toaster/contrib/tts/urlcheck.py index 86d7caac2a..8514de8956 100644 --- a/bitbake/lib/toaster/contrib/tts/urlcheck.py +++ b/bitbake/lib/toaster/contrib/tts/urlcheck.py | |||
@@ -2,40 +2,45 @@ from __future__ import print_function | |||
2 | import sys | 2 | import sys |
3 | 3 | ||
4 | import httplib2 | 4 | import httplib2 |
5 | import time | ||
6 | 5 | ||
7 | import config | 6 | import config |
8 | import urllist | 7 | import urllist |
9 | 8 | ||
10 | 9 | ||
11 | # TODO: turn to a test | ||
12 | def validate_html5(url): | 10 | def validate_html5(url): |
13 | h = httplib2.Http(".cache") | 11 | http_client = httplib2.Http(None) |
14 | status = "Failed" | 12 | status = "Failed" |
15 | errors = -1 | 13 | errors = -1 |
16 | warnings = -1 | 14 | warnings = -1 |
17 | 15 | ||
18 | # TODO: the w3c-validator must be a configurable setting | ||
19 | urlrequest = config.W3C_VALIDATOR+url | 16 | urlrequest = config.W3C_VALIDATOR+url |
17 | |||
18 | # pylint: disable=broad-except | ||
19 | # we disable the broad-except because we want to actually catch all possible exceptions | ||
20 | try: | 20 | try: |
21 | resp, content = h.request(urlrequest, "HEAD") | 21 | resp, _ = http_client.request(urlrequest, "HEAD") |
22 | if resp['x-w3c-validator-status'] != "Abort": | 22 | if resp['x-w3c-validator-status'] != "Abort": |
23 | status = resp['x-w3c-validator-status'] | 23 | status = resp['x-w3c-validator-status'] |
24 | errors = int(resp['x-w3c-validator-errors']) | 24 | errors = int(resp['x-w3c-validator-errors']) |
25 | warnings = int(resp['x-w3c-validator-warnings']) | 25 | warnings = int(resp['x-w3c-validator-warnings']) |
26 | except Exception as e: | 26 | except Exception as exc: |
27 | config.logger.warn("Failed validation call: %s" % e.__str__()) | 27 | config.logger.warn("Failed validation call: %s", exc) |
28 | return (status, errors, warnings) | 28 | return (status, errors, warnings) |
29 | 29 | ||
30 | if __name__ == "__main__": | ||
31 | print("Testing %s with %s" % (config.TOASTER_BASEURL, config.W3C_VALIDATOR)) | ||
32 | 30 | ||
33 | def print_validation(url): | 31 | def print_validation(url): |
34 | status, errors, warnings = validate_html5(url) | 32 | 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)) | 33 | config.logger.error("url %s is %s\terrors %s warnings %s (check at %s)", url, status, errors, warnings, config.W3C_VALIDATOR+url) |
34 | |||
35 | |||
36 | def main(): | ||
37 | print("Testing %s with %s" % (config.TOASTER_BASEURL, config.W3C_VALIDATOR)) | ||
36 | 38 | ||
37 | if len(sys.argv) > 1: | 39 | if len(sys.argv) > 1: |
38 | print_validation(sys.argv[1]) | 40 | print_validation(sys.argv[1]) |
39 | else: | 41 | else: |
40 | for url in urllist.URLS: | 42 | for url in urllist.URLS: |
41 | print_validation(config.TOASTER_BASEURL+url) | 43 | print_validation(config.TOASTER_BASEURL+url) |
44 | |||
45 | if __name__ == "__main__": | ||
46 | main() | ||