1

I have mounted a drive.

In it's "Get Info", I have an attribute named Image Disk

The location: /private/var/run/vmware/fuse/10323660103412696815/flat

How can I get this attribute using python?

os.stat does not give me this.

JayRizzo
  • 3,234
  • 3
  • 33
  • 49
AliBZ
  • 4,039
  • 12
  • 45
  • 67

1 Answers1

4

Use the getxattr function from the xattr module, which is a Python binding to the native function getxattr(2). For example:

import xattr
print xattr.getattr('/Volumes/MyDrive', 'Image Disk')

See this blog post for a more detailed example.

JayRizzo
  • 3,234
  • 3
  • 33
  • 49
Adam Rosenfield
  • 390,455
  • 97
  • 512
  • 589
  • Thanx but it doesn't return or print anything – AliBZ Jun 13 '12 at 00:25
  • 1
    @AliBZ: Is it possible the attribute isn't actually called "Image Disk", but rather something like "com.vmware.ImageDisk"? Try using ls -l@ or the xattr command-line tool to see. If that's it, just use the code from this answer with the right attribute name, and it will work. – abarnert Jun 13 '12 at 19:11
  • Right -- `xattr -l` or `ls -l@` from the command line, or `xattr.lisxtattr()` in Python, will give you a list of all of the extended attributes of the file. – Adam Rosenfield Jun 13 '12 at 19:18