From 4174479e682897af6d917831e2ca460d889536f7 Mon Sep 17 00:00:00 2001 From: Gard Spreemann Date: Thu, 17 Sep 2020 10:14:32 +0200 Subject: Upstream 0.3.1 tarball as released on PyPI. --- PKG-INFO | 2 +- cdsapi.egg-info/PKG-INFO | 2 +- cdsapi.egg-info/SOURCES.txt | 1 - cdsapi/api.py | 16 +++++++++++----- setup.py | 2 +- x.py | 31 ------------------------------- 6 files changed, 14 insertions(+), 40 deletions(-) delete mode 100755 x.py diff --git a/PKG-INFO b/PKG-INFO index 03ed29b..6de12ff 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: cdsapi -Version: 0.3.0 +Version: 0.3.1 Summary: Climate Data Store API Home-page: https://software.ecmwf.int/stash/projects/CDS/repos/cdsapi Author: ECMWF diff --git a/cdsapi.egg-info/PKG-INFO b/cdsapi.egg-info/PKG-INFO index 03ed29b..6de12ff 100644 --- a/cdsapi.egg-info/PKG-INFO +++ b/cdsapi.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: cdsapi -Version: 0.3.0 +Version: 0.3.1 Summary: Climate Data Store API Home-page: https://software.ecmwf.int/stash/projects/CDS/repos/cdsapi Author: ECMWF diff --git a/cdsapi.egg-info/SOURCES.txt b/cdsapi.egg-info/SOURCES.txt index f8d641d..cbd1fce 100644 --- a/cdsapi.egg-info/SOURCES.txt +++ b/cdsapi.egg-info/SOURCES.txt @@ -7,7 +7,6 @@ example-glaciers.py setup.cfg setup.py tox.ini -x.py cdsapi/__init__.py cdsapi/api.py cdsapi.egg-info/PKG-INFO diff --git a/cdsapi/api.py b/cdsapi/api.py index 2bd5c14..5726489 100644 --- a/cdsapi/api.py +++ b/cdsapi/api.py @@ -109,7 +109,7 @@ class Result(object): while tries < self.retry_max: - r = self.robust(requests.get)(url, + r = self.robust(self.session.get)(url, stream=True, verify=self.verify, headers=headers, @@ -255,6 +255,7 @@ class Client(object): debug_callback=None, metadata=None, forget=False, + session=requests.Session() ): if not quiet: @@ -305,7 +306,7 @@ class Client(object): self.info_callback = info_callback self.error_callback = error_callback - self.session = requests.Session() + self.session = session self.session.auth = tuple(self.key.split(':', 2)) self.metadata = metadata @@ -331,10 +332,15 @@ class Client(object): result.download(target) return result - def service(self, name, *args, **kwargs): + def service(self, name, *args, mimic_ui=False, **kwargs): self.delete = False # Don't delete results name = '/'.join(name.split('.')) - request = dict(args=args, kwargs=kwargs) + # To mimic the CDS ui the request should be populated directly with the kwargs + if mimic_ui: + request = kwargs + else: + request = dict(args=args, kwargs=kwargs) + if self.metadata: request['_cds_metadata'] = self.metadata request = toJSON(request) @@ -351,7 +357,7 @@ class Client(object): def status(self, context=None): url = '%s/status.json' % (self.url,) - r = requests.get(url, verify=self.verify) + r = self.session.get(url, verify=self.verify) r.raise_for_status() return r.json() diff --git a/setup.py b/setup.py index 920bf2d..2fb007b 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ def read(fname): return io.open(file_path, encoding='utf-8').read() -version = '0.3.0' +version = '0.3.1' setuptools.setup( diff --git a/x.py b/x.py deleted file mode 100755 index c6bf50c..0000000 --- a/x.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python - -# (C) Copyright 2018 ECMWF. -# -# This software is licensed under the terms of the Apache Licence Version 2.0 -# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. -# In applying this licence, ECMWF does not waive the privileges and immunities -# granted to it by virtue of its status as an intergovernmental organisation nor -# does it submit to any jurisdiction. - -import cdsapi - -c = cdsapi.Client() - -c.retrieve("reanalysis-era5-complete", - { - - 'class': 'ea', - 'expver': '5', - 'stream': 'oper', - 'type': 'fc', - 'step': '3/to/12/by/3', - 'param': '130.128', - 'levtype': 'ml', - 'levelist': '1/10/50/100', - 'date': '2020-06-01', - 'time': '06/18', - 'area': '80/-50/-25/0', # North, West, South, East. Default: global - 'grid': '1.0/1.0', # Latitude/longitude grid: east-west (longitude) and north-south resolution (latitude). Default: reduced Gaussian grid - }, - 'x.grib') -- cgit v1.2.3