How to set a files owner in python?
os.chown(path, uid, gid)
http://docs.python.org/library/os.html
The uid and gid can be retrieved from a string by
import pwd
import grp
import os
uid = pwd.getpwnam("nobody").pw_uid
gid = grp.getgrnam("nogroup").gr_gid
Reference: How to change the user and group permissions for a directory, by name?