libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [10/12] libcloud git commit: Update "get_size_price" so it can handle cases when pricing is not available.
Date Fri, 20 May 2016 10:09:10 GMT
Update "get_size_price" so it can handle cases when pricing is not available.


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/f1594bbb
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/f1594bbb
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/f1594bbb

Branch: refs/heads/trunk
Commit: f1594bbbb975bcf50f249778617359d009414b89
Parents: 4b53c91
Author: Tomaz Muraus <tomaz@tomaz.me>
Authored: Fri May 20 11:34:26 2016 +0200
Committer: Tomaz Muraus <tomaz@tomaz.me>
Committed: Fri May 20 11:34:26 2016 +0200

----------------------------------------------------------------------
 libcloud/pricing.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/f1594bbb/libcloud/pricing.py
----------------------------------------------------------------------
diff --git a/libcloud/pricing.py b/libcloud/pricing.py
index 42075fb..e568285 100644
--- a/libcloud/pricing.py
+++ b/libcloud/pricing.py
@@ -144,7 +144,13 @@ def get_size_price(driver_type, driver_name, size_id):
     :return: Size price.
     """
     pricing = get_pricing(driver_type=driver_type, driver_name=driver_name)
-    price = float(pricing[size_id])
+
+    try:
+        price = float(pricing[size_id])
+    except KeyError:
+        # Price not available
+        price = None
+
     return price
 
 


Mime
View raw message