diff options
| author | Scott Bahling <sbahling@suse.de> | 2016-02-20 20:14:08 +0100 |
|---|---|---|
| committer | Scott Bahling <sbahling@suse.de> | 2016-02-20 20:14:08 +0100 |
| commit | d8ed26683890b5a119ae59dd7cd3d55dd5bc7bb9 (patch) | |
| tree | 75e5feec9a12edcb83619bc828615a4f8fa68d9a | |
| parent | 4fe7816a5d6d9b1d9ee171c62c6111b95a925f1f (diff) | |
| download | obsapi-d8ed26683890b5a119ae59dd7cd3d55dd5bc7bb9.tar.gz obsapi-d8ed26683890b5a119ae59dd7cd3d55dd5bc7bb9.tar.xz obsapi-d8ed26683890b5a119ae59dd7cd3d55dd5bc7bb9.zip | |
Modify __api_get to function with self.retries set to 0
| -rw-r--r-- | obsapi/core.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/obsapi/core.py b/obsapi/core.py index 74b8997..c56d410 100644 --- a/obsapi/core.py +++ b/obsapi/core.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- +# import requests from requests.auth import HTTPBasicAuth from lxml import etree @@ -152,18 +154,25 @@ class ObsApi(object): def __api_get(self, api, payload=None): - for attempt in range(self.retries): + def try_get(): url = '{0}/{1}'.format(self.apiurl, api) r = requests.get(url, auth=self.auth, params=payload, verify=self.verify_ssl) self._response = r + return r + + for attempt in range(self.retries): + r = try_get() if self.success: return r print("Failed: %s" % self.response) print("retry: %s" % (attempt + 1)) + if self.retries == 0: + r = try_get() + return r @property |
