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
>
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.
> path): sys_path) join(sys_ path, name) isdir(name_ path) \ islink( name_path) :
> def get_attributes(
> sys_path = "/sys%s" % path
> try:
> names = os.listdir(
> except OSError:
> return None
>
> attributes = {}
> for name in names:
> name_path = posixpath.
> if name[0] == "." \
> or name in ["dev", "uevent"] \
> or posixpath.
> or posixpath.
> 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
>