~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-03-21 22:32:04 UTC
  • Revision ID: marc.tardif@canonical.com-20120321223204-8g7mvzzwmh8ifbrt
Added support for getting systems from a person (LP #899361)

Show diffs side-by-side

added added

removed removed

Lines of Context:
183
183
            else:
184
184
                return u"KEYBOARD"
185
185
 
 
186
            if test_bit(Input.KEY_CAMERA, bitmask, self._bits):
 
187
                return u"CAPTURE"
 
188
 
186
189
            if test_bit(Input.BTN_TOUCH, bitmask, self._bits):
187
190
                return u"TOUCH"
188
191
 
258
261
 
259
262
    @property
260
263
    def path(self):
261
 
        return self._environment.get("DEVPATH")
 
264
        devpath = self._environment.get("DEVPATH")
 
265
        if self._environment.get("DEVTYPE") == "disk" and self._stack:
 
266
            devpath = re.sub(r"/[^/]+/[^/]+$", "", devpath)
 
267
 
 
268
        return devpath
262
269
 
263
270
    @property
264
271
    def product_id(self):
327
334
            for device in reversed(self._stack):
328
335
                if device._environment.get("ID_BUS") == "usb":
329
336
                    return decode_id(device._environment["ID_MODEL_ENC"])
330
 
 
331
 
        if self._environment.get("DEVTYPE") == "disk" \
332
 
           and self._environment.get("ID_BUS") == "ata":
 
337
        elif self._environment.get("DEVTYPE") == "disk" \
 
338
           and "ID_MODEL_ENC" in self._environment:
333
339
            return decode_id(self._environment["ID_MODEL_ENC"])
334
340
 
335
341
        # floppy
356
362
            for device in reversed(self._stack):
357
363
                if device._environment.get("ID_BUS") == "usb":
358
364
                    return decode_id(device._environment["ID_VENDOR_ENC"])
 
365
        elif self._environment.get("DEVTYPE") == "disk" \
 
366
           and "ID_VENDOR_ENC" in self._environment:
 
367
            return decode_id(self._environment["ID_VENDOR_ENC"])
359
368
 
360
369
        return None
361
370
 
401
410
        multi_pattern = re.compile(r"(?P<key>[^=]+)=(?P<value>.*)")
402
411
 
403
412
        stack = []
404
 
        output = self.stream.read()
405
 
        for record in re.split("\n{2,}", output):
 
413
        udevadm = self.stream.read()
 
414
        for record in re.split("\n{2,}", udevadm):
406
415
            record = record.strip()
407
416
            if not record:
408
417
                continue
448
457
            stack.append(device)
449
458
 
450
459
 
451
 
def decode_id(id):
452
 
    encoded_id = id.encode("utf-8")
453
 
    decoded_id = encoded_id.decode("string-escape").decode("utf-8")
454
 
    return decoded_id.strip()
 
460
def decode_id(identifier):
 
461
    return (identifier
 
462
        .encode("utf-8")
 
463
        .decode("string-escape")
 
464
        .rstrip("\xFF")
 
465
        .decode("utf-8")
 
466
        .strip())