本文整理汇总了Python中Image.Image.fromJson方法的典型用法代码示例。如果您正苦于以下问题:Python Image.fromJson方法的具体用法?Python Image.fromJson怎么用?Python Image.fromJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image.Image
的用法示例。
在下文中一共展示了Image.fromJson方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getImage
# 需要导入模块: from Image import Image [as 别名]
# 或者: from Image.Image import fromJson [as 别名]
def getImage(self, name):
""" returns an Image for the given name, or None if not found """
retVal = None
img_data = self.client.inspect_image(name)
if img_data:
retVal = Image.fromJson(img_data)
retVal.tags = [ name if isinstance(name, ImageTag) else ImageTag.parse(name) ]
return retVal
示例2: test_fromJson
# 需要导入模块: from Image import Image [as 别名]
# 或者: from Image.Image import fromJson [as 别名]
def test_fromJson(self):
img = Image.fromJson({
"id": "2e2d7133e4a578bd861e85e7195412201f765d050af78c7906841ea62eb6f7dd",
"parent": "c79dab5561020bda9ce1b1cbe76283fc95f824cfb26a8a21a384993ed7f392bd",
"created": "2014-10-21T08:50:44.448455269Z",
"container": "b756100785c797b9f43d36f249b0d5688d88a1ca68df56d915cb436c4bfc7286",
"config": {
"Hostname": "965c252e48c3",
"User": "",
"Memory": 0,
"MemorySwap": 0,
"AttachStdin": False,
"AttachStdout": False,
"AttachStderr": False,
"PortSpecs": None,
"Tty": False,
"OpenStdin": False,
"StdinOnce": False,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"DOCKER_REGISTRY_CONFIG=/docker-registry/config/config_sample.yml",
"SETTINGS_FLAVOR=dev",
"HOME=/"
],
"Entrypoint": None,
"Cmd": [ "/bin/sh", "-c", "exec", "docker-registry" ],
"Image": "c79dab5561020bda9ce1b1cbe76283fc95f824cfb26a8a21a384993ed7f392bd",
"Volumes": None,
"WorkingDir": "",
},
})
eq_(img.id, "2e2d7133e4a578bd861e85e7195412201f765d050af78c7906841ea62eb6f7dd")
eq_(img.entrypoint, None)
eq_(img.command, [ "/bin/sh", "-c", "exec", "docker-registry" ])
eq_(img.env, {
"DOCKER_REGISTRY_CONFIG": "/docker-registry/config/config_sample.yml",
"SETTINGS_FLAVOR": "dev",
})