From d1fb694eefcaade19ffd38878f8b8f949632a9cb Mon Sep 17 00:00:00 2001 From: Baudouin Raoult Date: Wed, 16 Jan 2019 16:10:16 +0000 Subject: version 0.1.3. Better error message --- cdsapi/api.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'cdsapi') 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: -- cgit v1.2.3