in rabbitmq/transcode_check.py [0:0]
def check_shape_tag(vsid, shapeid, tagtofind):
"""
check if the given shape on the given item is of the given shape tag
if it is, then return the parsed document tree
:param vsid: vidispine item ID
:param shapeid: shape ID on the item ID
:param tagtofind: shape tagname
:return: either None or the parsed xml data
"""
url = "{0}/API/item/{1}/shape/{2}".format(settings.VIDISPINE_URL,vsid, shapeid)
result = requests.get(url, auth=(settings.VIDISPINE_USERNAME,settings.VIDISPINE_PASSWORD), headers={"Accept":"application/xml"})
if result.status_code == 200:
doc = fromstring(result.text.encode("utf-8"))
shape_tag_node = doc.find("{0}tag".format(xmlns))
if shape_tag_node is None:
logger.warning("shape {0} on item {1} has no shape tag node".format(shapeid, vsid))
return None
if shape_tag_node.text == tagtofind:
return doc
else:
return None
else:
raise Exception("could not list shape ids on {0}, server returned {1}".format(vsid, result.status_code))