[PATCH 1/2] Don't rely on terminal attributes being configurable (#1162702)
Samantha N. Bueno
sbueno+anaconda at redhat.com
Wed Nov 12 18:54:27 UTC 2014
On Wed, Nov 12, 2014 at 02:42:42PM +0100, Vratislav Podzimek wrote:
> 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.
Well, I've tested your patch on my s390x guest, and it does not fix the
issue. More comments inline below.
> 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:
Doesn't look like SystemError is being raised, instead it's just a
generic Exception.
So I guess an ugly "except Exception as sys_err". This returns a tuple--
18:18:05,369 DEBUG anaconda: (25, 'Inappropriate ioctl for device')
> + if sys_err.errno == 25:
if sys_err[0] == 25:
With these couple changes, the crash is averted. It's not elegant or
anything though. And pylint is going to complain that we're catching too
general an exception.
> + # "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)
Also, pylint complains that _in_data is never used, so couldn't you
instead leave out the variable assignment and just do the sys call?
> - termios.tcsetattr(fd, termios.TCSAFLUSH, old)
> +
> + if termios_attrs_changed:
> + termios.tcsetattr(fd, termios.TCSAFLUSH, old)
>
> return force_cont
> --
> 1.9.3
>
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
More information about the anaconda-patches
mailing list