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

« back to all changes in this revision

Viewing changes to providers/plainbox-provider-resource-generic/bin/efi_resource

  • Committer: Zygmunt Krynicki
  • Date: 2013-05-17 13:54:25 UTC
  • mto: This revision was merged to the branch mainline in revision 2130.
  • Revision ID: zygmunt.krynicki@canonical.com-20130517135425-cxcenxx5t0qrtbxd
checkbox-ng: add CheckBoxNG sub-project

CheckBoxNG (or lowercase as checkbox-ng, pypi:checkbox-ng) is a clean
implementation of CheckBox on top of PlainBox. It provides a new
executable, 'checkbox' that has some of the same commands that were
previously implemented in the plainbox package.

In particular CheckBoxNG comes with the 'checkbox sru' command
(the same one as in plainbox). Later on this sub-command will be removed
from plainbox.

CheckBoxNG depends on plainbox >= 0.3

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env 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 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
 
#
20
 
import os
21
 
import sys
22
 
 
23
 
from checkbox_support.parsers.efi import EfiParser
24
 
 
25
 
 
26
 
# Command to retrieve efi information.
27
 
COMMAND = "[ -d /sys/firmware/efi ] && cat /var/log/kern.log* | grep -m 1 -o --color=never 'EFI v.*' || true"
28
 
 
29
 
 
30
 
class EfiResult:
31
 
 
32
 
    attributes = ("path", "category", "product", "vendor",)
33
 
 
34
 
    def setEfiDevice(self, device):
35
 
        for attribute in self.attributes:
36
 
            value = getattr(device, attribute, None)
37
 
            if value is not None:
38
 
                print("%s: %s" % (attribute, value))
39
 
 
40
 
        print()
41
 
 
42
 
 
43
 
def main():
44
 
    stream = os.popen(COMMAND)
45
 
    efi = EfiParser(stream)
46
 
 
47
 
    result = EfiResult()
48
 
    efi.run(result)
49
 
 
50
 
    return 0
51
 
 
52
 
 
53
 
if __name__ == "__main__":
54
 
    sys.exit(main())