Skip to content

Commit 5f87aa4

Browse files
cleanup and ran autopep8 which added a few new lines here and there
1 parent d906d8b commit 5f87aa4

38 files changed

+1321
-138
lines changed

.pytest_cache/v/cache/lastfailed

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"tests/CLI/modules/block_tests.py::BlockTests::test_volume_order_performance_iops_not_multiple_of_100": true,
3+
"tests/CLI/modules/file_tests.py::FileTests::test_volume_order_performance_iops_not_multiple_of_100": true,
4+
"tests/managers/ordering_tests.py::OrderingTests::test_get_location_id_fixture": true
5+
}

.pytest_cache/v/cache/nodeids

Lines changed: 1130 additions & 0 deletions
Large diffs are not rendered by default.

SoftLayer/API.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ class Service(object):
333333
:param name str: The service name
334334
335335
"""
336+
336337
def __init__(self, client, name):
337338
self.client = client
338339
self.name = name

SoftLayer/CLI/columns.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
class Column(object):
1616
"""Column desctribes an attribute and how to fetch/display it."""
17+
1718
def __init__(self, name, path, mask=None):
1819
self.name = name
1920
self.path = path
@@ -26,6 +27,7 @@ def __init__(self, name, path, mask=None):
2627

2728
class ColumnFormatter(object):
2829
"""Maps each column using a function"""
30+
2931
def __init__(self):
3032
self.columns = []
3133
self.column_funcs = []

SoftLayer/CLI/core.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,17 @@ def cli(env,
121121
env.format = format
122122
env.ensure_client(config_file=config, is_demo=demo, proxy=proxy)
123123
env.vars['_start'] = time.time()
124+
logger = logging.getLogger()
124125

125126
if demo is False:
126-
logger = logging.getLogger()
127127
logger.addHandler(logging.StreamHandler())
128-
logger.setLevel(DEBUG_LOGGING_MAP.get(verbose, logging.DEBUG))
129-
env.vars['_timings'] = SoftLayer.DebugTransport(env.client.transport)
130128
else:
131129
# This section is for running CLI tests.
132130
logging.getLogger("urllib3").setLevel(logging.WARNING)
133-
env.vars['_timings'] = SoftLayer.TimingTransport(env.client.transport)
131+
logger.addHandler(logging.NullHandler())
134132

133+
logger.setLevel(DEBUG_LOGGING_MAP.get(verbose, logging.DEBUG))
134+
env.vars['_timings'] = SoftLayer.DebugTransport(env.client.transport)
135135
env.client.transport = env.vars['_timings']
136136

137137

SoftLayer/CLI/exceptions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# pylint: disable=keyword-arg-before-vararg
1111
class CLIHalt(SystemExit):
1212
"""Smoothly halt the execution of the command. No error."""
13+
1314
def __init__(self, code=0, *args):
1415
super(CLIHalt, self).__init__(*args)
1516
self.code = code
@@ -23,13 +24,15 @@ def __str__(self):
2324

2425
class CLIAbort(CLIHalt):
2526
"""Halt the execution of the command. Gives an exit code of 2."""
27+
2628
def __init__(self, msg, *args):
2729
super(CLIAbort, self).__init__(code=2, *args)
2830
self.message = msg
2931

3032

3133
class ArgumentError(CLIAbort):
3234
"""Halt the execution of the command because of invalid arguments."""
35+
3336
def __init__(self, msg, *args):
3437
super(ArgumentError, self).__init__(msg, *args)
3538
self.message = "Argument Error: %s" % msg

SoftLayer/CLI/file/snapshot/schedule_list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def cli(env, volume_id):
6363
file_schedule_type,
6464
replication,
6565
schedule.get('createDate', '')
66-
]
66+
]
6767
table_row.extend(schedule_properties)
6868
table.add_row(table_row)
6969

SoftLayer/CLI/formatting.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ class SequentialOutput(list):
232232
233233
:param separator str: string to use as a default separator
234234
"""
235+
235236
def __init__(self, separator=os.linesep, *args, **kwargs):
236237
self.separator = separator
237238
super(SequentialOutput, self).__init__(*args, **kwargs)
@@ -246,6 +247,7 @@ def __str__(self):
246247

247248
class CLIJSONEncoder(json.JSONEncoder):
248249
"""A JSON encoder which is able to use a .to_python() method on objects."""
250+
249251
def default(self, obj):
250252
"""Encode object if it implements to_python()."""
251253
if hasattr(obj, 'to_python'):
@@ -258,6 +260,7 @@ class Table(object):
258260
259261
:param list columns: a list of column names
260262
"""
263+
261264
def __init__(self, columns, title=None):
262265
duplicated_cols = [col for col, count
263266
in collections.Counter(columns).items()
@@ -311,6 +314,7 @@ def prettytable(self):
311314

312315
class KeyValueTable(Table):
313316
"""A table that is oriented towards key-value pairs."""
317+
314318
def to_python(self):
315319
"""Decode this KeyValueTable object to standard Python types."""
316320
mapping = {}
@@ -325,6 +329,7 @@ class FormattedItem(object):
325329
:param original: raw (machine-readable) value
326330
:param string formatted: human-readable value
327331
"""
332+
328333
def __init__(self, original, formatted=None):
329334
self.original = original
330335
if formatted is not None:

SoftLayer/CLI/user/detail.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from SoftLayer.CLI import helpers
1010
from SoftLayer import utils
1111

12-
from pprint import pprint as pp
1312

