def chown(self, fn):
        if self.uid or self.gid:
            uid = self.uid
            if not uid:
                uid = os.stat(fn).st_uid
            gid = self.gid
            if not gid:
                gid = os.stat(fn).st_gid
            try:
                os.chown(fn, uid, gid)
            except OSError, (code, message):
                sys.exit("can't chown(%s, %d, %d): %s, %s" %
                (repr(fn), uid, gid, code, message))
Change the ownership of a file to match the daemon uid/gid
dataset/ETHPy150Open kiberpipa/Intranet/pipa/ltsp/src/ltsp_usage_monitor/daemon.py/Daemon.chown