1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-31 10:11:17 +00:00

framework/output: add accessors for metrics and artifacts

- Add get_metric methods to Result and Output
- Add metrics and artifacts properties to Output
This commit is contained in:
Sergei Trofimov 2017-09-15 13:39:24 +01:00
parent 9b6d4d9fa6
commit 82b0b238c2

View File

@ -49,6 +49,18 @@ class Output(object):
def status(self, value): def status(self, value):
self.result.status = value self.result.status = value
@property
def metrics(self):
if self.result is None:
return []
return self.result.metrics
@property
def artifacts(self):
if self.result is None:
return []
return self.result.artifacts
def __init__(self, path): def __init__(self, path):
self.basepath = path self.basepath = path
self.result = None self.result = None
@ -84,6 +96,9 @@ class Output(object):
def add_event(self, message): def add_event(self, message):
self.result.add_event(message) self.result.add_event(message)
def get_metric(self, name):
return self.result.get_metric(name)
def get_artifact(self, name): def get_artifact(self, name):
return self.result.get_artifact(name) return self.result.get_artifact(name)
@ -241,6 +256,12 @@ class Result(object):
def add_event(self, message): def add_event(self, message):
self.events.append(Event(message)) self.events.append(Event(message))
def get_metric(self, name):
for metric in self.metrics:
if metric.name == name:
return metric
return None
def get_artifact(self, name): def get_artifact(self, name):
for artifact in self.artifacts: for artifact in self.artifacts:
if artifact.name == name: if artifact.name == name: