def chown(self, fn):
        """Change the ownership of a file to match the daemon uid/gid"""
        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 __HOLE__, (code, message):
                sys.exit("can't chown(%s, %d, %d): %s, %s" %
                (repr(fn), uid, gid, code, message))
dataset/ETHPy150Open kiberpipa/Intranet/pipa/ltsp/src/ltsp_usage_monitor/daemon.py/Daemon.chown