[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Human interaction in %PRE text mode with snack Dialog boxes



Meyers, John J wrote:

Hi All,
The %pre mode seems to conduct I/O with tty3. With primary anaconda user interaction displays on tty1. I need to interact with the user on tty1 during %pre; Using python and snack. Due to using various weird hardware in our environment a graphical install dos not work.
 The Code below is just an example of what I've tried.
%pre --interpreter /usr/bin/python
TTY = 1
import os
import sys
import snack
import time
import fcntl
import termios
os.system("chvt %d" % TTY)
fd = os.open("/dev/tty%d" % TTY, os.O_RDWR)
os.dup2(fd, 0)
os.dup2(fd, 1)
os.dup2(fd, 2)
sys.stdin = os.fdopen(0, "r")
sys.stdout = os.fdopen(1, "w")
sys.stderr = os.fdopen(2, "w")
screen = snack.SnackScreen()
snack.ButtonChoiceWindow(screen, "WARNING",
    "WARNING! Am I CRAZY!",
    buttons=["reboot", "continue"]):
    os.system("reboot")
    while 1: time.sleep(10)
screen.finish()
os.system("chvt %d" % 3)
%end
ANY suggestions??

I use code like this:
set_tty(1)  # change to tty1, we're called by
# kickstart with stdout as tty3

user_args = get_user_input(host_config, args.args.get('tb-host'))
set_tty(3)  # restore

Where:
def set_tty(n):
    f = open('/dev/tty%d' % n, 'a')
    os.dup2(f.fileno(), sys.stdin.fileno())
    os.dup2(f.fileno(), sys.stdout.fileno())
    os.dup2(f.fileno(), sys.stderr.fileno())

and get_user_input() uses snack.

Hope that helps.

Eric.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]