From d20aa895176d7c55aba78a50dfffadbcbc3bc923 Mon Sep 17 00:00:00 2001 From: majh Date: Thu, 14 Mar 2024 21:17:32 +0000 Subject: [PATCH 1/3] handle a user config with just a bearer token in it --- polytope/api/Auth.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/polytope/api/Auth.py b/polytope/api/Auth.py index a94d910..7f9a6e7 100644 --- a/polytope/api/Auth.py +++ b/polytope/api/Auth.py @@ -50,6 +50,8 @@ def get_auth_headers(self): user_key, user_email, _ = self.fetch_key(login=False) if user_key and user_email: auth_headers.append("EmailKey %s:%s" % (user_email, user_key)) + if user_key and not user_email: + auth_headers.append("Bearer %s" % (user_key)) config = self.config.get() bearer_key = config["user_key"] if bearer_key: @@ -152,16 +154,16 @@ def fetch_key(self, login=True): try: with open(str(key_file), "r") as infile: info = json.load(infile) - key = info["user_key"] - email = info["user_email"] + key = info.get("user_key", None) + email = info.get("user_email", None) # TODO: this is messy except FileNotFoundError: try: with open(str(Path.home() / ".ecmwfapirc"), "r") as infile: info = json.load(infile) - key = info["key"] - email = info["email"] + key = info.get("user_key", None) + email = info.get("user_email", None) except FileNotFoundError: key = None email = None From 9079af9bc2d9416816aa5f7a7de55e62ed865bf5 Mon Sep 17 00:00:00 2001 From: majh Date: Thu, 14 Mar 2024 21:17:55 +0000 Subject: [PATCH 2/3] correct type for covjson download --- polytope/api/RequestManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polytope/api/RequestManager.py b/polytope/api/RequestManager.py index 23f2118..8f5e778 100644 --- a/polytope/api/RequestManager.py +++ b/polytope/api/RequestManager.py @@ -579,7 +579,7 @@ def _download(self, response, output_file, append, request_id=None): output_file = request_id + ".covjson" else: random_id = "".join(random.choices(string.ascii_letters + string.digits, k=16)) - output_file = "tmp" + random_id + ".grib" + output_file = "tmp" + random_id + ".covjson" return self._download_to_file(response, output_file, append) elif content_type == "application/octet-stream": if output_file: From 13b1a38a577122ee4aa4c1d026a1488493410952 Mon Sep 17 00:00:00 2001 From: majh Date: Thu, 14 Mar 2024 21:18:09 +0000 Subject: [PATCH 3/3] bump version --- polytope/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polytope/version.py b/polytope/version.py index 4910b9e..ed9d4d8 100644 --- a/polytope/version.py +++ b/polytope/version.py @@ -1 +1 @@ -__version__ = "0.7.3" +__version__ = "0.7.4"