Merge ~kissiel/checkbox-support:parsers-migration into checkbox-support:master
- Git
- lp:~kissiel/checkbox-support
- parsers-migration
- Merge into master
Proposed by
Maciej Kisielewski
Status: | Merged |
---|---|
Approved by: | Maciej Kisielewski |
Approved revision: | b850fd93c6247258ea746dcb52030f502fcf71c3 |
Merged at revision: | 12c3cb142693f21968999fc579498b4462f46df0 |
Proposed branch: | ~kissiel/checkbox-support:parsers-migration |
Merge into: | checkbox-support:master |
Diff against target: |
1127 lines (+172/-298) 34 files modified
checkbox_support/contrib/xrandr.py (+0/-8) checkbox_support/dbus/__init__.py (+1/-8) checkbox_support/dbus/udisks2.py (+0/-1) checkbox_support/disk_support.py (+0/-1) checkbox_support/helpers/human_readable_bytes.py (+0/-1) checkbox_support/lib/bit.py (+1/-8) checkbox_support/lib/conversion.py (+1/-8) checkbox_support/lib/dmi.py (+1/-8) checkbox_support/lib/input.py (+0/-2) checkbox_support/lib/pci.py (+0/-8) checkbox_support/lib/tz.py (+1/-8) checkbox_support/lib/usb.py (+1/-8) checkbox_support/parsers/__init__.py (+111/-11) checkbox_support/parsers/cpuinfo.py (+1/-8) checkbox_support/parsers/cputable.py (+1/-8) checkbox_support/parsers/dkms_info.py (+1/-6) checkbox_support/parsers/dmidecode.py (+1/-8) checkbox_support/parsers/efi.py (+1/-8) checkbox_support/parsers/image_info.py (+1/-6) checkbox_support/parsers/lshwjson.py (+1/-8) checkbox_support/parsers/meminfo.py (+1/-8) checkbox_support/parsers/modinfo.py (+1/-6) checkbox_support/parsers/modprobe.py (+1/-6) checkbox_support/parsers/pactl.py (+1/-7) checkbox_support/parsers/pci_config.py (+1/-6) checkbox_support/parsers/tests/test_udevadm.py (+25/-56) checkbox_support/parsers/udevadm.py (+3/-13) checkbox_support/parsers/xinput.py (+1/-9) checkbox_support/scripts/audio_settings.py (+0/-7) checkbox_support/scripts/gputest_benchmark.py (+1/-7) checkbox_support/tests/__init__.py (+11/-1) checkbox_support/udev.py (+1/-7) dev/null (+0/-33) setup.py (+1/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sylvain Pineau (community) | Approve | ||
Review via email: mp+415224@code.launchpad.net |
Commit message
Description of the change
This MR has multiple goodies.
0. Parsers can now be invoked directly from checkbox support. The invocation is:
checkbox-
This enables us to get rid of the plainbox entry point, all of the logic related to "plainbox commands" from checkbox-ng, and parser abstract classes.
1. It refactors out some of the unnecessary abstractions in parser unit tests.
2. It removes _A LOT_ of imports from the times where python3 was considered the future.
3. It removes ugly header bits.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/checkbox_support/contrib/xrandr.py b/checkbox_support/contrib/xrandr.py |
2 | index 9a79f40..91fd173 100644 |
3 | --- a/checkbox_support/contrib/xrandr.py |
4 | +++ b/checkbox_support/contrib/xrandr.py |
5 | @@ -1,6 +1,3 @@ |
6 | -#!/usr/bin/python3 |
7 | -# -*- coding: utf-8 -*- |
8 | -# |
9 | # Python-XRandR provides a high level API for the XRandR extension of the |
10 | # X.org server. XRandR allows to configure resolution, refresh rate, rotation |
11 | # of the screen and multiple outputs of graphics cards. |
12 | @@ -36,11 +33,6 @@ |
13 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
14 | # MA 02110-1301 USA |
15 | |
16 | -from __future__ import absolute_import |
17 | -from __future__ import division |
18 | -from __future__ import print_function |
19 | -from __future__ import unicode_literals |
20 | - |
21 | from ctypes import ( |
22 | POINTER, |
23 | Structure, |
24 | diff --git a/checkbox_support/dbus/__init__.py b/checkbox_support/dbus/__init__.py |
25 | index 93f178d..8d2281a 100644 |
26 | --- a/checkbox_support/dbus/__init__.py |
27 | +++ b/checkbox_support/dbus/__init__.py |
28 | @@ -1,13 +1,12 @@ |
29 | # This file is part of Checkbox. |
30 | # |
31 | -# Copyright 2012 Canonical Ltd. |
32 | +# Copyright 2012-2022 Canonical Ltd. |
33 | # Written by: |
34 | # Zygmunt Krynicki <zygmunt.krynicki@canonical.com> |
35 | # |
36 | # Checkbox is free software: you can redistribute it and/or modify |
37 | # it under the terms of the GNU General Public License version 3, |
38 | # as published by the Free Software Foundation. |
39 | - |
40 | # |
41 | # Checkbox is distributed in the hope that it will be useful, |
42 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
43 | @@ -16,7 +15,6 @@ |
44 | # |
45 | # You should have received a copy of the GNU General Public License |
46 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
47 | -# |
48 | """ |
49 | checkbox_support.dbus |
50 | ===================== |
51 | @@ -24,11 +22,6 @@ checkbox_support.dbus |
52 | Utility modules for working with various things accessible over dbus |
53 | """ |
54 | |
55 | -from __future__ import absolute_import |
56 | -from __future__ import division |
57 | -from __future__ import print_function |
58 | -from __future__ import unicode_literals |
59 | - |
60 | import logging |
61 | |
62 | from dbus import SystemBus |
63 | diff --git a/checkbox_support/dbus/udisks2.py b/checkbox_support/dbus/udisks2.py |
64 | index 28e62a5..d156ded 100644 |
65 | --- a/checkbox_support/dbus/udisks2.py |
66 | +++ b/checkbox_support/dbus/udisks2.py |
67 | @@ -13,7 +13,6 @@ |
68 | # |
69 | # You should have received a copy of the GNU General Public License |
70 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
71 | - |
72 | """ |
73 | checkbox_support.dbus.udisks2 |
74 | ===================== |
75 | diff --git a/checkbox_support/disk_support.py b/checkbox_support/disk_support.py |
76 | index 09d8525..bba496b 100644 |
77 | --- a/checkbox_support/disk_support.py |
78 | +++ b/checkbox_support/disk_support.py |
79 | @@ -14,7 +14,6 @@ |
80 | # |
81 | # You should have received a copy of the GNU General Public License |
82 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
83 | -# |
84 | """ |
85 | Support functions related to disk devices for Checkbox. |
86 | """ |
87 | diff --git a/checkbox_support/helpers/human_readable_bytes.py b/checkbox_support/helpers/human_readable_bytes.py |
88 | index 7b1d391..8bafdf2 100644 |
89 | --- a/checkbox_support/helpers/human_readable_bytes.py |
90 | +++ b/checkbox_support/helpers/human_readable_bytes.py |
91 | @@ -15,7 +15,6 @@ |
92 | # |
93 | # You should have received a copy of the GNU General Public License |
94 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
95 | - |
96 | """ |
97 | checkbox_support.helpers.human_readable_bytes |
98 | ============================================= |
99 | diff --git a/checkbox_support/lib/bit.py b/checkbox_support/lib/bit.py |
100 | index 2cc3e6e..e0e9808 100644 |
101 | --- a/checkbox_support/lib/bit.py |
102 | +++ b/checkbox_support/lib/bit.py |
103 | @@ -1,12 +1,10 @@ |
104 | -# |
105 | # This file is part of Checkbox. |
106 | # |
107 | -# Copyright 2008 Canonical Ltd. |
108 | +# Copyright 2008-2022 Canonical Ltd. |
109 | # |
110 | # Checkbox is free software: you can redistribute it and/or modify |
111 | # it under the terms of the GNU General Public License version 3, |
112 | # as published by the Free Software Foundation. |
113 | - |
114 | # |
115 | # Checkbox is distributed in the hope that it will be useful, |
116 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
117 | @@ -16,11 +14,6 @@ |
118 | # You should have received a copy of the GNU General Public License |
119 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
120 | |
121 | -from __future__ import absolute_import |
122 | -from __future__ import division |
123 | -from __future__ import print_function |
124 | -from __future__ import unicode_literals |
125 | - |
126 | from struct import calcsize |
127 | |
128 | |
129 | diff --git a/checkbox_support/lib/conversion.py b/checkbox_support/lib/conversion.py |
130 | index b8ce871..d954c09 100644 |
131 | --- a/checkbox_support/lib/conversion.py |
132 | +++ b/checkbox_support/lib/conversion.py |
133 | @@ -1,12 +1,10 @@ |
134 | -# |
135 | # This file is part of Checkbox. |
136 | # |
137 | -# Copyright 2008 Canonical Ltd. |
138 | +# Copyright 2008-2022 Canonical Ltd. |
139 | # |
140 | # Checkbox is free software: you can redistribute it and/or modify |
141 | # it under the terms of the GNU General Public License version 3, |
142 | # as published by the Free Software Foundation. |
143 | - |
144 | # |
145 | # Checkbox is distributed in the hope that it will be useful, |
146 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
147 | @@ -16,11 +14,6 @@ |
148 | # You should have received a copy of the GNU General Public License |
149 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
150 | |
151 | -from __future__ import absolute_import |
152 | -from __future__ import division |
153 | -from __future__ import print_function |
154 | -from __future__ import unicode_literals |
155 | - |
156 | import re |
157 | from datetime import datetime, timedelta |
158 | |
159 | diff --git a/checkbox_support/lib/dmi.py b/checkbox_support/lib/dmi.py |
160 | index 13593d2..f93e824 100644 |
161 | --- a/checkbox_support/lib/dmi.py |
162 | +++ b/checkbox_support/lib/dmi.py |
163 | @@ -1,12 +1,10 @@ |
164 | -# |
165 | # This file is part of Checkbox. |
166 | # |
167 | -# Copyright 2008 Canonical Ltd. |
168 | +# Copyright 2008-2022 Canonical Ltd. |
169 | # |
170 | # Checkbox is free software: you can redistribute it and/or modify |
171 | # it under the terms of the GNU General Public License version 3, |
172 | # as published by the Free Software Foundation. |
173 | - |
174 | # |
175 | # Checkbox is distributed in the hope that it will be useful, |
176 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
177 | @@ -16,11 +14,6 @@ |
178 | # You should have received a copy of the GNU General Public License |
179 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
180 | |
181 | -from __future__ import absolute_import |
182 | -from __future__ import division |
183 | -from __future__ import print_function |
184 | -from __future__ import unicode_literals |
185 | - |
186 | import os |
187 | |
188 | from checkbox_support.lib.conversion import string_to_type |
189 | diff --git a/checkbox_support/lib/input.py b/checkbox_support/lib/input.py |
190 | index 263b1d5..62feb02 100644 |
191 | --- a/checkbox_support/lib/input.py |
192 | +++ b/checkbox_support/lib/input.py |
193 | @@ -1,4 +1,3 @@ |
194 | -# |
195 | # This file is part of Checkbox. |
196 | # |
197 | # Copyright 2008 Canonical Ltd. |
198 | @@ -6,7 +5,6 @@ |
199 | # Checkbox is free software: you can redistribute it and/or modify |
200 | # it under the terms of the GNU General Public License version 3, |
201 | # as published by the Free Software Foundation. |
202 | - |
203 | # |
204 | # Checkbox is distributed in the hope that it will be useful, |
205 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
206 | diff --git a/checkbox_support/lib/pci.py b/checkbox_support/lib/pci.py |
207 | index 94983c7..a0766dc 100644 |
208 | --- a/checkbox_support/lib/pci.py |
209 | +++ b/checkbox_support/lib/pci.py |
210 | @@ -1,4 +1,3 @@ |
211 | -# |
212 | # This file is part of Checkbox. |
213 | # |
214 | # Copyright 2008 Canonical Ltd. |
215 | @@ -6,7 +5,6 @@ |
216 | # Checkbox is free software: you can redistribute it and/or modify |
217 | # it under the terms of the GNU General Public License version 3, |
218 | # as published by the Free Software Foundation. |
219 | - |
220 | # |
221 | # Checkbox is distributed in the hope that it will be useful, |
222 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
223 | @@ -17,12 +15,6 @@ |
224 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
225 | |
226 | |
227 | -from __future__ import absolute_import |
228 | -from __future__ import division |
229 | -from __future__ import print_function |
230 | -from __future__ import unicode_literals |
231 | - |
232 | - |
233 | # See http://pciids.sourceforge.net/pci.ids.bz2 |
234 | class Pci(object): |
235 | |
236 | diff --git a/checkbox_support/lib/tz.py b/checkbox_support/lib/tz.py |
237 | index fd87409..c03d9ba 100644 |
238 | --- a/checkbox_support/lib/tz.py |
239 | +++ b/checkbox_support/lib/tz.py |
240 | @@ -1,12 +1,10 @@ |
241 | -# |
242 | # This file is part of Checkbox. |
243 | # |
244 | -# Copyright 2012 Canonical Ltd. |
245 | +# Copyright 2012-2022 Canonical Ltd. |
246 | # |
247 | # Checkbox is free software: you can redistribute it and/or modify |
248 | # it under the terms of the GNU General Public License version 3, |
249 | # as published by the Free Software Foundation. |
250 | - |
251 | # |
252 | # Checkbox is distributed in the hope that it will be useful, |
253 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
254 | @@ -16,11 +14,6 @@ |
255 | # You should have received a copy of the GNU General Public License |
256 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
257 | |
258 | -from __future__ import absolute_import |
259 | -from __future__ import division |
260 | -from __future__ import print_function |
261 | -from __future__ import unicode_literals |
262 | - |
263 | __all__ = ["tzutc"] |
264 | |
265 | from datetime import timedelta |
266 | diff --git a/checkbox_support/lib/usb.py b/checkbox_support/lib/usb.py |
267 | index 67e1626..2b63a81 100644 |
268 | --- a/checkbox_support/lib/usb.py |
269 | +++ b/checkbox_support/lib/usb.py |
270 | @@ -1,12 +1,10 @@ |
271 | -# |
272 | # This file is part of Checkbox. |
273 | # |
274 | -# Copyright 2008 Canonical Ltd. |
275 | +# Copyright 2008-2022 Canonical Ltd. |
276 | # |
277 | # Checkbox is free software: you can redistribute it and/or modify |
278 | # it under the terms of the GNU General Public License version 3, |
279 | # as published by the Free Software Foundation. |
280 | - |
281 | # |
282 | # Checkbox is distributed in the hope that it will be useful, |
283 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
284 | @@ -16,11 +14,6 @@ |
285 | # You should have received a copy of the GNU General Public License |
286 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
287 | |
288 | -from __future__ import absolute_import |
289 | -from __future__ import division |
290 | -from __future__ import print_function |
291 | -from __future__ import unicode_literals |
292 | - |
293 | |
294 | # See http://www.linux-usb.org/usb.ids |
295 | class Usb(object): |
296 | diff --git a/checkbox_support/parsers/__init__.py b/checkbox_support/parsers/__init__.py |
297 | index e5ec840..7797414 100644 |
298 | --- a/checkbox_support/parsers/__init__.py |
299 | +++ b/checkbox_support/parsers/__init__.py |
300 | @@ -1,11 +1,111 @@ |
301 | -from __future__ import absolute_import |
302 | -from __future__ import division |
303 | -from __future__ import print_function |
304 | -from __future__ import unicode_literals |
305 | - |
306 | -# The version is an incrementing number, if the version changes it means |
307 | -# one of the parser components has changed and may produce different |
308 | -# results for a given parsable input. |
309 | -# This should be updated manually when a parser component changes, note |
310 | -# that this includes changes to any module under checkbox.parsers. |
311 | -__version__ = '3' |
312 | +# This file is part of Checkbox. |
313 | +# |
314 | +# Copyright 2022 Canonical Ltd. |
315 | +# Written by: |
316 | +# Maciej Kisielewski <maciej.kisielewski@canonical.com> |
317 | +# |
318 | +# Checkbox is free software: you can redistribute it and/or modify |
319 | +# it under the terms of the GNU General Public License version 3, |
320 | +# as published by the Free Software Foundation. |
321 | +# |
322 | +# Checkbox is distributed in the hope that it will be useful, |
323 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
324 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
325 | +# GNU General Public License for more details. |
326 | +# |
327 | +# You should have received a copy of the GNU General Public License |
328 | +# along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
329 | +""" |
330 | +This module provides an entry point to checkbox-support-parse. |
331 | + |
332 | +The commands turns an output of system commands and turns them into json. |
333 | +When a new parser is added, it should be added to AVAILABLE_PARSER mapping." |
334 | +""" |
335 | + |
336 | +import io |
337 | +import json |
338 | +import re |
339 | +import sys |
340 | + |
341 | +from argparse import ArgumentParser |
342 | + |
343 | +from checkbox_support.parsers import dkms_info |
344 | +from checkbox_support.parsers import dmidecode |
345 | +from checkbox_support.parsers import image_info |
346 | +from checkbox_support.parsers import kernel_cmdline |
347 | +from checkbox_support.parsers import modinfo |
348 | +from checkbox_support.parsers import modprobe |
349 | +from checkbox_support.parsers import pactl |
350 | +from checkbox_support.parsers import pci_config |
351 | +from checkbox_support.parsers import udevadm |
352 | + |
353 | +AVAILABLE_PARSERS = { |
354 | + 'bto': image_info.parse_bto_attachment_output, |
355 | + 'buildstamp': image_info.parse_buildstamp_attachment_output, |
356 | + 'dkms': dkms_info.parse_dkms_info, |
357 | + 'dmidecode': dmidecode.parse_dmidecode_output, |
358 | + 'kernelcmdline': kernel_cmdline.parse_kernel_cmdline, |
359 | + 'modinfo': modinfo.parse_modinfo_attachment_output, |
360 | + 'modprobe': modprobe.parse_modprobe_d_output, |
361 | + 'pactl-list': pactl.parse_pactl_output, |
362 | + 'pci-subsys-id': pci_config.parse_pci_subsys_id, |
363 | + 'recovery-info': image_info.parse_recovery_info_attachment_output, |
364 | + 'udevadm': udevadm.parse_udevadm_output, |
365 | +} |
366 | +PARSER_LIST = sorted(list(AVAILABLE_PARSERS.keys())) |
367 | +Pattern = type(re.compile("")) |
368 | + |
369 | + |
370 | +def main(): |
371 | + """Entry point to the program.""" |
372 | + arg_parser = ArgumentParser( |
373 | + description="parse stdin with the specified parser") |
374 | + arg_parser.add_argument( |
375 | + "parser_name", metavar="PARSER-NAME", |
376 | + choices=['?'] + PARSER_LIST, |
377 | + help="Name of the parser to use") |
378 | + args = arg_parser.parse_args() |
379 | + if args.parser_name == '?': |
380 | + print("The following parsers are available:") |
381 | + print("\n".join(PARSER_LIST)) |
382 | + raise SystemExit() |
383 | + parser = AVAILABLE_PARSERS[args.parser_name] |
384 | + stdin = sys.stdin |
385 | + with io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8') as stdin: |
386 | + try: |
387 | + text = stdin.read() |
388 | + print(run_parsing(parser, text)) |
389 | + except UnicodeDecodeError as exc: |
390 | + msg = "Failed to decode input stream: {}".format(str(exc)) |
391 | + raise SystemExit(msg) from exc |
392 | + |
393 | + |
394 | +def run_parsing(parser_fn, text): |
395 | + """Do the actual parsing.""" |
396 | + try: |
397 | + ast = parser_fn(text) |
398 | + return json.dumps( |
399 | + ast, indent=4, sort_keys=True, default=_json_fallback) |
400 | + except Exception as exc: |
401 | + msg = "Failed to parse the text: {}".format(str(exc)) |
402 | + raise SystemExit(msg) from exc |
403 | + |
404 | + |
405 | +def _json_fallback(obj): |
406 | + """ |
407 | + Helper method to convert arbitrary objects to their JSON |
408 | + representation. |
409 | + |
410 | + Anything that has a 'as_json' attribute will be converted to the result |
411 | + of calling that method. For all other objects __dict__ is returned. |
412 | + """ |
413 | + if isinstance(obj, Pattern): |
414 | + return "<Pattern>" |
415 | + if hasattr(obj, "as_json"): |
416 | + return obj.as_json() |
417 | + if hasattr(obj, "__dict__"): |
418 | + return obj.__dict__ |
419 | + if hasattr(obj, "__slots__"): |
420 | + return {slot: getattr(obj, slot) for slot in obj.__slots__} |
421 | + raise NotImplementedError( |
422 | + "unable to json-ify {!r}".format(obj.__class__)) |
423 | diff --git a/checkbox_support/parsers/cpuinfo.py b/checkbox_support/parsers/cpuinfo.py |
424 | index 2e8aa81..5a2ce6b 100644 |
425 | --- a/checkbox_support/parsers/cpuinfo.py |
426 | +++ b/checkbox_support/parsers/cpuinfo.py |
427 | @@ -1,12 +1,10 @@ |
428 | -# |
429 | # This file is part of Checkbox. |
430 | # |
431 | -# Copyright 2011 Canonical Ltd. |
432 | +# Copyright 2011-2022 Canonical Ltd. |
433 | # |
434 | # Checkbox is free software: you can redistribute it and/or modify |
435 | # it under the terms of the GNU General Public License version 3, |
436 | # as published by the Free Software Foundation. |
437 | - |
438 | # |
439 | # Checkbox is distributed in the hope that it will be useful, |
440 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
441 | @@ -16,11 +14,6 @@ |
442 | # You should have received a copy of the GNU General Public License |
443 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
444 | |
445 | -from __future__ import absolute_import |
446 | -from __future__ import division |
447 | -from __future__ import print_function |
448 | -from __future__ import unicode_literals |
449 | - |
450 | from os import uname |
451 | import re |
452 | |
453 | diff --git a/checkbox_support/parsers/cputable.py b/checkbox_support/parsers/cputable.py |
454 | index e7e652e..767d236 100644 |
455 | --- a/checkbox_support/parsers/cputable.py |
456 | +++ b/checkbox_support/parsers/cputable.py |
457 | @@ -1,12 +1,10 @@ |
458 | -# |
459 | # This file is part of Checkbox. |
460 | # |
461 | -# Copyright 2011 Canonical Ltd. |
462 | +# Copyright 2011-2022 Canonical Ltd. |
463 | # |
464 | # Checkbox is free software: you can redistribute it and/or modify |
465 | # it under the terms of the GNU General Public License version 3, |
466 | # as published by the Free Software Foundation. |
467 | - |
468 | # |
469 | # Checkbox is distributed in the hope that it will be useful, |
470 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
471 | @@ -16,11 +14,6 @@ |
472 | # You should have received a copy of the GNU General Public License |
473 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
474 | |
475 | -from __future__ import absolute_import |
476 | -from __future__ import division |
477 | -from __future__ import print_function |
478 | -from __future__ import unicode_literals |
479 | - |
480 | import re |
481 | |
482 | |
483 | diff --git a/checkbox_support/parsers/dkms_info.py b/checkbox_support/parsers/dkms_info.py |
484 | index 89ba549..b23cf23 100644 |
485 | --- a/checkbox_support/parsers/dkms_info.py |
486 | +++ b/checkbox_support/parsers/dkms_info.py |
487 | @@ -1,6 +1,6 @@ |
488 | # This file is part of Checkbox. |
489 | # |
490 | -# Copyright 2015 Canonical Ltd. |
491 | +# Copyright 2015-2022 Canonical Ltd. |
492 | # |
493 | # Checkbox is free software: you can redistribute it and/or modify |
494 | # it under the terms of the GNU General Public License version 3, |
495 | @@ -14,11 +14,6 @@ |
496 | # You should have received a copy of the GNU General Public License |
497 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
498 | |
499 | -from __future__ import absolute_import |
500 | -from __future__ import division |
501 | -from __future__ import print_function |
502 | -from __future__ import unicode_literals |
503 | - |
504 | import io |
505 | import json |
506 | |
507 | diff --git a/checkbox_support/parsers/dmidecode.py b/checkbox_support/parsers/dmidecode.py |
508 | index 772a6df..5818be2 100644 |
509 | --- a/checkbox_support/parsers/dmidecode.py |
510 | +++ b/checkbox_support/parsers/dmidecode.py |
511 | @@ -1,12 +1,10 @@ |
512 | -# |
513 | # This file is part of Checkbox. |
514 | # |
515 | -# Copyright 2011 Canonical Ltd. |
516 | +# Copyright 2011-2022 Canonical Ltd. |
517 | # |
518 | # Checkbox is free software: you can redistribute it and/or modify |
519 | # it under the terms of the GNU General Public License version 3, |
520 | # as published by the Free Software Foundation. |
521 | - |
522 | # |
523 | # Checkbox is distributed in the hope that it will be useful, |
524 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
525 | @@ -16,11 +14,6 @@ |
526 | # You should have received a copy of the GNU General Public License |
527 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
528 | |
529 | -from __future__ import absolute_import |
530 | -from __future__ import division |
531 | -from __future__ import print_function |
532 | -from __future__ import unicode_literals |
533 | - |
534 | import io |
535 | import re |
536 | from string import hexdigits |
537 | diff --git a/checkbox_support/parsers/efi.py b/checkbox_support/parsers/efi.py |
538 | index e452888..c77f2c2 100644 |
539 | --- a/checkbox_support/parsers/efi.py |
540 | +++ b/checkbox_support/parsers/efi.py |
541 | @@ -1,12 +1,10 @@ |
542 | -# |
543 | # This file is part of Checkbox. |
544 | # |
545 | -# Copyright 2011 Canonical Ltd. |
546 | +# Copyright 2011-2022 Canonical Ltd. |
547 | # |
548 | # Checkbox is free software: you can redistribute it and/or modify |
549 | # it under the terms of the GNU General Public License version 3, |
550 | # as published by the Free Software Foundation. |
551 | - |
552 | # |
553 | # Checkbox is distributed in the hope that it will be useful, |
554 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
555 | @@ -16,11 +14,6 @@ |
556 | # You should have received a copy of the GNU General Public License |
557 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
558 | |
559 | -from __future__ import absolute_import |
560 | -from __future__ import division |
561 | -from __future__ import print_function |
562 | -from __future__ import unicode_literals |
563 | - |
564 | import re |
565 | |
566 | |
567 | diff --git a/checkbox_support/parsers/image_info.py b/checkbox_support/parsers/image_info.py |
568 | index 369792b..ff9d73c 100644 |
569 | --- a/checkbox_support/parsers/image_info.py |
570 | +++ b/checkbox_support/parsers/image_info.py |
571 | @@ -1,6 +1,6 @@ |
572 | # This file is part of Checkbox. |
573 | # |
574 | -# Copyright 2011-2015 Canonical Ltd. |
575 | +# Copyright 2011-2022 Canonical Ltd. |
576 | # |
577 | # Checkbox is free software: you can redistribute it and/or modify |
578 | # it under the terms of the GNU General Public License version 3, |
579 | @@ -26,11 +26,6 @@ There are 3 possible attachments containing data relevant to OEM images:: |
580 | A class is provided to parse each of these. |
581 | """ |
582 | |
583 | -from __future__ import absolute_import |
584 | -from __future__ import division |
585 | -from __future__ import print_function |
586 | -from __future__ import unicode_literals |
587 | - |
588 | import io |
589 | from xml.dom import minidom |
590 | from xml.parsers.expat import ExpatError |
591 | diff --git a/checkbox_support/parsers/lshwjson.py b/checkbox_support/parsers/lshwjson.py |
592 | index 9be6fb1..5a57f46 100644 |
593 | --- a/checkbox_support/parsers/lshwjson.py |
594 | +++ b/checkbox_support/parsers/lshwjson.py |
595 | @@ -1,12 +1,10 @@ |
596 | -# |
597 | # This file is part of Checkbox. |
598 | # |
599 | -# Copyright 2013 Canonical Ltd. |
600 | +# Copyright 2013-2022 Canonical Ltd. |
601 | # |
602 | # Checkbox is free software: you can redistribute it and/or modify |
603 | # it under the terms of the GNU General Public License version 3, |
604 | # as published by the Free Software Foundation. |
605 | - |
606 | # |
607 | # Checkbox is distributed in the hope that it will be useful, |
608 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
609 | @@ -16,11 +14,6 @@ |
610 | # You should have received a copy of the GNU General Public License |
611 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
612 | |
613 | -from __future__ import absolute_import |
614 | -from __future__ import division |
615 | -from __future__ import print_function |
616 | -from __future__ import unicode_literals |
617 | - |
618 | import json |
619 | import logging |
620 | |
621 | diff --git a/checkbox_support/parsers/meminfo.py b/checkbox_support/parsers/meminfo.py |
622 | index 3264ddb..0e4dbc9 100644 |
623 | --- a/checkbox_support/parsers/meminfo.py |
624 | +++ b/checkbox_support/parsers/meminfo.py |
625 | @@ -1,12 +1,10 @@ |
626 | -# |
627 | # This file is part of Checkbox. |
628 | # |
629 | -# Copyright 2011 Canonical Ltd. |
630 | +# Copyright 2011-2022 Canonical Ltd. |
631 | # |
632 | # Checkbox is free software: you can redistribute it and/or modify |
633 | # it under the terms of the GNU General Public License version 3, |
634 | # as published by the Free Software Foundation. |
635 | - |
636 | # |
637 | # Checkbox is distributed in the hope that it will be useful, |
638 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
639 | @@ -16,11 +14,6 @@ |
640 | # You should have received a copy of the GNU General Public License |
641 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
642 | |
643 | -from __future__ import absolute_import |
644 | -from __future__ import division |
645 | -from __future__ import print_function |
646 | -from __future__ import unicode_literals |
647 | - |
648 | import re |
649 | |
650 | |
651 | diff --git a/checkbox_support/parsers/modinfo.py b/checkbox_support/parsers/modinfo.py |
652 | index a26255a..dd217e9 100644 |
653 | --- a/checkbox_support/parsers/modinfo.py |
654 | +++ b/checkbox_support/parsers/modinfo.py |
655 | @@ -1,6 +1,6 @@ |
656 | # This file is part of Checkbox. |
657 | # |
658 | -# Copyright 2011-2015 Canonical Ltd. |
659 | +# Copyright 2011-2022 Canonical Ltd. |
660 | # |
661 | # Checkbox is free software: you can redistribute it and/or modify |
662 | # it under the terms of the GNU General Public License version 3, |
663 | @@ -14,11 +14,6 @@ |
664 | # You should have received a copy of the GNU General Public License |
665 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
666 | |
667 | -from __future__ import absolute_import |
668 | -from __future__ import division |
669 | -from __future__ import print_function |
670 | -from __future__ import unicode_literals |
671 | - |
672 | import io |
673 | |
674 | |
675 | diff --git a/checkbox_support/parsers/modprobe.py b/checkbox_support/parsers/modprobe.py |
676 | index 832903c..9645017 100644 |
677 | --- a/checkbox_support/parsers/modprobe.py |
678 | +++ b/checkbox_support/parsers/modprobe.py |
679 | @@ -1,6 +1,6 @@ |
680 | # This file is part of Checkbox. |
681 | # |
682 | -# Copyright 2015 Canonical Ltd. |
683 | +# Copyright 2015-2022 Canonical Ltd. |
684 | # |
685 | # Checkbox is free software: you can redistribute it and/or modify |
686 | # it under the terms of the GNU General Public License version 3, |
687 | @@ -14,11 +14,6 @@ |
688 | # You should have received a copy of the GNU General Public License |
689 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
690 | |
691 | -from __future__ import absolute_import |
692 | -from __future__ import division |
693 | -from __future__ import print_function |
694 | -from __future__ import unicode_literals |
695 | - |
696 | import io |
697 | import re |
698 | from collections import defaultdict |
699 | diff --git a/checkbox_support/parsers/pactl.py b/checkbox_support/parsers/pactl.py |
700 | index 741f59b..6c79430 100644 |
701 | --- a/checkbox_support/parsers/pactl.py |
702 | +++ b/checkbox_support/parsers/pactl.py |
703 | @@ -1,6 +1,6 @@ |
704 | # This file is part of Checkbox. |
705 | # |
706 | -# Copyright 2013-2019 Canonical Ltd. |
707 | +# Copyright 2013-2022 Canonical Ltd. |
708 | # Written by: |
709 | # Zygmunt Krynicki <zygmunt.krynicki@canonical.com> |
710 | # Sylvain Pineau <sylvain.pineau@canonical.com> |
711 | @@ -8,7 +8,6 @@ |
712 | # Checkbox is free software: you can redistribute it and/or modify |
713 | # it under the terms of the GNU General Public License version 3, |
714 | # as published by the Free Software Foundation. |
715 | - |
716 | # |
717 | # Checkbox is distributed in the hope that it will be useful, |
718 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
719 | @@ -18,11 +17,6 @@ |
720 | # You should have received a copy of the GNU General Public License |
721 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
722 | |
723 | -from __future__ import absolute_import |
724 | -from __future__ import division |
725 | -from __future__ import print_function |
726 | -from __future__ import unicode_literals |
727 | - |
728 | |
729 | """ |
730 | :mod:`checkbox_support.parsers.pactl` -- `pactl list` parser |
731 | diff --git a/checkbox_support/parsers/pci_config.py b/checkbox_support/parsers/pci_config.py |
732 | index 14d3367..fe27f20 100644 |
733 | --- a/checkbox_support/parsers/pci_config.py |
734 | +++ b/checkbox_support/parsers/pci_config.py |
735 | @@ -1,6 +1,6 @@ |
736 | # This file is part of Checkbox. |
737 | # |
738 | -# Copyright 2015 Canonical Ltd. |
739 | +# Copyright 2015-2022 Canonical Ltd. |
740 | # |
741 | # Checkbox is free software: you can redistribute it and/or modify |
742 | # it under the terms of the GNU General Public License version 3, |
743 | @@ -14,11 +14,6 @@ |
744 | # You should have received a copy of the GNU General Public License |
745 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
746 | |
747 | -from __future__ import absolute_import |
748 | -from __future__ import division |
749 | -from __future__ import print_function |
750 | -from __future__ import unicode_literals |
751 | - |
752 | import io |
753 | import re |
754 | |
755 | diff --git a/checkbox_support/parsers/tests/test_udevadm.py b/checkbox_support/parsers/tests/test_udevadm.py |
756 | index acb9880..d91ad69 100644 |
757 | --- a/checkbox_support/parsers/tests/test_udevadm.py |
758 | +++ b/checkbox_support/parsers/tests/test_udevadm.py |
759 | @@ -1,12 +1,10 @@ |
760 | -# |
761 | # This file is part of Checkbox. |
762 | # |
763 | -# Copyright 2012-2013 Canonical Ltd. |
764 | +# Copyright 2012-2022 Canonical Ltd. |
765 | # |
766 | # Checkbox is free software: you can redistribute it and/or modify |
767 | # it under the terms of the GNU General Public License version 3, |
768 | # as published by the Free Software Foundation. |
769 | - |
770 | # |
771 | # Checkbox is distributed in the hope that it will be useful, |
772 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
773 | @@ -16,14 +14,9 @@ |
774 | # You should have received a copy of the GNU General Public License |
775 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
776 | |
777 | -from __future__ import absolute_import |
778 | -from __future__ import division |
779 | -from __future__ import print_function |
780 | -from __future__ import unicode_literals |
781 | - |
782 | from io import StringIO |
783 | -from io import open |
784 | from unittest import TestCase |
785 | +from textwrap import dedent |
786 | |
787 | from pkg_resources import resource_filename |
788 | |
789 | @@ -31,22 +24,6 @@ from checkbox_support.parsers.udevadm import UdevadmParser, decode_id |
790 | from checkbox_support.parsers.udevadm import parse_udevadm_output |
791 | |
792 | |
793 | -class DeviceResult(object): |
794 | - |
795 | - def __init__(self): |
796 | - self.devices = [] |
797 | - |
798 | - def addDevice(self, device): |
799 | - self.devices.append(device) |
800 | - |
801 | - def getDevice(self, category): |
802 | - for device in self.devices: |
803 | - if device.category == category: |
804 | - return device |
805 | - |
806 | - return None |
807 | - |
808 | - |
809 | class UdevadmDataMixIn(object): |
810 | """ |
811 | Mix in with a helper method to load sample udevadm data |
812 | @@ -70,16 +47,6 @@ class UdevadmDataMixIn(object): |
813 | |
814 | class TestUdevadmParser(TestCase, UdevadmDataMixIn): |
815 | |
816 | - def getParser(self, string): |
817 | - stream = StringIO(string) |
818 | - return UdevadmParser(stream) |
819 | - |
820 | - def getResult(self, string): |
821 | - parser = self.getParser(string) |
822 | - result = DeviceResult() |
823 | - parser.run(result) |
824 | - return result |
825 | - |
826 | def parse(self, name, with_lsblk=True, with_partitions=False): |
827 | # Uncomment only for debugging purpose |
828 | """ |
829 | @@ -100,27 +67,29 @@ class TestUdevadmParser(TestCase, UdevadmDataMixIn): |
830 | return len([d for d in devices if d.category == category]) |
831 | |
832 | def test_openfirmware_network(self): |
833 | - result = self.getResult(""" |
834 | -P: /devices/soc.0/ffe64000.ethernet |
835 | -E: DEVPATH=/devices/soc.0/ffe64000.ethernet |
836 | -E: DRIVER=XXXXX |
837 | -E: MODALIAS=of:NethernetTXXXXXCXXXXX,XXXXX |
838 | -E: OF_COMPATIBLE_0=XXXXX,XXXXX |
839 | -E: OF_COMPATIBLE_N=1 |
840 | -E: OF_NAME=ethernet |
841 | -E: OF_TYPE=XXXXX |
842 | -E: SUBSYSTEM=platform |
843 | -E: UDEV_LOG=3 |
844 | - |
845 | -P: /devices/soc.0/ffe64000.ethernet/net/eth1 |
846 | -E: DEVPATH=/devices/soc.0/ffe64000.ethernet/net/eth1 |
847 | -E: IFINDEX=3 |
848 | -E: INTERFACE=eth1 |
849 | -E: SUBSYSTEM=net |
850 | -E: UDEV_LOG=3 |
851 | -""") |
852 | - device = result.getDevice("NETWORK") |
853 | - self.assertTrue(device) |
854 | + stream = StringIO(dedent(""" |
855 | + P: /devices/soc.0/ffe64000.ethernet |
856 | + E: DEVPATH=/devices/soc.0/ffe64000.ethernet |
857 | + E: DRIVER=XXXXX |
858 | + E: MODALIAS=of:NethernetTXXXXXCXXXXX,XXXXX |
859 | + E: OF_COMPATIBLE_0=XXXXX,XXXXX |
860 | + E: OF_COMPATIBLE_N=1 |
861 | + E: OF_NAME=ethernet |
862 | + E: OF_TYPE=XXXXX |
863 | + E: SUBSYSTEM=platform |
864 | + E: UDEV_LOG=3 |
865 | + |
866 | + P: /devices/soc.0/ffe64000.ethernet/net/eth1 |
867 | + E: DEVPATH=/devices/soc.0/ffe64000.ethernet/net/eth1 |
868 | + E: IFINDEX=3 |
869 | + E: INTERFACE=eth1 |
870 | + E: SUBSYSTEM=net |
871 | + E: UDEV_LOG=3 |
872 | + """)) |
873 | + parser = UdevadmParser(stream) |
874 | + devices = parser.run() |
875 | + self.assertEqual(devices[0].category, "NETWORK") |
876 | + |
877 | |
878 | def test_DELL_INSPIRON3521_TOUCHSCREEN(self): |
879 | """ |
880 | diff --git a/checkbox_support/parsers/tests/test_version.py b/checkbox_support/parsers/tests/test_version.py |
881 | deleted file mode 100644 |
882 | index 2404430..0000000 |
883 | --- a/checkbox_support/parsers/tests/test_version.py |
884 | +++ /dev/null |
885 | @@ -1,33 +0,0 @@ |
886 | -# -*- coding: utf-8 -*- |
887 | -# |
888 | -# This file is part of Checkbox. |
889 | -# |
890 | -# Copyright 2014 Canonical Ltd. |
891 | -# |
892 | -# Checkbox is free software: you can redistribute it and/or modify |
893 | -# it under the terms of the GNU General Public License version 3, |
894 | -# as published by the Free Software Foundation. |
895 | - |
896 | -# |
897 | -# Checkbox is distributed in the hope that it will be useful, |
898 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
899 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
900 | -# GNU General Public License for more details. |
901 | -# |
902 | -# You should have received a copy of the GNU General Public License |
903 | -# along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
904 | - |
905 | -from __future__ import absolute_import |
906 | -from __future__ import division |
907 | -from __future__ import print_function |
908 | -from __future__ import unicode_literals |
909 | - |
910 | -from unittest import TestCase |
911 | - |
912 | - |
913 | -class TestSubmissionModuleVersion(TestCase): |
914 | - |
915 | - def testVersion(self): |
916 | - from checkbox_support import parsers |
917 | - ver = getattr(parsers, "__version__") |
918 | - self.assertTrue(ver) |
919 | diff --git a/checkbox_support/parsers/udevadm.py b/checkbox_support/parsers/udevadm.py |
920 | index 4c089b8..057369c 100644 |
921 | --- a/checkbox_support/parsers/udevadm.py |
922 | +++ b/checkbox_support/parsers/udevadm.py |
923 | @@ -1201,7 +1201,7 @@ class UdevadmParser(object): |
924 | def getAttributes(self, path): |
925 | return {} |
926 | |
927 | - def run(self, result): |
928 | + def run(self): |
929 | # Some attribute lines have a space character after the |
930 | # ':', others don't have it (see udevadm-info.c). |
931 | line_pattern = re.compile(r"(?P<key>[A-Z]):\s*(?P<value>.*)") |
932 | @@ -1395,6 +1395,7 @@ class UdevadmParser(object): |
933 | # Remove Virtal CDROM devices |
934 | if not [k for k in device._environment if "ID_CDROM_" in k]: |
935 | self.devices.pop(device._raw_path, None) |
936 | + return list(self.devices.values()) |
937 | |
938 | [result.addDevice(device) for device in self.devices.values()] |
939 | |
940 | @@ -1426,14 +1427,6 @@ def known_to_be_video_device(vendor_id, product_id, pci_class, pci_subclass): |
941 | return product_id in [0x0152, 0x0412, 0x0402] |
942 | |
943 | |
944 | -class UdevResult(object): |
945 | - def __init__(self): |
946 | - self.devices = [] |
947 | - |
948 | - def addDevice(self, device): |
949 | - self.devices.append(device) |
950 | - |
951 | - |
952 | def parse_udevadm_output(output, lsblk=None, list_partitions=False, bits=None): |
953 | """ |
954 | Parse output of `LANG=C udevadm info --export-db` |
955 | @@ -1448,7 +1441,4 @@ def parse_udevadm_output(output, lsblk=None, list_partitions=False, bits=None): |
956 | universal_newlines=True) |
957 | except CalledProcessError: |
958 | lsblk = '' |
959 | - udev = UdevadmParser(output, lsblk, list_partitions, bits) |
960 | - result = UdevResult() |
961 | - udev.run(result) |
962 | - return result.devices |
963 | + return UdevadmParser(output, lsblk, list_partitions, bits).run() |
964 | diff --git a/checkbox_support/parsers/xinput.py b/checkbox_support/parsers/xinput.py |
965 | index d29af68..bc6d844 100644 |
966 | --- a/checkbox_support/parsers/xinput.py |
967 | +++ b/checkbox_support/parsers/xinput.py |
968 | @@ -1,13 +1,10 @@ |
969 | -# -*- coding: utf-8 -*- |
970 | -# |
971 | # This file is part of Checkbox. |
972 | # |
973 | -# Copyright 2012 Canonical Ltd. |
974 | +# Copyright 2012-2022 Canonical Ltd. |
975 | # |
976 | # Checkbox is free software: you can redistribute it and/or modify |
977 | # it under the terms of the GNU General Public License version 3, |
978 | # as published by the Free Software Foundation. |
979 | - |
980 | # |
981 | # Checkbox is distributed in the hope that it will be useful, |
982 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
983 | @@ -17,11 +14,6 @@ |
984 | # You should have received a copy of the GNU General Public License |
985 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
986 | |
987 | -from __future__ import absolute_import |
988 | -from __future__ import division |
989 | -from __future__ import print_function |
990 | -from __future__ import unicode_literals |
991 | - |
992 | from string import ascii_letters |
993 | from string import ascii_uppercase |
994 | import re |
995 | diff --git a/checkbox_support/scripts/audio_settings.py b/checkbox_support/scripts/audio_settings.py |
996 | index 1b3974c..cd76d08 100644 |
997 | --- a/checkbox_support/scripts/audio_settings.py |
998 | +++ b/checkbox_support/scripts/audio_settings.py |
999 | @@ -1,4 +1,3 @@ |
1000 | -# |
1001 | # This file is part of Checkbox. |
1002 | # |
1003 | # Copyright 2013-2020 Canonical Ltd. |
1004 | @@ -6,7 +5,6 @@ |
1005 | # Checkbox is free software: you can redistribute it and/or modify |
1006 | # it under the terms of the GNU General Public License version 3, |
1007 | # as published by the Free Software Foundation. |
1008 | - |
1009 | # |
1010 | # Checkbox is distributed in the hope that it will be useful, |
1011 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
1012 | @@ -16,11 +14,6 @@ |
1013 | # You should have received a copy of the GNU General Public License |
1014 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
1015 | |
1016 | -from __future__ import absolute_import |
1017 | -from __future__ import division |
1018 | -from __future__ import print_function |
1019 | -from __future__ import unicode_literals |
1020 | - |
1021 | from argparse import ArgumentParser |
1022 | from subprocess import check_output, check_call, CalledProcessError |
1023 | from io import open |
1024 | diff --git a/checkbox_support/scripts/gputest_benchmark.py b/checkbox_support/scripts/gputest_benchmark.py |
1025 | index 46bd34e..7abb2a3 100644 |
1026 | --- a/checkbox_support/scripts/gputest_benchmark.py |
1027 | +++ b/checkbox_support/scripts/gputest_benchmark.py |
1028 | @@ -1,13 +1,12 @@ |
1029 | # This file is part of Checkbox. |
1030 | # |
1031 | -# Copyright 2013 Canonical Ltd. |
1032 | +# Copyright 2013-2022 Canonical Ltd. |
1033 | # Written by: |
1034 | # Sylvain Pineau <sylvain.pineau@canonical.com> |
1035 | # |
1036 | # Checkbox is free software: you can redistribute it and/or modify |
1037 | # it under the terms of the GNU General Public License version 3, |
1038 | # as published by the Free Software Foundation. |
1039 | - |
1040 | # |
1041 | # Checkbox is distributed in the hope that it will be useful, |
1042 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
1043 | @@ -17,11 +16,6 @@ |
1044 | # You should have received a copy of the GNU General Public License |
1045 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
1046 | |
1047 | -from __future__ import absolute_import |
1048 | -from __future__ import division |
1049 | -from __future__ import print_function |
1050 | -from __future__ import unicode_literals |
1051 | - |
1052 | from io import open |
1053 | from subprocess import check_output, CalledProcessError |
1054 | from tempfile import TemporaryDirectory |
1055 | diff --git a/checkbox_support/tests/__init__.py b/checkbox_support/tests/__init__.py |
1056 | index 2ade626..615bd52 100644 |
1057 | --- a/checkbox_support/tests/__init__.py |
1058 | +++ b/checkbox_support/tests/__init__.py |
1059 | @@ -29,6 +29,7 @@ from __future__ import unicode_literals |
1060 | |
1061 | from inspect import getabsfile |
1062 | from unittest.loader import defaultTestLoader |
1063 | +from unittest import TestSuite |
1064 | import os |
1065 | |
1066 | import checkbox_support |
1067 | @@ -42,7 +43,16 @@ def load_unit_tests(): |
1068 | # python modules that start with the word 'test_' . |
1069 | start_dir = os.path.dirname(getabsfile(checkbox_support)) |
1070 | top_level_dir = os.path.normpath(os.path.join(start_dir, '..')) |
1071 | - return defaultTestLoader.discover(start_dir, top_level_dir=top_level_dir) |
1072 | + test_suite = TestSuite() |
1073 | + for path in os.listdir(start_dir): |
1074 | + # skip tests that come from a vendorized code |
1075 | + if path in ('__pycache__', 'vendor'): |
1076 | + continue |
1077 | + path = os.path.join(start_dir, path) |
1078 | + if os.path.isdir(path): |
1079 | + test_suite.addTests( |
1080 | + defaultTestLoader.discover(path, top_level_dir=top_level_dir)) |
1081 | + return test_suite |
1082 | |
1083 | |
1084 | def test_suite(): |
1085 | diff --git a/checkbox_support/udev.py b/checkbox_support/udev.py |
1086 | index a47c5c1..897ec08 100644 |
1087 | --- a/checkbox_support/udev.py |
1088 | +++ b/checkbox_support/udev.py |
1089 | @@ -1,13 +1,12 @@ |
1090 | # This file is part of Checkbox. |
1091 | # |
1092 | -# Copyright 2012 Canonical Ltd. |
1093 | +# Copyright 2012-2022 Canonical Ltd. |
1094 | # Written by: |
1095 | # Zygmunt Krynicki <zygmunt.krynicki@canonical.com> |
1096 | # |
1097 | # Checkbox is free software: you can redistribute it and/or modify |
1098 | # it under the terms of the GNU General Public License version 3, |
1099 | # as published by the Free Software Foundation. |
1100 | - |
1101 | # |
1102 | # Checkbox is distributed in the hope that it will be useful, |
1103 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
1104 | @@ -17,11 +16,6 @@ |
1105 | # You should have received a copy of the GNU General Public License |
1106 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
1107 | |
1108 | -from __future__ import absolute_import |
1109 | -from __future__ import division |
1110 | -from __future__ import print_function |
1111 | -from __future__ import unicode_literals |
1112 | - |
1113 | """ |
1114 | checkbox_support.udev |
1115 | ===================== |
1116 | diff --git a/setup.py b/setup.py |
1117 | index 673f4f0..9d1f916 100755 |
1118 | --- a/setup.py |
1119 | +++ b/setup.py |
1120 | @@ -93,6 +93,7 @@ setup( |
1121 | "checkbox_support.scripts.eddystone_scanner:main"), |
1122 | ("checkbox-support-lsusb=" |
1123 | "checkbox_support.scripts.lsusb:main"), |
1124 | + ("checkbox-support-parse=checkbox_support.parsers:main"), |
1125 | ], |
1126 | }, |
1127 | ) |
awesome work, and indeed the unit tests are faster to run!
The corresponding p-p-r and p-p-c commits will be a pleasure to review