diff --git a/owrx/config/core.py b/owrx/config/core.py index afa7e745..1134d86c 100644 --- a/owrx/config/core.py +++ b/owrx/config/core.py @@ -4,6 +4,9 @@ import os import re from glob import glob +import logging + +logger = logging.getLogger(__name__) class CoreConfig(object): defaults = { @@ -47,6 +50,11 @@ class CoreConfig(object): if not os.access(dir, os.W_OK): raise ConfigError(key, "{dir} is not writable".format(dir=dir)) + # Get complete path to a stored file from its filename by + # adding folder name + def getStoredFilePath(self, filename): + return self.get_temporary_directory() + "/" + filename + # Get list of stored files, sorted in reverse alphabetic order # (so that newer files appear first) def getStoredFiles(self): @@ -56,13 +64,13 @@ class CoreConfig(object): # Delete all stored files except for newest ones def cleanStoredFiles(self, keepN): - dir = self.get_temporary_directory() - files = self.getFileList() + files = self.getStoredFiles() for f in files[keepN:]: + logger.debug("Deleting stored file '%s'." % f) try: - os.unlink(dir + "/" + f) - except Exception: - pass + os.unlink(self.getStoredFilePath(f)) + except Exception as exptn: + logger.debug(str(exptn)) def get_web_port(self): return self.web_port diff --git a/owrx/controllers/file.py b/owrx/controllers/file.py index becbef96..c29653d0 100644 --- a/owrx/controllers/file.py +++ b/owrx/controllers/file.py @@ -4,7 +4,7 @@ from owrx.config.core import CoreConfig class FileController(AssetsController): def getFilePath(self, file): - return CoreConfig().get_temporary_directory() + "/" + file + return CoreConfig().getStoredFilePath(file) class FilesController(WebpageController): diff --git a/owrx/sstv.py b/owrx/sstv.py index b7db9ab5..5da7d422 100644 --- a/owrx/sstv.py +++ b/owrx/sstv.py @@ -1,4 +1,5 @@ from owrx.config.core import CoreConfig +from owrx.config import Config from csdr.module import ThreadModule from pycsdr.types import Format from datetime import datetime @@ -80,7 +81,14 @@ class SstvParser(ThreadModule): if self.height==0 or self.line