delete download artifact after import

This commit is contained in:
Tobias Wellnitz, DH1TW 2020-03-03 17:22:23 +01:00
parent 01869462df
commit 1891c88e38

View file

@ -996,6 +996,9 @@ class LookupLib(object):
self._invalid_operations_index = cty_dict["invalid_operations_index"]
self._zone_exceptions_index = cty_dict["zone_exceptions_index"]
if self._download:
self._cleanup_download_artifact(cty_file)
return True
def _load_countryfile(self,
@ -1030,6 +1033,9 @@ class LookupLib(object):
self._callsign_exceptions_index = cty_dict["exceptions_index"]
self._prefixes_index = cty_dict["prefixes_index"]
if self._download:
self._cleanup_download_artifact(cty_file)
return True
def _download_file(self, url, apikey=None):
@ -1091,6 +1097,19 @@ class LookupLib(object):
return cty_file_path
def _cleanup_download_artifact(self, filename):
"""
Delete the downloaded files which are not necessary anymore
Args:
filename (string): absolute path to the download artifact
"""
try:
os.remove(filename)
except:
self._logger.warning("unable delete the download artifact: %s", _download_file)
def _extract_clublog_header(self, cty_xml_filename):
"""
Extract the header of the Clublog XML File