summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBaudouin Raoult <baudouin.raoult@ecmwf.int>2019-01-16 16:10:16 +0000
committerBaudouin Raoult <baudouin.raoult@ecmwf.int>2019-01-16 16:10:16 +0000
commitd1fb694eefcaade19ffd38878f8b8f949632a9cb (patch)
treed60544abc963fb8aacad57ba7e3e1410793678fe
parent6b6c271a380a05de6c03341f3f7573e30a02b530 (diff)
version 0.1.3. Better error message
-rw-r--r--cdsapi/api.py8
-rwxr-xr-xexample-era5.py15
-rw-r--r--setup.py2
3 files changed, 14 insertions, 11 deletions
diff --git a/cdsapi/api.py b/cdsapi/api.py
index 9160916..88a3a8c 100644
--- a/cdsapi/api.py
+++ b/cdsapi/api.py
@@ -77,7 +77,8 @@ class Result(object):
finally:
r.close()
- assert total == size
+ if total != size:
+ raise Exception("Download failed: downloaded %s byte(s) out of %s" % (total, size))
elapsed = time.time() - start
if elapsed:
@@ -231,6 +232,9 @@ class Client(object):
result.download(target)
return result
+ def identity(self):
+ return self._api('%s/resources' % (self.url,), {})
+
def _api(self, url, request):
session = self.session
@@ -358,7 +362,7 @@ class Client(object):
r = call(*args, **kwargs)
except requests.exceptions.ConnectionError as e:
r = None
- self.warning("Recovering from connection error [%s], attemx ps %s of %s",
+ self.warning("Recovering from connection error [%s], attemps %s of %s",
e, tries, self.retry_max)
if r is not None:
diff --git a/example-era5.py b/example-era5.py
index 3e55a59..c0ad58b 100755
--- a/example-era5.py
+++ b/example-era5.py
@@ -10,18 +10,17 @@
import cdsapi
-c = cdsapi.Client()
+c = cdsapi.Client(debug=True)
r = c.retrieve(
- "reanalysis-era5-pressure-levels",
+ "reanalysis-era5-single-levels",
{
- "variable": "temperature",
- "pressure_level": "250",
+ "variable": "2t",
"product_type": "reanalysis",
- "date": "2017-12-01/2017-12-31",
- "time": "12:00",
- "format": "grib",
+ "date": "2012-12-01",
+ "time": "14:00",
+ "format": "netcdf",
},
)
-r.download("dowload.grib")
+r.download("test.nc")
diff --git a/setup.py b/setup.py
index eee5799..4b78db2 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.1.2.dev0'
+version = '0.1.3'
setuptools.setup(