3
# This file is part of Checkbox.
5
# Copyright 2011 Canonical Ltd.
7
# Checkbox is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
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.
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/>.
21
from subprocess import check_output, CalledProcessError
23
from checkbox.parsers.udevadm import UdevadmParser
28
attributes = ("path", "bus", "category", "driver", "product_id",
29
"vendor_id", "subproduct_id", "subvendor_id", "product",
30
"vendor", "interface",)
32
def addDevice(self, device):
33
for attribute in self.attributes:
34
value = getattr(device, attribute)
36
print("%s: %s" % (attribute, value))
43
output = check_output(['udevadm', 'info', '--export-db'])
44
except CalledProcessError as exc:
46
# Set the error policy to 'ignore' in order to let tests depending on this
47
# resource to properly match udev properties
48
output = output.decode("UTF-8", errors='ignore')
49
udev = UdevadmParser(output)
54
if __name__ == "__main__":