# HG changeset patch # User madrouin@astronotus.lmd.polytechnique.fr # Date 1538642330 -7200 # Node ID c3252b31b98ab54538ff078cab8807b59c0924c6 # Parent a6ed20f50a58b12d3f843946676aa962bce537b3 minor improvements diff -r a6ed20f50a58 -r c3252b31b98a scc_access/scc_access.py --- 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()