Repository: softlayer/softlayer-python

Issue:
dns record-remove AttributeError
I think the transcript speaks for itself. :)

```
$ slcli --version
slcli (SoftLayer Command-line), version 4.0.1
$ slcli dns record-remove 56530852
This action cannot be undone! Type "yes" or press Enter to abort: yes
An unexpected error has occured:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/SoftLayer/CLI/core.py", line 180, in main
    cli.main()
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 644, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/SoftLayer/CLI/dns/record_remove.py", line 20, in cli
    if not (env.skip_confirmations or formatting.no_going_back('yes')):
  File "/usr/local/lib/python2.7/site-packages/SoftLayer/CLI/formatting.py", line 195, in no_going_back
    ans = click.confirm(prompt, default='', show_default=False).lower()
AttributeError: 'bool' object has no attribute 'lower'

Feel free to report this error as it is likely a bug:
    https://github.com/softlayer/softlayer-python/issues
```


Discussion:

Patch:
diff --git a/SoftLayer/CLI/formatting.py b/SoftLayer/CLI/formatting.py
index 138e5318..b7f25a5c 100644
--- a/SoftLayer/CLI/formatting.py
+++ b/SoftLayer/CLI/formatting.py
@@ -192,8 +192,8 @@ def no_going_back(confirmation):
     prompt = ('This action cannot be undone! Type "%s" or press Enter '
               'to abort' % confirmation)
 
-    ans = click.confirm(prompt, default='', show_default=False).lower()
-    if ans == str(confirmation):
+    ans = click.prompt(prompt, default='', show_default=False)
+    if ans.lower() == str(confirmation):
         return True
 
     return False
diff --git a/SoftLayer/managers/messaging.py b/SoftLayer/managers/messaging.py
index 6c7e0237..8c273b6b 100644
--- a/SoftLayer/managers/messaging.py
+++ b/SoftLayer/managers/messaging.py
@@ -168,7 +168,12 @@ def _make_request(self, method, path, **kwargs):
 
         url = '/'.join((self.endpoint, 'v1', self.account_id, path))
         resp = requests.request(method, url, **kwargs)
-        resp.raise_for_status()
+        try:
+            resp.raise_for_status()
+        except requests.HTTPError as ex:
+            content = json.loads(ex.response.content)
+            raise exceptions.SoftLayerAPIError(ex.response.status_code,
+                                               content['message'])
         return resp
 
     def authenticate(self, username, api_key, auth_token=None):


Test patch:
diff --git a/SoftLayer/tests/CLI/helper_tests.py b/SoftLayer/tests/CLI/helper_tests.py
index 1dea9ab4..d6017355 100644
--- a/SoftLayer/tests/CLI/helper_tests.py
+++ b/SoftLayer/tests/CLI/helper_tests.py
@@ -41,21 +41,21 @@ def test_fail(self):
 
 class PromptTests(testing.TestCase):
 
-    @mock.patch('click.confirm')
-    def test_do_or_die(self, confirm_mock):
+    @mock.patch('click.prompt')
+    def test_do_or_die(self, prompt_mock):
         confirmed = '37347373737'
-        confirm_mock.return_value = confirmed
+        prompt_mock.return_value = confirmed
         result = formatting.no_going_back(confirmed)
         self.assertTrue(result)
 
         # no_going_back should cast int's to str()
         confirmed = '4712309182309'
-        confirm_mock.return_value = confirmed
+        prompt_mock.return_value = confirmed
         result = formatting.no_going_back(int(confirmed))
         self.assertTrue(result)
 
         confirmed = None
-        confirm_mock.return_value = ''
+        prompt_mock.return_value = ''
         result = formatting.no_going_back(confirmed)
         self.assertFalse(result)