Skip to content

Conversation

FernandoOjeda
Copy link
Contributor

Fixed hardware credentials issue #981

raise exceptions.SoftLayerError("No passwords found in operatingSystem")

for item in instance['operatingSystem']['passwords']:
table.add_row([item['username'], item['password']])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of raising an exception, I would prefer this to just print out "None"

table.add_row([item.get('username', 'None'), item.get('password', 'None')])

.get() allows you to specify a default value to return if the item isn't found. This article explain it in a bit more detail if you are interested.
https://docs.quantifiedcode.com/python-anti-patterns/correctness/not_using_get_to_return_a_default_value_from_a_dictionary.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 88.584% when pulling 53fb9e7 on FernandoOjeda:fo_hardware_credentials into 07ee664 on softlayer:master.

@allmightyspiff allmightyspiff merged commit b8bc75a into softlayer:master Jul 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants