sole/aafm — Issue #5: Windows - Unixisims (pwd/grp)
Author: psinnott
Created: 2011-10-12 02:47:26+00:00
State: open

aafm-gui imports and uses pwd and grp. An appropriate Windows replacement seems to be

def get_owner(self, filename):
#st = os.stat(filename)
#uid = st.st_uid
#user = pwd.getpwuid(uid)[0]
#return user

import win32api
import win32con
import win32security
sd = win32security.GetFileSecurity( filename , win32security.OWNER_SECURITY_INFORMATION)
owner_sid = sd.GetSecurityDescriptorOwner()
name, domain, type = win32security.LookupAccountSid (None, owner_sid)
return name

def get_group(self, filename):
#st = os.stat(filename)
#gid = st.st_gid
#return grp.getgrgid(gid)[0]
return ""