diff options
author | Baudouin Raoult <baudouin.raoult@ecmwf.int> | 2018-05-23 11:03:39 +0100 |
---|---|---|
committer | Baudouin Raoult <baudouin.raoult@ecmwf.int> | 2018-05-23 11:03:39 +0100 |
commit | 11a74dd1a24b3a2d7d1000f85c25c6fc7f60099e (patch) | |
tree | 5cf7a6ad9bbd771760101eab66cbed8e2527691b /cdsapi | |
parent | bc0e0537deeac7adfbcf1e0f8bc9a28adde334d3 (diff) | |
parent | 7a9489b18b5f873b6cb3cf8ac5e6b6cf2d8b01d4 (diff) |
Merge branch 'master' of ssh://software.ecmwf.int:7999/cds/cdsapi
Diffstat (limited to 'cdsapi')
-rw-r--r-- | cdsapi/__init__.py | 5 | ||||
-rw-r--r-- | cdsapi/api.py | 11 |
2 files changed, 12 insertions, 4 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 3f3be34..7488002 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'] @@ -45,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') |