def get_uid_gid(username, groupname=None):
  try:
    uid, default_grp = pwd.getpwnam(username)[2:4]
  except KeyError:
    raise KeyError("Couldn't get user id for user %s" % (username,))
  if groupname is None:
    gid = default_grp
  else:
    try:
      gid = grp.getgrnam(groupname)[2]
    except KeyError:
      raise KeyError("Couldn't get group id for group %s" % (groupname,))
  return (uid, gid)
Try to change UID and GID to the provided values.
dataset/ETHPy150Open cloudera/hue/desktop/core/src/desktop/lib/daemon_utils.py/get_uid_gid