From cf8d143d3eba280a286aa383de1c4278a3c85490 Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Tue, 25 Apr 2023 20:24:33 +0200 Subject: [PATCH] Handle CTRL-C gracefully with console token input Instead of presenting an exception backtrace splat when the user hits CTRL-C, just give a simple aborted message. Signed-off-by: David Sommerseth --- openvpn/connector/main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openvpn/connector/main.py b/openvpn/connector/main.py index 0f432e5..e5df786 100644 --- a/openvpn/connector/main.py +++ b/openvpn/connector/main.py @@ -103,8 +103,13 @@ def main(): token is provided. This token is used by this utility to download the proper VPN configuration profile and complete the configuration.\n""") - token = input('Enter setup token: ') - print("") + try: + token = input('Enter setup token: ') + print("") + except KeyboardInterrupt: + print('\n\nAborting\n') + sys.exit(0) + else: token = cliopts.token[0]