diff --git a/.gitignore b/.gitignore index 7b8deb96..730f3e88 100644 --- a/.gitignore +++ b/.gitignore @@ -164,3 +164,4 @@ stixcore/data/publish/ stixcore/data/test/products/end2end/ monitor_status.json stixcore/data/test/idb/v2.26.38/idb.sqlite +.python-version diff --git a/stixcore/io/RidLutManager.py b/stixcore/io/RidLutManager.py index 337dc574..51a5f983 100644 --- a/stixcore/io/RidLutManager.py +++ b/stixcore/io/RidLutManager.py @@ -70,9 +70,13 @@ def get_reason(self, rid): str verbal description of the request purpose """ - request = self.rid_lut.loc[rid] - reason = " ".join(np.atleast_1d(request['description'])) - return reason + try: + request = self.rid_lut.loc[rid] + reason = " ".join(np.atleast_1d(request['description'])) + return reason + except IndexError: + logger.warning("can't get request purpose: no request founds for rid: {rid}") + return "" def get_scaling_factor(self, rid): """Gets the trigger descaling factor connected to the BSD request. @@ -165,7 +169,7 @@ def read_rid_lut(cls, file, update=False): # the stix datacenter API is throttled to 2 calls per second time.sleep(0.5) except Exception: - logger.error("RID API ERROR", exc_info=True) + logger.warning("RID API ERROR", exc_info=True) rid_lut = unique(rid_lut, silent=True) ascii.write(rid_lut, file, overwrite=True, delimiter=",", quotechar='"') diff --git a/stixcore/processing/pipeline.py b/stixcore/processing/pipeline.py index 24163fec..22969ace 100644 --- a/stixcore/processing/pipeline.py +++ b/stixcore/processing/pipeline.py @@ -149,6 +149,7 @@ def emit(self, record): """Called in case of a logging event.""" self.allright = False self.error = record + self.err_file.touch() def __enter__(self): return self @@ -159,7 +160,7 @@ def __exit__(self, type, value, traceback): logging.getLogger().removeHandler(self.fh) PipelineStatus.instance.last_tm = (self.tm_file, datetime.now()) PipelineStatus.instance.current_tm = (None, datetime.now()) - if not self.allright: + if not self.allright or self.err_file.exists(): shutil.copyfile(self.log_file, self.err_file) PipelineStatus.instance.last_error = (self.tm_file, datetime.now(), self.error, self.err_file)