From 8ae1e145c20b5aa82728f97ba3f4f1d8e3a2e797 Mon Sep 17 00:00:00 2001 From: Alessandro Amici Date: Fri, 18 May 2018 09:20:10 +0200 Subject: Release. --- cdsapi/__init__.py | 5 +++-- cdsapi/api.py | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cdsapi/__init__.py b/cdsapi/__init__.py index e7cdf1b..c9e9d4e 100644 --- a/cdsapi/__init__.py +++ b/cdsapi/__init__.py @@ -16,7 +16,8 @@ # granted to it by virtue of its status as an intergovernmental organisation nor # does it submit to any jurisdiction. +from __future__ import absolute_import, division, print_function, unicode_literals -import cdsapi.api +from . import api -Client = cdsapi.api.Client +Client = api.Client diff --git a/cdsapi/api.py b/cdsapi/api.py index 0ada51b..c15c84c 100644 --- a/cdsapi/api.py +++ b/cdsapi/api.py @@ -6,12 +6,15 @@ # granted to it by virtue of its status as an intergovernmental organisation nor # does it submit to any jurisdiction. -import requests +from __future__ import absolute_import, division, print_function, unicode_literals + import json import time import os import logging +import requests + def bytes_to_string(n): u = ['', 'K', 'M', 'G', 'T', 'P'] -- cgit v1.2.3 From b999c1c23972fc81e67023273966e8c4630c4dc6 Mon Sep 17 00:00:00 2001 From: Alessandro Amici Date: Fri, 18 May 2018 09:20:10 +0200 Subject: Start some light python2 compatibility layer. --- cdsapi/__init__.py | 5 +++-- cdsapi/api.py | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cdsapi/__init__.py b/cdsapi/__init__.py index e7cdf1b..c9e9d4e 100644 --- a/cdsapi/__init__.py +++ b/cdsapi/__init__.py @@ -16,7 +16,8 @@ # granted to it by virtue of its status as an intergovernmental organisation nor # does it submit to any jurisdiction. +from __future__ import absolute_import, division, print_function, unicode_literals -import cdsapi.api +from . import api -Client = cdsapi.api.Client +Client = api.Client diff --git a/cdsapi/api.py b/cdsapi/api.py index 0ada51b..c15c84c 100644 --- a/cdsapi/api.py +++ b/cdsapi/api.py @@ -6,12 +6,15 @@ # granted to it by virtue of its status as an intergovernmental organisation nor # does it submit to any jurisdiction. -import requests +from __future__ import absolute_import, division, print_function, unicode_literals + import json import time import os import logging +import requests + def bytes_to_string(n): u = ['', 'K', 'M', 'G', 'T', 'P'] -- cgit v1.2.3 From decccb5a484c014fbee04bf299f0739f24380076 Mon Sep 17 00:00:00 2001 From: Alessandro Amici Date: Fri, 18 May 2018 20:41:04 +0200 Subject: Python 2 support. --- tests/test_api.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_api.py b/tests/test_api.py index f76a842..2403dca 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1,4 +1,6 @@ +from __future__ import absolute_import, division, print_function, unicode_literals + from cdsapi import api -- cgit v1.2.3 From 7a9489b18b5f873b6cb3cf8ac5e6b6cf2d8b01d4 Mon Sep 17 00:00:00 2001 From: Gionata Biavati Date: Tue, 22 May 2018 10:33:03 +0100 Subject: badly shaped .cdsapirc files (with empty lines) were causing the api to fail. Now untill the information required is provided, we are ignoring the badly formatted lines --- cdsapi/api.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cdsapi/api.py b/cdsapi/api.py index c15c84c..a53ebf0 100644 --- a/cdsapi/api.py +++ b/cdsapi/api.py @@ -48,8 +48,12 @@ class Client(object): config = {} with open(dotrc) as f: for l in f.readlines(): + try: k, v = l.strip().split(':', 1) - config[k] = v.strip() + if k in ['url', 'key']: + config[k] = v.strip() + except: + print('The file ~/.cdsapirc is badly formatted (remove extra lines not required)') url = config.get('url') key = config.get('key') -- cgit v1.2.3