1413
@click.command()
1514
@click.argument('identifier')
@@ -28,7 +27,7 @@
2827
@environment.pass_env
2928
def cli(env, identifier, keys, permissions, hardware, virtual, logins, events):
3029
"""User details."""
31-
30+
3231
mgr = SoftLayer.UserManager(env.client)
3332
user_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'username')
3433
object_mask = "userStatus[name], parent[id, username], apiAuthenticationKeys[authenticationKey], "\
@@ -55,7 +54,6 @@ def cli(env, identifier, keys, permissions, hardware, virtual, logins, events):
5554
if events:
5655
event_log = mgr.get_events(user_id)
5756
env.fout(print_events(event_log))
58-
5957

6058

6159
def basic_info(user, keys):
@@ -74,7 +72,7 @@ def basic_info(user, keys):
7472
table.add_row(['Email', user.get('email')])
7573
table.add_row(['OpenID', user.get('openIdConnectUserName')])
7674
address = "%s %s %s %s %s %s" % (
77-
user.get('address1'), user.get('address2'), user.get('city'), user.get('state'),
75+
user.get('address1'), user.get('address2'), user.get('city'), user.get('state'),
7876
user.get('country'), user.get('postalCode'))
7977
table.add_row(['Address', address])
8078
table.add_row(['Company', user.get('companyName')])
@@ -85,17 +83,18 @@ def basic_info(user, keys):
8583
table.add_row(['Status', utils.lookup(user, 'userStatus', 'name')])
8684
table.add_row(['PPTP VPN', user.get('pptpVpnAllowedFlag', 'No')])
8785
table.add_row(['SSL VPN', user.get('sslVpnAllowedFlag', 'No')])
88-
for login in user.get('unsuccessfulLogins'):
86+
for login in user.get('unsuccessfulLogins'):
8987
login_string = "%s From: %s" % (login.get('createDate'), login.get('ipAddress'))
9088
table.add_row(['Last Failed Login', login_string])
9189
break
92-
for login in user.get('successfulLogins'):
90+
for login in user.get('successfulLogins'):
9391
login_string = "%s From: %s" % (login.get('createDate'), login.get('ipAddress'))
9492
table.add_row(['Last Login', login_string])
9593
break
9694

9795
return table
9896

97+
9998
def print_permissions(permissions):
10099
"""Prints out a users permissions"""
101100

@@ -104,12 +103,13 @@ def print_permissions(permissions):
104103
table.add_row([perm['keyName'], perm['name']])
105104
return table
106105

106+
107107
def print_access(access, title):
108108
"""Prints out the hardware or virtual guests a user can access"""
109109

110110
columns = ['id', 'hostname', 'Primary Public IP', 'Primary Private IP', 'Created']
111111
table = formatting.Table(columns, title)
112-
112+
113113
for host in access:
114114
host_id = host.get('id')
115115
host_fqdn = host.get('fullyQualifiedDomainName', '-')
@@ -119,6 +119,7 @@ def print_access(access, title):
119119
table.add_row([host_id, host_fqdn, host_primary, host_private, host_created])
120120
return table
121121

122+
122123
def print_dedicated_access(access):
123124
"""Prints out the dedicated hosts a user can access"""
124125

@@ -133,19 +134,20 @@ def print_dedicated_access(access):
133134
table.add_row([host_id, host_fqdn, host_cpu, host_mem, host_disk, host_created])
134135
return table
135136

137+
136138
def print_logins(logins):
137139
"""Prints out the login history for a user"""
138140
table = formatting.Table(['Date', 'IP Address', 'Successufl Login?'])
139141
for login in logins:
140142
table.add_row([login.get('createDate'), login.get('ipAddress'), login.get('successFlag')])
141143
return table
142144

145+
143146
def print_events(events):
144147
"""Prints out the event log for a user"""
145148
columns = ['Date', 'Type', 'IP Address', 'label', 'username']
146149
table = formatting.Table(columns)
147150
for event in events:
148-
table.add_row([event.get('eventCreateDate'), event.get('eventName'),
149-
event.get('ipAddress'), event.get('label'), event.get('username')])
151+
table.add_row([event.get('eventCreateDate'), event.get('eventName'),
152+
event.get('ipAddress'), event.get('label'), event.get('username')])
150153
return table
151-

SoftLayer/CLI/user/edit_permissions.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,28 @@
55

66
import SoftLayer
77
from SoftLayer.CLI import environment
8-
from SoftLayer.CLI import formatting
98
from SoftLayer.CLI import helpers
10-
from SoftLayer import utils
11-
12-
from pprint import pprint as pp
139

1410

1511
@click.command()
1612
@click.argument('identifier')
1713
@click.option('--enable/--disable', default=True,
18-
help="Enable or Disable selected permissions")
14+
help="Enable or Disable selected permissions")
1915
@click.option('--permission', '-p', multiple=True,
20-
help="Permission keyName to set, multiple instances allowed.")
16+
help="Permission keyName to set, multiple instances allowed.")
2117
@environment.pass_env
2218
def cli(env, identifier, enable, permission):
2319
"""Enable or Disable specific permissions."""
24-
20+
2521
mgr = SoftLayer.UserManager(env.client)
2622
user_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'username')
27-
object_mask = "mask[id,permissions,isMasterUserFlag]"
23+
result = False
2824
if enable:
2925
result = mgr.add_permissions(user_id, permission)
30-
click.secho("Permissions added successfully: %s" % ", ".join(permission), fg='green')
3126
else:
3227
result = mgr.remove_permissions(user_id, permission)
33-
click.secho("Permissions removed successfully: %s" % ", ".join(permission), fg='green')
3428

29+
if result:
30+
click.secho("Permissions updated successfully: %s" % ", ".join(permission), fg='green')
31+
else:
32+
click.secho("Failed to update permissions: %s" % ", ".join(permission), fg='red')

0 commit comments

Comments
 (0)