[PATCH 1/2] Don't rely on terminal attributes being configurable (#1162702)

Vratislav Podzimek vpodzime at redhat.com
Wed Nov 12 13:42:42 UTC 2014


In some cases (I'm looking at you s390x) terminal attributes cannot be set.
There's nothing we can do about it, but instead of crashing we should simply
continue with the terminal attributes unchanged.

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 pyanaconda/ui/lib/entropy.py | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/pyanaconda/ui/lib/entropy.py b/pyanaconda/ui/lib/entropy.py
index 903a796..c8cea29 100644
--- a/pyanaconda/ui/lib/entropy.py
+++ b/pyanaconda/ui/lib/entropy.py
@@ -67,11 +67,21 @@ def _tui_wait(msg, desired_entropy):
     print(_("After %d minutes, the installation will continue regardless of the "
             "amount of available entropy") % (MAX_ENTROPY_WAIT / 60))
     fd = sys.stdin.fileno()
-    old = termios.tcgetattr(fd)
-    new = termios.tcgetattr(fd)
-    new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
-    new[6][termios.VMIN] = 1
-    termios.tcsetattr(fd, termios.TCSANOW, new)
+    termios_attrs_changed = False
+
+    try:
+        old = termios.tcgetattr(fd)
+        new = termios.tcgetattr(fd)
+        new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
+        new[6][termios.VMIN] = 1
+        termios.tcsetattr(fd, termios.TCSANOW, new)
+        termios_attrs_changed = True
+    except SystemError as sys_err:
+        if sys_err.errno == 25:
+            # "Inappropriate ioctl for device" --> terminal attributes not supported
+            pass
+        else:
+            raise
 
     # wait for the entropy to become high enough or time has run out
     cur_entr = get_current_entropy()
@@ -107,6 +117,8 @@ def _tui_wait(msg, desired_entropy):
     # termios state
     while sys.stdin in select.select([sys.stdin], [], [], 0)[0]:
         _in_data = sys.stdin.read(1)
-    termios.tcsetattr(fd, termios.TCSAFLUSH, old)
+
+    if termios_attrs_changed:
+        termios.tcsetattr(fd, termios.TCSAFLUSH, old)
 
     return force_cont
-- 
1.9.3



More information about the anaconda-patches mailing list