summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrazer Clews <frazer.clews@codethink.co.uk>2020-05-04 14:26:39 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-05-05 13:22:29 +0100
commit6fd3f6f37947613f415c931e16d1f9ebe2f07f6c (patch)
tree2d7c4c1b51aae084d0c21f7dc07d5b4fcf83bf3d
parent1c914ba04b549dbbee63752bcf1fc3af1a03794e (diff)
downloadpoky-6fd3f6f37947613f415c931e16d1f9ebe2f07f6c.tar.gz
bitbake: lib/toaster: fixup codebase so pydocstyle can parse
fixed literal comparison in lsupdates so the integer isn't treated as a singleton, also fix indentation in perf (Bitbake rev: 58c8752cd430a7a89bbf1ed5f21b515b17b514b0) Signed-off-by: Frazer Clews <frazer.clews@codethink.co.uk> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/toaster/orm/management/commands/lsupdates.py2
-rw-r--r--bitbake/lib/toaster/toastermain/management/commands/perf.py68
2 files changed, 35 insertions, 35 deletions
diff --git a/bitbake/lib/toaster/orm/management/commands/lsupdates.py b/bitbake/lib/toaster/orm/management/commands/lsupdates.py
index a4dbcaa76e..2fbd7be3d2 100644
--- a/bitbake/lib/toaster/orm/management/commands/lsupdates.py
+++ b/bitbake/lib/toaster/orm/management/commands/lsupdates.py
@@ -68,7 +68,7 @@ class Command(BaseCommand):
68 (what, 68 (what,
69 pec)) 69 pec))
70 sys.stdout.flush() 70 sys.stdout.flush()
71 if int(pec) is 100: 71 if int(pec) == 100:
72 sys.stdout.write("\n") 72 sys.stdout.write("\n")
73 sys.stdout.flush() 73 sys.stdout.flush()
74 74
diff --git a/bitbake/lib/toaster/toastermain/management/commands/perf.py b/bitbake/lib/toaster/toastermain/management/commands/perf.py
index 7d629fb37f..5c41c5b2f2 100644
--- a/bitbake/lib/toaster/toastermain/management/commands/perf.py
+++ b/bitbake/lib/toaster/toastermain/management/commands/perf.py
@@ -17,46 +17,46 @@ class Command(BaseCommand):
17 help = "Test the response time for all toaster urls" 17 help = "Test the response time for all toaster urls"
18 18
19 def handle(self, *args, **options): 19 def handle(self, *args, **options):
20 root_urlconf = __import__(settings.ROOT_URLCONF) 20 root_urlconf = __import__(settings.ROOT_URLCONF)
21 patterns = root_urlconf.urls.urlpatterns 21 patterns = root_urlconf.urls.urlpatterns
22 global full_url 22 global full_url
23 for pat in patterns: 23 for pat in patterns:
24 if pat.__class__.__name__ == 'RegexURLResolver': 24 if pat.__class__.__name__ == 'RegexURLResolver':
25 url_root_res = str(pat).split('^')[1].replace('>', '') 25 url_root_res = str(pat).split('^')[1].replace('>', '')
26 if 'gui' in url_root_res: 26 if 'gui' in url_root_res:
27 for url_patt in pat.url_patterns: 27 for url_patt in pat.url_patterns:
28 full_url = self.get_full_url(url_patt, url_root_res) 28 full_url = self.get_full_url(url_patt, url_root_res)
29 info = self.url_info(full_url) 29 info = self.url_info(full_url)
30 status_code = info[0] 30 status_code = info[0]
31 load_time = info[1] 31 load_time = info[1]
32 print('Trying \'' + full_url + '\', ' + str(status_code) + ', ' + str(load_time)) 32 print('Trying \'' + full_url + '\', ' + str(status_code) + ', ' + str(load_time))
33 33
34 def get_full_url(self, url_patt, url_root_res): 34 def get_full_url(self, url_patt, url_root_res):
35 full_url = str(url_patt).split('^')[1].replace('$>', '').replace('(?P<file_path>(?:/[', '/bin/busybox').replace('.*', '') 35 full_url = str(url_patt).split('^')[1].replace('$>', '').replace('(?P<file_path>(?:/[', '/bin/busybox').replace('.*', '')
36 full_url = str(url_root_res + full_url) 36 full_url = str(url_root_res + full_url)
37 full_url = re.sub('\(\?P<.*?>\\\d\+\)', '1', full_url) 37 full_url = re.sub('\(\?P<.*?>\\\d\+\)', '1', full_url)
38 full_url = 'http://localhost:8000/' + full_url 38 full_url = 'http://localhost:8000/' + full_url
39 return full_url 39 return full_url
40 40
41 def url_info(self, full_url): 41 def url_info(self, full_url):
42 client = Client() 42 client = Client()
43 info = [] 43 info = []
44 try: 44 try:
45 resp = client.get(full_url, follow = True) 45 resp = client.get(full_url, follow = True)
46 except Exception as e_status_code: 46 except Exception as e_status_code:
47 self.error('Url: %s, error: %s' % (full_url, e_status_code)) 47 self.error('Url: %s, error: %s' % (full_url, e_status_code))
48 resp = type('object', (), {'status_code':0, 'content': str(e_status_code)}) 48 resp = type('object', (), {'status_code':0, 'content': str(e_status_code)})
49 status_code = resp.status_code 49 status_code = resp.status_code
50 info.append(status_code) 50 info.append(status_code)
51 try: 51 try:
52 req = requests.get(full_url) 52 req = requests.get(full_url)
53 except Exception as e_load_time: 53 except Exception as e_load_time:
54 self.error('Url: %s, error: %s' % (full_url, e_load_time)) 54 self.error('Url: %s, error: %s' % (full_url, e_load_time))
55 load_time = req.elapsed 55 load_time = req.elapsed
56 info.append(load_time) 56 info.append(load_time)
57 return info 57 return info
58 58
59 def error(self, *args): 59 def error(self, *args):
60 for arg in args: 60 for arg in args:
61 print(arg, end=' ', file=sys.stderr) 61 print(arg, end=' ', file=sys.stderr)
62 print(file=sys.stderr) 62 print(file=sys.stderr)