mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 10:10:46 +00:00
instruments: Add teardown method to clean up tempfiles
Implement the `teardown` method in instruments that utilise tempfiles which were previously left behind.
This commit is contained in:
parent
5e69f06d77
commit
bb1552151a
@ -159,3 +159,7 @@ class AcmeCapeInstrument(Instrument):
|
|||||||
|
|
||||||
def get_raw(self):
|
def get_raw(self):
|
||||||
return [self.raw_data_file]
|
return [self.raw_data_file]
|
||||||
|
|
||||||
|
def teardown(self):
|
||||||
|
if os.path.isfile(self.raw_data_file):
|
||||||
|
os.remove(self.raw_data_file)
|
||||||
|
@ -142,3 +142,7 @@ class ArmEnergyProbeInstrument(Instrument):
|
|||||||
|
|
||||||
def get_raw(self):
|
def get_raw(self):
|
||||||
return [self.output_file_raw]
|
return [self.output_file_raw]
|
||||||
|
|
||||||
|
def teardown(self):
|
||||||
|
if os.path.isfile(self.output_file_raw):
|
||||||
|
os.remove(self.output_file_raw)
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
|
||||||
@ -154,6 +155,8 @@ class DaqInstrument(Instrument):
|
|||||||
|
|
||||||
def teardown(self):
|
def teardown(self):
|
||||||
self.execute('close')
|
self.execute('close')
|
||||||
|
if os.path.isdir(tempdir):
|
||||||
|
shutil.rmtree(tempdir)
|
||||||
|
|
||||||
def execute(self, command, **kwargs):
|
def execute(self, command, **kwargs):
|
||||||
return execute_command(self.server_config, command, **kwargs)
|
return execute_command(self.server_config, command, **kwargs)
|
||||||
|
@ -126,3 +126,7 @@ class EnergyProbeInstrument(Instrument):
|
|||||||
|
|
||||||
def get_raw(self):
|
def get_raw(self):
|
||||||
return [self.raw_data_file]
|
return [self.raw_data_file]
|
||||||
|
|
||||||
|
def teardown(self):
|
||||||
|
if os.path.isfile(self.raw_data_file):
|
||||||
|
os.remove(self.raw_data_file)
|
||||||
|
@ -70,6 +70,11 @@ class FramesInstrument(Instrument):
|
|||||||
def _init_channels(self):
|
def _init_channels(self):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
def teardown(self):
|
||||||
|
if not self.keep_raw:
|
||||||
|
if os.path.isfile(self._raw_file):
|
||||||
|
os.remove(self._raw_file)
|
||||||
|
|
||||||
|
|
||||||
class GfxInfoFramesInstrument(FramesInstrument):
|
class GfxInfoFramesInstrument(FramesInstrument):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user