本文整理汇总了Python中stratuslab.Util.checkUrlExists方法的典型用法代码示例。如果您正苦于以下问题:Python Util.checkUrlExists方法的具体用法?Python Util.checkUrlExists怎么用?Python Util.checkUrlExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stratuslab.Util
的用法示例。
在下文中一共展示了Util.checkUrlExists方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: doWork
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import checkUrlExists [as 别名]
def doWork(self):
# checking marketplace endpoint URL
url_is_ok = Util.checkUrlExists(ENDPOINT_MKP, 30)
if url_is_ok is True:
req = urllib2.Request(ENDPOINT_MKP)
response = urllib2.urlopen(req)
content = response.read()
xml = Util.etree_from_text(content)
desc_nodes = xml.iter("{" + RDF + "}Description")
all_desc = []
desc = {}
for desc_node in desc_nodes:
desc["description"] = desc_node.find('{' + DCTERMS + '}description').text
desc["identifier"] = desc_node.find('{' + DCTERMS + '}identifier').text
desc["creator"] = desc_node.find('{' + DCTERMS + '}creator').text
desc["created"] = desc_node.find('{' + DCTERMS + '}created').text
desc["os"] = desc_node.find('{' + SLTERMS + '}os').text
desc["os-version"] = desc_node.find('{' + SLTERMS + '}os-version').text
desc["os-arch"] = desc_node.find('{' + SLTERMS + '}os-arch').text
# cast in str for NoneType object (otherwise, we should use try/Except)
print "Description: " + str(desc["description"])
print "ID: " + str(desc["identifier"])
print "OS: " + str(desc["os"]), str(desc["os-version"]), "| Arch: " + str(desc["os-arch"])
print "Creator: " + str(desc["creator"])
print "Created at: " + str(desc["created"].replace("Z", "").split('T'))
print "####\n"
all_desc.append(desc)
示例2: _checkImageByUrl
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import checkUrlExists [as 别名]
def _checkImageByUrl(self, imageUrl):
try:
Util.checkUrlExists(imageUrl)
except (Exceptions.ValidationException, Exceptions.ExecutionException), ex:
raise Exceptions.ValidationException("Unable to access image '%s': %s" %
(imageUrl, str(ex)))
示例3: doWork
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import checkUrlExists [as 别名]
def doWork(self):
id = self.options.image
# checking marketplace endpoint URL
url_is_ok = Util.checkUrlExists(ENDPOINT_MKP, 30)
if url_is_ok is True and id is not False:
req = urllib2.Request(ENDPOINT_MKP)
response = urllib2.urlopen(req)
content = response.read()
xml = Util.etree_from_text(content)
desc_nodes = xml.iter("{" + RDF + "}Description")
desc = {}
for desc_node in desc_nodes:
desc["identifier"] = desc_node.find('{' + DCTERMS + '}identifier').text
if id == desc["identifier"]:
desc["checksum"] = {}
desc["checksum"]["val"] = []
desc["checksum"]["algo"] = []
desc["description"] = desc_node.find('{' + DCTERMS + '}description').text
desc["creator"] = desc_node.find('{' + DCTERMS + '}creator').text
desc["created"] = desc_node.find('{' + DCTERMS + '}created').text
desc["valid"] = desc_node.find('{' + DCTERMS + '}valid').text
desc["os"] = desc_node.find('{' + SLTERMS + '}os').text
desc["os-version"] = desc_node.find('{' + SLTERMS + '}os-version').text
desc["os-arch"] = desc_node.find('{' + SLTERMS + '}os-arch').text
desc["version"] = desc_node.find('{' + SLTERMS + '}version').text
desc["compression"] = desc_node.find('{' + DCTERMS + '}compression').text
desc["location"] = desc_node.find('{' + SLTERMS + '}location').text
desc["location"] = desc_node.find('{' + SLTERMS + '}location').text
desc["format"] = desc_node.find('{' + DCTERMS + '}format').text
desc["publisher"] = desc_node.find('{' + DCTERMS + '}publisher').text
desc["hypervisor"] = desc_node.find('{' + SLTERMS + '}hypervisor').text
for check in desc_node.findall('{' + SLREQ + '}checksum'):
desc["checksum"]["algo"].append(check.find('{' + SLREQ + '}algorithm').text)
desc["checksum"]["val"].append(check.find('{' + SLREQ + '}value').text)
for endorsement in desc_node.findall('{' + SLREQ + '}endorsement'):
for endorser in endorsement.findall('{' + SLREQ + '}endorser'):
desc["email"] = endorser.find('{' + SLREQ + '}email').text
# cast in str for None object (otherwise, I should use try/Except)
print "Description: " + str(desc["description"])
print "ID: " + str(desc["identifier"])
print "Creator: " + str(desc["creator"])
print "Created at: " + str(desc["created"].replace("Z", "").split('T'))
print "Validity: " + str(desc["valid"].replace("Z", "").split('T'))
print "OS: " + str(desc["os"]), str(desc["os-version"]), "| Arch: " + str(desc["os-arch"])
print "Version: " + str(desc["version"])
print "Compression: " + str(desc["compression"])
print "Location: " + str(desc["location"])
print "Format: " + str(desc["format"])
print "Publisher: " + str(desc["publisher"])
print "Hypervisor: " + str(desc["hypervisor"])
print "Endorser: " + str(desc["email"])
for i in range(len(desc["checksum"]["algo"])):
print str(desc["checksum"]["algo"][i]), str(desc["checksum"]["val"][i])
print "####\n"
示例4: doWork
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import checkUrlExists [as 别名]
def doWork(self):
key_criteria = {"creator": "",
"email": "",
"os": "",
"description": "",
"regexp": "",
"arch": ""}
use_regexp = False
if self.options.creator is not None:
creator = self.options.creator
key_criteria["creator"] = creator
if self.options.email is not None:
email = self.options.email
key_criteria["email"] = email
if self.options.os is not None:
os = self.options.os
key_criteria["os"] = os
if self.options.description is not None:
description = self.options.description
key_criteria["description"] = description
description_compile = None
if self.options.regexp is not None:
regexp = self.options.regexp
use_regexp = True
key_criteria["description"] = regexp
description_compile = re.compile(regexp)
if self.options.arch is not None:
arch = self.options.arch
key_criteria["arch"] = arch
# checking marketplace endpoint URL
url_is_ok = Util.checkUrlExists(ENDPOINT_MKP, 30)
if url_is_ok is True:
req = urllib2.Request(ENDPOINT_MKP)
response = urllib2.urlopen(req)
content = response.read()
xml = Util.etree_from_text(content)
desc_nodes = xml.iter("{" + RDF + "}Description")
desc = {}
found = 0
for desc_node in desc_nodes:
if key_criteria["creator"] != "":
desc["creator"] = desc_node.find('{' + DCTERMS + '}creator').text
if key_criteria["creator"] == desc["creator"]:
if found < 1:
print "####"
found += 1
print "CREATOR FOUND"
if key_criteria["os"] != "":
desc["os"] = desc_node.find('{' + SLTERMS + '}os').text
if key_criteria["os"] == desc["os"]:
if found < 1:
print "####"
found += 1
print "OS FOUND"
if key_criteria["arch"] != "":
desc["arch"] = desc_node.find('{' + SLTERMS + '}os-arch').text
if key_criteria["arch"] == desc["arch"]:
if found < 1:
print "####"
found += 1
print "ARCH FOUND"
if key_criteria["description"] != "":
desc["description"] = desc_node.find('{' + DCTERMS + '}description').text
if use_regexp is False:
if key_criteria["description"] == desc["description"]:
if found < 1:
print "####"
found += 1
print "DESCRIPTION FOUND"
else:
if desc["description"] is not None and description_compile is not None:
if description_compile.search(desc["description"]):
if found < 1:
print "####"
found += 1
print "DESCRIPTION[REGEXP] FOUND"
if key_criteria["email"] != "":
for endorsement in desc_node.findall('{' + SLREQ + '}endorsement'):
for endorser in endorsement.findall('{' + SLREQ + '}endorser'):
desc["email"] = endorser.find('{' + SLREQ + '}email').text
if key_criteria["email"] == desc["email"]:
if found < 1:
print "####"
found += 1
print "EMAIL FOUND"
#.........这里部分代码省略.........