mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
instruments: Add keep_raw
parameter to control teardown deletion
Add a `keep_raw` parameter that prevents raw files from being deleted during teardown in case they are still required.
This commit is contained in:
parent
bb1552151a
commit
0d6c6883dd
@ -58,12 +58,14 @@ class AcmeCapeInstrument(Instrument):
|
||||
iio_capture=which('iio-capture'),
|
||||
host='baylibre-acme.local',
|
||||
iio_device='iio:device0',
|
||||
buffer_size=256):
|
||||
buffer_size=256,
|
||||
keep_raw=False):
|
||||
super(AcmeCapeInstrument, self).__init__(target)
|
||||
self.iio_capture = iio_capture
|
||||
self.host = host
|
||||
self.iio_device = iio_device
|
||||
self.buffer_size = buffer_size
|
||||
self.keep_raw = keep_raw
|
||||
self.sample_rate_hz = 100
|
||||
if self.iio_capture is None:
|
||||
raise HostError('Missing iio-capture binary')
|
||||
@ -161,5 +163,6 @@ class AcmeCapeInstrument(Instrument):
|
||||
return [self.raw_data_file]
|
||||
|
||||
def teardown(self):
|
||||
if os.path.isfile(self.raw_data_file):
|
||||
os.remove(self.raw_data_file)
|
||||
if not self.keep_raw:
|
||||
if os.path.isfile(self.raw_data_file):
|
||||
os.remove(self.raw_data_file)
|
||||
|
@ -71,7 +71,7 @@ class ArmEnergyProbeInstrument(Instrument):
|
||||
|
||||
MAX_CHANNELS = 12 # 4 Arm Energy Probes
|
||||
|
||||
def __init__(self, target, config_file='./config-aep', ):
|
||||
def __init__(self, target, config_file='./config-aep', keep_raw=False):
|
||||
super(ArmEnergyProbeInstrument, self).__init__(target)
|
||||
self.arm_probe = which('arm-probe')
|
||||
if self.arm_probe is None:
|
||||
@ -80,6 +80,7 @@ class ArmEnergyProbeInstrument(Instrument):
|
||||
self.attributes = ['power', 'voltage', 'current']
|
||||
self.sample_rate_hz = 10000
|
||||
self.config_file = config_file
|
||||
self.keep_raw = keep_raw
|
||||
|
||||
self.parser = AepParser()
|
||||
#TODO make it generic
|
||||
@ -144,5 +145,6 @@ class ArmEnergyProbeInstrument(Instrument):
|
||||
return [self.output_file_raw]
|
||||
|
||||
def teardown(self):
|
||||
if os.path.isfile(self.output_file_raw):
|
||||
os.remove(self.output_file_raw)
|
||||
if not self.keep_raw:
|
||||
if os.path.isfile(self.output_file_raw):
|
||||
os.remove(self.output_file_raw)
|
||||
|
@ -45,9 +45,11 @@ class DaqInstrument(Instrument):
|
||||
dv_range=0.2,
|
||||
sample_rate_hz=10000,
|
||||
channel_map=(0, 1, 2, 3, 4, 5, 6, 7, 16, 17, 18, 19, 20, 21, 22, 23),
|
||||
keep_raw=False
|
||||
):
|
||||
# pylint: disable=no-member
|
||||
super(DaqInstrument, self).__init__(target)
|
||||
self.keep_raw = keep_raw
|
||||
self._need_reset = True
|
||||
self._raw_files = []
|
||||
if execute_command is None:
|
||||
@ -155,8 +157,9 @@ class DaqInstrument(Instrument):
|
||||
|
||||
def teardown(self):
|
||||
self.execute('close')
|
||||
if os.path.isdir(tempdir):
|
||||
shutil.rmtree(tempdir)
|
||||
if not self.keep_raw:
|
||||
if os.path.isdir(tempdir):
|
||||
shutil.rmtree(tempdir)
|
||||
|
||||
def execute(self, command, **kwargs):
|
||||
return execute_command(self.server_config, command, **kwargs)
|
||||
|
@ -34,9 +34,11 @@ class EnergyProbeInstrument(Instrument):
|
||||
def __init__(self, target, resistor_values,
|
||||
labels=None,
|
||||
device_entry='/dev/ttyACM0',
|
||||
keep_raw=False
|
||||
):
|
||||
super(EnergyProbeInstrument, self).__init__(target)
|
||||
self.resistor_values = resistor_values
|
||||
self.keep_raw = keep_raw
|
||||
if labels is not None:
|
||||
self.labels = labels
|
||||
else:
|
||||
@ -128,5 +130,6 @@ class EnergyProbeInstrument(Instrument):
|
||||
return [self.raw_data_file]
|
||||
|
||||
def teardown(self):
|
||||
if os.path.isfile(self.raw_data_file):
|
||||
os.remove(self.raw_data_file)
|
||||
if self.keep_raw:
|
||||
if os.path.isfile(self.raw_data_file):
|
||||
os.remove(self.raw_data_file)
|
||||
|
Loading…
x
Reference in New Issue
Block a user