~launchpad-results/launchpad-results/trunk

« back to all changes in this revision

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

  • Committer: Marc Tardif
  • Date: 2011-08-09 15:46:45 UTC
  • Revision ID: marc.tardif@canonical.com-20110809154645-i151emhk6onjggx5
Added hardware for systems and system units.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2010-2011 Canonical Ltd.  This software is licensed under the
 
2
# GNU Affero General Public License version 3 (see the file LICENSE).
 
3
 
 
4
__metaclass__ = type
 
5
 
 
6
__all__ = [
 
7
    "DmesgParser",
 
8
    ]
 
9
 
 
10
from re import compile
 
11
from string import hexdigits
 
12
 
 
13
 
 
14
ADDRESS_RE = compile(r"^.*eth.*(?P<address>([%(hex)s]{2}:){5}[%(hex)s]{2})"
 
15
    % {"hex": hexdigits})
 
16
 
 
17
 
 
18
class DmesgParser:
 
19
 
 
20
    def __init__(self, stream):
 
21
        self.stream = stream
 
22
 
 
23
    def run(self, result):
 
24
        for line in self.stream:
 
25
            match = ADDRESS_RE.match(line)
 
26
            if match:
 
27
                address = match.group("address")
 
28
                result.addAddress(address)