[Python-modules-commits] [python-digitalocean] 17/19: Fix the a crash when the request timeout is set via the environment variable.

Andrew Starr-Bochicchio asb at moszumanska.debian.org
Tue Jun 20 00:31:30 UTC 2017


This is an automated email from the git hooks/post-receive script.

asb pushed a commit to annotated tag 1.10.1
in repository python-digitalocean.

commit 61e0c8877e8d0f4dbdfb1c7c5d707f1130dc6a85
Author: Joro <acev at chessdom.com>
Date:   Tue Oct 18 18:04:48 2016 -0700

    Fix the a crash when the request timeout is set via the environment variable.
---
 digitalocean/baseapi.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/digitalocean/baseapi.py b/digitalocean/baseapi.py
index 9576469..6e75be2 100644
--- a/digitalocean/baseapi.py
+++ b/digitalocean/baseapi.py
@@ -103,7 +103,15 @@ class BaseAPI(object):
             To set a timeout, use the REQUEST_TIMEOUT_ENV_VAR environment
             variable.
         """
-        return os.environ.get(REQUEST_TIMEOUT_ENV_VAR)
+        timeout_str = os.environ.get(REQUEST_TIMEOUT_ENV_VAR)
+        if timeout_str:
+            try:
+                return float(timeout_str)
+            except:
+                self._log.error('Failed parsing the request read timeout of '
+                                '"%s". Please use a valid float number!' %
+                                        timeout_str)
+        return None
 
     def get_data(self, url, type=GET, params=None):
         """
@@ -120,7 +128,7 @@ class BaseAPI(object):
 
         if req.status_code == 404:
             raise NotFoundError()
-            
+
         try:
             data = req.json()
         except ValueError as e:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-digitalocean.git



More information about the Python-modules-commits mailing list