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 | 1 | #!/usr/bin/python3 | ||
7 | 2 | # -*- coding: utf-8 -*- | ||
8 | 3 | # | ||
9 | 4 | # Python-XRandR provides a high level API for the XRandR extension of the | 1 | # Python-XRandR provides a high level API for the XRandR extension of the |
10 | 5 | # X.org server. XRandR allows to configure resolution, refresh rate, rotation | 2 | # X.org server. XRandR allows to configure resolution, refresh rate, rotation |
11 | 6 | # of the screen and multiple outputs of graphics cards. | 3 | # of the screen and multiple outputs of graphics cards. |
12 | @@ -36,11 +33,6 @@ | |||
13 | 36 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | 33 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
14 | 37 | # MA 02110-1301 USA | 34 | # MA 02110-1301 USA |
15 | 38 | 35 | ||
16 | 39 | from __future__ import absolute_import | ||
17 | 40 | from __future__ import division | ||
18 | 41 | from __future__ import print_function | ||
19 | 42 | from __future__ import unicode_literals | ||
20 | 43 | |||
21 | 44 | from ctypes import ( | 36 | from ctypes import ( |
22 | 45 | POINTER, | 37 | POINTER, |
23 | 46 | Structure, | 38 | 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 | 1 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
30 | 2 | # | 2 | # |
32 | 3 | # Copyright 2012 Canonical Ltd. | 3 | # Copyright 2012-2022 Canonical Ltd. |
33 | 4 | # Written by: | 4 | # Written by: |
34 | 5 | # Zygmunt Krynicki <zygmunt.krynicki@canonical.com> | 5 | # Zygmunt Krynicki <zygmunt.krynicki@canonical.com> |
35 | 6 | # | 6 | # |
36 | 7 | # Checkbox is free software: you can redistribute it and/or modify | 7 | # Checkbox is free software: you can redistribute it and/or modify |
37 | 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, |
38 | 9 | # as published by the Free Software Foundation. | 9 | # as published by the Free Software Foundation. |
39 | 10 | |||
40 | 11 | # | 10 | # |
41 | 12 | # Checkbox is distributed in the hope that it will be useful, | 11 | # Checkbox is distributed in the hope that it will be useful, |
42 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
43 | @@ -16,7 +15,6 @@ | |||
44 | 16 | # | 15 | # |
45 | 17 | # You should have received a copy of the GNU General Public License | 16 | # You should have received a copy of the GNU General Public License |
46 | 18 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 17 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
47 | 19 | # | ||
48 | 20 | """ | 18 | """ |
49 | 21 | checkbox_support.dbus | 19 | checkbox_support.dbus |
50 | 22 | ===================== | 20 | ===================== |
51 | @@ -24,11 +22,6 @@ checkbox_support.dbus | |||
52 | 24 | Utility modules for working with various things accessible over dbus | 22 | Utility modules for working with various things accessible over dbus |
53 | 25 | """ | 23 | """ |
54 | 26 | 24 | ||
55 | 27 | from __future__ import absolute_import | ||
56 | 28 | from __future__ import division | ||
57 | 29 | from __future__ import print_function | ||
58 | 30 | from __future__ import unicode_literals | ||
59 | 31 | |||
60 | 32 | import logging | 25 | import logging |
61 | 33 | 26 | ||
62 | 34 | from dbus import SystemBus | 27 | 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 | 13 | # | 13 | # |
69 | 14 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
70 | 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/>. |
71 | 16 | |||
72 | 17 | """ | 16 | """ |
73 | 18 | checkbox_support.dbus.udisks2 | 17 | checkbox_support.dbus.udisks2 |
74 | 19 | ===================== | 18 | ===================== |
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 | 14 | # | 14 | # |
81 | 15 | # You should have received a copy of the GNU General Public License | 15 | # You should have received a copy of the GNU General Public License |
82 | 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/>. |
83 | 17 | # | ||
84 | 18 | """ | 17 | """ |
85 | 19 | Support functions related to disk devices for Checkbox. | 18 | Support functions related to disk devices for Checkbox. |
86 | 20 | """ | 19 | """ |
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 | 15 | # | 15 | # |
93 | 16 | # You should have received a copy of the GNU General Public License | 16 | # You should have received a copy of the GNU General Public License |
94 | 17 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 17 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
95 | 18 | |||
96 | 19 | """ | 18 | """ |
97 | 20 | checkbox_support.helpers.human_readable_bytes | 19 | checkbox_support.helpers.human_readable_bytes |
98 | 21 | ============================================= | 20 | ============================================= |
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 | 1 | # | ||
105 | 2 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
106 | 3 | # | 2 | # |
108 | 4 | # Copyright 2008 Canonical Ltd. | 3 | # Copyright 2008-2022 Canonical Ltd. |
109 | 5 | # | 4 | # |
110 | 6 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
111 | 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, |
112 | 8 | # as published by the Free Software Foundation. | 7 | # as published by the Free Software Foundation. |
113 | 9 | |||
114 | 10 | # | 8 | # |
115 | 11 | # Checkbox is distributed in the hope that it will be useful, | 9 | # Checkbox is distributed in the hope that it will be useful, |
116 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
117 | @@ -16,11 +14,6 @@ | |||
118 | 16 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
119 | 17 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
120 | 18 | 16 | ||
121 | 19 | from __future__ import absolute_import | ||
122 | 20 | from __future__ import division | ||
123 | 21 | from __future__ import print_function | ||
124 | 22 | from __future__ import unicode_literals | ||
125 | 23 | |||
126 | 24 | from struct import calcsize | 17 | from struct import calcsize |
127 | 25 | 18 | ||
128 | 26 | 19 | ||
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 | 1 | # | ||
135 | 2 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
136 | 3 | # | 2 | # |
138 | 4 | # Copyright 2008 Canonical Ltd. | 3 | # Copyright 2008-2022 Canonical Ltd. |
139 | 5 | # | 4 | # |
140 | 6 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
141 | 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, |
142 | 8 | # as published by the Free Software Foundation. | 7 | # as published by the Free Software Foundation. |
143 | 9 | |||
144 | 10 | # | 8 | # |
145 | 11 | # Checkbox is distributed in the hope that it will be useful, | 9 | # Checkbox is distributed in the hope that it will be useful, |
146 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
147 | @@ -16,11 +14,6 @@ | |||
148 | 16 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
149 | 17 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
150 | 18 | 16 | ||
151 | 19 | from __future__ import absolute_import | ||
152 | 20 | from __future__ import division | ||
153 | 21 | from __future__ import print_function | ||
154 | 22 | from __future__ import unicode_literals | ||
155 | 23 | |||
156 | 24 | import re | 17 | import re |
157 | 25 | from datetime import datetime, timedelta | 18 | from datetime import datetime, timedelta |
158 | 26 | 19 | ||
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 | 1 | # | ||
165 | 2 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
166 | 3 | # | 2 | # |
168 | 4 | # Copyright 2008 Canonical Ltd. | 3 | # Copyright 2008-2022 Canonical Ltd. |
169 | 5 | # | 4 | # |
170 | 6 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
171 | 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, |
172 | 8 | # as published by the Free Software Foundation. | 7 | # as published by the Free Software Foundation. |
173 | 9 | |||
174 | 10 | # | 8 | # |
175 | 11 | # Checkbox is distributed in the hope that it will be useful, | 9 | # Checkbox is distributed in the hope that it will be useful, |
176 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
177 | @@ -16,11 +14,6 @@ | |||
178 | 16 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
179 | 17 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
180 | 18 | 16 | ||
181 | 19 | from __future__ import absolute_import | ||
182 | 20 | from __future__ import division | ||
183 | 21 | from __future__ import print_function | ||
184 | 22 | from __future__ import unicode_literals | ||
185 | 23 | |||
186 | 24 | import os | 17 | import os |
187 | 25 | 18 | ||
188 | 26 | from checkbox_support.lib.conversion import string_to_type | 19 | 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 | 1 | # | ||
195 | 2 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
196 | 3 | # | 2 | # |
197 | 4 | # Copyright 2008 Canonical Ltd. | 3 | # Copyright 2008 Canonical Ltd. |
198 | @@ -6,7 +5,6 @@ | |||
199 | 6 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
200 | 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, |
201 | 8 | # as published by the Free Software Foundation. | 7 | # as published by the Free Software Foundation. |
202 | 9 | |||
203 | 10 | # | 8 | # |
204 | 11 | # Checkbox is distributed in the hope that it will be useful, | 9 | # Checkbox is distributed in the hope that it will be useful, |
205 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | # 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 | 1 | # | ||
212 | 2 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
213 | 3 | # | 2 | # |
214 | 4 | # Copyright 2008 Canonical Ltd. | 3 | # Copyright 2008 Canonical Ltd. |
215 | @@ -6,7 +5,6 @@ | |||
216 | 6 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
217 | 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, |
218 | 8 | # as published by the Free Software Foundation. | 7 | # as published by the Free Software Foundation. |
219 | 9 | |||
220 | 10 | # | 8 | # |
221 | 11 | # Checkbox is distributed in the hope that it will be useful, | 9 | # Checkbox is distributed in the hope that it will be useful, |
222 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
223 | @@ -17,12 +15,6 @@ | |||
224 | 17 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
225 | 18 | 16 | ||
226 | 19 | 17 | ||
227 | 20 | from __future__ import absolute_import | ||
228 | 21 | from __future__ import division | ||
229 | 22 | from __future__ import print_function | ||
230 | 23 | from __future__ import unicode_literals | ||
231 | 24 | |||
232 | 25 | |||
233 | 26 | # See http://pciids.sourceforge.net/pci.ids.bz2 | 18 | # See http://pciids.sourceforge.net/pci.ids.bz2 |
234 | 27 | class Pci(object): | 19 | class Pci(object): |
235 | 28 | 20 | ||
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 | 1 | # | ||
242 | 2 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
243 | 3 | # | 2 | # |
245 | 4 | # Copyright 2012 Canonical Ltd. | 3 | # Copyright 2012-2022 Canonical Ltd. |
246 | 5 | # | 4 | # |
247 | 6 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
248 | 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, |
249 | 8 | # as published by the Free Software Foundation. | 7 | # as published by the Free Software Foundation. |
250 | 9 | |||
251 | 10 | # | 8 | # |
252 | 11 | # Checkbox is distributed in the hope that it will be useful, | 9 | # Checkbox is distributed in the hope that it will be useful, |
253 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
254 | @@ -16,11 +14,6 @@ | |||
255 | 16 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
256 | 17 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
257 | 18 | 16 | ||
258 | 19 | from __future__ import absolute_import | ||
259 | 20 | from __future__ import division | ||
260 | 21 | from __future__ import print_function | ||
261 | 22 | from __future__ import unicode_literals | ||
262 | 23 | |||
263 | 24 | __all__ = ["tzutc"] | 17 | __all__ = ["tzutc"] |
264 | 25 | 18 | ||
265 | 26 | from datetime import timedelta | 19 | 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 | 1 | # | ||
272 | 2 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
273 | 3 | # | 2 | # |
275 | 4 | # Copyright 2008 Canonical Ltd. | 3 | # Copyright 2008-2022 Canonical Ltd. |
276 | 5 | # | 4 | # |
277 | 6 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
278 | 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, |
279 | 8 | # as published by the Free Software Foundation. | 7 | # as published by the Free Software Foundation. |
280 | 9 | |||
281 | 10 | # | 8 | # |
282 | 11 | # Checkbox is distributed in the hope that it will be useful, | 9 | # Checkbox is distributed in the hope that it will be useful, |
283 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
284 | @@ -16,11 +14,6 @@ | |||
285 | 16 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
286 | 17 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
287 | 18 | 16 | ||
288 | 19 | from __future__ import absolute_import | ||
289 | 20 | from __future__ import division | ||
290 | 21 | from __future__ import print_function | ||
291 | 22 | from __future__ import unicode_literals | ||
292 | 23 | |||
293 | 24 | 17 | ||
294 | 25 | # See http://www.linux-usb.org/usb.ids | 18 | # See http://www.linux-usb.org/usb.ids |
295 | 26 | class Usb(object): | 19 | 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 @@ | |||
312 | 1 | from __future__ import absolute_import | 1 | # This file is part of Checkbox. |
313 | 2 | from __future__ import division | 2 | # |
314 | 3 | from __future__ import print_function | 3 | # Copyright 2022 Canonical Ltd. |
315 | 4 | from __future__ import unicode_literals | 4 | # Written by: |
316 | 5 | 5 | # Maciej Kisielewski <maciej.kisielewski@canonical.com> | |
317 | 6 | # The version is an incrementing number, if the version changes it means | 6 | # |
318 | 7 | # one of the parser components has changed and may produce different | 7 | # Checkbox is free software: you can redistribute it and/or modify |
319 | 8 | # results for a given parsable input. | 8 | # it under the terms of the GNU General Public License version 3, |
320 | 9 | # This should be updated manually when a parser component changes, note | 9 | # as published by the Free Software Foundation. |
321 | 10 | # that this includes changes to any module under checkbox.parsers. | 10 | # |
322 | 11 | __version__ = '3' | 11 | # Checkbox is distributed in the hope that it will be useful, |
323 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
324 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
325 | 14 | # GNU General Public License for more details. | ||
326 | 15 | # | ||
327 | 16 | # You should have received a copy of the GNU General Public License | ||
328 | 17 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | ||
329 | 18 | """ | ||
330 | 19 | This module provides an entry point to checkbox-support-parse. | ||
331 | 20 | |||
332 | 21 | The commands turns an output of system commands and turns them into json. | ||
333 | 22 | When a new parser is added, it should be added to AVAILABLE_PARSER mapping." | ||
334 | 23 | """ | ||
335 | 24 | |||
336 | 25 | import io | ||
337 | 26 | import json | ||
338 | 27 | import re | ||
339 | 28 | import sys | ||
340 | 29 | |||
341 | 30 | from argparse import ArgumentParser | ||
342 | 31 | |||
343 | 32 | from checkbox_support.parsers import dkms_info | ||
344 | 33 | from checkbox_support.parsers import dmidecode | ||
345 | 34 | from checkbox_support.parsers import image_info | ||
346 | 35 | from checkbox_support.parsers import kernel_cmdline | ||
347 | 36 | from checkbox_support.parsers import modinfo | ||
348 | 37 | from checkbox_support.parsers import modprobe | ||
349 | 38 | from checkbox_support.parsers import pactl | ||
350 | 39 | from checkbox_support.parsers import pci_config | ||
351 | 40 | from checkbox_support.parsers import udevadm | ||
352 | 41 | |||
353 | 42 | AVAILABLE_PARSERS = { | ||
354 | 43 | 'bto': image_info.parse_bto_attachment_output, | ||
355 | 44 | 'buildstamp': image_info.parse_buildstamp_attachment_output, | ||
356 | 45 | 'dkms': dkms_info.parse_dkms_info, | ||
357 | 46 | 'dmidecode': dmidecode.parse_dmidecode_output, | ||
358 | 47 | 'kernelcmdline': kernel_cmdline.parse_kernel_cmdline, | ||
359 | 48 | 'modinfo': modinfo.parse_modinfo_attachment_output, | ||
360 | 49 | 'modprobe': modprobe.parse_modprobe_d_output, | ||
361 | 50 | 'pactl-list': pactl.parse_pactl_output, | ||
362 | 51 | 'pci-subsys-id': pci_config.parse_pci_subsys_id, | ||
363 | 52 | 'recovery-info': image_info.parse_recovery_info_attachment_output, | ||
364 | 53 | 'udevadm': udevadm.parse_udevadm_output, | ||
365 | 54 | } | ||
366 | 55 | PARSER_LIST = sorted(list(AVAILABLE_PARSERS.keys())) | ||
367 | 56 | Pattern = type(re.compile("")) | ||
368 | 57 | |||
369 | 58 | |||
370 | 59 | def main(): | ||
371 | 60 | """Entry point to the program.""" | ||
372 | 61 | arg_parser = ArgumentParser( | ||
373 | 62 | description="parse stdin with the specified parser") | ||
374 | 63 | arg_parser.add_argument( | ||
375 | 64 | "parser_name", metavar="PARSER-NAME", | ||
376 | 65 | choices=['?'] + PARSER_LIST, | ||
377 | 66 | help="Name of the parser to use") | ||
378 | 67 | args = arg_parser.parse_args() | ||
379 | 68 | if args.parser_name == '?': | ||
380 | 69 | print("The following parsers are available:") | ||
381 | 70 | print("\n".join(PARSER_LIST)) | ||
382 | 71 | raise SystemExit() | ||
383 | 72 | parser = AVAILABLE_PARSERS[args.parser_name] | ||
384 | 73 | stdin = sys.stdin | ||
385 | 74 | with io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8') as stdin: | ||
386 | 75 | try: | ||
387 | 76 | text = stdin.read() | ||
388 | 77 | print(run_parsing(parser, text)) | ||
389 | 78 | except UnicodeDecodeError as exc: | ||
390 | 79 | msg = "Failed to decode input stream: {}".format(str(exc)) | ||
391 | 80 | raise SystemExit(msg) from exc | ||
392 | 81 | |||
393 | 82 | |||
394 | 83 | def run_parsing(parser_fn, text): | ||
395 | 84 | """Do the actual parsing.""" | ||
396 | 85 | try: | ||
397 | 86 | ast = parser_fn(text) | ||
398 | 87 | return json.dumps( | ||
399 | 88 | ast, indent=4, sort_keys=True, default=_json_fallback) | ||
400 | 89 | except Exception as exc: | ||
401 | 90 | msg = "Failed to parse the text: {}".format(str(exc)) | ||
402 | 91 | raise SystemExit(msg) from exc | ||
403 | 92 | |||
404 | 93 | |||
405 | 94 | def _json_fallback(obj): | ||
406 | 95 | """ | ||
407 | 96 | Helper method to convert arbitrary objects to their JSON | ||
408 | 97 | representation. | ||
409 | 98 | |||
410 | 99 | Anything that has a 'as_json' attribute will be converted to the result | ||
411 | 100 | of calling that method. For all other objects __dict__ is returned. | ||
412 | 101 | """ | ||
413 | 102 | if isinstance(obj, Pattern): | ||
414 | 103 | return "<Pattern>" | ||
415 | 104 | if hasattr(obj, "as_json"): | ||
416 | 105 | return obj.as_json() | ||
417 | 106 | if hasattr(obj, "__dict__"): | ||
418 | 107 | return obj.__dict__ | ||
419 | 108 | if hasattr(obj, "__slots__"): | ||
420 | 109 | return {slot: getattr(obj, slot) for slot in obj.__slots__} | ||
421 | 110 | raise NotImplementedError( | ||
422 | 111 | "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 | 1 | # | ||
429 | 2 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
430 | 3 | # | 2 | # |
432 | 4 | # Copyright 2011 Canonical Ltd. | 3 | # Copyright 2011-2022 Canonical Ltd. |
433 | 5 | # | 4 | # |
434 | 6 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
435 | 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, |
436 | 8 | # as published by the Free Software Foundation. | 7 | # as published by the Free Software Foundation. |
437 | 9 | |||
438 | 10 | # | 8 | # |
439 | 11 | # Checkbox is distributed in the hope that it will be useful, | 9 | # Checkbox is distributed in the hope that it will be useful, |
440 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
441 | @@ -16,11 +14,6 @@ | |||
442 | 16 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
443 | 17 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
444 | 18 | 16 | ||
445 | 19 | from __future__ import absolute_import | ||
446 | 20 | from __future__ import division | ||
447 | 21 | from __future__ import print_function | ||
448 | 22 | from __future__ import unicode_literals | ||
449 | 23 | |||
450 | 24 | from os import uname | 17 | from os import uname |
451 | 25 | import re | 18 | import re |
452 | 26 | 19 | ||
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 | 1 | # | ||
459 | 2 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
460 | 3 | # | 2 | # |
462 | 4 | # Copyright 2011 Canonical Ltd. | 3 | # Copyright 2011-2022 Canonical Ltd. |
463 | 5 | # | 4 | # |
464 | 6 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
465 | 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, |
466 | 8 | # as published by the Free Software Foundation. | 7 | # as published by the Free Software Foundation. |
467 | 9 | |||
468 | 10 | # | 8 | # |
469 | 11 | # Checkbox is distributed in the hope that it will be useful, | 9 | # Checkbox is distributed in the hope that it will be useful, |
470 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
471 | @@ -16,11 +14,6 @@ | |||
472 | 16 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
473 | 17 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
474 | 18 | 16 | ||
475 | 19 | from __future__ import absolute_import | ||
476 | 20 | from __future__ import division | ||
477 | 21 | from __future__ import print_function | ||
478 | 22 | from __future__ import unicode_literals | ||
479 | 23 | |||
480 | 24 | import re | 17 | import re |
481 | 25 | 18 | ||
482 | 26 | 19 | ||
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 | 1 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
489 | 2 | # | 2 | # |
491 | 3 | # Copyright 2015 Canonical Ltd. | 3 | # Copyright 2015-2022 Canonical Ltd. |
492 | 4 | # | 4 | # |
493 | 5 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
494 | 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, |
495 | @@ -14,11 +14,6 @@ | |||
496 | 14 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
497 | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
498 | 16 | 16 | ||
499 | 17 | from __future__ import absolute_import | ||
500 | 18 | from __future__ import division | ||
501 | 19 | from __future__ import print_function | ||
502 | 20 | from __future__ import unicode_literals | ||
503 | 21 | |||
504 | 22 | import io | 17 | import io |
505 | 23 | import json | 18 | import json |
506 | 24 | 19 | ||
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 | 1 | # | ||
513 | 2 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
514 | 3 | # | 2 | # |
516 | 4 | # Copyright 2011 Canonical Ltd. | 3 | # Copyright 2011-2022 Canonical Ltd. |
517 | 5 | # | 4 | # |
518 | 6 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
519 | 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, |
520 | 8 | # as published by the Free Software Foundation. | 7 | # as published by the Free Software Foundation. |
521 | 9 | |||
522 | 10 | # | 8 | # |
523 | 11 | # Checkbox is distributed in the hope that it will be useful, | 9 | # Checkbox is distributed in the hope that it will be useful, |
524 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
525 | @@ -16,11 +14,6 @@ | |||
526 | 16 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
527 | 17 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
528 | 18 | 16 | ||
529 | 19 | from __future__ import absolute_import | ||
530 | 20 | from __future__ import division | ||
531 | 21 | from __future__ import print_function | ||
532 | 22 | from __future__ import unicode_literals | ||
533 | 23 | |||
534 | 24 | import io | 17 | import io |
535 | 25 | import re | 18 | import re |
536 | 26 | from string import hexdigits | 19 | 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 | 1 | # | ||
543 | 2 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
544 | 3 | # | 2 | # |
546 | 4 | # Copyright 2011 Canonical Ltd. | 3 | # Copyright 2011-2022 Canonical Ltd. |
547 | 5 | # | 4 | # |
548 | 6 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
549 | 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, |
550 | 8 | # as published by the Free Software Foundation. | 7 | # as published by the Free Software Foundation. |
551 | 9 | |||
552 | 10 | # | 8 | # |
553 | 11 | # Checkbox is distributed in the hope that it will be useful, | 9 | # Checkbox is distributed in the hope that it will be useful, |
554 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
555 | @@ -16,11 +14,6 @@ | |||
556 | 16 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
557 | 17 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
558 | 18 | 16 | ||
559 | 19 | from __future__ import absolute_import | ||
560 | 20 | from __future__ import division | ||
561 | 21 | from __future__ import print_function | ||
562 | 22 | from __future__ import unicode_literals | ||
563 | 23 | |||
564 | 24 | import re | 17 | import re |
565 | 25 | 18 | ||
566 | 26 | 19 | ||
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 | 1 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
573 | 2 | # | 2 | # |
575 | 3 | # Copyright 2011-2015 Canonical Ltd. | 3 | # Copyright 2011-2022 Canonical Ltd. |
576 | 4 | # | 4 | # |
577 | 5 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
578 | 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, |
579 | @@ -26,11 +26,6 @@ There are 3 possible attachments containing data relevant to OEM images:: | |||
580 | 26 | A class is provided to parse each of these. | 26 | A class is provided to parse each of these. |
581 | 27 | """ | 27 | """ |
582 | 28 | 28 | ||
583 | 29 | from __future__ import absolute_import | ||
584 | 30 | from __future__ import division | ||
585 | 31 | from __future__ import print_function | ||
586 | 32 | from __future__ import unicode_literals | ||
587 | 33 | |||
588 | 34 | import io | 29 | import io |
589 | 35 | from xml.dom import minidom | 30 | from xml.dom import minidom |
590 | 36 | from xml.parsers.expat import ExpatError | 31 | 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 | 1 | # | ||
597 | 2 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
598 | 3 | # | 2 | # |
600 | 4 | # Copyright 2013 Canonical Ltd. | 3 | # Copyright 2013-2022 Canonical Ltd. |
601 | 5 | # | 4 | # |
602 | 6 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
603 | 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, |
604 | 8 | # as published by the Free Software Foundation. | 7 | # as published by the Free Software Foundation. |
605 | 9 | |||
606 | 10 | # | 8 | # |
607 | 11 | # Checkbox is distributed in the hope that it will be useful, | 9 | # Checkbox is distributed in the hope that it will be useful, |
608 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
609 | @@ -16,11 +14,6 @@ | |||
610 | 16 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
611 | 17 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
612 | 18 | 16 | ||
613 | 19 | from __future__ import absolute_import | ||
614 | 20 | from __future__ import division | ||
615 | 21 | from __future__ import print_function | ||
616 | 22 | from __future__ import unicode_literals | ||
617 | 23 | |||
618 | 24 | import json | 17 | import json |
619 | 25 | import logging | 18 | import logging |
620 | 26 | 19 | ||
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 | 1 | # | ||
627 | 2 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
628 | 3 | # | 2 | # |
630 | 4 | # Copyright 2011 Canonical Ltd. | 3 | # Copyright 2011-2022 Canonical Ltd. |
631 | 5 | # | 4 | # |
632 | 6 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
633 | 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, |
634 | 8 | # as published by the Free Software Foundation. | 7 | # as published by the Free Software Foundation. |
635 | 9 | |||
636 | 10 | # | 8 | # |
637 | 11 | # Checkbox is distributed in the hope that it will be useful, | 9 | # Checkbox is distributed in the hope that it will be useful, |
638 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
639 | @@ -16,11 +14,6 @@ | |||
640 | 16 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
641 | 17 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
642 | 18 | 16 | ||
643 | 19 | from __future__ import absolute_import | ||
644 | 20 | from __future__ import division | ||
645 | 21 | from __future__ import print_function | ||
646 | 22 | from __future__ import unicode_literals | ||
647 | 23 | |||
648 | 24 | import re | 17 | import re |
649 | 25 | 18 | ||
650 | 26 | 19 | ||
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 | 1 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
657 | 2 | # | 2 | # |
659 | 3 | # Copyright 2011-2015 Canonical Ltd. | 3 | # Copyright 2011-2022 Canonical Ltd. |
660 | 4 | # | 4 | # |
661 | 5 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
662 | 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, |
663 | @@ -14,11 +14,6 @@ | |||
664 | 14 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
665 | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
666 | 16 | 16 | ||
667 | 17 | from __future__ import absolute_import | ||
668 | 18 | from __future__ import division | ||
669 | 19 | from __future__ import print_function | ||
670 | 20 | from __future__ import unicode_literals | ||
671 | 21 | |||
672 | 22 | import io | 17 | import io |
673 | 23 | 18 | ||
674 | 24 | 19 | ||
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 | 1 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
681 | 2 | # | 2 | # |
683 | 3 | # Copyright 2015 Canonical Ltd. | 3 | # Copyright 2015-2022 Canonical Ltd. |
684 | 4 | # | 4 | # |
685 | 5 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
686 | 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, |
687 | @@ -14,11 +14,6 @@ | |||
688 | 14 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
689 | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
690 | 16 | 16 | ||
691 | 17 | from __future__ import absolute_import | ||
692 | 18 | from __future__ import division | ||
693 | 19 | from __future__ import print_function | ||
694 | 20 | from __future__ import unicode_literals | ||
695 | 21 | |||
696 | 22 | import io | 17 | import io |
697 | 23 | import re | 18 | import re |
698 | 24 | from collections import defaultdict | 19 | 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 | 1 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
705 | 2 | # | 2 | # |
707 | 3 | # Copyright 2013-2019 Canonical Ltd. | 3 | # Copyright 2013-2022 Canonical Ltd. |
708 | 4 | # Written by: | 4 | # Written by: |
709 | 5 | # Zygmunt Krynicki <zygmunt.krynicki@canonical.com> | 5 | # Zygmunt Krynicki <zygmunt.krynicki@canonical.com> |
710 | 6 | # Sylvain Pineau <sylvain.pineau@canonical.com> | 6 | # Sylvain Pineau <sylvain.pineau@canonical.com> |
711 | @@ -8,7 +8,6 @@ | |||
712 | 8 | # Checkbox is free software: you can redistribute it and/or modify | 8 | # Checkbox is free software: you can redistribute it and/or modify |
713 | 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, |
714 | 10 | # as published by the Free Software Foundation. | 10 | # as published by the Free Software Foundation. |
715 | 11 | |||
716 | 12 | # | 11 | # |
717 | 13 | # Checkbox is distributed in the hope that it will be useful, | 12 | # Checkbox is distributed in the hope that it will be useful, |
718 | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
719 | @@ -18,11 +17,6 @@ | |||
720 | 18 | # You should have received a copy of the GNU General Public License | 17 | # You should have received a copy of the GNU General Public License |
721 | 19 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 18 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
722 | 20 | 19 | ||
723 | 21 | from __future__ import absolute_import | ||
724 | 22 | from __future__ import division | ||
725 | 23 | from __future__ import print_function | ||
726 | 24 | from __future__ import unicode_literals | ||
727 | 25 | |||
728 | 26 | 20 | ||
729 | 27 | """ | 21 | """ |
730 | 28 | :mod:`checkbox_support.parsers.pactl` -- `pactl list` parser | 22 | :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 | 1 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
737 | 2 | # | 2 | # |
739 | 3 | # Copyright 2015 Canonical Ltd. | 3 | # Copyright 2015-2022 Canonical Ltd. |
740 | 4 | # | 4 | # |
741 | 5 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
742 | 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, |
743 | @@ -14,11 +14,6 @@ | |||
744 | 14 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
745 | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
746 | 16 | 16 | ||
747 | 17 | from __future__ import absolute_import | ||
748 | 18 | from __future__ import division | ||
749 | 19 | from __future__ import print_function | ||
750 | 20 | from __future__ import unicode_literals | ||
751 | 21 | |||
752 | 22 | import io | 17 | import io |
753 | 23 | import re | 18 | import re |
754 | 24 | 19 | ||
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 | 1 | # | ||
761 | 2 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
762 | 3 | # | 2 | # |
764 | 4 | # Copyright 2012-2013 Canonical Ltd. | 3 | # Copyright 2012-2022 Canonical Ltd. |
765 | 5 | # | 4 | # |
766 | 6 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
767 | 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, |
768 | 8 | # as published by the Free Software Foundation. | 7 | # as published by the Free Software Foundation. |
769 | 9 | |||
770 | 10 | # | 8 | # |
771 | 11 | # Checkbox is distributed in the hope that it will be useful, | 9 | # Checkbox is distributed in the hope that it will be useful, |
772 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
773 | @@ -16,14 +14,9 @@ | |||
774 | 16 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
775 | 17 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
776 | 18 | 16 | ||
777 | 19 | from __future__ import absolute_import | ||
778 | 20 | from __future__ import division | ||
779 | 21 | from __future__ import print_function | ||
780 | 22 | from __future__ import unicode_literals | ||
781 | 23 | |||
782 | 24 | from io import StringIO | 17 | from io import StringIO |
783 | 25 | from io import open | ||
784 | 26 | from unittest import TestCase | 18 | from unittest import TestCase |
785 | 19 | from textwrap import dedent | ||
786 | 27 | 20 | ||
787 | 28 | from pkg_resources import resource_filename | 21 | from pkg_resources import resource_filename |
788 | 29 | 22 | ||
789 | @@ -31,22 +24,6 @@ from checkbox_support.parsers.udevadm import UdevadmParser, decode_id | |||
790 | 31 | from checkbox_support.parsers.udevadm import parse_udevadm_output | 24 | from checkbox_support.parsers.udevadm import parse_udevadm_output |
791 | 32 | 25 | ||
792 | 33 | 26 | ||
793 | 34 | class DeviceResult(object): | ||
794 | 35 | |||
795 | 36 | def __init__(self): | ||
796 | 37 | self.devices = [] | ||
797 | 38 | |||
798 | 39 | def addDevice(self, device): | ||
799 | 40 | self.devices.append(device) | ||
800 | 41 | |||
801 | 42 | def getDevice(self, category): | ||
802 | 43 | for device in self.devices: | ||
803 | 44 | if device.category == category: | ||
804 | 45 | return device | ||
805 | 46 | |||
806 | 47 | return None | ||
807 | 48 | |||
808 | 49 | |||
809 | 50 | class UdevadmDataMixIn(object): | 27 | class UdevadmDataMixIn(object): |
810 | 51 | """ | 28 | """ |
811 | 52 | Mix in with a helper method to load sample udevadm data | 29 | Mix in with a helper method to load sample udevadm data |
812 | @@ -70,16 +47,6 @@ class UdevadmDataMixIn(object): | |||
813 | 70 | 47 | ||
814 | 71 | class TestUdevadmParser(TestCase, UdevadmDataMixIn): | 48 | class TestUdevadmParser(TestCase, UdevadmDataMixIn): |
815 | 72 | 49 | ||
816 | 73 | def getParser(self, string): | ||
817 | 74 | stream = StringIO(string) | ||
818 | 75 | return UdevadmParser(stream) | ||
819 | 76 | |||
820 | 77 | def getResult(self, string): | ||
821 | 78 | parser = self.getParser(string) | ||
822 | 79 | result = DeviceResult() | ||
823 | 80 | parser.run(result) | ||
824 | 81 | return result | ||
825 | 82 | |||
826 | 83 | def parse(self, name, with_lsblk=True, with_partitions=False): | 50 | def parse(self, name, with_lsblk=True, with_partitions=False): |
827 | 84 | # Uncomment only for debugging purpose | 51 | # Uncomment only for debugging purpose |
828 | 85 | """ | 52 | """ |
829 | @@ -100,27 +67,29 @@ class TestUdevadmParser(TestCase, UdevadmDataMixIn): | |||
830 | 100 | return len([d for d in devices if d.category == category]) | 67 | return len([d for d in devices if d.category == category]) |
831 | 101 | 68 | ||
832 | 102 | def test_openfirmware_network(self): | 69 | def test_openfirmware_network(self): |
854 | 103 | result = self.getResult(""" | 70 | stream = StringIO(dedent(""" |
855 | 104 | P: /devices/soc.0/ffe64000.ethernet | 71 | P: /devices/soc.0/ffe64000.ethernet |
856 | 105 | E: DEVPATH=/devices/soc.0/ffe64000.ethernet | 72 | E: DEVPATH=/devices/soc.0/ffe64000.ethernet |
857 | 106 | E: DRIVER=XXXXX | 73 | E: DRIVER=XXXXX |
858 | 107 | E: MODALIAS=of:NethernetTXXXXXCXXXXX,XXXXX | 74 | E: MODALIAS=of:NethernetTXXXXXCXXXXX,XXXXX |
859 | 108 | E: OF_COMPATIBLE_0=XXXXX,XXXXX | 75 | E: OF_COMPATIBLE_0=XXXXX,XXXXX |
860 | 109 | E: OF_COMPATIBLE_N=1 | 76 | E: OF_COMPATIBLE_N=1 |
861 | 110 | E: OF_NAME=ethernet | 77 | E: OF_NAME=ethernet |
862 | 111 | E: OF_TYPE=XXXXX | 78 | E: OF_TYPE=XXXXX |
863 | 112 | E: SUBSYSTEM=platform | 79 | E: SUBSYSTEM=platform |
864 | 113 | E: UDEV_LOG=3 | 80 | E: UDEV_LOG=3 |
865 | 114 | 81 | ||
866 | 115 | P: /devices/soc.0/ffe64000.ethernet/net/eth1 | 82 | P: /devices/soc.0/ffe64000.ethernet/net/eth1 |
867 | 116 | E: DEVPATH=/devices/soc.0/ffe64000.ethernet/net/eth1 | 83 | E: DEVPATH=/devices/soc.0/ffe64000.ethernet/net/eth1 |
868 | 117 | E: IFINDEX=3 | 84 | E: IFINDEX=3 |
869 | 118 | E: INTERFACE=eth1 | 85 | E: INTERFACE=eth1 |
870 | 119 | E: SUBSYSTEM=net | 86 | E: SUBSYSTEM=net |
871 | 120 | E: UDEV_LOG=3 | 87 | E: UDEV_LOG=3 |
872 | 121 | """) | 88 | """)) |
873 | 122 | device = result.getDevice("NETWORK") | 89 | parser = UdevadmParser(stream) |
874 | 123 | self.assertTrue(device) | 90 | devices = parser.run() |
875 | 91 | self.assertEqual(devices[0].category, "NETWORK") | ||
876 | 92 | |||
877 | 124 | 93 | ||
878 | 125 | def test_DELL_INSPIRON3521_TOUCHSCREEN(self): | 94 | def test_DELL_INSPIRON3521_TOUCHSCREEN(self): |
879 | 126 | """ | 95 | """ |
880 | diff --git a/checkbox_support/parsers/tests/test_version.py b/checkbox_support/parsers/tests/test_version.py | |||
881 | 127 | deleted file mode 100644 | 96 | 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 | 1 | # -*- coding: utf-8 -*- | ||
887 | 2 | # | ||
888 | 3 | # This file is part of Checkbox. | ||
889 | 4 | # | ||
890 | 5 | # Copyright 2014 Canonical Ltd. | ||
891 | 6 | # | ||
892 | 7 | # Checkbox is free software: you can redistribute it and/or modify | ||
893 | 8 | # it under the terms of the GNU General Public License version 3, | ||
894 | 9 | # as published by the Free Software Foundation. | ||
895 | 10 | |||
896 | 11 | # | ||
897 | 12 | # Checkbox is distributed in the hope that it will be useful, | ||
898 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
899 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
900 | 15 | # GNU General Public License for more details. | ||
901 | 16 | # | ||
902 | 17 | # You should have received a copy of the GNU General Public License | ||
903 | 18 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | ||
904 | 19 | |||
905 | 20 | from __future__ import absolute_import | ||
906 | 21 | from __future__ import division | ||
907 | 22 | from __future__ import print_function | ||
908 | 23 | from __future__ import unicode_literals | ||
909 | 24 | |||
910 | 25 | from unittest import TestCase | ||
911 | 26 | |||
912 | 27 | |||
913 | 28 | class TestSubmissionModuleVersion(TestCase): | ||
914 | 29 | |||
915 | 30 | def testVersion(self): | ||
916 | 31 | from checkbox_support import parsers | ||
917 | 32 | ver = getattr(parsers, "__version__") | ||
918 | 33 | 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 | 1201 | def getAttributes(self, path): | 1201 | def getAttributes(self, path): |
925 | 1202 | return {} | 1202 | return {} |
926 | 1203 | 1203 | ||
928 | 1204 | def run(self, result): | 1204 | def run(self): |
929 | 1205 | # Some attribute lines have a space character after the | 1205 | # Some attribute lines have a space character after the |
930 | 1206 | # ':', others don't have it (see udevadm-info.c). | 1206 | # ':', others don't have it (see udevadm-info.c). |
931 | 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>.*)") |
932 | @@ -1395,6 +1395,7 @@ class UdevadmParser(object): | |||
933 | 1395 | # Remove Virtal CDROM devices | 1395 | # Remove Virtal CDROM devices |
934 | 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]: |
935 | 1397 | self.devices.pop(device._raw_path, None) | 1397 | self.devices.pop(device._raw_path, None) |
936 | 1398 | return list(self.devices.values()) | ||
937 | 1398 | 1399 | ||
938 | 1399 | [result.addDevice(device) for device in self.devices.values()] | 1400 | [result.addDevice(device) for device in self.devices.values()] |
939 | 1400 | 1401 | ||
940 | @@ -1426,14 +1427,6 @@ def known_to_be_video_device(vendor_id, product_id, pci_class, pci_subclass): | |||
941 | 1426 | return product_id in [0x0152, 0x0412, 0x0402] | 1427 | return product_id in [0x0152, 0x0412, 0x0402] |
942 | 1427 | 1428 | ||
943 | 1428 | 1429 | ||
944 | 1429 | class UdevResult(object): | ||
945 | 1430 | def __init__(self): | ||
946 | 1431 | self.devices = [] | ||
947 | 1432 | |||
948 | 1433 | def addDevice(self, device): | ||
949 | 1434 | self.devices.append(device) | ||
950 | 1435 | |||
951 | 1436 | |||
952 | 1437 | def parse_udevadm_output(output, lsblk=None, list_partitions=False, bits=None): | 1430 | def parse_udevadm_output(output, lsblk=None, list_partitions=False, bits=None): |
953 | 1438 | """ | 1431 | """ |
954 | 1439 | Parse output of `LANG=C udevadm info --export-db` | 1432 | 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 | 1448 | universal_newlines=True) | 1441 | universal_newlines=True) |
957 | 1449 | except CalledProcessError: | 1442 | except CalledProcessError: |
958 | 1450 | lsblk = '' | 1443 | lsblk = '' |
963 | 1451 | udev = UdevadmParser(output, lsblk, list_partitions, bits) | 1444 | return UdevadmParser(output, lsblk, list_partitions, bits).run() |
960 | 1452 | result = UdevResult() | ||
961 | 1453 | udev.run(result) | ||
962 | 1454 | return result.devices | ||
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 | 1 | # -*- coding: utf-8 -*- | ||
970 | 2 | # | ||
971 | 3 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
972 | 4 | # | 2 | # |
974 | 5 | # Copyright 2012 Canonical Ltd. | 3 | # Copyright 2012-2022 Canonical Ltd. |
975 | 6 | # | 4 | # |
976 | 7 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
977 | 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, |
978 | 9 | # as published by the Free Software Foundation. | 7 | # as published by the Free Software Foundation. |
979 | 10 | |||
980 | 11 | # | 8 | # |
981 | 12 | # Checkbox is distributed in the hope that it will be useful, | 9 | # Checkbox is distributed in the hope that it will be useful, |
982 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
983 | @@ -17,11 +14,6 @@ | |||
984 | 17 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
985 | 18 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
986 | 19 | 16 | ||
987 | 20 | from __future__ import absolute_import | ||
988 | 21 | from __future__ import division | ||
989 | 22 | from __future__ import print_function | ||
990 | 23 | from __future__ import unicode_literals | ||
991 | 24 | |||
992 | 25 | from string import ascii_letters | 17 | from string import ascii_letters |
993 | 26 | from string import ascii_uppercase | 18 | from string import ascii_uppercase |
994 | 27 | import re | 19 | 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 | 1 | # | ||
1001 | 2 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
1002 | 3 | # | 2 | # |
1003 | 4 | # Copyright 2013-2020 Canonical Ltd. | 3 | # Copyright 2013-2020 Canonical Ltd. |
1004 | @@ -6,7 +5,6 @@ | |||
1005 | 6 | # Checkbox is free software: you can redistribute it and/or modify | 5 | # Checkbox is free software: you can redistribute it and/or modify |
1006 | 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, |
1007 | 8 | # as published by the Free Software Foundation. | 7 | # as published by the Free Software Foundation. |
1008 | 9 | |||
1009 | 10 | # | 8 | # |
1010 | 11 | # Checkbox is distributed in the hope that it will be useful, | 9 | # Checkbox is distributed in the hope that it will be useful, |
1011 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
1012 | @@ -16,11 +14,6 @@ | |||
1013 | 16 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
1014 | 17 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
1015 | 18 | 16 | ||
1016 | 19 | from __future__ import absolute_import | ||
1017 | 20 | from __future__ import division | ||
1018 | 21 | from __future__ import print_function | ||
1019 | 22 | from __future__ import unicode_literals | ||
1020 | 23 | |||
1021 | 24 | from argparse import ArgumentParser | 17 | from argparse import ArgumentParser |
1022 | 25 | from subprocess import check_output, check_call, CalledProcessError | 18 | from subprocess import check_output, check_call, CalledProcessError |
1023 | 26 | from io import open | 19 | 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 | 1 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
1030 | 2 | # | 2 | # |
1032 | 3 | # Copyright 2013 Canonical Ltd. | 3 | # Copyright 2013-2022 Canonical Ltd. |
1033 | 4 | # Written by: | 4 | # Written by: |
1034 | 5 | # Sylvain Pineau <sylvain.pineau@canonical.com> | 5 | # Sylvain Pineau <sylvain.pineau@canonical.com> |
1035 | 6 | # | 6 | # |
1036 | 7 | # Checkbox is free software: you can redistribute it and/or modify | 7 | # Checkbox is free software: you can redistribute it and/or modify |
1037 | 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, |
1038 | 9 | # as published by the Free Software Foundation. | 9 | # as published by the Free Software Foundation. |
1039 | 10 | |||
1040 | 11 | # | 10 | # |
1041 | 12 | # Checkbox is distributed in the hope that it will be useful, | 11 | # Checkbox is distributed in the hope that it will be useful, |
1042 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
1043 | @@ -17,11 +16,6 @@ | |||
1044 | 17 | # You should have received a copy of the GNU General Public License | 16 | # You should have received a copy of the GNU General Public License |
1045 | 18 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 17 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
1046 | 19 | 18 | ||
1047 | 20 | from __future__ import absolute_import | ||
1048 | 21 | from __future__ import division | ||
1049 | 22 | from __future__ import print_function | ||
1050 | 23 | from __future__ import unicode_literals | ||
1051 | 24 | |||
1052 | 25 | from io import open | 19 | from io import open |
1053 | 26 | from subprocess import check_output, CalledProcessError | 20 | from subprocess import check_output, CalledProcessError |
1054 | 27 | from tempfile import TemporaryDirectory | 21 | 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 | 29 | 29 | ||
1061 | 30 | from inspect import getabsfile | 30 | from inspect import getabsfile |
1062 | 31 | from unittest.loader import defaultTestLoader | 31 | from unittest.loader import defaultTestLoader |
1063 | 32 | from unittest import TestSuite | ||
1064 | 32 | import os | 33 | import os |
1065 | 33 | 34 | ||
1066 | 34 | import checkbox_support | 35 | import checkbox_support |
1067 | @@ -42,7 +43,16 @@ def load_unit_tests(): | |||
1068 | 42 | # python modules that start with the word 'test_' . | 43 | # python modules that start with the word 'test_' . |
1069 | 43 | start_dir = os.path.dirname(getabsfile(checkbox_support)) | 44 | start_dir = os.path.dirname(getabsfile(checkbox_support)) |
1070 | 44 | top_level_dir = os.path.normpath(os.path.join(start_dir, '..')) | 45 | top_level_dir = os.path.normpath(os.path.join(start_dir, '..')) |
1072 | 45 | return defaultTestLoader.discover(start_dir, top_level_dir=top_level_dir) | 46 | test_suite = TestSuite() |
1073 | 47 | for path in os.listdir(start_dir): | ||
1074 | 48 | # skip tests that come from a vendorized code | ||
1075 | 49 | if path in ('__pycache__', 'vendor'): | ||
1076 | 50 | continue | ||
1077 | 51 | path = os.path.join(start_dir, path) | ||
1078 | 52 | if os.path.isdir(path): | ||
1079 | 53 | test_suite.addTests( | ||
1080 | 54 | defaultTestLoader.discover(path, top_level_dir=top_level_dir)) | ||
1081 | 55 | return test_suite | ||
1082 | 46 | 56 | ||
1083 | 47 | 57 | ||
1084 | 48 | def test_suite(): | 58 | 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 | 1 | # This file is part of Checkbox. | 1 | # This file is part of Checkbox. |
1091 | 2 | # | 2 | # |
1093 | 3 | # Copyright 2012 Canonical Ltd. | 3 | # Copyright 2012-2022 Canonical Ltd. |
1094 | 4 | # Written by: | 4 | # Written by: |
1095 | 5 | # Zygmunt Krynicki <zygmunt.krynicki@canonical.com> | 5 | # Zygmunt Krynicki <zygmunt.krynicki@canonical.com> |
1096 | 6 | # | 6 | # |
1097 | 7 | # Checkbox is free software: you can redistribute it and/or modify | 7 | # Checkbox is free software: you can redistribute it and/or modify |
1098 | 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, |
1099 | 9 | # as published by the Free Software Foundation. | 9 | # as published by the Free Software Foundation. |
1100 | 10 | |||
1101 | 11 | # | 10 | # |
1102 | 12 | # Checkbox is distributed in the hope that it will be useful, | 11 | # Checkbox is distributed in the hope that it will be useful, |
1103 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
1104 | @@ -17,11 +16,6 @@ | |||
1105 | 17 | # You should have received a copy of the GNU General Public License | 16 | # You should have received a copy of the GNU General Public License |
1106 | 18 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | 17 | # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. |
1107 | 19 | 18 | ||
1108 | 20 | from __future__ import absolute_import | ||
1109 | 21 | from __future__ import division | ||
1110 | 22 | from __future__ import print_function | ||
1111 | 23 | from __future__ import unicode_literals | ||
1112 | 24 | |||
1113 | 25 | """ | 19 | """ |
1114 | 26 | checkbox_support.udev | 20 | checkbox_support.udev |
1115 | 27 | ===================== | 21 | ===================== |
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 | 93 | "checkbox_support.scripts.eddystone_scanner:main"), | 93 | "checkbox_support.scripts.eddystone_scanner:main"), |
1122 | 94 | ("checkbox-support-lsusb=" | 94 | ("checkbox-support-lsusb=" |
1123 | 95 | "checkbox_support.scripts.lsusb:main"), | 95 | "checkbox_support.scripts.lsusb:main"), |
1124 | 96 | ("checkbox-support-parse=checkbox_support.parsers:main"), | ||
1125 | 96 | ], | 97 | ], |
1126 | 97 | }, | 98 | }, |
1127 | 98 | ) | 99 | ) |
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