def get_uid_gid(uid, gid=None):
    """Try to change UID and GID to the provided values.
    UID and GID are given as names like 'nobody' not integer.

    Src: http://mail.mems-exchange.org/durusmail/quixote-users/4940/1/
    """
    import pwd, grp
    uid, default_grp = pwd.getpwnam(uid)[2:4]
    if gid is None:
        gid = default_grp
    else:
        try:
            gid = grp.getgrnam(gid)[2]            
        except __HOLE__:
            gid = default_grp
    return (uid, gid)
dataset/ETHPy150Open lincolnloop/django-cpserver/django_cpserver/management/commands/runcpserver.py/get_uid_gid