Skip to content

Commit 4b4cad8

Browse files
author
caberos
committed
Merge branch 'master' of https://github.com/softlayer/softlayer-python into issue1324
2 parents f0f5a21 + 582dbe9 commit 4b4cad8

File tree

12 files changed

+41
-46
lines changed

12 files changed

+41
-46
lines changed

SoftLayer/CLI/exceptions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class CLIHalt(SystemExit):
1212
"""Smoothly halt the execution of the command. No error."""
1313

1414
def __init__(self, code=0, *args):
15-
super(CLIHalt, self).__init__(*args)
15+
super().__init__(*args)
1616
self.code = code
1717

1818
def __str__(self):
@@ -26,13 +26,13 @@ class CLIAbort(CLIHalt):
2626
"""Halt the execution of the command. Gives an exit code of 2."""
2727

2828
def __init__(self, msg, *args):
29-
super(CLIAbort, self).__init__(code=2, *args)
29+
super().__init__(code=2, *args)
3030
self.message = msg
3131

3232

3333
class ArgumentError(CLIAbort):
3434
"""Halt the execution of the command because of invalid arguments."""
3535

3636
def __init__(self, msg, *args):
37-
super(ArgumentError, self).__init__(msg, *args)
37+
super().__init__(msg, *args)
3838
self.message = "Argument Error: %s" % msg

SoftLayer/CLI/formatting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class SequentialOutput(list):
235235

236236
def __init__(self, separator=os.linesep, *args, **kwargs):
237237
self.separator = separator
238-
super(SequentialOutput, self).__init__(*args, **kwargs)
238+
super().__init__(*args, **kwargs)
239239

240240
def to_python(self):
241241
"""returns itself, since it itself is a list."""
@@ -252,7 +252,7 @@ def default(self, obj):
252252
"""Encode object if it implements to_python()."""
253253
if hasattr(obj, 'to_python'):
254254
return obj.to_python()
255-
return super(CLIJSONEncoder, self).default(obj)
255+
return super().default(obj)
256256

257257

258258
class Table(object):

SoftLayer/CLI/hardware/dns.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,6 @@ def cli(env, identifier, a_record, aaaa_record, ptr, ttl):
6060
# done this way to stay within 80 character lines
6161
ipv6 = instance['primaryNetworkComponent']['primaryVersion6IpAddressRecord']['ipAddress']
6262
dns.sync_host_record(zone_id, instance['hostname'], ipv6, 'aaaa', ttl)
63-
except KeyError:
64-
raise exceptions.CLIAbort("%s does not have an ipv6 address" % instance['fullyQualifiedDomainName'])
63+
except KeyError as ex:
64+
message = "{} does not have an ipv6 address".format(instance['fullyQualifiedDomainName'])
65+
raise exceptions.CLIAbort(message) from ex

SoftLayer/CLI/metadata.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,10 @@ def cli(env, prop):
5454

5555
meta_prop = META_MAPPING.get(prop) or prop
5656
env.fout(SoftLayer.MetadataManager().get(meta_prop))
57-
except SoftLayer.TransportError:
58-
raise exceptions.CLIAbort(
59-
'Cannot connect to the backend service address. Make sure '
60-
'this command is being ran from a device on the backend '
61-
'network.')
57+
except SoftLayer.TransportError as ex:
58+
message = 'Cannot connect to the backend service address. Make sure '\
59+
'this command is being ran from a device on the backend network.'
60+
raise exceptions.CLIAbort(message) from ex
6261

6362

6463
def get_network():

SoftLayer/CLI/report/bandwidth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ def _validate_datetime(ctx, param, value):
1919

2020
try:
2121
return datetime.datetime.strptime(value, "%Y-%m-%d %H:%M:%S")
22-
except (ValueError, TypeError):
23-
raise click.BadParameter(
24-
"not in the format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS'")
22+
except (ValueError, TypeError) as ex:
23+
message = "not in the format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS'"
24+
raise click.BadParameter(message) from ex
2525

2626

2727
def _get_pooled_bandwidth(env, start, end):

