~ubuntu-branches/ubuntu/quantal/checkbox/quantal

« back to all changes in this revision

Viewing changes to checkbox/lib/dmi.py

  • Committer: Package Import Robot
  • Author(s): Daniel Manrique, Marc Tardif, Daniel Manrique, Jeff Lane, Ara Pulido, Brendan Donegan, Javier Collado
  • Date: 2011-11-18 12:46:21 UTC
  • Revision ID: package-import@ubuntu.com-20111118124621-87rjnjm27ool11e6
Tags: 0.13
New upstream release (LP: #892268):

[Marc Tardif]
* Generate a submission.xml file that contains all device and attachment
* Write the report before reporting the validation error.
* Changed device.product to dmi.product for the formfactor (LP: #875312)

[Daniel Manrique]
* Use gettext for string (LP: #869267)
* Move progress indicator to main checkbox dialog instead of a 
  transient window (LP: #868995)
* Ignore malformed dpkg entries in package_resource (LP: #794747)
* Reset window title after finishing a manual test (LP: #874690)
* Handle "@" in locale names (as in ca@valencia).

[Jeff Lane]
* Went through all the job files and:
  * Updated descriptions to match Unity UI structure
  * Added descriptions where necessary
  * Added further details to some descriptions
  * Moved some jobs to more appropriate files
  * Fixed job names in older job files to match new naming scheme 
    (suite/testname)
  * Added jobs to local.txt to ensure all job files are now parsed
    (this allows easier addition of existing tests to whitelists)
  * Changed remaining manual job descriptions to match the new format
* Updated CD and DVD write tests to be more clear about when to skip
  them (LP: #772794)

[Ara Pulido]
* Rewrote all job descriptions to match OEM QA syntax

[Brendan Donegan]  
* Fix the code that assigns keys in checkbox-cli so that it never assigns
  keys which have other uses. (LP: #877467)
* Show details of unmet job requirements (LP: #855852)
* Ensure that connect_wireless chooses a wireless connection from the list
  of available connections (LP: #877752)
* Have the bluetooth/detect tests require a device with the category
  BLUETOOTH to run, thus preventing the test from failing on systems with
  no Bluetooth device (LP: #862322)
* Rename attachment jobs to not have a forward slash in their name
  (LP: #887964)
* Guard against trying to write files to logical partitions on USB sticks
  (which will obviously fail) in usb_test (LP: #887049)
* Make the OpenGL test ignore the return value of glxgears and improve
  the test description (LP: #890725)
* Allow input/mouse test to run if a TOUCH device is present
  (LP: #886129)

[ Javier Collado ]
* Broken job dependencies fixed (LP: #888447)
* Regex support when specifying blacklists and whitelists on the
  commandline (LP: #588647)

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# You should have received a copy of the GNU General Public License
17
17
# along with Checkbox.  If not, see <http://www.gnu.org/licenses/>.
18
18
#
 
19
import os
 
20
 
19
21
 
20
22
# See also 3.3.4.1 of the "System Management BIOS Reference Specification,
21
23
# Version 2.6.1" (Preliminary Standard) document, available from
22
24
# http://www.dmtf.org/standards/smbios.
23
25
class Dmi:
24
26
    chassis = (
25
 
        ("Undefined",             "unknown"), # 0x00
 
27
        ("Undefined",             "unknown"),  # 0x00
26
28
        ("Other",                 "unknown"),
27
29
        ("Unknown",               "unknown"),
28
30
        ("Desktop",               "desktop"),
53
55
        ("Blade",                 "server"),
54
56
        ("Blade Enclosure",       "unknown"))
55
57
 
56
 
    chassis_names = [c[0] for c in chassis]
57
 
    chassis_types = [c[1] for c in chassis]
 
58
    chassis_names = tuple(c[0] for c in chassis)
 
59
    chassis_types = tuple(c[1] for c in chassis)
58
60
    chassis_name_to_type = dict(chassis)
59
61
 
60
 
 
61
 
class DmiNotAvailable(object):
62
 
    def __init__(self, function):
63
 
        self._function = function
64
 
 
65
 
    def __get__(self, instance, cls=None):
66
 
        self._instance = instance
67
 
        return self
68
 
 
69
 
    def __call__(self, *args, **kwargs):
70
 
        name = self._function(self._instance, *args, **kwargs)
71
 
        if name == "Not Available":
72
 
            name = None
73
 
 
74
 
        return name
 
62
    type_names = (
 
63
        "BIOS",  # 0x00
 
64
        "System",
 
65
        "Base Board",
 
66
        "Chassis",
 
67
        "Processor",
 
68
        "Memory Controller",
 
69
        "Memory Module",
 
70
        "Cache",
 
71
        "Port Connector",
 
72
        "System Slots",
 
73
        "On Board Devices",
 
74
        "OEM Strings",
 
75
        "System Configuration Options",
 
76
        "BIOS Language",
 
77
        "Group Associations",
 
78
        "System Event Log",
 
79
        "Physical Memory Array",
 
80
        "Memory Device",
 
81
        "32-bit Memory Error",
 
82
        "Memory Array Mapped Address",
 
83
        "Memory Device Mapped Address",
 
84
        "Built-in Pointing Device",
 
85
        "Portable Battery",
 
86
        "System Reset",
 
87
        "Hardware Security",
 
88
        "System Power Controls",
 
89
        "Voltage Probe",
 
90
        "Cooling Device",
 
91
        "Temperature Probe",
 
92
        "Electrical Current Probe",
 
93
        "Out-of-band Remote Access",
 
94
        "Boot Integrity Services",
 
95
        "System Boot",
 
96
        "64-bit Memory Error",
 
97
        "Management Device",
 
98
        "Management Device Component",
 
99
        "Management Device Threshold Data",
 
100
        "Memory Channel",
 
101
        "IPMI Device",
 
102
        "Power Supply",
 
103
        )
 
104
 
 
105
 
 
106
class DmiDevice:
 
107
 
 
108
    bus = "dmi"
 
109
    driver = None
 
110
    product_id = None
 
111
    vendor_id = None
 
112
 
 
113
    _product_blacklist = (
 
114
        "<BAD INDEX>",
 
115
        "N/A",
 
116
        "Not Available",
 
117
        "INVALID",
 
118
        "OEM",
 
119
        "Product Name",
 
120
        "System Product Name",
 
121
        "To be filled by O.E.M.",
 
122
        "To Be Filled By O.E.M.",
 
123
        "To Be Filled By O.E.M. by More String",
 
124
        "Unknown",
 
125
        "Uknown",
 
126
        "Unknow",
 
127
        "xxxxxxxxxxxxxx",
 
128
        )
 
129
    _vendor_blacklist = (
 
130
        "<BAD INDEX>",
 
131
        "Not Available",
 
132
        "OEM",
 
133
        "OEM Manufacturer",
 
134
        "System manufacturer",
 
135
        "System Manufacturer",
 
136
        "System Name",
 
137
        "To be filled by O.E.M.",
 
138
        "To Be Filled By O.E.M.",
 
139
        "To Be Filled By O.E.M. by More String",
 
140
        "Unknow",  # XXX This is correct mispelling
 
141
        "Unknown",
 
142
        )
 
143
    _serial_blacklist = (
 
144
       "0",
 
145
       "00000000",
 
146
       "00 00 00 00 00 00 00 00",
 
147
       "0123456789",
 
148
       "Base Board Serial Number",
 
149
       "Chassis Serial Number",
 
150
       "N/A",
 
151
       "None",
 
152
       "Not Applicable",
 
153
       "Not Available",
 
154
       "Not Specified",
 
155
       "OEM",
 
156
       "System Serial Number",
 
157
       )
 
158
    _version_blacklist = (
 
159
        "-1",
 
160
        "<BAD INDEX>",
 
161
        "N/A",
 
162
        "None",
 
163
        "Not Applicable",
 
164
        "Not Available",
 
165
        "Not Specified",
 
166
        "OEM",
 
167
        "System Version",
 
168
        "Unknown",
 
169
        "x.x",
 
170
        )
 
171
 
 
172
    def __init__(self, attributes, category):
 
173
        self._attributes = attributes
 
174
        self.category = category
 
175
 
 
176
    @property
 
177
    def path(self):
 
178
        path = "/devices/virtual/dmi/id"
 
179
        return os.path.join(path, self.category.lower())
 
180
 
 
181
    @property
 
182
    def product(self):
 
183
        if self.category == "CHASSIS":
 
184
            type_string = self._attributes.get("chassis_type", "0")
 
185
            try:
 
186
                type_index = int(type_string)
 
187
                return Dmi.chassis_names[type_index]
 
188
            except ValueError:
 
189
                return type_string
 
190
 
 
191
        for name in "name", "version":
 
192
            attribute = "%s_%s" % (self.category.lower(), name)
 
193
            product = self._attributes.get(attribute)
 
194
            if product and product not in self._product_blacklist:
 
195
                return product
 
196
 
 
197
        return None
 
198
 
 
199
    @property
 
200
    def vendor(self):
 
201
        for name in "manufacturer", "vendor":
 
202
            attribute = "%s_%s" % (self.category.lower(), name)
 
203
            vendor = self._attributes.get(attribute)
 
204
            if vendor and vendor not in self._vendor_blacklist:
 
205
                return vendor
 
206
 
 
207
        return None
 
208
 
 
209
    @property
 
210
    def serial(self):
 
211
        attribute = "%s_serial" % self.category.lower()
 
212
        serial = self._attributes.get(attribute)
 
213
        if serial and serial not in self._serial_blacklist:
 
214
            return serial
 
215
 
 
216
        return None
 
217
 
 
218
    @property
 
219
    def version(self):
 
220
        attribute = "%s_version" % self.category.lower()
 
221
        version = self._attributes.get(attribute)
 
222
        if version and version not in self._version_blacklist:
 
223
            return version
 
224
 
 
225
        return None