1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +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:
Marc Bonnici 2019-10-02 16:16:01 +01:00 committed by setrofim
parent 5e69f06d77
commit bb1552151a
5 changed files with 20 additions and 0 deletions

View File

@ -159,3 +159,7 @@ class AcmeCapeInstrument(Instrument):
def get_raw(self):
return [self.raw_data_file]
def teardown(self):
if os.path.isfile(self.raw_data_file):
os.remove(self.raw_data_file)

View File

@ -142,3 +142,7 @@ class ArmEnergyProbeInstrument(Instrument):
def get_raw(self):
return [self.output_file_raw]
def teardown(self):
if os.path.isfile(self.output_file_raw):
os.remove(self.output_file_raw)

View File

@ -14,6 +14,7 @@
#
import os
import shutil
import tempfile
from itertools import chain
@ -154,6 +155,8 @@ class DaqInstrument(Instrument):
def teardown(self):
self.execute('close')
if os.path.isdir(tempdir):
shutil.rmtree(tempdir)
def execute(self, command, **kwargs):
return execute_command(self.server_config, command, **kwargs)

View File

@ -126,3 +126,7 @@ class EnergyProbeInstrument(Instrument):
def get_raw(self):
return [self.raw_data_file]
def teardown(self):
if os.path.isfile(self.raw_data_file):
os.remove(self.raw_data_file)

View File

@ -70,6 +70,11 @@ class FramesInstrument(Instrument):
def _init_channels(self):
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):