Skip to content

Commit f46f928

Browse files
author
Clark Perkins
committed
Removed unused pieces
1 parent bdd2079 commit f46f928

File tree

3 files changed

+8
-79
lines changed

3 files changed

+8
-79
lines changed

stackdio/client/__init__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
from .region import RegionMixin
3333
from .settings import SettingsMixin
3434
from .stack import StackMixin
35-
from .version import _parse_version_string
3635

3736
logger = logging.getLogger(__name__)
3837
logger.addHandler(logging.NullHandler())
@@ -60,13 +59,16 @@ def __init__(self, url=None, username=None, password=None, verify=True, cfg_file
6059

6160
if self.usable():
6261
try:
63-
_, self.version = _parse_version_string(self.get_version(raise_for_status=False))
62+
raw_version = self.get_version(raise_for_status=False)
63+
self.version = raw_version.split('.')
6464
except MissingUrlException:
65-
self.version = None
65+
raw_version = None
6666

67-
if self.version and (self.version[0] != 0 or self.version[1] != 7):
68-
raise IncompatibleVersionException('Server version {0}.{1}.{2} not '
69-
'supported.'.format(*self.version))
67+
if raw_version and (self.version[0] != 0 or self.version[1] != 7):
68+
raise IncompatibleVersionException(
69+
'Server version {0} not supported. Please upgrade '
70+
'stackdio-cli to {1}.{2}.0 or higher.'.format(raw_version, *self.version)
71+
)
7072

7173
@property
7274
def url(self):

stackdio/client/stack.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
from .exceptions import StackException
1919
from .http import HttpMixin, get, post, put, delete
20-
from .version import deprecated
2120

2221

2322
class StackMixin(HttpMixin):

stackdio/client/version.py

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -97,78 +97,6 @@ def get_git_changeset():
9797
__version__ = get_version(VERSION)
9898

9999

100-
def _unsupported_function(func, current_version, accepted_versions):
101-
raise IncompatibleVersionException("%s: %s is not one of %s" %
102-
(func.__name__,
103-
".".join([str(v) for v in current_version]),
104-
list(accepted_versions)))
105-
106-
107-
def _parse_version_string(version_string):
108-
original_version_string = version_string
109-
comparisons = {
110-
"=": operator.eq,
111-
"!=": operator.ne,
112-
"<": operator.lt,
113-
">": operator.gt,
114-
"<=": operator.le,
115-
">=": operator.ge
116-
}
117-
118-
# Determine the comparison function
119-
comp_string = "="
120-
if version_string[0] in ["<", ">", "=", "!"]:
121-
offset = 1
122-
if version_string[1] == "=":
123-
offset += 1
124-
125-
comp_string = version_string[:offset]
126-
version_string = version_string[offset:]
127-
128-
# Check if the version appears compatible
129-
try:
130-
int(version_string[0])
131-
except ValueError:
132-
raise InvalidVersionStringException(original_version_string)
133-
134-
# String trailing info
135-
version_string = re.split("[a-zA-Z]", version_string)[0]
136-
if version_string[-1] == '.':
137-
version_string = version_string[:-1]
138-
version = version_string.split(".")
139-
140-
# Pad length to 3
141-
version += [0] * (3 - len(version))
142-
143-
# Convert to ints
144-
version = [int(num) for num in version]
145-
146-
try:
147-
return comparisons[comp_string], tuple(version)
148-
except KeyError:
149-
raise InvalidVersionStringException(original_version_string)
150-
151-
152-
def accepted_versions(*versions):
153-
def decorator(func):
154-
if not versions:
155-
return func
156-
157-
parsed_versions = [_parse_version_string(version_string)
158-
for version_string in versions]
159-
160-
@wraps(func)
161-
def wrapper(obj, *args, **kwargs):
162-
for parsed_version in parsed_versions:
163-
comparison, version = parsed_version
164-
if comparison(obj.version, version):
165-
return func(obj, *args, **kwargs)
166-
167-
return _unsupported_function(func, obj.version, versions)
168-
return wrapper
169-
return decorator
170-
171-
172100
def deprecated(func):
173101
"""
174102
This is a decorator which can be used to mark functions

0 commit comments

Comments
 (0)