handles keyboard interrupt
When an user intentionally provides an keyboard interrupt, keystoneclient throws the entire traceback on to the terminal instead of handling it. keystoneclient will now handle the keyboard interrrupt and provides an crisp message on to the terminal. Change-Id: I1026d259fd0688dd2b950b1bdb135d219da2a60a Closes-Bug: #1367283
This commit is contained in:
parent
99078247c7
commit
5000a851d8
|
@ -461,7 +461,9 @@ class OpenStackHelpFormatter(argparse.HelpFormatter):
|
|||
def main():
|
||||
try:
|
||||
OpenStackIdentityShell().main(sys.argv[1:])
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("... terminating keystone client", file=sys.stderr)
|
||||
sys.exit(130)
|
||||
except Exception as e:
|
||||
print(encodeutils.safe_encode(six.text_type(e)), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
|
|
@ -520,3 +520,13 @@ class ShellTest(utils.TestCase):
|
|||
'http://example.com:4321/go',
|
||||
'http://example.com:9876/adm')
|
||||
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
|
||||
|
||||
def test_shell_keyboard_interrupt(self):
|
||||
shell_mock = mock.MagicMock()
|
||||
with mock.patch('keystoneclient.shell.OpenStackIdentityShell.main',
|
||||
shell_mock):
|
||||
try:
|
||||
shell_mock.side_effect = KeyboardInterrupt()
|
||||
openstack_shell.main()
|
||||
except SystemExit as ex:
|
||||
self.assertEqual(130, ex.code)
|
||||
|
|
Loading…
Reference in New Issue