3737logger .addHandler (logging .NullHandler ())
3838
3939
40+ def _get_server_version_info (version_str ):
41+ basic_info = version_str .split ('.' )
42+
43+ major = int (basic_info [0 ])
44+ minor = int (basic_info [1 ])
45+
46+ version_type = 'final'
47+ extra_id = 0
48+
49+ try :
50+ patch_v = int (basic_info [2 ])
51+ except ValueError :
52+ for vtype in ('a' , 'b' , 'rc' ):
53+ if vtype in basic_info [2 ]:
54+ version_type = vtype
55+ idx = basic_info [2 ].find (vtype )
56+ patch_v = int (basic_info [:idx ])
57+ extra_id = int (basic_info [2 ][idx + len (vtype ):])
58+
59+ if version_type == 'final' :
60+ raise ValueError ('Invalid version: {}' .format (version_str ))
61+
62+ if len (basic_info ) > 3 :
63+ for vtype in ('dev' , 'post' ):
64+ if basic_info [3 ].startswith (vtype ):
65+ version_type = vtype
66+ extra_id = int (basic_info [3 ][len (vtype ):])
67+
68+ if version_type == 'final' :
69+ raise ValueError ('Invalid version: {}' .format (version_str ))
70+
71+ return major , minor , patch_v , version_type , extra_id
72+
73+
4074class StackdioClient (BlueprintMixin , FormulaMixin , AccountMixin , ImageMixin ,
4175 RegionMixin , StackMixin , SettingsMixin , HttpMixin ):
4276
@@ -60,11 +94,12 @@ def __init__(self, url=None, username=None, password=None, verify=True, cfg_file
6094 if self .usable ():
6195 try :
6296 raw_version = self .get_version (raise_for_status = False )
63- self .version = raw_version . split ( '.' )
97+ self .version = _get_server_version_info ( raw_version )
6498 except MissingUrlException :
6599 raw_version = None
100+ self .version = None
66101
67- if raw_version and (self .version [0 ] != 0 or self .version [1 ] != 7 ):
102+ if self . version and (self .version [0 ] != 0 or self .version [1 ] != 7 ):
68103 raise IncompatibleVersionException (
69104 'Server version {0} not supported. Please upgrade '
70105 'stackdio-cli to {1}.{2}.0 or higher.' .format (raw_version , * self .version )
0 commit comments