~launchpad-results/launchpad-results/trunk

« back to all changes in this revision

Viewing changes to lib/lpresults/xunit/parsers/udevadm.py

  • Committer: Marc Tardif
  • Date: 2012-01-10 17:25:04 UTC
  • Revision ID: marc.tardif@canonical.com-20120110172504-w6ebyjdx279mqv3w
Fixed decoding of submissions with utf-8 strings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
        # Change the bus from 'acpi' to 'pnp' for some devices
66
66
        if PNP_RE.match(self._environment.get("MODALIAS", "")) \
67
67
           and self.path.endswith(":00"):
68
 
            return "pnp"
 
68
            return u"pnp"
69
69
 
70
70
        # Change the bus from 'block' to parent
71
71
        if self._environment.get("DEVTYPE") == "disk" and self._stack:
80
80
    @property
81
81
    def category(self):
82
82
        if "IFINDEX" in self._environment:
83
 
            return "NETWORK"
 
83
            return u"NETWORK"
84
84
 
85
85
        if "PCI_CLASS" in self._environment:
86
86
            pci_class_string = self._environment["PCI_CLASS"]
95
95
 
96
96
            if class_id == Pci.BASE_CLASS_NETWORK:
97
97
                if subclass_id == Pci.CLASS_NETWORK_WIRELESS:
98
 
                    return "WIRELESS"
 
98
                    return u"WIRELESS"
99
99
                else:
100
 
                    return "NETWORK"
 
100
                    return u"NETWORK"
101
101
 
102
102
            if class_id == Pci.BASE_CLASS_DISPLAY:
103
103
                if subclass_id == Pci.CLASS_DISPLAY_VGA:
104
 
                    return "VIDEO"
 
104
                    return u"VIDEO"
105
105
                else:
106
 
                    return "OTHER"
 
106
                    return u"OTHER"
107
107
 
108
108
            if class_id == Pci.BASE_CLASS_SERIAL \
109
109
               and subclass_id == Pci.CLASS_SERIAL_USB:
110
 
                return "USB"
 
110
                return u"USB"
111
111
 
112
112
            if class_id == Pci.BASE_CLASS_STORAGE:
113
113
                if subclass_id == Pci.CLASS_STORAGE_SCSI:
114
 
                    return "SCSI"
 
114
                    return u"SCSI"
115
115
 
116
116
                if subclass_id == Pci.CLASS_STORAGE_IDE:
117
 
                    return "IDE"
 
117
                    return u"IDE"
118
118
 
119
119
                if subclass_id == Pci.CLASS_STORAGE_FLOPPY:
120
 
                    return "FLOPPY"
 
120
                    return u"FLOPPY"
121
121
 
122
122
                if subclass_id == Pci.CLASS_STORAGE_RAID:
123
 
                    return "RAID"
 
123
                    return u"RAID"
124
124
 
125
125
            if class_id == Pci.BASE_CLASS_COMMUNICATION \
126
126
               and subclass_id == Pci.CLASS_COMMUNICATION_MODEM:
127
 
                return "MODEM"
 
127
                return u"MODEM"
128
128
 
129
129
            if class_id == Pci.BASE_CLASS_INPUT \
130
130
               and subclass_id == Pci.CLASS_INPUT_SCANNER:
131
 
                return "SCANNER"
 
131
                return u"SCANNER"
132
132
 
133
133
            if class_id == Pci.BASE_CLASS_MULTIMEDIA:
134
134
                if subclass_id == Pci.CLASS_MULTIMEDIA_VIDEO:
135
 
                    return "CAPTURE"
 
135
                    return u"CAPTURE"
136
136
 
137
137
                if subclass_id == Pci.CLASS_MULTIMEDIA_AUDIO \
138
138
                   or subclass_id == Pci.CLASS_MULTIMEDIA_AUDIO_DEVICE:
139
 
                    return "AUDIO"
 
139
                    return u"AUDIO"
140
140
 
141
141
            if class_id == Pci.BASE_CLASS_SERIAL \
142
142
               and subclass_id == Pci.CLASS_SERIAL_FIREWIRE:
143
 
                return "FIREWIRE"
 
143
                return u"FIREWIRE"
144
144
 
145
145
            if class_id == Pci.BASE_CLASS_BRIDGE \
146
146
               and (subclass_id == Pci.CLASS_BRIDGE_PCMCIA \
147
147
                    or subclass_id == Pci.CLASS_BRIDGE_CARDBUS):
148
 
                return "SOCKET"
 
148
                return u"SOCKET"
149
149
 
