Wed, 03 Feb 2021 16:18:14 +0200
Support for module status code in new version.
scc_access/scc_access.py | file | annotate | diff | comparison | revisions |
--- a/scc_access/scc_access.py Sat Jan 09 19:42:15 2021 +0200 +++ b/scc_access/scc_access.py Wed Feb 03 16:18:14 2021 +0200 @@ -362,8 +362,8 @@ # try to deal with error 404 error_count = 0 - error_max = 6 - time_sleep = 10 + error_max = 3 + time_sleep = 3 # try to wait for measurement to appear in API measurement = None @@ -385,17 +385,13 @@ if measurement is not None: while measurement.is_running: - logger.info("Measurement is being processed. status: {}, {}, {}, {}, {}, {}). Please wait.".format( - measurement.upload, - measurement.hirelpp, - measurement.cloudmask, - measurement.elpp, - measurement.elda, - measurement.elic)) + measurement.log_processing_status() time.sleep(10) measurement, status = self.get_measurement(measurement_id) logger.info("Measurement processing finished.") + measurement.log_detailed_status() + if measurement.hirelpp == 127: logger.info("Downloading HiRElPP files.") self.download_hirelpp(measurement_id) @@ -413,9 +409,7 @@ if measurement.elic == 127: logger.info("Downloading ELIC files.") self.download_elic(measurement_id) - - # TODO: Need to check ELDEC code (when it becomes available in the API) - if measurement.is_calibration: + if measurement.is_calibration and measurement.eldec==0: logger.info("Downloading ELDEC files.") self.download_eldec(measurement_id) logger.info("--- Processing finished. ---") @@ -660,16 +654,26 @@ def __init__(self, base_url, dict_response): # Define expected attributes to assist debugging + + self.hirelpp = None + self.hirelpp_exit_code = None self.cloudmask = None + self.cloudmask_exit_code = None + self.elpp = None + self.elpp_exit_code = None self.elda = None + self.elda_exit_code = None self.elic = None - self.elpp = None - self.hirelpp = None + self.elic_exit_code = None + self.eldec = None + self.eldec_exit_code = None + self.elquick = None + self.elquick_exit_code = None + self.id = None self.is_calibration = None self.is_running = None - self.pre_processing_exit_code = None - self.processing_exit_code = None + self.resource_uri = None self.start = None self.stop = None @@ -678,6 +682,36 @@ super().__init__(base_url, dict_response) + def log_processing_status(self): + """ Log module status. """ + logger.info("Measurement is being processed. Status: {}, {}, {}, {}, {}, {}). Please wait.".format( + self.upload, + self.hirelpp, + self.cloudmask, + self.elpp, + self.elda, + self.elic)) + + def log_detailed_status(self): + """ Log module exit and status codes.""" + logger.info("Measurement exit status:".format(self.id)) + if self.is_calibration: + self._log_module_status('ElPP', self.elpp, self.elpp_exit_code) + self._log_module_status('ElDEC', self.eldec, self.eldec_exit_code) + else: + self._log_module_status('HiRElPP', self.hirelpp, self.hirelpp_exit_code) + self._log_module_status('CloudScreen', self.cloudmask, self.cloudmask_exit_code) + self._log_module_status('ElPP', self.elpp, self.elpp_exit_code) + self._log_module_status('ELDA', self.elda, self.elda_exit_code) + self._log_module_status('ELIC', self.elic, self.elic_exit_code) + self._log_module_status('ELQuick', self.elquick, self.elquick_exit_code) + + def _log_module_status(self, name, status, exit_code): + if exit_code: + logger.warning("{0} exit code: {2[exit_code]} - {2[description]}".format(name, status, exit_code)) + else: + logger.info("{0} exit code: {2}".format(name, status, exit_code)) + @property def rerun_elda_url(self): url_pattern = urlparse.urljoin(self.base_url, 'data_processing/measurements/{0}/rerun-elda/')