libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [12/40] libcloud git commit: Compare version using disutils package LooseVersion
Date Fri, 02 Dec 2016 04:33:14 GMT
Compare  version using disutils package LooseVersion


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

Branch: refs/heads/trunk
Commit: cd7fe0e5c8ed10f6aa8e6cf573d9239ef10bcaa4
Parents: 75111a4
Author: Samuel Chong <samuelchong1@gmail.com>
Authored: Tue Nov 15 11:33:47 2016 +1100
Committer: Samuel Chong <samuelchong1@gmail.com>
Committed: Tue Nov 15 11:33:47 2016 +1100

----------------------------------------------------------------------
 libcloud/common/dimensiondata.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/cd7fe0e5/libcloud/common/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/common/dimensiondata.py b/libcloud/common/dimensiondata.py
index c58d5dd..3cb9f66 100644
--- a/libcloud/common/dimensiondata.py
+++ b/libcloud/common/dimensiondata.py
@@ -17,6 +17,7 @@ Dimension Data Common Components
 """
 from base64 import b64encode
 from time import sleep
+from distutils.version import LooseVersion, StrictVersion
 from libcloud.utils.py3 import httplib
 from libcloud.utils.py3 import b
 from libcloud.common.base import ConnectionUserAndKey, XmlResponse, RawResponse
@@ -375,13 +376,13 @@ class DimensionDataConnection(ConnectionUserAndKey):
     api_version_1 = 0.9
 
     # Earliest version supported
-    oldest_api_version = 2.2
+    oldest_api_version = '2.2'
 
     # Latest version supported
-    latest_api_version = 2.3
+    latest_api_version = '2.3'
 
     # Default api version
-    active_api_version = 2.3
+    active_api_version = '2.3'
 
     _orgId = None
     responseCls = DimensionDataResponse
@@ -404,7 +405,8 @@ class DimensionDataConnection(ConnectionUserAndKey):
             self.host = conn_kwargs['region']['host']
 
         if api_version:
-            if float(api_version) < self.oldest_api_version:
+            if LooseVersion(api_version) < LooseVersion(
+                    self.oldest_api_version):
                 msg = 'API Version specified is too old. No longer ' \
                       'supported. Please upgrade to the latest version {}' \
                     .format(self.active_api_version)
@@ -412,7 +414,8 @@ class DimensionDataConnection(ConnectionUserAndKey):
                 raise DimensionDataAPIException(code=None,
                                                 msg=msg,
                                                 driver=self.driver)
-            elif float(api_version) > self.latest_api_version:
+            elif LooseVersion(api_version) > LooseVersion(
+                    self.latest_api_version):
                 msg = 'Unsupported API Version. The version specified is ' \
                       'not release yet. Please use the latest supported ' \
                       'version {}' \


Mime
View raw message