def xattr_writes_supported(path):
 try:
  import xattr
 except ImportError:
  return False
 def set_xattr(path, key, value):
  xattr.setxattr(path, ('user.%s' % key), str(value))
 fake_filepath = os.path.join(path, 'testing-checkme')
 result = True
 with open(fake_filepath, 'wb') as fake_file:
  fake_file.write('XXX')
  fake_file.flush()
 try:
  set_xattr(fake_filepath, 'hits', '1')
 except IOError as e:
  if (e.errno == errno.EOPNOTSUPP):
   result = False
 else:
  if os.path.exists(fake_filepath):
   os.unlink(fake_filepath)
 return result

def xattr_writes_supported ( path ) : try : import xattr except ImportError : return False def set_xattr ( path , key , value ) : xattr . setxattr ( path , ( 'user.%s' % key ) , str ( value ) ) fake_filepath = os . path . join ( path , 'testing-checkme' ) result = True with open ( fake_filepath , 'wb' ) as fake_file : fake_file . write ( 'XXX' ) fake_file . flush ( ) try : set_xattr ( fake_filepath , 'hits' , '1' ) except IOError as e : if ( e . errno == errno . EOPNOTSUPP ) : result = False else : if os . path . exists ( fake_filepath ) : os . unlink ( fake_filepath ) return result
returns true if the we can write a file to the supplied path and subsequently write a xattr to that file .