mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
collector: Update the Collector Interface
Update `get_trace` to `get_data` to better reflect the purpose. The return type of said method will be a `CollectorOutput` object will contain one or more `CollectorOutputEntry` objects which will be used to provide the `path`and `path_kind` attributes to indicate the path to the obtained output and it's type (currently a "file" or "directory") respectively.
This commit is contained in:
parent
19887de71e
commit
9bf9f2dd1b
@ -15,12 +15,14 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from devlib.utils.types import caseless_string
|
||||||
|
|
||||||
class CollectorBase(object):
|
class CollectorBase(object):
|
||||||
|
|
||||||
def __init__(self, target):
|
def __init__(self, target):
|
||||||
self.target = target
|
self.target = target
|
||||||
self.logger = logging.getLogger(self.__class__.__name__)
|
self.logger = logging.getLogger(self.__class__.__name__)
|
||||||
|
self.output_path = None
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
pass
|
pass
|
||||||
@ -31,6 +33,12 @@ class CollectorBase(object):
|
|||||||
def stop(self):
|
def stop(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def set_output(self, output_path):
|
||||||
|
self.output_path = output_path
|
||||||
|
|
||||||
|
def get_data(self):
|
||||||
|
return CollectorOutput()
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
self.reset()
|
self.reset()
|
||||||
self.start()
|
self.start()
|
||||||
@ -39,5 +47,29 @@ class CollectorBase(object):
|
|||||||
def __exit__(self, exc_type, exc_value, traceback):
|
def __exit__(self, exc_type, exc_value, traceback):
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
def get_trace(self, outfile):
|
class CollectorOutputEntry(object):
|
||||||
pass
|
|
||||||
|
path_kinds = ['file', 'directory']
|
||||||
|
|
||||||
|
def __init__(self, path, path_kind):
|
||||||
|
self.path = path
|
||||||
|
|
||||||
|
path_kind = caseless_string(path_kind)
|
||||||
|
if path_kind not in self.path_kinds:
|
||||||
|
msg = '{} is not a valid path_kind [{}]'
|
||||||
|
raise ValueError(msg.format(path_kind, ' '.join(self.path_kinds)))
|
||||||
|
self.path_kind = path_kind
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.path
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return '<{} ({})>'.format(self.path, self.path_kind)
|
||||||
|
|
||||||
|
def __fspath__(self):
|
||||||
|
"""Allow using with os.path operations"""
|
||||||
|
return self.path
|
||||||
|
|
||||||
|
|
||||||
|
class CollectorOutput(list):
|
||||||
|
pass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user