Merge ~paride/autopkgtest-cloud:pre-commit-pylint into autopkgtest-cloud:master
- Git
- lp:~paride/autopkgtest-cloud
- pre-commit-pylint
- Merge into master
Status: | Merged |
---|---|
Merged at revision: | dbef7e8d5b717d51d47ce76bc8ada8057e0acf1b |
Proposed branch: | ~paride/autopkgtest-cloud:pre-commit-pylint |
Merge into: | autopkgtest-cloud:master |
Diff against target: |
845 lines (+168/-65) 26 files modified
.launchpad.yaml (+26/-2) .pre-commit-config.yaml (+25/-0) .pylintrc (+45/-1) charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/cleanup-instances (+0/-5) charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/create-armhf-cluster-member (+1/-0) charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/create-nova-image-with-proposed-package (+1/-0) charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/filter-amqp (+1/-2) charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/filter-amqp-dupes-upstream (+3/-3) charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/metrics (+2/-3) charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/retry-github-test (+1/-0) charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/run-autopkgtest (+2/-2) charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/seed-new-release (+2/-0) charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker (+12/-9) charms/focal/autopkgtest-cloud-worker/lib/systemd.py (+2/-1) charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py (+6/-2) charms/focal/autopkgtest-web/reactive/autopkgtest_web.py (+0/-1) charms/focal/autopkgtest-web/webcontrol/browse.cgi (+15/-9) charms/focal/autopkgtest-web/webcontrol/cache-amqp (+1/-0) charms/focal/autopkgtest-web/webcontrol/download-all-results (+6/-7) charms/focal/autopkgtest-web/webcontrol/download-results (+0/-1) charms/focal/autopkgtest-web/webcontrol/private_results/app.py (+2/-3) charms/focal/autopkgtest-web/webcontrol/publish-db (+1/-3) charms/focal/autopkgtest-web/webcontrol/request/submit.py (+9/-6) charms/focal/autopkgtest-web/webcontrol/request/tests/test_app.py (+1/-0) charms/focal/autopkgtest-web/webcontrol/update-github-jobs (+1/-1) mojo/add-floating-ip (+3/-4) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tim Andersson | Pending | ||
Canonical's Ubuntu QA | Pending | ||
Review via email: mp+445630@code.launchpad.net |
Commit message
Run pylint via pre-commit and therefore in CI. Fix or disable all the pylint warnings.
Description of the change
Paride Legovini (paride) wrote : | # |
Tim Andersson (andersson123) : | # |
Tim Andersson (andersson123) : | # |
Tim Andersson (andersson123) : | # |
Tim Andersson (andersson123) : | # |
Tim Andersson (andersson123) wrote : | # |
Looks like this MP also contains a bunch of linting changes that aren't mentioned in the commits? Presumably from running pre-commit/pylint locally. Is there a way to remove this and put it on a separate commit so we can verify the linting changes are only made by a specific linting program?
Tim Andersson (andersson123) wrote : | # |
I think we should also move the ppa to canonical-ubuntu-qa
There is no better way to install python deps.
I like the two pylint hooks as long as the one without import errors doesn't run in CI
Paride Legovini (paride) : | # |
Paride Legovini (paride) wrote : | # |
Addressed review comments and rebased, however we need Brian to create a PPA under ~canonical-
Tim Andersson (andersson123) wrote : | # |
It still looks to me like the linting changes are in the diff or am I wrong? I think this is good to go when we have the new ppa and the linting changes are out
Paride Legovini (paride) wrote : | # |
I am not sure I understand this question:
> It still looks to me like the linting changes are in the diff or am I wrong?
The proposed branch is mostly made up of linting changes.
Are you suggesting adding pylint to pre-commit/lpci in a MP, and then the "make pylint happy" changes in a separate one? That is doable, but will mean landing a change that will introduce a CI step that will fail which is not nice. And the linting changes and pre-commit/lpci changes are in separate commits.
Paride Legovini (paride) wrote : | # |
I updated the branch to use the canonical-
This is ready for review again.
Tim Andersson (andersson123) : | # |
Tim Andersson (andersson123) wrote : | # |
re-reviewed, LGTM! Just one question about docstring disables in pylint
Paride Legovini (paride) : | # |
Preview Diff
1 | diff --git a/.launchpad.yaml b/.launchpad.yaml | |||
2 | index a744b71..ee74e0f 100755 | |||
3 | --- a/.launchpad.yaml | |||
4 | +++ b/.launchpad.yaml | |||
5 | @@ -5,12 +5,36 @@ pipeline: | |||
6 | 5 | 5 | ||
7 | 6 | jobs: | 6 | jobs: |
8 | 7 | pre_commit: | 7 | pre_commit: |
10 | 8 | series: jammy | 8 | series: focal |
11 | 9 | architectures: amd64 | 9 | architectures: amd64 |
12 | 10 | package-repositories: | ||
13 | 11 | - type: apt | ||
14 | 12 | formats: [deb] | ||
15 | 13 | suites: [focal] | ||
16 | 14 | ppa: canonical-ubuntu-qa/backport-pre-commit | ||
17 | 15 | snaps: | ||
18 | 16 | - name: yq | ||
19 | 10 | packages: | 17 | packages: |
20 | 11 | - git | 18 | - git |
21 | 12 | - pre-commit | 19 | - pre-commit |
23 | 13 | run: pre-commit run --all-files --show-diff-on-failure | 20 | - pylint |
24 | 21 | # These are not directly declared in layer.yaml. | ||
25 | 22 | # Maybe they are brought in by some included layer? | ||
26 | 23 | - python3-systemd | ||
27 | 24 | - python3-apt | ||
28 | 25 | run-before: | | ||
29 | 26 | # Install dependencies as declared in the layer files | ||
30 | 27 | DEBIAN_FRONTEND=noninteractive \ | ||
31 | 28 | apt-get install -qy \ | ||
32 | 29 | $(cat charms/focal/autopkgtest-cloud-worker/layer.yaml | \ | ||
33 | 30 | yq -r '.options.basic.packages[]') \ | ||
34 | 31 | $(cat charms/focal/autopkgtest-cloud-worker/layer.yaml | \ | ||
35 | 32 | yq -r '.options.apt.packages[]') \ | ||
36 | 33 | $(cat charms/focal/autopkgtest-web/layer.yaml | \ | ||
37 | 34 | yq -r '.options.basic.packages[]') \ | ||
38 | 35 | $(cat charms/focal/autopkgtest-web/layer.yaml | \ | ||
39 | 36 | yq -r '.options.apt.packages[]') | ||
40 | 37 | run: pre-commit run --hook-stage manual --all-files --show-diff-on-failure | ||
41 | 14 | build_charms: | 38 | build_charms: |
42 | 15 | series: focal | 39 | series: focal |
43 | 16 | architectures: amd64 | 40 | architectures: amd64 |
44 | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml | |||
45 | index 0735120..d3bc39f 100644 | |||
46 | --- a/.pre-commit-config.yaml | |||
47 | +++ b/.pre-commit-config.yaml | |||
48 | @@ -22,3 +22,28 @@ repos: | |||
49 | 22 | rev: 5.12.0 | 22 | rev: 5.12.0 |
50 | 23 | hooks: | 23 | hooks: |
51 | 24 | - id: isort | 24 | - id: isort |
52 | 25 | - repo: local | ||
53 | 26 | hooks: | ||
54 | 27 | # Run pylint with --disable import-error. | ||
55 | 28 | # This is meant to run on developers' machines where not all the | ||
56 | 29 | # Python modules may be installed. | ||
57 | 30 | - id: pylint | ||
58 | 31 | name: pylint | ||
59 | 32 | stages: | ||
60 | 33 | [commit-msg, post-checkout, post-commit, post-merge, post-rewrite, | ||
61 | 34 | pre-commit, pre-merge-commit, pre-push, pre-rebase, | ||
62 | 35 | prepare-commit-msg] | ||
63 | 36 | entry: pylint | ||
64 | 37 | args: | ||
65 | 38 | - "--disable=import-error" | ||
66 | 39 | language: system | ||
67 | 40 | types: [python] | ||
68 | 41 | # Run pylint without disabling import-error. | ||
69 | 42 | # This is meant to run in CI (pre-commit run --hook-stage manual). | ||
70 | 43 | # The CI environment is expected to have all the required dependencies. | ||
71 | 44 | - id: pylint | ||
72 | 45 | name: pylint (with import errors) | ||
73 | 46 | stages: [manual] | ||
74 | 47 | entry: pylint | ||
75 | 48 | language: system | ||
76 | 49 | types: [python] | ||
77 | diff --git a/.pylintrc b/.pylintrc | |||
78 | index a831f0a..b6b77fa 100644 | |||
79 | --- a/.pylintrc | |||
80 | +++ b/.pylintrc | |||
81 | @@ -2,4 +2,48 @@ | |||
82 | 2 | 2 | ||
83 | 3 | jobs=0 | 3 | jobs=0 |
84 | 4 | 4 | ||
86 | 5 | disable=invalid-name, import-error, no-name-in-module | 5 | [MESSAGES CONTROL] |
87 | 6 | |||
88 | 7 | disable= | ||
89 | 8 | R, | ||
90 | 9 | anomalous-backslash-in-string, | ||
91 | 10 | arguments-differ, | ||
92 | 11 | bad-continuation, # leave this to black | ||
93 | 12 | bad-option-value, # for older versions of pylint | ||
94 | 13 | broad-except, | ||
95 | 14 | broad-exception-caught, | ||
96 | 15 | consider-using-f-string, | ||
97 | 16 | duplicate-string-formatting-argument, | ||
98 | 17 | fixme, | ||
99 | 18 | global-statement, | ||
100 | 19 | global-variable-not-assigned, | ||
101 | 20 | invalid-name, | ||
102 | 21 | logging-format-interpolation, | ||
103 | 22 | logging-fstring-interpolation, | ||
104 | 23 | logging-not-lazy, | ||
105 | 24 | missing-class-docstring, | ||
106 | 25 | missing-function-docstring, | ||
107 | 26 | missing-module-docstring, | ||
108 | 27 | missing-timeout, | ||
109 | 28 | possibly-unused-variable, | ||
110 | 29 | protected-access, | ||
111 | 30 | redefined-builtin, | ||
112 | 31 | redefined-outer-name, | ||
113 | 32 | unspecified-encoding, | ||
114 | 33 | unused-argument, | ||
115 | 34 | wrong-import-order, # leave this to isort | ||
116 | 35 | |||
117 | 36 | [REPORTS] | ||
118 | 37 | |||
119 | 38 | # Show just the errors, no full report | ||
120 | 39 | reports=no | ||
121 | 40 | score=no | ||
122 | 41 | |||
123 | 42 | [TYPECHECK] | ||
124 | 43 | |||
125 | 44 | ignored-modules= | ||
126 | 45 | amulet, | ||
127 | 46 | charmhelpers, | ||
128 | 47 | charms, | ||
129 | 48 | lib, | ||
130 | 49 | utils, | ||
131 | diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/cleanup-instances b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/cleanup-instances | |||
132 | index 727634e..024ad93 100755 | |||
133 | --- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/cleanup-instances | |||
134 | +++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/cleanup-instances | |||
135 | @@ -6,7 +6,6 @@ import re | |||
136 | 6 | import socket | 6 | import socket |
137 | 7 | import subprocess | 7 | import subprocess |
138 | 8 | import time | 8 | import time |
139 | 9 | from urllib.error import HTTPError | ||
140 | 10 | 9 | ||
141 | 11 | import novaclient.client | 10 | import novaclient.client |
142 | 12 | import novaclient.exceptions | 11 | import novaclient.exceptions |
143 | @@ -109,7 +108,6 @@ for instance in nova.servers.list(): | |||
144 | 109 | instance.delete() | 108 | instance.delete() |
145 | 110 | except novaclient.exceptions.NotFound: | 109 | except novaclient.exceptions.NotFound: |
146 | 111 | logging.warning("Couldn't delete instance: not found") | 110 | logging.warning("Couldn't delete instance: not found") |
147 | 112 | pass | ||
148 | 113 | continue | 111 | continue |
149 | 114 | 112 | ||
150 | 115 | if not instance.name.startswith("adt-"): | 113 | if not instance.name.startswith("adt-"): |
151 | @@ -144,7 +142,6 @@ for instance in nova.servers.list(): | |||
152 | 144 | ) | 142 | ) |
153 | 145 | except novaclient.exceptions.NotFound: | 143 | except novaclient.exceptions.NotFound: |
154 | 146 | logging.warning("Couldn't delete instance: not found") | 144 | logging.warning("Couldn't delete instance: not found") |
155 | 147 | pass | ||
156 | 148 | 145 | ||
157 | 149 | # check matching adt-run process for instance name | 146 | # check matching adt-run process for instance name |
158 | 150 | try: | 147 | try: |
159 | @@ -180,7 +177,6 @@ for instance in nova.servers.list(): | |||
160 | 180 | ) | 177 | ) |
161 | 181 | except novaclient.exceptions.NotFound: | 178 | except novaclient.exceptions.NotFound: |
162 | 182 | logging.warning("Couldn't delete instance: not found") | 179 | logging.warning("Couldn't delete instance: not found") |
163 | 183 | pass | ||
164 | 184 | except IndexError: | 180 | except IndexError: |
165 | 185 | logging.warning("instance %s has invalid name" % instance.name) | 181 | logging.warning("instance %s has invalid name" % instance.name) |
166 | 186 | 182 | ||
167 | @@ -189,4 +185,3 @@ for instance in nova.servers.list(): | |||
168 | 189 | influx_client.write_points(measurements) | 185 | influx_client.write_points(measurements) |
169 | 190 | except InfluxDBClientError as err: | 186 | except InfluxDBClientError as err: |
170 | 191 | logging.warning("Write to InfluxDB failed: %s" % err) | 187 | logging.warning("Write to InfluxDB failed: %s" % err) |
171 | 192 | pass | ||
172 | diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/create-armhf-cluster-member b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/create-armhf-cluster-member | |||
173 | index 75e4c74..c512b22 100755 | |||
174 | --- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/create-armhf-cluster-member | |||
175 | +++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/create-armhf-cluster-member | |||
176 | @@ -49,6 +49,7 @@ def usage(): | |||
177 | 49 | 49 | ||
178 | 50 | try: | 50 | try: |
179 | 51 | role = sys.argv[1] | 51 | role = sys.argv[1] |
180 | 52 | to_join = None | ||
181 | 52 | if role in ("leader", "node"): | 53 | if role in ("leader", "node"): |
182 | 53 | to_join = sys.argv[2] | 54 | to_join = sys.argv[2] |
183 | 54 | except IndexError: | 55 | except IndexError: |
184 | diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/create-nova-image-with-proposed-package b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/create-nova-image-with-proposed-package | |||
185 | index 641f771..e48f3f4 100755 | |||
186 | --- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/create-nova-image-with-proposed-package | |||
187 | +++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/create-nova-image-with-proposed-package | |||
188 | @@ -73,6 +73,7 @@ def setup_image(image_path, source): | |||
189 | 73 | ) | 73 | ) |
190 | 74 | 74 | ||
191 | 75 | # find and install proposed binaries for source | 75 | # find and install proposed binaries for source |
192 | 76 | # pylint: disable=line-too-long | ||
193 | 76 | img_shell.stdin.write( | 77 | img_shell.stdin.write( |
194 | 77 | ( | 78 | ( |
195 | 78 | """ | 79 | """ |
196 | diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/filter-amqp b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/filter-amqp | |||
197 | index 9ff9df2..76e51ca 100755 | |||
198 | --- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/filter-amqp | |||
199 | +++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/filter-amqp | |||
200 | @@ -2,9 +2,8 @@ | |||
201 | 2 | # Filter out AMQP requests that match a given regex | 2 | # Filter out AMQP requests that match a given regex |
202 | 3 | 3 | ||
203 | 4 | import logging | 4 | import logging |
205 | 5 | import optparse | 5 | import optparse # pylint: disable=deprecated-module |
206 | 6 | import re | 6 | import re |
207 | 7 | import sys | ||
208 | 8 | import urllib.parse | 7 | import urllib.parse |
209 | 9 | 8 | ||
210 | 10 | import amqplib.client_0_8 as amqp | 9 | import amqplib.client_0_8 as amqp |
211 | diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/filter-amqp-dupes-upstream b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/filter-amqp-dupes-upstream | |||
212 | index 9e49803..c255239 100755 | |||
213 | --- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/filter-amqp-dupes-upstream | |||
214 | +++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/filter-amqp-dupes-upstream | |||
215 | @@ -3,10 +3,8 @@ | |||
216 | 3 | 3 | ||
217 | 4 | import json | 4 | import json |
218 | 5 | import logging | 5 | import logging |
220 | 6 | import optparse | 6 | import optparse # pylint: disable=deprecated-module |
221 | 7 | import os | 7 | import os |
222 | 8 | import re | ||
223 | 9 | import sys | ||
224 | 10 | import urllib.parse | 8 | import urllib.parse |
225 | 11 | from collections import defaultdict | 9 | from collections import defaultdict |
226 | 12 | 10 | ||
227 | @@ -65,6 +63,7 @@ def filter_amqp(options, host): | |||
228 | 65 | try: | 63 | try: |
229 | 66 | (delivery_tag, old_submit_time) = seen[pkg][pr] | 64 | (delivery_tag, old_submit_time) = seen[pkg][pr] |
230 | 67 | if old_submit_time <= submit_time: | 65 | if old_submit_time <= submit_time: |
231 | 66 | # pylint: disable=line-too-long | ||
232 | 68 | logging.info( | 67 | logging.info( |
233 | 69 | f"{dry_run}We have seen PR {pr} in {queue_name} before: acking the previous request" | 68 | f"{dry_run}We have seen PR {pr} in {queue_name} before: acking the previous request" |
234 | 70 | ) | 69 | ) |
235 | @@ -99,6 +98,7 @@ def main(): | |||
236 | 99 | help="additionally show queue items that are not removed", | 98 | help="additionally show queue items that are not removed", |
237 | 100 | ) | 99 | ) |
238 | 101 | 100 | ||
239 | 101 | # pylint: disable=unused-variable | ||
240 | 102 | opts, args = parser.parse_args() | 102 | opts, args = parser.parse_args() |
241 | 103 | 103 | ||
242 | 104 | logging.basicConfig( | 104 | logging.basicConfig( |
243 | diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/metrics b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/metrics | |||
244 | index f11d3ca..7224dd3 100755 | |||
245 | --- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/metrics | |||
246 | +++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/metrics | |||
247 | @@ -84,10 +84,9 @@ def get_units(): | |||
248 | 84 | continue | 84 | continue |
249 | 85 | 85 | ||
250 | 86 | try: | 86 | try: |
252 | 87 | (region, arch, n) = name_cloud.split("-", -1) | 87 | (_, arch, _) = name_cloud.split("-", -1) |
253 | 88 | except ValueError: | 88 | except ValueError: |
254 | 89 | # autopkgtest@lcy01-1.service | 89 | # autopkgtest@lcy01-1.service |
255 | 90 | (region, n) = name_cloud.split("-", -1) | ||
256 | 91 | arch = "amd64" | 90 | arch = "amd64" |
257 | 92 | (active, error) = counts.setdefault(arch, (0, 0)) | 91 | (active, error) = counts.setdefault(arch, (0, 0)) |
258 | 93 | 92 | ||
259 | @@ -111,7 +110,7 @@ def get_remotes(): | |||
260 | 111 | if not r.startswith("lxd"): | 110 | if not r.startswith("lxd"): |
261 | 112 | continue | 111 | continue |
262 | 113 | 112 | ||
264 | 114 | (_, arch, ip) = r.split("-", 3) | 113 | (_, arch, _) = r.split("-", 3) |
265 | 115 | (cluster_active, cluster_error) = cluster_counts.setdefault( | 114 | (cluster_active, cluster_error) = cluster_counts.setdefault( |
266 | 116 | arch, (0, 0) | 115 | arch, (0, 0) |
267 | 117 | ) | 116 | ) |
268 | diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/retry-github-test b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/retry-github-test | |||
269 | index 4e258a6..799c905 100755 | |||
270 | --- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/retry-github-test | |||
271 | +++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/retry-github-test | |||
272 | @@ -17,6 +17,7 @@ p.add_argument( | |||
273 | 17 | help="GitHub PR API URL (e. g. https://api.github.com/repos/JoeDev/coolproj/pulls/1", | 17 | help="GitHub PR API URL (e. g. https://api.github.com/repos/JoeDev/coolproj/pulls/1", |
274 | 18 | ) | 18 | ) |
275 | 19 | p.add_argument( | 19 | p.add_argument( |
276 | 20 | # pylint: disable=line-too-long | ||
277 | 20 | "test_url", | 21 | "test_url", |
278 | 21 | help="autopkgtest URL (https://autopkgtest.ubuntu.com/request.cgi?release=xenial&arch=i386&...)", | 22 | help="autopkgtest URL (https://autopkgtest.ubuntu.com/request.cgi?release=xenial&arch=i386&...)", |
279 | 22 | ) | 23 | ) |
280 | diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/run-autopkgtest b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/run-autopkgtest | |||
281 | index f59de0e..2584323 100755 | |||
282 | --- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/run-autopkgtest | |||
283 | +++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/run-autopkgtest | |||
284 | @@ -122,7 +122,7 @@ def parse_args(): | |||
285 | 122 | # verify syntax of triggers | 122 | # verify syntax of triggers |
286 | 123 | for t in args.trigger: | 123 | for t in args.trigger: |
287 | 124 | try: | 124 | try: |
289 | 125 | (src, ver) = t.split("/") | 125 | (_, _) = t.split("/") |
290 | 126 | except ValueError: | 126 | except ValueError: |
291 | 127 | parser.error( | 127 | parser.error( |
292 | 128 | 'Invalid trigger format "%s", must be "sourcepkg/version"' % t | 128 | 'Invalid trigger format "%s", must be "sourcepkg/version"' % t |
293 | @@ -131,7 +131,7 @@ def parse_args(): | |||
294 | 131 | # verify syntax of PPAs | 131 | # verify syntax of PPAs |
295 | 132 | for t in args.ppa: | 132 | for t in args.ppa: |
296 | 133 | try: | 133 | try: |
298 | 134 | (user, name) = t.split("/") | 134 | (_, _) = t.split("/") |
299 | 135 | except ValueError: | 135 | except ValueError: |
300 | 136 | parser.error( | 136 | parser.error( |
301 | 137 | 'Invalid ppa format "%s", must be "lpuser/ppaname"' % t | 137 | 'Invalid ppa format "%s", must be "lpuser/ppaname"' % t |
302 | diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/seed-new-release b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/seed-new-release | |||
303 | index 05b2aab..3f14045 100755 | |||
304 | --- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/seed-new-release | |||
305 | +++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/seed-new-release | |||
306 | @@ -40,6 +40,8 @@ def copy_result(rel_path, source, target): | |||
307 | 40 | to_path = target.split("-")[-1] + rel_path | 40 | to_path = target.split("-")[-1] + rel_path |
308 | 41 | 41 | ||
309 | 42 | try: | 42 | try: |
310 | 43 | # pylint: disable=used-before-assignment | ||
311 | 44 | # false positive with older pylint versions | ||
312 | 43 | print("Getting %s" % from_path) | 45 | print("Getting %s" % from_path) |
313 | 44 | headers, contents = swift_con.get_object(source, from_path) | 46 | headers, contents = swift_con.get_object(source, from_path) |
314 | 45 | except swiftclient.exceptions.ClientException: | 47 | except swiftclient.exceptions.ClientException: |
315 | diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker | |||
316 | index 1bbcbae..2af9dc1 100755 | |||
317 | --- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker | |||
318 | +++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker | |||
319 | @@ -4,6 +4,8 @@ | |||
320 | 4 | # | 4 | # |
321 | 5 | # Requirements: python3-amqplib python3-swiftclient python3-influxdb | 5 | # Requirements: python3-amqplib python3-swiftclient python3-influxdb |
322 | 6 | # Requirements for running autopkgtest from git: python3-debian libdpkg-perl | 6 | # Requirements for running autopkgtest from git: python3-debian libdpkg-perl |
323 | 7 | # | ||
324 | 8 | # pylint: disable=too-many-lines,line-too-long | ||
325 | 7 | 9 | ||
326 | 8 | import argparse | 10 | import argparse |
327 | 9 | import configparser | 11 | import configparser |
328 | @@ -267,6 +269,9 @@ def read_per_package_configs(cfg): | |||
329 | 267 | } | 269 | } |
330 | 268 | 270 | ||
331 | 269 | for entry in entries: | 271 | for entry in entries: |
332 | 272 | package = None | ||
333 | 273 | arch = None | ||
334 | 274 | release = None | ||
335 | 270 | try: | 275 | try: |
336 | 271 | (package, arch, release) = entry.split("/", 3) | 276 | (package, arch, release) = entry.split("/", 3) |
337 | 272 | except ValueError: | 277 | except ValueError: |
338 | @@ -564,9 +569,7 @@ def cleanup_and_sleep(out_dir): | |||
339 | 564 | """Empty the output dir for the next run, otherwise autopkgtest complains""" | 569 | """Empty the output dir for the next run, otherwise autopkgtest complains""" |
340 | 565 | shutil.rmtree(out_dir) | 570 | shutil.rmtree(out_dir) |
341 | 566 | os.mkdir(out_dir) | 571 | os.mkdir(out_dir) |
342 | 567 | running_test = False | ||
343 | 568 | time.sleep(300) | 572 | time.sleep(300) |
344 | 569 | running_test = True | ||
345 | 570 | 573 | ||
346 | 571 | 574 | ||
347 | 572 | def request(msg): | 575 | def request(msg): |
348 | @@ -799,13 +802,6 @@ def request(msg): | |||
349 | 799 | "PPA user %s, name %s has GPG fingerprint %s" | 802 | "PPA user %s, name %s has GPG fingerprint %s" |
350 | 800 | % (ppauser, ppaname, fingerprint) | 803 | % (ppauser, ppaname, fingerprint) |
351 | 801 | ) | 804 | ) |
352 | 802 | except (IOError, ValueError, KeyError) as e: | ||
353 | 803 | logging.error( | ||
354 | 804 | 'Cannot get PPA information: "%s". Consuming the request - it will be left dangling; retry once the problem is resolved.' | ||
355 | 805 | % e | ||
356 | 806 | ) | ||
357 | 807 | msg.channel.basic_ack(msg.delivery_tag) | ||
358 | 808 | return | ||
359 | 809 | except HTTPError as e: | 805 | except HTTPError as e: |
360 | 810 | # It's quite common to get 503s from LP; retry a | 806 | # It's quite common to get 503s from LP; retry a |
361 | 811 | # few times. | 807 | # few times. |
362 | @@ -813,6 +809,13 @@ def request(msg): | |||
363 | 813 | raise | 809 | raise |
364 | 814 | logging.warning("Got error 503 from launchpad API") | 810 | logging.warning("Got error 503 from launchpad API") |
365 | 815 | time.sleep(10) | 811 | time.sleep(10) |
366 | 812 | except (IOError, ValueError, KeyError) as e: | ||
367 | 813 | logging.error( | ||
368 | 814 | 'Cannot get PPA information: "%s". Consuming the request - it will be left dangling; retry once the problem is resolved.' | ||
369 | 815 | % e | ||
370 | 816 | ) | ||
371 | 817 | msg.channel.basic_ack(msg.delivery_tag) | ||
372 | 818 | return | ||
373 | 816 | else: | 819 | else: |
374 | 817 | break | 820 | break |
375 | 818 | else: | 821 | else: |
376 | diff --git a/charms/focal/autopkgtest-cloud-worker/lib/systemd.py b/charms/focal/autopkgtest-cloud-worker/lib/systemd.py | |||
377 | index 6a87cbd..a7f6c19 100644 | |||
378 | --- a/charms/focal/autopkgtest-cloud-worker/lib/systemd.py | |||
379 | +++ b/charms/focal/autopkgtest-cloud-worker/lib/systemd.py | |||
380 | @@ -132,7 +132,7 @@ def get_units(): | |||
381 | 132 | lxd_object_paths = defaultdict(lambda: defaultdict(dict)) | 132 | lxd_object_paths = defaultdict(lambda: defaultdict(dict)) |
382 | 133 | 133 | ||
383 | 134 | for unit in units: | 134 | for unit in units: |
385 | 135 | (name, _, _, active, _, _, object_path, _, _, _) = unit | 135 | (name, _, _, _, _, _, object_path, _, _, _) = unit |
386 | 136 | if name.startswith("build-adt-image@") and name.endswith(".timer"): | 136 | if name.startswith("build-adt-image@") and name.endswith(".timer"): |
387 | 137 | name_release_region_arch = name[16:][:-6] | 137 | name_release_region_arch = name[16:][:-6] |
388 | 138 | (release, region, arch) = name_release_region_arch.split("-", -1) | 138 | (release, region, arch) = name_release_region_arch.split("-", -1) |
389 | @@ -334,6 +334,7 @@ def set_up_systemd_units(target_cloud_config, target_lxd_config, releases): | |||
390 | 334 | releases_to_disable = currently_enabled_releases - set(releases) | 334 | releases_to_disable = currently_enabled_releases - set(releases) |
391 | 335 | 335 | ||
392 | 336 | if releases_to_disable: | 336 | if releases_to_disable: |
393 | 337 | # pylint: disable=line-too-long | ||
394 | 337 | print( | 338 | print( |
395 | 338 | "Disabling build-adt-image timers for {region}/{arch}/{releases_to_disable}".format( | 339 | "Disabling build-adt-image timers for {region}/{arch}/{releases_to_disable}".format( |
396 | 339 | **locals() | 340 | **locals() |
397 | diff --git a/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py b/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py | |||
398 | index 12b0b66..2095e42 100644 | |||
399 | --- a/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py | |||
400 | +++ b/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py | |||
401 | @@ -26,7 +26,6 @@ from charms.reactive import ( | |||
402 | 26 | when_not, | 26 | when_not, |
403 | 27 | when_not_all, | 27 | when_not_all, |
404 | 28 | ) | 28 | ) |
405 | 29 | from charms.reactive.relations import endpoint_from_flag | ||
406 | 30 | from utils import UnixUser, install_autodep8 | 29 | from utils import UnixUser, install_autodep8 |
407 | 31 | 30 | ||
408 | 32 | AUTOPKGTEST_LOCATION = os.path.expanduser("~ubuntu/autopkgtest") | 31 | AUTOPKGTEST_LOCATION = os.path.expanduser("~ubuntu/autopkgtest") |
409 | @@ -131,6 +130,7 @@ def set_up_systemd_units(): | |||
410 | 131 | dest = os.path.join(os.path.sep, "etc", "systemd", "system", base) | 130 | dest = os.path.join(os.path.sep, "etc", "systemd", "system", base) |
411 | 132 | 131 | ||
412 | 133 | def link_and_enable(): | 132 | def link_and_enable(): |
413 | 133 | # pylint: disable=cell-var-from-loop | ||
414 | 134 | os.symlink(unit, dest) | 134 | os.symlink(unit, dest) |
415 | 135 | if "@" not in base: | 135 | if "@" not in base: |
416 | 136 | subprocess.check_call(["systemctl", "enable", base]) | 136 | subprocess.check_call(["systemctl", "enable", base]) |
417 | @@ -240,6 +240,7 @@ def clear_rabbitmq(): | |||
418 | 240 | 240 | ||
419 | 241 | @when("config.changed.nova-rcs") | 241 | @when("config.changed.nova-rcs") |
420 | 242 | def update_nova_rcs(): | 242 | def update_nova_rcs(): |
421 | 243 | # pylint: disable=import-outside-toplevel | ||
422 | 243 | import base64 | 244 | import base64 |
423 | 244 | from io import BytesIO | 245 | from io import BytesIO |
424 | 245 | from tarfile import TarFile | 246 | from tarfile import TarFile |
425 | @@ -303,6 +304,7 @@ def enable_units_initially(): | |||
426 | 303 | "config.changed.releases", | 304 | "config.changed.releases", |
427 | 304 | ) | 305 | ) |
428 | 305 | def enable_disable_units(): | 306 | def enable_disable_units(): |
429 | 307 | # pylint: disable=import-outside-toplevel | ||
430 | 306 | from lib.systemd import set_up_systemd_units | 308 | from lib.systemd import set_up_systemd_units |
431 | 307 | 309 | ||
432 | 308 | nworkers = config().get("n-workers") or "" | 310 | nworkers = config().get("n-workers") or "" |
433 | @@ -422,6 +424,7 @@ def write_swift_config(): | |||
434 | 422 | ) | 424 | ) |
435 | 423 | @when_any("config.set.nova-rcs", "config.set.lxd-remotes") | 425 | @when_any("config.set.nova-rcs", "config.set.lxd-remotes") |
436 | 424 | def write_worker_config(): | 426 | def write_worker_config(): |
437 | 427 | # pylint: disable=import-outside-toplevel | ||
438 | 425 | import configparser | 428 | import configparser |
439 | 426 | 429 | ||
440 | 427 | nworkers = config().get("n-workers") or "" | 430 | nworkers = config().get("n-workers") or "" |
441 | @@ -457,7 +460,7 @@ def write_worker_config(): | |||
442 | 457 | "/NET_NAME/": config().get("net-name"), | 460 | "/NET_NAME/": config().get("net-name"), |
443 | 458 | } | 461 | } |
444 | 459 | 462 | ||
446 | 460 | for k in replacements: | 463 | for k in replacements: # pylint: disable=consider-using-dict-items |
447 | 461 | if replacements[k]: | 464 | if replacements[k]: |
448 | 462 | s = s.replace(k, replacements[k]) | 465 | s = s.replace(k, replacements[k]) |
449 | 463 | 466 | ||
450 | @@ -535,6 +538,7 @@ def write_mirror(): | |||
451 | 535 | @when("autopkgtest.reload-needed") | 538 | @when("autopkgtest.reload-needed") |
452 | 536 | @when_not("autopkgtest.daemon-reload-needed") | 539 | @when_not("autopkgtest.daemon-reload-needed") |
453 | 537 | def reload_systemd_units(): | 540 | def reload_systemd_units(): |
454 | 541 | # pylint: disable=import-outside-toplevel | ||
455 | 538 | from lib.systemd import reload_units | 542 | from lib.systemd import reload_units |
456 | 539 | 543 | ||
457 | 540 | reload_units() | 544 | reload_units() |
458 | diff --git a/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py b/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py | |||
459 | index ccea20f..842348b 100644 | |||
460 | --- a/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py | |||
461 | +++ b/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py | |||
462 | @@ -8,7 +8,6 @@ from charmhelpers.core.hookenv import charm_dir, config | |||
463 | 8 | from charms.layer import status | 8 | from charms.layer import status |
464 | 9 | from charms.reactive import ( | 9 | from charms.reactive import ( |
465 | 10 | clear_flag, | 10 | clear_flag, |
466 | 11 | hook, | ||
467 | 12 | set_flag, | 11 | set_flag, |
468 | 13 | when, | 12 | when, |
469 | 14 | when_all, | 13 | when_all, |
470 | diff --git a/charms/focal/autopkgtest-web/webcontrol/browse.cgi b/charms/focal/autopkgtest-web/webcontrol/browse.cgi | |||
471 | index efdc9b7..d7d7146 100755 | |||
472 | --- a/charms/focal/autopkgtest-web/webcontrol/browse.cgi | |||
473 | +++ b/charms/focal/autopkgtest-web/webcontrol/browse.cgi | |||
474 | @@ -7,7 +7,6 @@ import json | |||
475 | 7 | import os | 7 | import os |
476 | 8 | import re | 8 | import re |
477 | 9 | import sqlite3 | 9 | import sqlite3 |
478 | 10 | import urllib.parse | ||
479 | 11 | from collections import OrderedDict | 10 | from collections import OrderedDict |
480 | 12 | from wsgiref.handlers import CGIHandler | 11 | from wsgiref.handlers import CGIHandler |
481 | 13 | 12 | ||
482 | @@ -168,7 +167,7 @@ def get_source_versions(db, release): | |||
483 | 168 | 167 | ||
484 | 169 | srcs = {} | 168 | srcs = {} |
485 | 170 | for pkg, ver in db.execute( | 169 | for pkg, ver in db.execute( |
487 | 171 | "SELECT package, version " "FROM current_version " "WHERE release = ?", | 170 | "SELECT package, version FROM current_version WHERE release = ?", |
488 | 172 | (release,), | 171 | (release,), |
489 | 173 | ): | 172 | ): |
490 | 174 | srcs[pkg] = ver | 173 | srcs[pkg] = ver |
491 | @@ -185,6 +184,7 @@ def success_count_for_release_and_arch(db, release, arch, src_versions): | |||
492 | 185 | # but succeeded for a trigger that is not published), don't count it as | 184 | # but succeeded for a trigger that is not published), don't count it as |
493 | 186 | # success | 185 | # success |
494 | 187 | cur_pkg = None | 186 | cur_pkg = None |
495 | 187 | # pylint: disable=unused-variable | ||
496 | 188 | for pkg, triggers, code in db.execute( | 188 | for pkg, triggers, code in db.execute( |
497 | 189 | "SELECT test.package, triggers, exitcode " | 189 | "SELECT test.package, triggers, exitcode " |
498 | 190 | "FROM test, result, current_version " | 190 | "FROM test, result, current_version " |
499 | @@ -213,6 +213,7 @@ def success_count_for_release_and_arch(db, release, arch, src_versions): | |||
500 | 213 | # it can happen that src_versions does not have a trigger source | 213 | # it can happen that src_versions does not have a trigger source |
501 | 214 | # pacakge if that trigger source got removed in the final release | 214 | # pacakge if that trigger source got removed in the final release |
502 | 215 | if src_versions.get(src) != ver: | 215 | if src_versions.get(src) != ver: |
503 | 216 | # pylint: disable=line-too-long | ||
504 | 216 | # logging.debug('%s/%s/%s: ignoring non-current trigger %s', release, arch, pkg, trigger) | 217 | # logging.debug('%s/%s/%s: ignoring non-current trigger %s', release, arch, pkg, trigger) |
505 | 217 | continue | 218 | continue |
506 | 218 | # if we arrive here, we have a passing test result for pkg with current | 219 | # if we arrive here, we have a passing test result for pkg with current |
507 | @@ -267,6 +268,7 @@ def package_overview(package, _=None): | |||
508 | 267 | package=package, | 268 | package=package, |
509 | 268 | releases=[ | 269 | releases=[ |
510 | 269 | release | 270 | release |
511 | 271 | # pylint: disable=consider-iterating-dictionary | ||
512 | 270 | for release in results.keys() | 272 | for release in results.keys() |
513 | 271 | if release in SUPPORTED_UBUNTU_RELEASES | 273 | if release in SUPPORTED_UBUNTU_RELEASES |
514 | 272 | ], | 274 | ], |
515 | @@ -340,7 +342,11 @@ def running(): | |||
516 | 340 | for c in queue_info: | 342 | for c in queue_info: |
517 | 341 | for r in releases: | 343 | for r in releases: |
518 | 342 | for a in arches: | 344 | for a in arches: |
520 | 343 | (queue_length, queue_items) = ( | 345 | # pylint: disable=unused-variable |
521 | 346 | ( | ||
522 | 347 | queue_length, | ||
523 | 348 | queue_items, | ||
524 | 349 | ) = ( | ||
525 | 344 | queue_info.get(c, {}).get(r, {}).get(a, (0, [])) | 350 | queue_info.get(c, {}).get(r, {}).get(a, (0, [])) |
526 | 345 | ) | 351 | ) |
527 | 346 | queue_lengths.setdefault(c, {}).setdefault(r, {})[ | 352 | queue_lengths.setdefault(c, {}).setdefault(r, {})[ |
528 | @@ -367,12 +373,12 @@ def running(): | |||
529 | 367 | 373 | ||
530 | 368 | @app.route("/queue_size.json") | 374 | @app.route("/queue_size.json") |
531 | 369 | def queuesize_json(): | 375 | def queuesize_json(): |
532 | 370 | out = {} | ||
533 | 371 | queue_info = get_queue_info()[2] | 376 | queue_info = get_queue_info()[2] |
534 | 372 | # Strip the number of queue items, this is just their contents | 377 | # Strip the number of queue items, this is just their contents |
536 | 373 | for context in queue_info: | 378 | for context in queue_info: # pylint: disable=consider-using-dict-items |
537 | 374 | for release in queue_info[context]: | 379 | for release in queue_info[context]: |
538 | 375 | for arch in queue_info[context][release]: | 380 | for arch in queue_info[context][release]: |
539 | 381 | # pylint: disable=unused-variable | ||
540 | 376 | (queue_size, queue_items) = queue_info[context][release][arch] | 382 | (queue_size, queue_items) = queue_info[context][release][arch] |
541 | 377 | queue_info[context][release][arch] = len(queue_items) | 383 | queue_info[context][release][arch] = len(queue_items) |
542 | 378 | return json.dumps(queue_info, indent=2) | 384 | return json.dumps(queue_info, indent=2) |
543 | @@ -380,12 +386,12 @@ def queuesize_json(): | |||
544 | 380 | 386 | ||
545 | 381 | @app.route("/queues.json") | 387 | @app.route("/queues.json") |
546 | 382 | def queues_json(): | 388 | def queues_json(): |
547 | 383 | out = {} | ||
548 | 384 | queue_info = get_queue_info()[2] | 389 | queue_info = get_queue_info()[2] |
549 | 385 | # Strip the number of queue items, this is just their contents | 390 | # Strip the number of queue items, this is just their contents |
551 | 386 | for context in queue_info: | 391 | for context in queue_info: # pylint: disable=consider-using-dict-items |
552 | 387 | for release in queue_info[context]: | 392 | for release in queue_info[context]: |
553 | 388 | for arch in queue_info[context][release]: | 393 | for arch in queue_info[context][release]: |
554 | 394 | # pylint: disable=unused-variable | ||
555 | 389 | (queue_size, queue_items) = queue_info[context][release][arch] | 395 | (queue_size, queue_items) = queue_info[context][release][arch] |
556 | 390 | queue_info[context][release][arch] = queue_items | 396 | queue_info[context][release][arch] = queue_items |
557 | 391 | return flask.Response( | 397 | return flask.Response( |
558 | @@ -416,7 +422,7 @@ def statistics(): | |||
559 | 416 | 422 | ||
560 | 417 | # ensure we don't run into KeyErrors in the jinja template | 423 | # ensure we don't run into KeyErrors in the jinja template |
561 | 418 | data = {} | 424 | data = {} |
563 | 419 | for release in release_arches: | 425 | for release in release_arches: # pylint: disable=consider-using-dict-items |
564 | 420 | data[release] = {} | 426 | data[release] = {} |
565 | 421 | for arch in release_arches[release]: | 427 | for arch in release_arches[release]: |
566 | 422 | data[release][arch] = {} | 428 | data[release][arch] = {} |
567 | @@ -450,7 +456,7 @@ def statistics(): | |||
568 | 450 | pass | 456 | pass |
569 | 451 | 457 | ||
570 | 452 | # number of packages with tests that pass | 458 | # number of packages with tests that pass |
572 | 453 | for release in release_arches: | 459 | for release in release_arches: # pylint: disable=consider-using-dict-items |
573 | 454 | sources = get_source_versions(db_con, release) | 460 | sources = get_source_versions(db_con, release) |
574 | 455 | for arch in release_arches[release]: | 461 | for arch in release_arches[release]: |
575 | 456 | data[release][arch][ | 462 | data[release][arch][ |
576 | diff --git a/charms/focal/autopkgtest-web/webcontrol/cache-amqp b/charms/focal/autopkgtest-web/webcontrol/cache-amqp | |||
577 | index 1f72747..b626171 100755 | |||
578 | --- a/charms/focal/autopkgtest-web/webcontrol/cache-amqp | |||
579 | +++ b/charms/focal/autopkgtest-web/webcontrol/cache-amqp | |||
580 | @@ -62,6 +62,7 @@ class AutopkgtestQueueContents: | |||
581 | 62 | routing_key=queue_name, | 62 | routing_key=queue_name, |
582 | 63 | ) | 63 | ) |
583 | 64 | else: # not the leader | 64 | else: # not the leader |
584 | 65 | # pylint: disable=line-too-long | ||
585 | 65 | logging.error( | 66 | logging.error( |
586 | 66 | "We are not the leader, and there is no semaphore queue yet, we can't do anything - exiting." | 67 | "We are not the leader, and there is no semaphore queue yet, we can't do anything - exiting." |
587 | 67 | ) | 68 | ) |
588 | diff --git a/charms/focal/autopkgtest-web/webcontrol/download-all-results b/charms/focal/autopkgtest-web/webcontrol/download-all-results | |||
589 | index 0ae5c4e..53a3983 100755 | |||
590 | --- a/charms/focal/autopkgtest-web/webcontrol/download-all-results | |||
591 | +++ b/charms/focal/autopkgtest-web/webcontrol/download-all-results | |||
592 | @@ -42,10 +42,10 @@ def list_remote_container(container_url): | |||
593 | 42 | url += f"&marker={urllib.parse.quote(start)}" | 42 | url += f"&marker={urllib.parse.quote(start)}" |
594 | 43 | 43 | ||
595 | 44 | LOGGER.debug('Retrieving "%s"', url) | 44 | LOGGER.debug('Retrieving "%s"', url) |
597 | 45 | for retry in range(5): | 45 | for _ in range(5): |
598 | 46 | try: | 46 | try: |
599 | 47 | resp = urlopen(url) | 47 | resp = urlopen(url) |
601 | 48 | except http.client.RemoteDisconnected as e: | 48 | except http.client.RemoteDisconnected: |
602 | 49 | LOGGER.debug("Got disconnected, sleeping") | 49 | LOGGER.debug("Got disconnected, sleeping") |
603 | 50 | time.sleep(5) | 50 | time.sleep(5) |
604 | 51 | continue | 51 | continue |
605 | @@ -82,6 +82,7 @@ def list_remote_container(container_url): | |||
606 | 82 | def list_our_results(release): | 82 | def list_our_results(release): |
607 | 83 | LOGGER.debug("Finding already recorded results for %s", release) | 83 | LOGGER.debug("Finding already recorded results for %s", release) |
608 | 84 | c = db_con.cursor() | 84 | c = db_con.cursor() |
609 | 85 | # pylint: disable=line-too-long | ||
610 | 85 | c.execute( | 86 | c.execute( |
611 | 86 | "SELECT run_id FROM result INNER JOIN test ON test.id = result.test_id WHERE test.release=?", | 87 | "SELECT run_id FROM result INNER JOIN test ON test.id = result.test_id WHERE test.release=?", |
612 | 87 | (release,), | 88 | (release,), |
613 | @@ -108,7 +109,7 @@ def fetch_one_result(url): | |||
614 | 108 | LOGGER.error("Failure to fetch %s: %s", url, str(e)) | 109 | LOGGER.error("Failure to fetch %s: %s", url, str(e)) |
615 | 109 | # we tolerate "not found" (something went wrong on uploading the | 110 | # we tolerate "not found" (something went wrong on uploading the |
616 | 110 | # result), but other things indicate infrastructure problems | 111 | # result), but other things indicate infrastructure problems |
618 | 111 | if hasattr(e, "code") and e.code == 404: | 112 | if hasattr(e, "code") and e.code == 404: # pylint: disable=no-member |
619 | 112 | return | 113 | return |
620 | 113 | sys.exit(1) | 114 | sys.exit(1) |
621 | 114 | 115 | ||
622 | @@ -119,7 +120,7 @@ def fetch_one_result(url): | |||
623 | 119 | srcver = ( | 120 | srcver = ( |
624 | 120 | tar.extractfile("testpkg-version").read().decode().strip() | 121 | tar.extractfile("testpkg-version").read().decode().strip() |
625 | 121 | ) | 122 | ) |
627 | 122 | except KeyError as e: | 123 | except KeyError: |
628 | 123 | # not found | 124 | # not found |
629 | 124 | if exitcode in (4, 12, 20): | 125 | if exitcode in (4, 12, 20): |
630 | 125 | # repair it | 126 | # repair it |
631 | @@ -137,7 +138,7 @@ def fetch_one_result(url): | |||
632 | 137 | requester = ( | 138 | requester = ( |
633 | 138 | tar.extractfile("requester").read().decode().strip() | 139 | tar.extractfile("requester").read().decode().strip() |
634 | 139 | ) | 140 | ) |
636 | 140 | except KeyError as e: | 141 | except KeyError: |
637 | 141 | requester = "" | 142 | requester = "" |
638 | 142 | except (KeyError, ValueError, tarfile.TarError) as e: | 143 | except (KeyError, ValueError, tarfile.TarError) as e: |
639 | 143 | LOGGER.debug("%s is damaged, ignoring: %s", url, str(e)) | 144 | LOGGER.debug("%s is damaged, ignoring: %s", url, str(e)) |
640 | @@ -194,8 +195,6 @@ def fetch_one_result(url): | |||
641 | 194 | def fetch_container(release, container_url): | 195 | def fetch_container(release, container_url): |
642 | 195 | """Download new results from a swift container""" | 196 | """Download new results from a swift container""" |
643 | 196 | 197 | ||
644 | 197 | marker = "" | ||
645 | 198 | |||
646 | 199 | try: | 198 | try: |
647 | 200 | our_results = list_our_results(release) | 199 | our_results = list_our_results(release) |
648 | 201 | known_results = list_remote_container(container_url) | 200 | known_results = list_remote_container(container_url) |
649 | diff --git a/charms/focal/autopkgtest-web/webcontrol/download-results b/charms/focal/autopkgtest-web/webcontrol/download-results | |||
650 | index 419af47..0f14155 100755 | |||
651 | --- a/charms/focal/autopkgtest-web/webcontrol/download-results | |||
652 | +++ b/charms/focal/autopkgtest-web/webcontrol/download-results | |||
653 | @@ -7,7 +7,6 @@ import os | |||
654 | 7 | import socket | 7 | import socket |
655 | 8 | import sqlite3 | 8 | import sqlite3 |
656 | 9 | import urllib.parse | 9 | import urllib.parse |
657 | 10 | from urllib.request import urlopen | ||
658 | 11 | 10 | ||
659 | 12 | import amqplib.client_0_8 as amqp | 11 | import amqplib.client_0_8 as amqp |
660 | 13 | from helpers.utils import get_test_id, init_db | 12 | from helpers.utils import get_test_id, init_db |
661 | diff --git a/charms/focal/autopkgtest-web/webcontrol/private_results/app.py b/charms/focal/autopkgtest-web/webcontrol/private_results/app.py | |||
662 | index ee7b6d0..9ae1e89 100644 | |||
663 | --- a/charms/focal/autopkgtest-web/webcontrol/private_results/app.py | |||
664 | +++ b/charms/focal/autopkgtest-web/webcontrol/private_results/app.py | |||
665 | @@ -15,13 +15,12 @@ from flask import ( | |||
666 | 15 | session, | 15 | session, |
667 | 16 | ) | 16 | ) |
668 | 17 | from flask_openid import OpenID | 17 | from flask_openid import OpenID |
669 | 18 | from helpers.utils import setup_key | ||
670 | 19 | from request.submit import Submit | ||
671 | 18 | from werkzeug.middleware.proxy_fix import ProxyFix | 20 | from werkzeug.middleware.proxy_fix import ProxyFix |
672 | 19 | 21 | ||
673 | 20 | sys.path.append("..") | 22 | sys.path.append("..") |
674 | 21 | 23 | ||
675 | 22 | from helpers.utils import setup_key | ||
676 | 23 | from request.submit import Submit | ||
677 | 24 | |||
678 | 25 | HTML = """ | 24 | HTML = """ |
679 | 26 | <!doctype html> | 25 | <!doctype html> |
680 | 27 | <html> | 26 | <html> |
681 | diff --git a/charms/focal/autopkgtest-web/webcontrol/publish-db b/charms/focal/autopkgtest-web/webcontrol/publish-db | |||
682 | index f35c9e8..76a2177 100755 | |||
683 | --- a/charms/focal/autopkgtest-web/webcontrol/publish-db | |||
684 | +++ b/charms/focal/autopkgtest-web/webcontrol/publish-db | |||
685 | @@ -4,11 +4,9 @@ | |||
686 | 4 | # This is being used for statistics. | 4 | # This is being used for statistics. |
687 | 5 | 5 | ||
688 | 6 | import configparser | 6 | import configparser |
689 | 7 | import fcntl | ||
690 | 8 | import gzip | 7 | import gzip |
691 | 9 | import logging | 8 | import logging |
692 | 10 | import os | 9 | import os |
693 | 11 | import shutil | ||
694 | 12 | import sqlite3 | 10 | import sqlite3 |
695 | 13 | import tempfile | 11 | import tempfile |
696 | 14 | import urllib.request | 12 | import urllib.request |
697 | @@ -156,6 +154,7 @@ def get_sources(db_con, release): | |||
698 | 156 | ) | 154 | ) |
699 | 157 | temp_file.seek(0) | 155 | temp_file.seek(0) |
700 | 158 | with gzip.open(temp_file) as fd: | 156 | with gzip.open(temp_file) as fd: |
701 | 157 | # pylint: disable=c-extension-no-member | ||
702 | 159 | for section in apt_pkg.TagFile(fd): | 158 | for section in apt_pkg.TagFile(fd): |
703 | 160 | db_con.execute( | 159 | db_con.execute( |
704 | 161 | "INSERT INTO current_version " | 160 | "INSERT INTO current_version " |
705 | @@ -177,7 +176,6 @@ def get_sources(db_con, release): | |||
706 | 177 | except urllib.error.HTTPError as e: | 176 | except urllib.error.HTTPError as e: |
707 | 178 | if e.code == 304: | 177 | if e.code == 304: |
708 | 179 | logging.debug("url {} not modified".format(url)) | 178 | logging.debug("url {} not modified".format(url)) |
709 | 180 | pass | ||
710 | 181 | 179 | ||
711 | 182 | 180 | ||
712 | 183 | if __name__ == "__main__": | 181 | if __name__ == "__main__": |
713 | diff --git a/charms/focal/autopkgtest-web/webcontrol/request/submit.py b/charms/focal/autopkgtest-web/webcontrol/request/submit.py | |||
714 | index bc283a7..ac2d5c0 100644 | |||
715 | --- a/charms/focal/autopkgtest-web/webcontrol/request/submit.py | |||
716 | +++ b/charms/focal/autopkgtest-web/webcontrol/request/submit.py | |||
717 | @@ -63,6 +63,7 @@ class Submit: | |||
718 | 63 | assert self.amqp_creds.scheme == "amqp" | 63 | assert self.amqp_creds.scheme == "amqp" |
719 | 64 | logging.debug("AMQP credentials: %s" % repr(self.amqp_creds)) | 64 | logging.debug("AMQP credentials: %s" % repr(self.amqp_creds)) |
720 | 65 | 65 | ||
721 | 66 | # pylint: disable=dangerous-default-value | ||
722 | 66 | def validate_distro_request( | 67 | def validate_distro_request( |
723 | 67 | self, release, arch, package, triggers, requester, ppas=[], **kwargs | 68 | self, release, arch, package, triggers, requester, ppas=[], **kwargs |
724 | 68 | ): | 69 | ): |
725 | @@ -132,10 +133,10 @@ class Submit: | |||
726 | 132 | for trigger in triggers: | 133 | for trigger in triggers: |
727 | 133 | try: | 134 | try: |
728 | 134 | trigsrc, trigver = trigger.split("/") | 135 | trigsrc, trigver = trigger.split("/") |
730 | 135 | except ValueError: | 136 | except ValueError as exc: |
731 | 136 | raise ValueError( | 137 | raise ValueError( |
732 | 137 | "Malformed trigger, must be srcpackage/version" | 138 | "Malformed trigger, must be srcpackage/version" |
734 | 138 | ) | 139 | ) from exc |
735 | 139 | # Debian Policy 5.6.1 and 5.6.12 | 140 | # Debian Policy 5.6.1 and 5.6.12 |
736 | 140 | if not NAME.match(trigsrc) or not VERSION.match(trigver): | 141 | if not NAME.match(trigsrc) or not VERSION.match(trigver): |
737 | 141 | raise ValueError("Malformed trigger") | 142 | raise ValueError("Malformed trigger") |
738 | @@ -197,6 +198,7 @@ class Submit: | |||
739 | 197 | "service." % (package, trigsrc) | 198 | "service." % (package, trigsrc) |
740 | 198 | ) | 199 | ) |
741 | 199 | 200 | ||
742 | 201 | # pylint: disable=dangerous-default-value | ||
743 | 200 | def validate_git_request( | 202 | def validate_git_request( |
744 | 201 | self, release, arch, package, ppas=[], env=[], **kwargs | 203 | self, release, arch, package, ppas=[], env=[], **kwargs |
745 | 202 | ): | 204 | ): |
746 | @@ -303,7 +305,7 @@ class Submit: | |||
747 | 303 | ) | 305 | ) |
748 | 304 | 306 | ||
749 | 305 | @classmethod | 307 | @classmethod |
751 | 306 | def post_json(klass, url, data, auth_file, project): | 308 | def post_json(cls, url, data, auth_file, project): |
752 | 307 | """Send POST request with JSON data via basic auth. | 309 | """Send POST request with JSON data via basic auth. |
753 | 308 | 310 | ||
754 | 309 | 'data' is a dictionary which will be posted to 'url' in JSON encoded | 311 | 'data' is a dictionary which will be posted to 'url' in JSON encoded |
755 | @@ -388,7 +390,7 @@ class Submit: | |||
756 | 388 | ) | 390 | ) |
757 | 389 | else: | 391 | else: |
758 | 390 | c.execute( | 392 | c.execute( |
760 | 391 | "SELECT count(arch) FROM test " "WHERE package=? AND arch=?", | 393 | "SELECT count(arch) FROM test WHERE package=? AND arch=?", |
761 | 392 | (package, arch), | 394 | (package, arch), |
762 | 393 | ) | 395 | ) |
763 | 394 | return c.fetchone()[0] > 0 | 396 | return c.fetchone()[0] > 0 |
764 | @@ -459,18 +461,19 @@ class Submit: | |||
765 | 459 | ) | 461 | ) |
766 | 460 | return code >= 200 and code < 300 | 462 | return code >= 200 and code < 300 |
767 | 461 | 463 | ||
768 | 464 | # pylint: disable=dangerous-default-value | ||
769 | 462 | def in_allowed_team(self, person, package=[], teams=[]): | 465 | def in_allowed_team(self, person, package=[], teams=[]): |
770 | 463 | """Check if person is in ALLOWED_TEAMS""" | 466 | """Check if person is in ALLOWED_TEAMS""" |
771 | 464 | 467 | ||
772 | 465 | for team in teams or ALLOWED_TEAMS: | 468 | for team in teams or ALLOWED_TEAMS: |
774 | 466 | (code, response) = self.lp_request("~%s/participants" % team, {}) | 469 | (_, response) = self.lp_request("~%s/participants" % team, {}) |
775 | 467 | for e in response.get("entries", []): | 470 | for e in response.get("entries", []): |
776 | 468 | if e.get("name") == person: | 471 | if e.get("name") == person: |
777 | 469 | return True | 472 | return True |
778 | 470 | return False | 473 | return False |
779 | 471 | 474 | ||
780 | 472 | @classmethod | 475 | @classmethod |
782 | 473 | def lp_request(klass, obj, query): | 476 | def lp_request(cls, obj, query): |
783 | 474 | """Do a Launchpad REST request | 477 | """Do a Launchpad REST request |
784 | 475 | 478 | ||
785 | 476 | Request https://api.launchpad.net/1.0/<obj>?<query>. | 479 | Request https://api.launchpad.net/1.0/<obj>?<query>. |
786 | diff --git a/charms/focal/autopkgtest-web/webcontrol/request/tests/test_app.py b/charms/focal/autopkgtest-web/webcontrol/request/tests/test_app.py | |||
787 | index 44067b9..42dac0c 100644 | |||
788 | --- a/charms/focal/autopkgtest-web/webcontrol/request/tests/test_app.py | |||
789 | +++ b/charms/focal/autopkgtest-web/webcontrol/request/tests/test_app.py | |||
790 | @@ -1,3 +1,4 @@ | |||
791 | 1 | # pylint: disable=no-value-for-parameter,no-member | ||
792 | 1 | """Test the Flask app.""" | 2 | """Test the Flask app.""" |
793 | 2 | 3 | ||
794 | 3 | import os | 4 | import os |
795 | diff --git a/charms/focal/autopkgtest-web/webcontrol/update-github-jobs b/charms/focal/autopkgtest-web/webcontrol/update-github-jobs | |||
796 | index 334722f..6362803 100755 | |||
797 | --- a/charms/focal/autopkgtest-web/webcontrol/update-github-jobs | |||
798 | +++ b/charms/focal/autopkgtest-web/webcontrol/update-github-jobs | |||
799 | @@ -21,7 +21,7 @@ external_url = None | |||
800 | 21 | 21 | ||
801 | 22 | def result_matches_job(result_url, params): | 22 | def result_matches_job(result_url, params): |
802 | 23 | # download result.tar and get exit code and testinfo | 23 | # download result.tar and get exit code and testinfo |
804 | 24 | for retry in range(5): | 24 | for _ in range(5): |
805 | 25 | try: | 25 | try: |
806 | 26 | with urllib.request.urlopen(result_url + "/result.tar") as f: | 26 | with urllib.request.urlopen(result_url + "/result.tar") as f: |
807 | 27 | tar_bytes = io.BytesIO(f.read()) | 27 | tar_bytes = io.BytesIO(f.read()) |
808 | diff --git a/mojo/add-floating-ip b/mojo/add-floating-ip | |||
809 | index 57c9839..0a816bf 100755 | |||
810 | --- a/mojo/add-floating-ip | |||
811 | +++ b/mojo/add-floating-ip | |||
812 | @@ -8,6 +8,7 @@ | |||
813 | 8 | import json | 8 | import json |
814 | 9 | import os | 9 | import os |
815 | 10 | import subprocess | 10 | import subprocess |
816 | 11 | import sys | ||
817 | 11 | 12 | ||
818 | 12 | import novaclient.client | 13 | import novaclient.client |
819 | 13 | 14 | ||
820 | @@ -94,14 +95,14 @@ def get_unit_floating_ip(unit_name): | |||
821 | 94 | try: | 95 | try: |
822 | 95 | # Get the existing one | 96 | # Get the existing one |
823 | 96 | fip = nova_tenant.floating_ips.find(ip=myip) | 97 | fip = nova_tenant.floating_ips.find(ip=myip) |
825 | 97 | except Exception: | 98 | except Exception as exc: |
826 | 98 | # If this happens you're going to need to either get that back in the list, | 99 | # If this happens you're going to need to either get that back in the list, |
827 | 99 | # or blow away the state file so it gets a new IP. | 100 | # or blow away the state file so it gets a new IP. |
828 | 100 | raise ( | 101 | raise ( |
829 | 101 | RuntimeError( | 102 | RuntimeError( |
830 | 102 | "Desired IP {} not in floating ips list!".format(myip) | 103 | "Desired IP {} not in floating ips list!".format(myip) |
831 | 103 | ) | 104 | ) |
833 | 104 | ) | 105 | ) from exc |
834 | 105 | 106 | ||
835 | 106 | if fip.instance_id: | 107 | if fip.instance_id: |
836 | 107 | # If it's already associated, ensure it's associated to us | 108 | # If it's already associated, ensure it's associated to us |
837 | @@ -147,8 +148,6 @@ add-floating-ip | |||
838 | 147 | 148 | ||
839 | 148 | 149 | ||
840 | 149 | def main(): | 150 | def main(): |
841 | 150 | import sys | ||
842 | 151 | |||
843 | 152 | if len(sys.argv) >= 2: | 151 | if len(sys.argv) >= 2: |
844 | 153 | args = sys.argv[1:] | 152 | args = sys.argv[1:] |
845 | 154 | elif "targets" in os.environ: | 153 | elif "targets" in os.environ: |
Individual pylint tags are tackled in separate commits.
Changes that need more attention in review:
* In CI I had to add a PPA where I backported pre-commit to Focal. That's under my LP user. Should I move that under canonical- ubuntu- qa?
* Any better way of installing Python dependencies than the yq trick I used in .launchpad.yaml?
* Do we like the two pylint hooks, one with --disable= import- error (meant for dev machines) and one without that flag (running in CI, where Python deps were installed)?