Blame SOURCES/bz1354498-01-handle-exceptions-when-waiting-for-response-from-user.patch

15f218
From 35d19fd293a758c0696410a490daa349bfcc9e21 Mon Sep 17 00:00:00 2001
15f218
From: Tomas Jelinek <tojeline@redhat.com>
15f218
Date: Mon, 8 Aug 2016 15:05:51 +0200
15f218
Subject: [PATCH] handle exceptions when waiting for response from user
15f218
15f218
---
15f218
 pcs/utils.py | 22 ++++++++++++++++------
15f218
 1 file changed, 16 insertions(+), 6 deletions(-)
15f218
15f218
diff --git a/pcs/utils.py b/pcs/utils.py
15f218
index 8b2cf7c..53cc0b0 100644
15f218
--- a/pcs/utils.py
15f218
+++ b/pcs/utils.py
15f218
@@ -1801,14 +1801,24 @@ def get_terminal_input(message=None):
15f218
     if message:
15f218
         sys.stdout.write(message)
15f218
         sys.stdout.flush()
15f218
-    if PYTHON2:
15f218
-        return raw_input("")
15f218
-    else:
15f218
-        return input("")
15f218
+    try:
15f218
+        if PYTHON2:
15f218
+            return raw_input("")
15f218
+        else:
15f218
+            return input("")
15f218
+    except EOFError:
15f218
+        return ""
15f218
+    except KeyboardInterrupt:
15f218
+        print("Interrupted")
15f218
+        sys.exit(1)
15f218
 
15f218
 def get_terminal_password(message="Password: "):
15f218
-    if sys.stdout.isatty():
15f218
-        return getpass.getpass(message)
15f218
+    if sys.stdin.isatty():
15f218
+        try:
15f218
+            return getpass.getpass(message)
15f218
+        except KeyboardInterrupt:
15f218
+            print("Interrupted")
15f218
+            sys.exit(1)
15f218
     else:
15f218
         return get_terminal_input(message)
15f218
 
15f218
-- 
15f218
1.8.3.1
15f218