376 max_attempts = retry_max + 1 |
376 max_attempts = retry_max + 1 |
377 |
377 |
378 # try to wait for measurement to appear in API |
378 # try to wait for measurement to appear in API |
379 measurement = None |
379 measurement = None |
380 logger.info("Looking for measurement %s on the SCC.", measurement_id) |
380 logger.info("Looking for measurement %s on the SCC.", measurement_id) |
|
381 |
381 while attempts_count < max_attempts: |
382 while attempts_count < max_attempts: |
382 attempts_count += 1 |
383 attempts_count += 1 |
383 measurement, status = self.get_measurement(measurement_id) |
384 measurement, status = self.get_measurement(measurement_id) |
384 if status != 200: |
385 if status != 200: |
385 logger.warning("Measurement not found.") |
386 logger.warning("Measurement not found.") |
386 if attempts_count < max_attempts: |
387 if attempts_count < max_attempts: |
387 logger.warning("Waiting %ds.", time_sleep) |
388 logger.warning("Waiting %ds.", time_sleep) |
388 time.sleep(time_sleep) |
389 time.sleep(time_sleep) |
389 else: |
390 else: |
390 break |
391 break |
391 |
392 print("Measurement: {}".format(measurement)) |
392 if attempts_count == max_attempts: |
393 |
|
394 if measurement is None: |
393 logger.error("Measurement %s doesn't seem to exist.", measurement_id) |
395 logger.error("Measurement %s doesn't seem to exist.", measurement_id) |
394 if exit_if_missing: |
396 if exit_if_missing: |
395 sys.exit(1) |
397 sys.exit(1) |
396 else: |
398 else: |
397 return measurement |
399 return measurement |
398 |
400 |
399 logger.info('Measurement %s found.', measurement_id) |
401 logger.info('Measurement %s found.', measurement_id) |
400 |
402 while not measurement.has_finished: |
401 if measurement is not None: |
403 measurement.log_processing_status() |
402 while not measurement.has_finished: |
404 time.sleep(10) |
403 measurement.log_processing_status() |
405 measurement, status = self.get_measurement(measurement_id) |
404 time.sleep(10) |
406 |
405 measurement, status = self.get_measurement(measurement_id) |
407 logger.info("Measurement processing finished.") |
406 |
408 measurement.log_detailed_status() |
407 logger.info("Measurement processing finished.") |
409 |
408 measurement.log_detailed_status() |
410 if measurement.hirelpp == 127: |
409 |
411 logger.info("Downloading HiRElPP files.") |
410 if measurement.hirelpp == 127: |
412 self.download_hirelpp(measurement_id) |
411 logger.info("Downloading HiRElPP files.") |
413 if measurement.cloudmask == 127: |
412 self.download_hirelpp(measurement_id) |
414 logger.info("Downloading cloud screening files.") |
413 if measurement.cloudmask == 127: |
415 self.download_cloudmask(measurement_id) |
414 logger.info("Downloading cloud screening files.") |
416 if measurement.elpp == 127: |
415 self.download_cloudmask(measurement_id) |
417 logger.info("Downloading ElPP files.") |
416 if measurement.elpp == 127: |
418 self.download_elpp(measurement_id) |
417 logger.info("Downloading ElPP files.") |
419 if measurement.elda == 127: |
418 self.download_elpp(measurement_id) |
420 logger.info("Downloading ELDA files.") |
419 if measurement.elda == 127: |
421 self.download_elda(measurement_id) |
420 logger.info("Downloading ELDA files.") |
422 logger.info("Downloading ELDA plots.") |
421 self.download_elda(measurement_id) |
423 self.download_plots(measurement_id) |
422 logger.info("Downloading ELDA plots.") |
424 if measurement.elic == 127: |
423 self.download_plots(measurement_id) |
425 logger.info("Downloading ELIC files.") |
424 if measurement.elic == 127: |
426 self.download_elic(measurement_id) |
425 logger.info("Downloading ELIC files.") |
427 if measurement.is_calibration and measurement.eldec==0: |
426 self.download_elic(measurement_id) |
428 logger.info("Downloading ELDEC files.") |
427 if measurement.is_calibration and measurement.eldec==0: |
429 self.download_eldec(measurement_id) |
428 logger.info("Downloading ELDEC files.") |
430 logger.info("--- Processing finished. ---") |
429 self.download_eldec(measurement_id) |
|
430 logger.info("--- Processing finished. ---") |
|
431 |
431 |
432 return measurement |
432 return measurement |
433 |
433 |
434 def get_measurement(self, measurement_id): |
434 def get_measurement(self, measurement_id): |
435 |
435 |