SoftLayer/CLI/virt/dns.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,6 @@ def cli(env, identifier, a_record, aaaa_record, ptr, ttl):
6060
# done this way to stay within 80 character lines
6161
ipv6 = instance['primaryNetworkComponent']['primaryVersion6IpAddressRecord']['ipAddress']
6262
dns.sync_host_record(zone_id, instance['hostname'], ipv6, 'aaaa', ttl)
63-
except KeyError:
64-
raise exceptions.CLIAbort("%s does not have an ipv6 address" % instance['fullyQualifiedDomainName'])
63+
except KeyError as ex:
64+
message = "{} does not have an ipv6 address".format(instance['fullyQualifiedDomainName'])
65+
raise exceptions.CLIAbort(message) from ex

SoftLayer/fixtures/SoftLayer_Account.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: UTF-8 -*-
2-
3-
# # pylint: disable=bad-continuation
41
getPrivateBlockDeviceTemplateGroups = [{
52
'accountId': 1234,
63
'blockDevices': [],

SoftLayer/managers/ordering.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
from SoftLayer import exceptions
1313

1414

15-
CATEGORY_MASK = '''id,
16-
isRequired,
17-
itemCategory[id, name, categoryCode]
18-
'''
15+
CATEGORY_MASK = '''id, isRequired, itemCategory[id, name, categoryCode]'''
1916

2017
ITEM_MASK = '''id, keyName, description, itemCategory, categories, prices'''
2118

@@ -359,10 +356,10 @@ def get_price_id_list(self, package_keyname, item_keynames, core=None):
359356
# keyName with the current item we are searching for
360357
matching_item = [i for i in items
361358
if i['keyName'] == item_keyname][0]
362-
except IndexError:
363-
raise exceptions.SoftLayerError(
364-
"Item {} does not exist for package {}".format(item_keyname,
365-
package_keyname))
359+
except IndexError as ex:
360+
message = "Item {} does not exist for package {}".format(item_keyname,
361+
package_keyname)
362+
raise exceptions.SoftLayerError(message) from ex
366363

367364
# we want to get the price ID that has no location attached to it,
368365
# because that is the most generic price. verifyOrder/placeOrder

SoftLayer/managers/storage_utils.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -533,10 +533,9 @@ def prepare_volume_order_object(manager, storage_type, location, size,
533533
# Find the ID for the requested location
534534
try:
535535
location_id = get_location_id(manager, location)
536-
except ValueError:
537-
raise exceptions.SoftLayerError(
538-
"Invalid datacenter name specified. "
539-
"Please provide the lower case short name (e.g.: dal09)")
536+
except ValueError as ex:
537+
message = "Invalid datacenter name specified. Please provide the lower case short name (e.g.: dal09)"
538+
raise exceptions.SoftLayerError(message) from ex
540539

541540
# Determine the category code to use for the order (and product package)
542541
order_type_is_saas, order_category_code = _get_order_type_and_category(
@@ -676,10 +675,9 @@ def prepare_replicant_order_object(manager, snapshot_schedule, location,
676675
# Find the ID for the requested location
677676
try:
678677
location_id = get_location_id(manager, location)
679-
except ValueError:
680-
raise exceptions.SoftLayerError(
681-
"Invalid datacenter name specified. "
682-
"Please provide the lower case short name (e.g.: dal09)")
678+
except ValueError as ex:
679+
message = "Invalid datacenter name specified. Please provide the lower case short name (e.g.: dal09)"
680+
raise exceptions.SoftLayerError(message) from ex
683681

684682
# Get sizes and properties needed for the order
685683
volume_size = int(volume['capacityGb'])

SoftLayer/managers/vs_capacity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ def create_guest(self, capacity_id, test, guest_object):
143143
try:
144144
capacity_flavor = capacity['instances'][0]['billingItem']['item']['keyName']
145145
flavor = _flavor_string(capacity_flavor, guest_object['primary_disk'])
146-
except KeyError:
147-
raise SoftLayerError("Unable to find capacity Flavor.")
146+
except KeyError as ex:
147+
raise SoftLayerError("Unable to find capacity Flavor.") from ex
148148

149149
guest_object['flavor'] = flavor
150150
guest_object['datacenter'] = capacity['backendRouter']['datacenter']['name']

0 commit comments

Comments
 (0)