Skip to content

Commit 597cd42

Browse files
author
Clark Perkins
committed
Removed a couple unused pieces
1 parent 11bfd57 commit 597cd42

File tree

4 files changed

+14
-52
lines changed

4 files changed

+14
-52
lines changed

stackdio/cli/__init__.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,16 @@
77
import os
88
import sys
99

10-
from cmd2 import Cmd
1110
import keyring
11+
from cmd2 import Cmd
1212
from requests import ConnectionError
1313

14-
15-
from stackdio.client import StackdIO
16-
1714
from stackdio.cli import mixins
15+
from stackdio.client import StackdIO
1816

1917

20-
class StackdioShell(
21-
Cmd,
22-
mixins.bootstrap.BootstrapMixin,
23-
mixins.stacks.StackMixin,
24-
mixins.formulas.FormulaMixin,
25-
mixins.blueprints.BlueprintMixin):
18+
class StackdioShell(Cmd, mixins.bootstrap.BootstrapMixin, mixins.stacks.StackMixin,
19+
mixins.formulas.FormulaMixin, mixins.blueprints.BlueprintMixin):
2620

2721
CFG_DIR = os.path.expanduser("~/.stackdio-cli/")
2822
CFG_FILE = os.path.join(CFG_DIR, "config.json")
@@ -192,7 +186,6 @@ def do_account_summary(self, args=None):
192186

193187

194188
def main():
195-
196189
parser = argparse.ArgumentParser(
197190
description="Invoke the stackdio cli")
198191
parser.add_argument("--debug", action="store_true", help="Enable debugging output")

stackdio/client/__init__.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,15 @@
1717

1818
import logging
1919

20-
from .http import get, post, patch
21-
from .exceptions import BlueprintException, StackException, IncompatibleVersionException
22-
20+
from .account import AccountMixin
2321
from .blueprint import BlueprintMixin
22+
from .exceptions import BlueprintException, StackException, IncompatibleVersionException
2423
from .formula import FormulaMixin
25-
from .account import AccountMixin
24+
from .http import get, post, patch
2625
from .image import ImageMixin
2726
from .region import RegionMixin
2827
from .settings import SettingsMixin
2928
from .stack import StackMixin
30-
3129
from .version import _parse_version_string
3230

3331
logger = logging.getLogger(__name__)
@@ -37,10 +35,7 @@ class StackdIO(BlueprintMixin, FormulaMixin, AccountMixin,
3735
ImageMixin, RegionMixin, StackMixin, SettingsMixin):
3836

3937
def __init__(self, protocol="https", host="localhost", port=443,
40-
base_url=None, auth=None, auth_admin=None,
41-
verify=True):
42-
"""auth_admin is optional, only needed for creating provider, profile,
43-
and base security groups"""
38+
base_url=None, auth=None, verify=True):
4439

4540
super(StackdIO, self).__init__(auth=auth, verify=verify)
4641
if base_url:
@@ -52,7 +47,6 @@ def __init__(self, protocol="https", host="localhost", port=443,
5247
port=port)
5348

5449
self.auth = auth
55-
self.auth_admin = auth_admin
5650

5751
_, self.version = _parse_version_string(self.get_version())
5852

stackdio/client/exceptions.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ class BlueprintException(Exception):
2424
pass
2525

2626

27-
class NoAdminException(Exception):
28-
pass
29-
30-
3127
class IncompatibleVersionException(Exception):
3228
pass
3329

stackdio/client/http.py

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,16 @@
2121
import logging
2222
import requests
2323

24-
from functools import wraps
2524
from inspect import getcallargs
2625

27-
from .exceptions import NoAdminException
28-
2926
logger = logging.getLogger(__name__)
27+
logger.addHandler(logging.NullHandler())
3028

3129
HTTP_INSECURE_MESSAGE = "\n".join([
3230
"You have chosen not to verify ssl connections.",
3331
"This is insecure, but it's your choice.",
34-
"This has been your single warning."])
32+
"This has been your single warning."
33+
])
3534

3635

3736
class HttpMixin(object):
@@ -49,7 +48,7 @@ def __init__(self, auth=None, verify=True):
4948
'auth': auth,
5049
'verify': verify,
5150
}
52-
self._http_log = logging.getLogger(__name__)
51+
self._http_log = logger
5352

5453
if not verify:
5554
if self._http_log.handlers:
@@ -95,7 +94,8 @@ def response(self, rfunc):
9594

9695
def __repr__(self):
9796
if self.obj:
98-
return '<bound method HTTP {0} request for \'/api/{1}\' on {2}>'.format(method, path, repr(self.obj))
97+
return ('<bound method HTTP {0} request for '
98+
'\'/api/{1}\' on {2}>'.format(method, path, repr(self.obj)))
9999
else:
100100
return super(Request, self).__repr__()
101101

@@ -180,7 +180,6 @@ def __call__(self, *args, **kwargs):
180180

181181

182182
# Define the decorators for all the methods
183-
184183
def get(path, paginate=False, jsonify=True):
185184
return request(path, 'GET', paginate=paginate, jsonify=jsonify)
186185

@@ -207,23 +206,3 @@ def patch(path):
207206

208207
def delete(path):
209208
return request(path, 'DELETE')
210-
211-
212-
def use_admin_auth(func):
213-
214-
@wraps(func)
215-
def wrapper(obj, *args, **kwargs):
216-
# Save and set the auth to use the admin auth
217-
auth = obj._http_options['auth']
218-
try:
219-
obj._http_options['auth'] = obj._http_options['admin']
220-
except KeyError:
221-
raise NoAdminException("No admin credentials were specified")
222-
223-
# Call the original function
224-
output = func(*args, **kwargs)
225-
226-
# Set the auth back to the original
227-
obj._http_options['auth'] = auth
228-
return output
229-
return wrapper

0 commit comments

Comments
 (0)