appleLoops.py 文件源码

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

项目:appleLoops 作者: carlashley 项目源码 文件源码
def local_version(self, pkg_id):
        cmd = ['/usr/sbin/pkgutil', '--pkg-info-plist', pkg_id]
        (result, error) = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()  # NOQA

        if result:
            try:
                ver = plistlib.readPlistFromString(result)['pkg-version']
            except:
                # If the plist can't be read, or throws an exception, the package is probably not installed.  # NOQA
                ver = '0.0.0'

        if error:
            # If there is an error, then the package is probably not installed.
            # Unlikely to happen, because Apple seems to send stderr to stdout here.  # NOQA
            ver = '0.0.0'

        return ver
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号