appliances.py 文件源码

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

项目:gns3-documentation-template 作者: GNS3 项目源码 文件源码
def get_appliances():
    """
    This will download an archive of all GNS3 appliances and load them to a dictionnary
    """
    appliances = {}

    url = 'https://github.com/GNS3/gns3-registry/archive/master.zip'
    response = urllib.request.urlopen(url)
    z = zipfile.ZipFile(io.BytesIO(response.read()))
    for path in z.namelist():
        if path.endswith('.gns3a'):
            with z.open(path, 'r') as f:
                id = os.path.basename(path).split('.')[0]
                appliance = json.loads(f.read().decode())
                if appliance["status"] != "broken":
                    appliances[id] = appliance
    return appliances
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号