Merge ~kissiel/checkbox-support:parsers-migration into checkbox-support: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)
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Review via email: mp+415224@code.launchpad.net

Description of the change

This MR has multiple goodies.

0. Parsers can now be invoked directly from checkbox support. The invocation is:
checkbox-support-parse <PARSER_NAME>
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.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

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

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/checkbox_support/contrib/xrandr.py b/checkbox_support/contrib/xrandr.py
index 9a79f40..91fd173 100644
--- a/checkbox_support/contrib/xrandr.py
+++ b/checkbox_support/contrib/xrandr.py
@@ -1,6 +1,3 @@
1#!/usr/bin/python3
2# -*- coding: utf-8 -*-
3#
4# Python-XRandR provides a high level API for the XRandR extension of the1# Python-XRandR provides a high level API for the XRandR extension of the
5# X.org server. XRandR allows to configure resolution, refresh rate, rotation2# X.org server. XRandR allows to configure resolution, refresh rate, rotation
6# of the screen and multiple outputs of graphics cards.3# of the screen and multiple outputs of graphics cards.
@@ -36,11 +33,6 @@
36# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,33# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
37# MA 02110-1301 USA34# MA 02110-1301 USA
3835
39from __future__ import absolute_import
40from __future__ import division
41from __future__ import print_function
42from __future__ import unicode_literals
43
44from ctypes import (36from ctypes import (
45 POINTER,37 POINTER,
46 Structure,38 Structure,
diff --git a/checkbox_support/dbus/__init__.py b/checkbox_support/dbus/__init__.py
index 93f178d..8d2281a 100644
--- a/checkbox_support/dbus/__init__.py
+++ b/checkbox_support/dbus/__init__.py
@@ -1,13 +1,12 @@
1# This file is part of Checkbox.1# This file is part of Checkbox.
2#2#
3# Copyright 2012 Canonical Ltd.3# Copyright 2012-2022 Canonical Ltd.
4# Written by:4# Written by:
5# Zygmunt Krynicki <zygmunt.krynicki@canonical.com>5# Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
6#6#
7# Checkbox is free software: you can redistribute it and/or modify7# Checkbox is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License version 3,8# it under the terms of the GNU General Public License version 3,
9# as published by the Free Software Foundation.9# as published by the Free Software Foundation.
10
11#10#
12# Checkbox is distributed in the hope that it will be useful,11# Checkbox is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of12# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,7 +15,6 @@
16#15#
17# You should have received a copy of the GNU General Public License16# You should have received a copy of the GNU General Public License
18# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
19#
20"""18"""
21checkbox_support.dbus19checkbox_support.dbus
22=====================20=====================
@@ -24,11 +22,6 @@ checkbox_support.dbus
24Utility modules for working with various things accessible over dbus22Utility modules for working with various things accessible over dbus
25"""23"""
2624
27from __future__ import absolute_import
28from __future__ import division
29from __future__ import print_function
30from __future__ import unicode_literals
31
32import logging25import logging
3326
34from dbus import SystemBus27from dbus import SystemBus
diff --git a/checkbox_support/dbus/udisks2.py b/checkbox_support/dbus/udisks2.py
index 28e62a5..d156ded 100644
--- a/checkbox_support/dbus/udisks2.py
+++ b/checkbox_support/dbus/udisks2.py
@@ -13,7 +13,6 @@
13#13#
14# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17"""16"""
18checkbox_support.dbus.udisks217checkbox_support.dbus.udisks2
19=====================18=====================
diff --git a/checkbox_support/disk_support.py b/checkbox_support/disk_support.py
index 09d8525..bba496b 100644
--- a/checkbox_support/disk_support.py
+++ b/checkbox_support/disk_support.py
@@ -14,7 +14,6 @@
14#14#
15# You should have received a copy of the GNU General Public License15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17#
18"""17"""
19Support functions related to disk devices for Checkbox.18Support functions related to disk devices for Checkbox.
20"""19"""
diff --git a/checkbox_support/helpers/human_readable_bytes.py b/checkbox_support/helpers/human_readable_bytes.py
index 7b1d391..8bafdf2 100644
--- a/checkbox_support/helpers/human_readable_bytes.py
+++ b/checkbox_support/helpers/human_readable_bytes.py
@@ -15,7 +15,6 @@
15#15#
16# You should have received a copy of the GNU General Public License16# You should have received a copy of the GNU General Public License
17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
18
19"""18"""
20checkbox_support.helpers.human_readable_bytes19checkbox_support.helpers.human_readable_bytes
21=============================================20=============================================
diff --git a/checkbox_support/lib/bit.py b/checkbox_support/lib/bit.py
index 2cc3e6e..e0e9808 100644
--- a/checkbox_support/lib/bit.py
+++ b/checkbox_support/lib/bit.py
@@ -1,12 +1,10 @@
1#
2# This file is part of Checkbox.1# This file is part of Checkbox.
3#2#
4# Copyright 2008 Canonical Ltd.3# Copyright 2008-2022 Canonical Ltd.
5#4#
6# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
8# as published by the Free Software Foundation.7# as published by the Free Software Foundation.
9
10#8#
11# Checkbox is distributed in the hope that it will be useful,9# Checkbox is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of10# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,11 +14,6 @@
16# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1816
19from __future__ import absolute_import
20from __future__ import division
21from __future__ import print_function
22from __future__ import unicode_literals
23
24from struct import calcsize17from struct import calcsize
2518
2619
diff --git a/checkbox_support/lib/conversion.py b/checkbox_support/lib/conversion.py
index b8ce871..d954c09 100644
--- a/checkbox_support/lib/conversion.py
+++ b/checkbox_support/lib/conversion.py
@@ -1,12 +1,10 @@
1#
2# This file is part of Checkbox.1# This file is part of Checkbox.
3#2#
4# Copyright 2008 Canonical Ltd.3# Copyright 2008-2022 Canonical Ltd.
5#4#
6# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
8# as published by the Free Software Foundation.7# as published by the Free Software Foundation.
9
10#8#
11# Checkbox is distributed in the hope that it will be useful,9# Checkbox is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of10# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,11 +14,6 @@
16# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1816
19from __future__ import absolute_import
20from __future__ import division
21from __future__ import print_function
22from __future__ import unicode_literals
23
24import re17import re
25from datetime import datetime, timedelta18from datetime import datetime, timedelta
2619
diff --git a/checkbox_support/lib/dmi.py b/checkbox_support/lib/dmi.py
index 13593d2..f93e824 100644
--- a/checkbox_support/lib/dmi.py
+++ b/checkbox_support/lib/dmi.py
@@ -1,12 +1,10 @@
1#
2# This file is part of Checkbox.1# This file is part of Checkbox.
3#2#
4# Copyright 2008 Canonical Ltd.3# Copyright 2008-2022 Canonical Ltd.
5#4#
6# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
8# as published by the Free Software Foundation.7# as published by the Free Software Foundation.
9
10#8#
11# Checkbox is distributed in the hope that it will be useful,9# Checkbox is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of10# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,11 +14,6 @@
16# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1816
19from __future__ import absolute_import
20from __future__ import division
21from __future__ import print_function
22from __future__ import unicode_literals
23
24import os17import os
2518
26from checkbox_support.lib.conversion import string_to_type19from checkbox_support.lib.conversion import string_to_type
diff --git a/checkbox_support/lib/input.py b/checkbox_support/lib/input.py
index 263b1d5..62feb02 100644
--- a/checkbox_support/lib/input.py
+++ b/checkbox_support/lib/input.py
@@ -1,4 +1,3 @@
1#
2# This file is part of Checkbox.1# This file is part of Checkbox.
3#2#
4# Copyright 2008 Canonical Ltd.3# Copyright 2008 Canonical Ltd.
@@ -6,7 +5,6 @@
6# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
8# as published by the Free Software Foundation.7# as published by the Free Software Foundation.
9
10#8#
11# Checkbox is distributed in the hope that it will be useful,9# Checkbox is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of10# but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/checkbox_support/lib/pci.py b/checkbox_support/lib/pci.py
index 94983c7..a0766dc 100644
--- a/checkbox_support/lib/pci.py
+++ b/checkbox_support/lib/pci.py
@@ -1,4 +1,3 @@
1#
2# This file is part of Checkbox.1# This file is part of Checkbox.
3#2#
4# Copyright 2008 Canonical Ltd.3# Copyright 2008 Canonical Ltd.
@@ -6,7 +5,6 @@
6# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
8# as published by the Free Software Foundation.7# as published by the Free Software Foundation.
9
10#8#
11# Checkbox is distributed in the hope that it will be useful,9# Checkbox is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of10# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,12 +15,6 @@
17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1816
1917
20from __future__ import absolute_import
21from __future__ import division
22from __future__ import print_function
23from __future__ import unicode_literals
24
25
26# See http://pciids.sourceforge.net/pci.ids.bz218# See http://pciids.sourceforge.net/pci.ids.bz2
27class Pci(object):19class Pci(object):
2820
diff --git a/checkbox_support/lib/tz.py b/checkbox_support/lib/tz.py
index fd87409..c03d9ba 100644
--- a/checkbox_support/lib/tz.py
+++ b/checkbox_support/lib/tz.py
@@ -1,12 +1,10 @@
1#
2# This file is part of Checkbox.1# This file is part of Checkbox.
3#2#
4# Copyright 2012 Canonical Ltd.3# Copyright 2012-2022 Canonical Ltd.
5#4#
6# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
8# as published by the Free Software Foundation.7# as published by the Free Software Foundation.
9
10#8#
11# Checkbox is distributed in the hope that it will be useful,9# Checkbox is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of10# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,11 +14,6 @@
16# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1816
19from __future__ import absolute_import
20from __future__ import division
21from __future__ import print_function
22from __future__ import unicode_literals
23
24__all__ = ["tzutc"]17__all__ = ["tzutc"]
2518
26from datetime import timedelta19from datetime import timedelta
diff --git a/checkbox_support/lib/usb.py b/checkbox_support/lib/usb.py
index 67e1626..2b63a81 100644
--- a/checkbox_support/lib/usb.py
+++ b/checkbox_support/lib/usb.py
@@ -1,12 +1,10 @@
1#
2# This file is part of Checkbox.1# This file is part of Checkbox.
3#2#
4# Copyright 2008 Canonical Ltd.3# Copyright 2008-2022 Canonical Ltd.
5#4#
6# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
8# as published by the Free Software Foundation.7# as published by the Free Software Foundation.
9
10#8#
11# Checkbox is distributed in the hope that it will be useful,9# Checkbox is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of10# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,11 +14,6 @@
16# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1816
19from __future__ import absolute_import
20from __future__ import division
21from __future__ import print_function
22from __future__ import unicode_literals
23
2417
25# See http://www.linux-usb.org/usb.ids18# See http://www.linux-usb.org/usb.ids
26class Usb(object):19class Usb(object):
diff --git a/checkbox_support/parsers/__init__.py b/checkbox_support/parsers/__init__.py
index e5ec840..7797414 100644
--- a/checkbox_support/parsers/__init__.py
+++ b/checkbox_support/parsers/__init__.py
@@ -1,11 +1,111 @@
1from __future__ import absolute_import1# This file is part of Checkbox.
2from __future__ import division2#
3from __future__ import print_function3# Copyright 2022 Canonical Ltd.
4from __future__ import unicode_literals4# Written by:
55# Maciej Kisielewski <maciej.kisielewski@canonical.com>
6# The version is an incrementing number, if the version changes it means6#
7# one of the parser components has changed and may produce different7# Checkbox is free software: you can redistribute it and/or modify
8# results for a given parsable input.8# it under the terms of the GNU General Public License version 3,
9# This should be updated manually when a parser component changes, note9# as published by the Free Software Foundation.
10# that this includes changes to any module under checkbox.parsers.10#
11__version__ = '3'11# Checkbox is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
18"""
19This module provides an entry point to checkbox-support-parse.
20
21The commands turns an output of system commands and turns them into json.
22When a new parser is added, it should be added to AVAILABLE_PARSER mapping."
23"""
24
25import io
26import json
27import re
28import sys
29
30from argparse import ArgumentParser
31
32from checkbox_support.parsers import dkms_info
33from checkbox_support.parsers import dmidecode
34from checkbox_support.parsers import image_info
35from checkbox_support.parsers import kernel_cmdline
36from checkbox_support.parsers import modinfo
37from checkbox_support.parsers import modprobe
38from checkbox_support.parsers import pactl
39from checkbox_support.parsers import pci_config
40from checkbox_support.parsers import udevadm
41
42AVAILABLE_PARSERS = {
43 'bto': image_info.parse_bto_attachment_output,
44 'buildstamp': image_info.parse_buildstamp_attachment_output,
45 'dkms': dkms_info.parse_dkms_info,
46 'dmidecode': dmidecode.parse_dmidecode_output,
47 'kernelcmdline': kernel_cmdline.parse_kernel_cmdline,
48 'modinfo': modinfo.parse_modinfo_attachment_output,
49 'modprobe': modprobe.parse_modprobe_d_output,
50 'pactl-list': pactl.parse_pactl_output,
51 'pci-subsys-id': pci_config.parse_pci_subsys_id,
52 'recovery-info': image_info.parse_recovery_info_attachment_output,
53 'udevadm': udevadm.parse_udevadm_output,
54}
55PARSER_LIST = sorted(list(AVAILABLE_PARSERS.keys()))
56Pattern = type(re.compile(""))
57
58
59def main():
60 """Entry point to the program."""
61 arg_parser = ArgumentParser(
62 description="parse stdin with the specified parser")
63 arg_parser.add_argument(
64 "parser_name", metavar="PARSER-NAME",
65 choices=['?'] + PARSER_LIST,
66 help="Name of the parser to use")
67 args = arg_parser.parse_args()
68 if args.parser_name == '?':
69 print("The following parsers are available:")
70 print("\n".join(PARSER_LIST))
71 raise SystemExit()
72 parser = AVAILABLE_PARSERS[args.parser_name]
73 stdin = sys.stdin
74 with io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8') as stdin:
75 try:
76 text = stdin.read()
77 print(run_parsing(parser, text))
78 except UnicodeDecodeError as exc:
79 msg = "Failed to decode input stream: {}".format(str(exc))
80 raise SystemExit(msg) from exc
81
82
83def run_parsing(parser_fn, text):
84 """Do the actual parsing."""
85 try:
86 ast = parser_fn(text)
87 return json.dumps(
88 ast, indent=4, sort_keys=True, default=_json_fallback)
89 except Exception as exc:
90 msg = "Failed to parse the text: {}".format(str(exc))
91 raise SystemExit(msg) from exc
92
93
94def _json_fallback(obj):
95 """
96 Helper method to convert arbitrary objects to their JSON
97 representation.
98
99 Anything that has a 'as_json' attribute will be converted to the result
100 of calling that method. For all other objects __dict__ is returned.
101 """
102 if isinstance(obj, Pattern):
103 return "<Pattern>"
104 if hasattr(obj, "as_json"):
105 return obj.as_json()
106 if hasattr(obj, "__dict__"):
107 return obj.__dict__
108 if hasattr(obj, "__slots__"):
109 return {slot: getattr(obj, slot) for slot in obj.__slots__}
110 raise NotImplementedError(
111 "unable to json-ify {!r}".format(obj.__class__))
diff --git a/checkbox_support/parsers/cpuinfo.py b/checkbox_support/parsers/cpuinfo.py
index 2e8aa81..5a2ce6b 100644
--- a/checkbox_support/parsers/cpuinfo.py
+++ b/checkbox_support/parsers/cpuinfo.py
@@ -1,12 +1,10 @@
1#
2# This file is part of Checkbox.1# This file is part of Checkbox.
3#2#
4# Copyright 2011 Canonical Ltd.3# Copyright 2011-2022 Canonical Ltd.
5#4#
6# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
8# as published by the Free Software Foundation.7# as published by the Free Software Foundation.
9
10#8#
11# Checkbox is distributed in the hope that it will be useful,9# Checkbox is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of10# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,11 +14,6 @@
16# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1816
19from __future__ import absolute_import
20from __future__ import division
21from __future__ import print_function
22from __future__ import unicode_literals
23
24from os import uname17from os import uname
25import re18import re
2619
diff --git a/checkbox_support/parsers/cputable.py b/checkbox_support/parsers/cputable.py
index e7e652e..767d236 100644
--- a/checkbox_support/parsers/cputable.py
+++ b/checkbox_support/parsers/cputable.py
@@ -1,12 +1,10 @@
1#
2# This file is part of Checkbox.1# This file is part of Checkbox.
3#2#
4# Copyright 2011 Canonical Ltd.3# Copyright 2011-2022 Canonical Ltd.
5#4#
6# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
8# as published by the Free Software Foundation.7# as published by the Free Software Foundation.
9
10#8#
11# Checkbox is distributed in the hope that it will be useful,9# Checkbox is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of10# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,11 +14,6 @@
16# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1816
19from __future__ import absolute_import
20from __future__ import division
21from __future__ import print_function
22from __future__ import unicode_literals
23
24import re17import re
2518
2619
diff --git a/checkbox_support/parsers/dkms_info.py b/checkbox_support/parsers/dkms_info.py
index 89ba549..b23cf23 100644
--- a/checkbox_support/parsers/dkms_info.py
+++ b/checkbox_support/parsers/dkms_info.py
@@ -1,6 +1,6 @@
1# This file is part of Checkbox.1# This file is part of Checkbox.
2#2#
3# Copyright 2015 Canonical Ltd.3# Copyright 2015-2022 Canonical Ltd.
4#4#
5# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
@@ -14,11 +14,6 @@
14# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1616
17from __future__ import absolute_import
18from __future__ import division
19from __future__ import print_function
20from __future__ import unicode_literals
21
22import io17import io
23import json18import json
2419
diff --git a/checkbox_support/parsers/dmidecode.py b/checkbox_support/parsers/dmidecode.py
index 772a6df..5818be2 100644
--- a/checkbox_support/parsers/dmidecode.py
+++ b/checkbox_support/parsers/dmidecode.py
@@ -1,12 +1,10 @@
1#
2# This file is part of Checkbox.1# This file is part of Checkbox.
3#2#
4# Copyright 2011 Canonical Ltd.3# Copyright 2011-2022 Canonical Ltd.
5#4#
6# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
8# as published by the Free Software Foundation.7# as published by the Free Software Foundation.
9
10#8#
11# Checkbox is distributed in the hope that it will be useful,9# Checkbox is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of10# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,11 +14,6 @@
16# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1816
19from __future__ import absolute_import
20from __future__ import division
21from __future__ import print_function
22from __future__ import unicode_literals
23
24import io17import io
25import re18import re
26from string import hexdigits19from string import hexdigits
diff --git a/checkbox_support/parsers/efi.py b/checkbox_support/parsers/efi.py
index e452888..c77f2c2 100644
--- a/checkbox_support/parsers/efi.py
+++ b/checkbox_support/parsers/efi.py
@@ -1,12 +1,10 @@
1#
2# This file is part of Checkbox.1# This file is part of Checkbox.
3#2#
4# Copyright 2011 Canonical Ltd.3# Copyright 2011-2022 Canonical Ltd.
5#4#
6# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
8# as published by the Free Software Foundation.7# as published by the Free Software Foundation.
9
10#8#
11# Checkbox is distributed in the hope that it will be useful,9# Checkbox is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of10# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,11 +14,6 @@
16# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1816
19from __future__ import absolute_import
20from __future__ import division
21from __future__ import print_function
22from __future__ import unicode_literals
23
24import re17import re
2518
2619
diff --git a/checkbox_support/parsers/image_info.py b/checkbox_support/parsers/image_info.py
index 369792b..ff9d73c 100644
--- a/checkbox_support/parsers/image_info.py
+++ b/checkbox_support/parsers/image_info.py
@@ -1,6 +1,6 @@
1# This file is part of Checkbox.1# This file is part of Checkbox.
2#2#
3# Copyright 2011-2015 Canonical Ltd.3# Copyright 2011-2022 Canonical Ltd.
4#4#
5# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
@@ -26,11 +26,6 @@ There are 3 possible attachments containing data relevant to OEM images::
26A class is provided to parse each of these.26A class is provided to parse each of these.
27"""27"""
2828
29from __future__ import absolute_import
30from __future__ import division
31from __future__ import print_function
32from __future__ import unicode_literals
33
34import io29import io
35from xml.dom import minidom30from xml.dom import minidom
36from xml.parsers.expat import ExpatError31from xml.parsers.expat import ExpatError
diff --git a/checkbox_support/parsers/lshwjson.py b/checkbox_support/parsers/lshwjson.py
index 9be6fb1..5a57f46 100644
--- a/checkbox_support/parsers/lshwjson.py
+++ b/checkbox_support/parsers/lshwjson.py
@@ -1,12 +1,10 @@
1#
2# This file is part of Checkbox.1# This file is part of Checkbox.
3#2#
4# Copyright 2013 Canonical Ltd.3# Copyright 2013-2022 Canonical Ltd.
5#4#
6# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
8# as published by the Free Software Foundation.7# as published by the Free Software Foundation.
9
10#8#
11# Checkbox is distributed in the hope that it will be useful,9# Checkbox is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of10# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,11 +14,6 @@
16# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1816
19from __future__ import absolute_import
20from __future__ import division
21from __future__ import print_function
22from __future__ import unicode_literals
23
24import json17import json
25import logging18import logging
2619
diff --git a/checkbox_support/parsers/meminfo.py b/checkbox_support/parsers/meminfo.py
index 3264ddb..0e4dbc9 100644
--- a/checkbox_support/parsers/meminfo.py
+++ b/checkbox_support/parsers/meminfo.py
@@ -1,12 +1,10 @@
1#
2# This file is part of Checkbox.1# This file is part of Checkbox.
3#2#
4# Copyright 2011 Canonical Ltd.3# Copyright 2011-2022 Canonical Ltd.
5#4#
6# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
8# as published by the Free Software Foundation.7# as published by the Free Software Foundation.
9
10#8#
11# Checkbox is distributed in the hope that it will be useful,9# Checkbox is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of10# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,11 +14,6 @@
16# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1816
19from __future__ import absolute_import
20from __future__ import division
21from __future__ import print_function
22from __future__ import unicode_literals
23
24import re17import re
2518
2619
diff --git a/checkbox_support/parsers/modinfo.py b/checkbox_support/parsers/modinfo.py
index a26255a..dd217e9 100644
--- a/checkbox_support/parsers/modinfo.py
+++ b/checkbox_support/parsers/modinfo.py
@@ -1,6 +1,6 @@
1# This file is part of Checkbox.1# This file is part of Checkbox.
2#2#
3# Copyright 2011-2015 Canonical Ltd.3# Copyright 2011-2022 Canonical Ltd.
4#4#
5# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
@@ -14,11 +14,6 @@
14# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1616
17from __future__ import absolute_import
18from __future__ import division
19from __future__ import print_function
20from __future__ import unicode_literals
21
22import io17import io
2318
2419
diff --git a/checkbox_support/parsers/modprobe.py b/checkbox_support/parsers/modprobe.py
index 832903c..9645017 100644
--- a/checkbox_support/parsers/modprobe.py
+++ b/checkbox_support/parsers/modprobe.py
@@ -1,6 +1,6 @@
1# This file is part of Checkbox.1# This file is part of Checkbox.
2#2#
3# Copyright 2015 Canonical Ltd.3# Copyright 2015-2022 Canonical Ltd.
4#4#
5# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
@@ -14,11 +14,6 @@
14# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1616
17from __future__ import absolute_import
18from __future__ import division
19from __future__ import print_function
20from __future__ import unicode_literals
21
22import io17import io
23import re18import re
24from collections import defaultdict19from collections import defaultdict
diff --git a/checkbox_support/parsers/pactl.py b/checkbox_support/parsers/pactl.py
index 741f59b..6c79430 100644
--- a/checkbox_support/parsers/pactl.py
+++ b/checkbox_support/parsers/pactl.py
@@ -1,6 +1,6 @@
1# This file is part of Checkbox.1# This file is part of Checkbox.
2#2#
3# Copyright 2013-2019 Canonical Ltd.3# Copyright 2013-2022 Canonical Ltd.
4# Written by:4# Written by:
5# Zygmunt Krynicki <zygmunt.krynicki@canonical.com>5# Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
6# Sylvain Pineau <sylvain.pineau@canonical.com>6# Sylvain Pineau <sylvain.pineau@canonical.com>
@@ -8,7 +8,6 @@
8# Checkbox is free software: you can redistribute it and/or modify8# Checkbox is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License version 3,9# it under the terms of the GNU General Public License version 3,
10# as published by the Free Software Foundation.10# as published by the Free Software Foundation.
11
12#11#
13# Checkbox is distributed in the hope that it will be useful,12# Checkbox is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of13# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,11 +17,6 @@
18# You should have received a copy of the GNU General Public License17# You should have received a copy of the GNU General Public License
19# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.18# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
2019
21from __future__ import absolute_import
22from __future__ import division
23from __future__ import print_function
24from __future__ import unicode_literals
25
2620
27"""21"""
28:mod:`checkbox_support.parsers.pactl` -- `pactl list` parser22:mod:`checkbox_support.parsers.pactl` -- `pactl list` parser
diff --git a/checkbox_support/parsers/pci_config.py b/checkbox_support/parsers/pci_config.py
index 14d3367..fe27f20 100644
--- a/checkbox_support/parsers/pci_config.py
+++ b/checkbox_support/parsers/pci_config.py
@@ -1,6 +1,6 @@
1# This file is part of Checkbox.1# This file is part of Checkbox.
2#2#
3# Copyright 2015 Canonical Ltd.3# Copyright 2015-2022 Canonical Ltd.
4#4#
5# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
@@ -14,11 +14,6 @@
14# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1616
17from __future__ import absolute_import
18from __future__ import division
19from __future__ import print_function
20from __future__ import unicode_literals
21
22import io17import io
23import re18import re
2419
diff --git a/checkbox_support/parsers/tests/test_udevadm.py b/checkbox_support/parsers/tests/test_udevadm.py
index acb9880..d91ad69 100644
--- a/checkbox_support/parsers/tests/test_udevadm.py
+++ b/checkbox_support/parsers/tests/test_udevadm.py
@@ -1,12 +1,10 @@
1#
2# This file is part of Checkbox.1# This file is part of Checkbox.
3#2#
4# Copyright 2012-2013 Canonical Ltd.3# Copyright 2012-2022 Canonical Ltd.
5#4#
6# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
8# as published by the Free Software Foundation.7# as published by the Free Software Foundation.
9
10#8#
11# Checkbox is distributed in the hope that it will be useful,9# Checkbox is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of10# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,14 +14,9 @@
16# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1816
19from __future__ import absolute_import
20from __future__ import division
21from __future__ import print_function
22from __future__ import unicode_literals
23
24from io import StringIO17from io import StringIO
25from io import open
26from unittest import TestCase18from unittest import TestCase
19from textwrap import dedent
2720
28from pkg_resources import resource_filename21from pkg_resources import resource_filename
2922
@@ -31,22 +24,6 @@ from checkbox_support.parsers.udevadm import UdevadmParser, decode_id
31from checkbox_support.parsers.udevadm import parse_udevadm_output24from checkbox_support.parsers.udevadm import parse_udevadm_output
3225
3326
34class DeviceResult(object):
35
36 def __init__(self):
37 self.devices = []
38
39 def addDevice(self, device):
40 self.devices.append(device)
41
42 def getDevice(self, category):
43 for device in self.devices:
44 if device.category == category:
45 return device
46
47 return None
48
49
50class UdevadmDataMixIn(object):27class UdevadmDataMixIn(object):
51 """28 """
52 Mix in with a helper method to load sample udevadm data29 Mix in with a helper method to load sample udevadm data
@@ -70,16 +47,6 @@ class UdevadmDataMixIn(object):
7047
71class TestUdevadmParser(TestCase, UdevadmDataMixIn):48class TestUdevadmParser(TestCase, UdevadmDataMixIn):
7249
73 def getParser(self, string):
74 stream = StringIO(string)
75 return UdevadmParser(stream)
76
77 def getResult(self, string):
78 parser = self.getParser(string)
79 result = DeviceResult()
80 parser.run(result)
81 return result
82
83 def parse(self, name, with_lsblk=True, with_partitions=False):50 def parse(self, name, with_lsblk=True, with_partitions=False):
84 # Uncomment only for debugging purpose51 # Uncomment only for debugging purpose
85 """52 """
@@ -100,27 +67,29 @@ class TestUdevadmParser(TestCase, UdevadmDataMixIn):
100 return len([d for d in devices if d.category == category])67 return len([d for d in devices if d.category == category])
10168
102 def test_openfirmware_network(self):69 def test_openfirmware_network(self):
103 result = self.getResult("""70 stream = StringIO(dedent("""
104P: /devices/soc.0/ffe64000.ethernet71 P: /devices/soc.0/ffe64000.ethernet
105E: DEVPATH=/devices/soc.0/ffe64000.ethernet72 E: DEVPATH=/devices/soc.0/ffe64000.ethernet
106E: DRIVER=XXXXX73 E: DRIVER=XXXXX
107E: MODALIAS=of:NethernetTXXXXXCXXXXX,XXXXX74 E: MODALIAS=of:NethernetTXXXXXCXXXXX,XXXXX
108E: OF_COMPATIBLE_0=XXXXX,XXXXX75 E: OF_COMPATIBLE_0=XXXXX,XXXXX
109E: OF_COMPATIBLE_N=176 E: OF_COMPATIBLE_N=1
110E: OF_NAME=ethernet77 E: OF_NAME=ethernet
111E: OF_TYPE=XXXXX78 E: OF_TYPE=XXXXX
112E: SUBSYSTEM=platform79 E: SUBSYSTEM=platform
113E: UDEV_LOG=380 E: UDEV_LOG=3
11481
115P: /devices/soc.0/ffe64000.ethernet/net/eth182 P: /devices/soc.0/ffe64000.ethernet/net/eth1
116E: DEVPATH=/devices/soc.0/ffe64000.ethernet/net/eth183 E: DEVPATH=/devices/soc.0/ffe64000.ethernet/net/eth1
117E: IFINDEX=384 E: IFINDEX=3
118E: INTERFACE=eth185 E: INTERFACE=eth1
119E: SUBSYSTEM=net86 E: SUBSYSTEM=net
120E: UDEV_LOG=387 E: UDEV_LOG=3
121""")88 """))
122 device = result.getDevice("NETWORK")89 parser = UdevadmParser(stream)
123 self.assertTrue(device)90 devices = parser.run()
91 self.assertEqual(devices[0].category, "NETWORK")
92
12493
125 def test_DELL_INSPIRON3521_TOUCHSCREEN(self):94 def test_DELL_INSPIRON3521_TOUCHSCREEN(self):
126 """95 """
diff --git a/checkbox_support/parsers/tests/test_version.py b/checkbox_support/parsers/tests/test_version.py
127deleted file mode 10064496deleted file mode 100644
index 2404430..0000000
--- a/checkbox_support/parsers/tests/test_version.py
+++ /dev/null
@@ -1,33 +0,0 @@
1# -*- coding: utf-8 -*-
2#
3# This file is part of Checkbox.
4#
5# Copyright 2014 Canonical Ltd.
6#
7# Checkbox is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License version 3,
9# as published by the Free Software Foundation.
10
11#
12# Checkbox is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
19
20from __future__ import absolute_import
21from __future__ import division
22from __future__ import print_function
23from __future__ import unicode_literals
24
25from unittest import TestCase
26
27
28class TestSubmissionModuleVersion(TestCase):
29
30 def testVersion(self):
31 from checkbox_support import parsers
32 ver = getattr(parsers, "__version__")
33 self.assertTrue(ver)
diff --git a/checkbox_support/parsers/udevadm.py b/checkbox_support/parsers/udevadm.py
index 4c089b8..057369c 100644
--- a/checkbox_support/parsers/udevadm.py
+++ b/checkbox_support/parsers/udevadm.py
@@ -1201,7 +1201,7 @@ class UdevadmParser(object):
1201 def getAttributes(self, path):1201 def getAttributes(self, path):
1202 return {}1202 return {}
12031203
1204 def run(self, result):1204 def run(self):
1205 # Some attribute lines have a space character after the1205 # Some attribute lines have a space character after the
1206 # ':', others don't have it (see udevadm-info.c).1206 # ':', others don't have it (see udevadm-info.c).
1207 line_pattern = re.compile(r"(?P<key>[A-Z]):\s*(?P<value>.*)")1207 line_pattern = re.compile(r"(?P<key>[A-Z]):\s*(?P<value>.*)")
@@ -1395,6 +1395,7 @@ class UdevadmParser(object):
1395 # Remove Virtal CDROM devices1395 # Remove Virtal CDROM devices
1396 if not [k for k in device._environment if "ID_CDROM_" in k]:1396 if not [k for k in device._environment if "ID_CDROM_" in k]:
1397 self.devices.pop(device._raw_path, None)1397 self.devices.pop(device._raw_path, None)
1398 return list(self.devices.values())
13981399
1399 [result.addDevice(device) for device in self.devices.values()]1400 [result.addDevice(device) for device in self.devices.values()]
14001401
@@ -1426,14 +1427,6 @@ def known_to_be_video_device(vendor_id, product_id, pci_class, pci_subclass):
1426 return product_id in [0x0152, 0x0412, 0x0402]1427 return product_id in [0x0152, 0x0412, 0x0402]
14271428
14281429
1429class UdevResult(object):
1430 def __init__(self):
1431 self.devices = []
1432
1433 def addDevice(self, device):
1434 self.devices.append(device)
1435
1436
1437def parse_udevadm_output(output, lsblk=None, list_partitions=False, bits=None):1430def parse_udevadm_output(output, lsblk=None, list_partitions=False, bits=None):
1438 """1431 """
1439 Parse output of `LANG=C udevadm info --export-db`1432 Parse output of `LANG=C udevadm info --export-db`
@@ -1448,7 +1441,4 @@ def parse_udevadm_output(output, lsblk=None, list_partitions=False, bits=None):
1448 universal_newlines=True)1441 universal_newlines=True)
1449 except CalledProcessError:1442 except CalledProcessError:
1450 lsblk = ''1443 lsblk = ''
1451 udev = UdevadmParser(output, lsblk, list_partitions, bits)1444 return UdevadmParser(output, lsblk, list_partitions, bits).run()
1452 result = UdevResult()
1453 udev.run(result)
1454 return result.devices
diff --git a/checkbox_support/parsers/xinput.py b/checkbox_support/parsers/xinput.py
index d29af68..bc6d844 100644
--- a/checkbox_support/parsers/xinput.py
+++ b/checkbox_support/parsers/xinput.py
@@ -1,13 +1,10 @@
1# -*- coding: utf-8 -*-
2#
3# This file is part of Checkbox.1# This file is part of Checkbox.
4#2#
5# Copyright 2012 Canonical Ltd.3# Copyright 2012-2022 Canonical Ltd.
6#4#
7# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
9# as published by the Free Software Foundation.7# as published by the Free Software Foundation.
10
11#8#
12# Checkbox is distributed in the hope that it will be useful,9# Checkbox is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of10# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,11 +14,6 @@
17# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
18# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1916
20from __future__ import absolute_import
21from __future__ import division
22from __future__ import print_function
23from __future__ import unicode_literals
24
25from string import ascii_letters17from string import ascii_letters
26from string import ascii_uppercase18from string import ascii_uppercase
27import re19import re
diff --git a/checkbox_support/scripts/audio_settings.py b/checkbox_support/scripts/audio_settings.py
index 1b3974c..cd76d08 100644
--- a/checkbox_support/scripts/audio_settings.py
+++ b/checkbox_support/scripts/audio_settings.py
@@ -1,4 +1,3 @@
1#
2# This file is part of Checkbox.1# This file is part of Checkbox.
3#2#
4# Copyright 2013-2020 Canonical Ltd.3# Copyright 2013-2020 Canonical Ltd.
@@ -6,7 +5,6 @@
6# Checkbox is free software: you can redistribute it and/or modify5# Checkbox is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 3,6# it under the terms of the GNU General Public License version 3,
8# as published by the Free Software Foundation.7# as published by the Free Software Foundation.
9
10#8#
11# Checkbox is distributed in the hope that it will be useful,9# Checkbox is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of10# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,11 +14,6 @@
16# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.15# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1816
19from __future__ import absolute_import
20from __future__ import division
21from __future__ import print_function
22from __future__ import unicode_literals
23
24from argparse import ArgumentParser17from argparse import ArgumentParser
25from subprocess import check_output, check_call, CalledProcessError18from subprocess import check_output, check_call, CalledProcessError
26from io import open19from io import open
diff --git a/checkbox_support/scripts/gputest_benchmark.py b/checkbox_support/scripts/gputest_benchmark.py
index 46bd34e..7abb2a3 100644
--- a/checkbox_support/scripts/gputest_benchmark.py
+++ b/checkbox_support/scripts/gputest_benchmark.py
@@ -1,13 +1,12 @@
1# This file is part of Checkbox.1# This file is part of Checkbox.
2#2#
3# Copyright 2013 Canonical Ltd.3# Copyright 2013-2022 Canonical Ltd.
4# Written by:4# Written by:
5# Sylvain Pineau <sylvain.pineau@canonical.com>5# Sylvain Pineau <sylvain.pineau@canonical.com>
6#6#
7# Checkbox is free software: you can redistribute it and/or modify7# Checkbox is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License version 3,8# it under the terms of the GNU General Public License version 3,
9# as published by the Free Software Foundation.9# as published by the Free Software Foundation.
10
11#10#
12# Checkbox is distributed in the hope that it will be useful,11# Checkbox is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of12# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,11 +16,6 @@
17# You should have received a copy of the GNU General Public License16# You should have received a copy of the GNU General Public License
18# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1918
20from __future__ import absolute_import
21from __future__ import division
22from __future__ import print_function
23from __future__ import unicode_literals
24
25from io import open19from io import open
26from subprocess import check_output, CalledProcessError20from subprocess import check_output, CalledProcessError
27from tempfile import TemporaryDirectory21from tempfile import TemporaryDirectory
diff --git a/checkbox_support/tests/__init__.py b/checkbox_support/tests/__init__.py
index 2ade626..615bd52 100644
--- a/checkbox_support/tests/__init__.py
+++ b/checkbox_support/tests/__init__.py
@@ -29,6 +29,7 @@ from __future__ import unicode_literals
2929
30from inspect import getabsfile30from inspect import getabsfile
31from unittest.loader import defaultTestLoader31from unittest.loader import defaultTestLoader
32from unittest import TestSuite
32import os33import os
3334
34import checkbox_support35import checkbox_support
@@ -42,7 +43,16 @@ def load_unit_tests():
42 # python modules that start with the word 'test_' .43 # python modules that start with the word 'test_' .
43 start_dir = os.path.dirname(getabsfile(checkbox_support))44 start_dir = os.path.dirname(getabsfile(checkbox_support))
44 top_level_dir = os.path.normpath(os.path.join(start_dir, '..'))45 top_level_dir = os.path.normpath(os.path.join(start_dir, '..'))
45 return defaultTestLoader.discover(start_dir, top_level_dir=top_level_dir)46 test_suite = TestSuite()
47 for path in os.listdir(start_dir):
48 # skip tests that come from a vendorized code
49 if path in ('__pycache__', 'vendor'):
50 continue
51 path = os.path.join(start_dir, path)
52 if os.path.isdir(path):
53 test_suite.addTests(
54 defaultTestLoader.discover(path, top_level_dir=top_level_dir))
55 return test_suite
4656
4757
48def test_suite():58def test_suite():
diff --git a/checkbox_support/udev.py b/checkbox_support/udev.py
index a47c5c1..897ec08 100644
--- a/checkbox_support/udev.py
+++ b/checkbox_support/udev.py
@@ -1,13 +1,12 @@
1# This file is part of Checkbox.1# This file is part of Checkbox.
2#2#
3# Copyright 2012 Canonical Ltd.3# Copyright 2012-2022 Canonical Ltd.
4# Written by:4# Written by:
5# Zygmunt Krynicki <zygmunt.krynicki@canonical.com>5# Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
6#6#
7# Checkbox is free software: you can redistribute it and/or modify7# Checkbox is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License version 3,8# it under the terms of the GNU General Public License version 3,
9# as published by the Free Software Foundation.9# as published by the Free Software Foundation.
10
11#10#
12# Checkbox is distributed in the hope that it will be useful,11# Checkbox is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of12# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,11 +16,6 @@
17# You should have received a copy of the GNU General Public License16# You should have received a copy of the GNU General Public License
18# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1918
20from __future__ import absolute_import
21from __future__ import division
22from __future__ import print_function
23from __future__ import unicode_literals
24
25"""19"""
26checkbox_support.udev20checkbox_support.udev
27=====================21=====================
diff --git a/setup.py b/setup.py
index 673f4f0..9d1f916 100755
--- a/setup.py
+++ b/setup.py
@@ -93,6 +93,7 @@ setup(
93 "checkbox_support.scripts.eddystone_scanner:main"),93 "checkbox_support.scripts.eddystone_scanner:main"),
94 ("checkbox-support-lsusb="94 ("checkbox-support-lsusb="
95 "checkbox_support.scripts.lsusb:main"),95 "checkbox_support.scripts.lsusb:main"),
96 ("checkbox-support-parse=checkbox_support.parsers:main"),
96 ],97 ],
97 },98 },
98)99)

Subscribers

People subscribed via source and target branches