diff options
author | Baudouin Raoult <baudouin.raoult@ecmwf.int> | 2019-01-16 16:10:16 +0000 |
---|---|---|
committer | Baudouin Raoult <baudouin.raoult@ecmwf.int> | 2019-01-16 16:10:16 +0000 |
commit | d1fb694eefcaade19ffd38878f8b8f949632a9cb (patch) | |
tree | d60544abc963fb8aacad57ba7e3e1410793678fe /cdsapi | |
parent | 6b6c271a380a05de6c03341f3f7573e30a02b530 (diff) |
version 0.1.3. Better error message
Diffstat (limited to 'cdsapi')
-rw-r--r-- | cdsapi/api.py | 8 |
1 files changed, 6 insertions, 2 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: |