os_unix.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:solaris-ips 作者: oracle 项目源码 文件源码
def get_usernames_by_gid(gid, dirpath):
        if not already_called():
                get_usernames_by_gid(gid, dirpath)

        try:
                load_passwd(dirpath)
                return [unam
                    for unam, pwdentry in users[dirpath].items()
                    if str(pwdentry.pw_gid) == gid
                ]
        except OSError as e:
                if e.errno != errno.ENOENT:
                        raise
                # If the password file doesn't exist, bootstrap
                # ourselves from the current environment.
                # The following call could be expensive.
                allpwdentries = pwd.getpwall()
                if not allpwdentries:
                        allpwdentries = []
                return [
                    pwdentry.pw_name
                    for pwdentry in allpwdentries
                    if str(pwdentry.pw_gid) == gid
                ]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号