Commit 6df4efe5 authored by tsanona's avatar tsanona

Slight change in dealing with results of requests.

Change in version. Added default minimum_fill.
parent d7389d07
Pipeline #16011 passed with stages
in 19 minutes and 23 seconds
......@@ -82,9 +82,12 @@ class Gts2Request(dict):
# get data, update dict from json
result = requests.get(self.api_call, verify=False, auth=opts["auth"]["auth"], timeout=opts["timeout"])
status = {"http_code": result.status_code}
status_code = result.status_code
status = {"http_code": status_code}
self.update(result.json())
# if api responds with http error it can't create json
if status_code < 400:
self.update(result.json())
self.update(status)
......@@ -712,7 +715,7 @@ def __get_auth(logger=None):
def client(outpath="", out_prefix="", out_mode="json", geo_ll=(), geo_ur=(), sensor="S2A", bands="", max_cloudy="0.5",
level="L2A", start_date="", end_date="", version="0.13", suffix="", minimum_fill="",
level="L2A", start_date="", end_date="", version="0.15", suffix="", minimum_fill="0.8",
only_tile="", stack_resolution="10", quiet=False, rgb_extension="jpg", rgb_bands_selection="realistic",
merge_tifs=False, merge_tile=None, onlytime=False, timeout=None):
"""
......@@ -792,17 +795,17 @@ def client(outpath="", out_prefix="", out_mode="json", geo_ll=(), geo_ur=(), sen
"onlytime": onlytime, "timeout": timeout}
# actual API request
logger.info("Requesting data from the GTS2 server ...", )
logger.info(msg="Requesting data from the GTS2 server ...")
a_stime = time.time()
api_result = Gts2Request(opts, logger=logger)
a_runtime = time.time() - a_stime
logger.info(">>>>>> Runtime of API: %7.2f minutes" % (a_runtime / 60.))
if api_result["http_code"] >= 500:
if api_result["http_code"] >= 400:
logger.error("##################")
raise ChildProcessError("API call not right or server Problem (http_code={code}).".format(
code=api_result["http_code"]))
if api_result["ControlValues"]["API_status"] == 1:
if "ControlValues" in api_result and api_result["ControlValues"]["API_status"] == 1:
logger.error("##################")
logger.error(str(api_result["ControlValues"]["API_message"]))
raise ChildProcessError("Something went wrong on GTS2 Server (http_code={code}).".format(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment