Comment 10 for bug 399319

Revision history for this message
Abel Deuring (adeuring) wrote : Re: [Bug 399319] Re: Remove the HAL dependency from Launchpad HWDB and checkbox

On 23.08.2009 00:59, Marc Tardif wrote:
> If you are worried about the attribute-walk behavior being recursive,
> here's essentially what udevadm does given the path returned by udevadm
> info --export-db:

Right; that's a nice way to add all attribute data. I thin k it would
make sense to include it in the submitted data.

>
> def get_attributes(path):
> sys_path = "/sys%s" % path
> try:
> names = os.listdir(sys_path)
> except OSError:
> return None
>
> attributes = {}
> for name in names:
> name_path = posixpath.join(sys_path, name)
> if name[0] == "." \
> or name in ["dev", "uevent"] \
> or posixpath.isdir(name_path) \
> or posixpath.islink(name_path):
> continue
>
> try:
> value = open(name_path, "r").read().strip()
> except IOError:
> continue
>
> if [c for c in value if not isprint(c)]:
> continue
>
> attributes[name] = value
>
> return attributes
>