Thu, 04 Oct 2018 10:38:50 +0200
minor improvements
scc_access/scc_access.py | file | annotate | diff | comparison | revisions |
--- a/scc_access/scc_access.py Thu Oct 04 10:30:59 2018 +0200 +++ b/scc_access/scc_access.py Thu Oct 04 10:38:50 2018 +0200 @@ -221,6 +221,7 @@ error_count = 0 error_max = 6 + # try to wait for measurement to appear in API measurement = None while error_count < error_max or measurement is None: measurement = self.get_measurement(measurement_id) @@ -232,6 +233,7 @@ logger.critical("measurement %s doesn't seem to exist", measurement_id) if measurement is not None: + error_count = 0 while measurement.is_running: logger.info("Measurement is being processed (status: %s, %s, %s). Please wait.", measurement.upload, measurement.pre_processing, measurement.processing) time.sleep(10) @@ -277,9 +279,13 @@ auth=self.auth, verify=False) + # maybe the measurements isn't already available on the database. + if response.status_code == 404: + return None + if response.status_code != 200: logger.error('Could not access API. Status code %s.' % response.status_code) - return None + sys.exit(1) response_dict = response.json()