150
150
        if "TYPE" in self._environment and "INTERFACE" in self._environment:
151
151
            interface_class, interface_subclass, interface_protocol = (
152
152
                int(i) for i in self._environment["INTERFACE"].split("/"))
153
153
 
154
154
            if interface_class == Usb.BASE_CLASS_AUDIO:
155
 
                return "AUDIO"
 
155
                return u"AUDIO"
156
156
 
157
157
            if interface_class == Usb.BASE_CLASS_PRINTER:
158
 
                return "PRINTER"
 
158
                return u"PRINTER"
159
159
 
160
160
            if interface_class == Usb.BASE_CLASS_STORAGE:
161
161
                if interface_subclass == Usb.CLASS_STORAGE_FLOPPY:
162
 
                    return "FLOPPY"
 
162
                    return u"FLOPPY"
163
163
 
164
164
                if interface_subclass == Usb.CLASS_STORAGE_SCSI:
165
 
                    return "SCSI"
 
165
                    return u"SCSI"
166
166
 
167
167
            if interface_class == Usb.BASE_CLASS_VIDEO:
168
 
                return "CAPTURE"
 
168
                return u"CAPTURE"
169
169
 
170
170
            if interface_class == Usb.BASE_CLASS_WIRELESS:
171
171
                if interface_protocol == Usb.PROTOCOL_BLUETOOTH:
172
 
                    return "BLUETOOTH"
 
172
                    return u"BLUETOOTH"
173
173
                else:
174
 
                    return "WIRELESS"
 
174
                    return u"WIRELESS"
175
175
 
176
176
        if "KEY" in self._environment:
177
177
            key = self._environment["KEY"].strip("=")
181
181
                if not test_bit(i, bitmask, self._bits):
182
182
                    break
183
183
            else:
184
 
                return "KEYBOARD"
 
184
                return u"KEYBOARD"
185
185
 
186
186
            if test_bit(Input.BTN_TOUCH, bitmask, self._bits):
187
 
                return "TOUCH"
 
187
                return u"TOUCH"
188
188
 
189
189
            if test_bit(Input.BTN_MOUSE, bitmask, self._bits):
190
 
                return "MOUSE"
 
190
                return u"MOUSE"
191
191
 
192
192
        if "ID_TYPE" in self._environment:
193
193
            id_type = self._environment["ID_TYPE"]
194
194
 
195
195
            if id_type == "cd":
196
 
                return "CDROM"
 
196
                return u"CDROM"
197
197
 
198
198
            if id_type == "disk":
199
 
                return "DISK"
 
199
                return u"DISK"
200
200
 
201
201
            if id_type == "video":
202
 
                return "VIDEO"
 
202
                return u"VIDEO"
203
203
 
204
204
        if "DEVTYPE" in self._environment:
205
205
            devtype = self._environment["DEVTYPE"]
206
206
            if devtype == "disk":
207
207
                if "ID_CDROM" in self._environment:
208
 
                    return "CDROM"
 
208
                    return u"CDROM"
209
209
 
210
210
                if "ID_DRIVE_FLOPPY" in self._environment:
211
 
                    return "FLOPPY"
 
211
                    return u"FLOPPY"
212
212
 
213
213
            if devtype == "scsi_device":
214
214
                match = SCSI_RE.match(self._environment.get("MODALIAS", ""))
217
217
                # Check FLASH drives, see /lib/udev/rules.d/80-udisks.rules
218
218
                if type in (0, 7, 14) \
219
219
                   and not any(d.driver == "rts_pstor" for d in self._stack):
220
 
                    return "DISK"
 
220
                    return u"DISK"
221
221
 
222
222
                if type == 1:
223
 
                    return "TAPE"
 
223
                    return u"TAPE"
224
224
 
225
225
                if type == 2:
226
 
                    return "PRINTER"
 
226
                    return u"PRINTER"
227
227
 
228
228
                if type in (4, 5):
229
 
                    return "CDROM"
 
229
                    return u"CDROM"
230
230
 
231
231
                if type == 6:
232
 
                    return "SCANNER"
 
232
                    return u"SCANNER"
233
233
 
234
234
                if type == 12:
235
 
                    return "RAID"
 
235
                    return u"RAID"
236
236
 
237
237
        if "DRIVER" in self._environment:
238
238
            if self._environment["DRIVER"] == "floppy":
239
 
                return "FLOPPY"
 
239
                return u"FLOPPY"
240
240
 
241
241
        if self.product:
242
 
            return "OTHER"
 
242
            return u"OTHER"
243
243
 
244
244
        return None
245
245