def __init__(self, xml=None): if xml is None: self._metricComparator = None self._metricName = None self._result = None self._parameters = [] elif isinstance(xml, str) or isinstance(xml, bytes) or iselement(xml): if isinstance(xml, str) or isinstance(xml, bytes): root = ElementTree.fromstring(xml) else: root = xml if root.tag != "value": raise PerfRepoException("Invalid xml.") self._metricComparator = root.get("metricComparator") self._metricName = root.get("metricName") self._result = float(root.get("result")) self._parameters = [] for param in root.find("parameters"): if param.tag != "parameter": continue self._parameters.append( (param.get("name"), param.get("value"))) else: raise PerfRepoException("Parameter xml must be"\ " a string, an Element or None")
def __init__(self, xml=None): if xml is None: self._id = None self._name = None self._uid = None self._description = "" self._groupid = None self._metrics = [] elif isinstance(xml, str) or isinstance(xml, bytes) or iselement(xml): if isinstance(xml, str) or isinstance(xml, bytes): root = ElementTree.fromstring(xml) else: root = xml if root.tag != "test": raise PerfRepoException("Invalid xml.") self._id = root.get("id") self._name = root.get("name") self._uid = root.get("uid") self._groupid = root.get("groupId") if root.find("description") is not None: self._description = root.find("description").text else: self._description = "" self._metrics = [] for metric in root.find("metrics"): if metric.tag != "metric": continue self._metrics.append(PerfRepoMetric(metric)) else: raise PerfRepoException("Parameter xml must be"\ " a string, an Element or None")
def __init__(self, xml=None): if xml is None: self._id = None self._name = None self._started = datetime.datetime.utcnow().isoformat() self._testId = None self._testUid = None self._comment = "" self._values = [] self._tags = [] self._parameters = [] elif isinstance(xml, str) or isinstance(xml, bytes) or iselement(xml): if isinstance(xml, str) or isinstance(xml, bytes): root = ElementTree.fromstring(xml) else: root = xml if root.tag != "testExecution": raise PerfRepoException("Invalid xml.") self._id = root.get("id") self._name = root.get("name") self._started = root.get("started") self._testId = root.get("testId") self._testUid = root.get("testUid") if root.find("comment") is not None: self._comment = root.find("comment").text else: self._comment = "" self._values = [] for value in root.find("values"): if value.tag != "value": continue self._values.append(PerfRepoValue(value)) self._tags = [] for tag in root.find("tags"): if tag.tag != "tag": continue self._tags.append(tag.get("name")) self._parameters = [] for param in root.find("parameters"): if param.tag != "parameter": continue self._parameters.append( (param.get("name"), param.get("value"))) else: raise PerfRepoException("Parameter xml must be"\ " a string, an Element or None")
def set_before_date(self, date, date_format="%Y-%m-%d"): try: before = datetime.datetime.strptime(date, date_format) except ValueError: raise PerfRepoException("Failed to convert before-date") self._before = before.isoformat()
def set_after_date(self, date, date_format="%Y-%m-%d"): try: after = datetime.datetime.strptime(date, date_format) except ValueError: raise PerfRepoException("Failed to convert after-date") self._after = after.isoformat()
def validate(self): if self._report_id is None: raise PerfRepoException("report id must be specified!") if self._access_level is None: raise PerfRepoException("access level must be specified!") if self._access_type is None: raise PerfRepoException("access level must be specified!") if self._access_level == "GROUP" and self._group_id == None: raise PerfRepoException("When access level is GROUP, "\ "group id must be specified!") if self._access_level == "USER" and self._user_id == None: raise PerfRepoException("When access level is GROUP, "\ "user id must be specified!")
def __init__(self, xml=None): self._user = None if xml is None: self._id = None self._name = None self._type = None self._properties = {} self._permissions = [] elif isinstance(xml, str) or isinstance(xml, bytes) or iselement(xml): if isinstance(xml, str) or isinstance(xml, bytes): root = ElementTree.fromstring(xml) else: root = xml if root.tag != "report": raise PerfRepoException("Invalid xml.") self._id = root.get("id") self._name = root.get("name") self._type = root.get("type") self._properties = {} for entry in root.find("properties"): if entry.tag != "entry": continue key_tag = entry.find("key") value_tag = entry.find("value") tmp_dict = dot_to_dict(value_tag.get("name"), value_tag.get("value")) recursive_dict_update(self._properties, tmp_dict) self._permissions = [] for entry in root.find("permissions"): if entry.tag != "permission": continue self._permissions.append(PerfRepoReportPermission(entry)) self._permissions[-1].set_report_id(self._id) self._permissions[-1].validate() else: raise PerfRepoException("Parameter xml must be"\ " a string, an Element or None")
def __init__(self, xml=None): self._report_id = None self._access_type = None self._access_level = None self._user_id = None self._group_id = None if xml is None: pass elif isinstance(xml, str) or isinstance(xml, bytes) or iselement(xml): if isinstance(xml, str) or isinstance(xml, bytes): root = ElementTree.fromstring(xml) else: root = xml if root.tag != "report-permission" and root.tag != "permission": raise PerfRepoException("Invalid xml.") self._id = root.find("id").text try: self._report_id = root.find("report-id").text except: self._report_id = None self._access_type = root.find("access-type").text self._access_level = root.find("access-level").text try: self._user_id = root.find("user-id").text except: self._user_id = None try: self._group_id = root.find("group-id").text except: self._group_id = None else: raise PerfRepoException("Parameter xml must be"\ " a string, an Element or None")
def __init__(self, xml=None): if xml is None: self._id = None self._name = None self._description = "" self._comparator = None elif isinstance(xml, str) or isinstance(xml, bytes) or iselement(xml): if isinstance(xml, str) or isinstance(xml, bytes): root = ElementTree.fromstring(xml) else: root = xml if root.tag != "metric": raise PerfRepoException("Invalid xml.") self._id = root.get("id") self._name = root.get("name") self._comparator = root.get("comparator") if root.find("description") is not None: self._description = root.find("description").text else: self._description = "" else: raise PerfRepoException("Parameter xml must be"\ " a string, an Element or None")
def __init__(self, xml=None): self._ids = None self._testUid = None self._testname = None self._tags = [] self._parameters = [] self._after = None self._before = None self._howmany = None if isinstance(xml, str) or isinstance(xml, bytes) or iselement(xml): if isinstance(xml, str) or isinstance(xml, bytes): root = ElementTree.fromstring(xml) else: root = xml if root.tag != "test-execution-search": raise PerfRepoException("Invalid xml.") elem_ids = root.find("ids") if elem_ids is not None: ids = [] for id in elem_ids: ids.append(id.text) self.set_ids(ids) self._testname = root.get("test-name") self._testUid = root.get("test-uid") elem_tags = root.find("tags") if elem_tags is not None and elem_tags.text is not None: tags = root.find("tags").text self._tags = tags.split() params = root.find("parameters") for param in params.findall("parameter"): pname = param.find("name") pvalue = param.find("value") self.add_parameter(pname.text, pvalue.text)
def set_comparator(self, comparator): if comparator not in ["HB", "LB"]: raise PerfRepoException("Invalid comparator value.") self._comparator = comparator
def set_access_level(self, access_level): if access_level not in ["USER", "GROUP", "PUBLIC"]: raise PerfRepoException("Possible access level values: "\ "USER, GROUP, PUBLIC") self._access_level = access_level
def set_access_type(self, access_type): if access_type not in ["READ", "WRITE"]: raise PerfRepoException("Possible access type values: READ, WRITE") self._access_type = access_type
def set_report_id(self, report_id): try: self._report_id = int(report_id) except: raise PerfRepoException("report id must be an integer")
def set_comparator(self, comparator): if comparator not in ["HB", "LB"]: raise PerfRepoException("Comparator must be HB/LB.") self._metricComparator = comparator