~jocave/checkbox/hybrid-amd-gpu-mods

« back to all changes in this revision

Viewing changes to checkbox-old/scripts/udev_resource

  • Committer: Zygmunt Krynicki
  • Date: 2013-05-29 07:50:30 UTC
  • mto: This revision was merged to the branch mainline in revision 2153.
  • Revision ID: zygmunt.krynicki@canonical.com-20130529075030-ngwz245hs2u3y6us
checkbox: move current checkbox code into checkbox-old

This patch cleans up the top-level directory of the project into dedicated
sub-project directories. One for checkbox-old (the current checkbox and all the
associated stuff), one for plainbox and another for checkbox-ng.

There are some associated changes, such as updating the 'source' mode of
checkbox provider in plainbox, and fixing paths in various test scripts that we
have.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python3
 
2
#
 
3
# This file is part of Checkbox.
 
4
#
 
5
# Copyright 2011 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 as published by
 
9
# the Free Software Foundation, either version 3 of the License, or
 
10
# (at your option) any later version.
 
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
#
 
20
 
 
21
from subprocess import check_output, CalledProcessError
 
22
 
 
23
from checkbox.parsers.udevadm import UdevadmParser
 
24
 
 
25
 
 
26
class UdevResult:
 
27
 
 
28
    attributes = ("path", "bus", "category", "driver", "product_id",
 
29
                  "vendor_id", "subproduct_id", "subvendor_id", "product",
 
30
                  "vendor", "interface",)
 
31
 
 
32
    def addDevice(self, device):
 
33
        for attribute in self.attributes:
 
34
            value = getattr(device, attribute)
 
35
            if value is not None:
 
36
                print("%s: %s" % (attribute, value))
 
37
 
 
38
        print()
 
39
 
 
40
 
 
41
def main():
 
42
    try:
 
43
        output = check_output(['udevadm', 'info', '--export-db'])
 
44
    except CalledProcessError as exc:
 
45
        raise SystemExit(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)
 
50
    result = UdevResult()
 
51
    udev.run(result)
 
52
 
 
53
 
 
54
if __name__ == "__main__":
 
55
    main()