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

RE: Grabbing user input in the %pre section using the python snack library



> > I'm glad it helped. I forgot to mention the problems on RHEL4 (and I
> > think FC2 as well), but I haven't used either in a while.
> 
> Did you ever have any success with getting user input on RHEL4 w/o
> using snack (or heck, with)? I've been messing around with it in python
> and haven't had any success so far ..

Well, here's the hack I came up with to support RHEL4. The "/tmp/pre" is in there as for some reason RHEL4 has been wanting to execute the %pre section twice???? Note that I use Cobbler so the $os_version is replaced on Kickstart generation .. Convoluted, but it works .. Basically using python for anything not RHEL4 and Python for everything else. Solves for not being able to properly set tty in RHEL4 in python.

if [ ! -e /tmp/pre ];
then

    #disk lay stuff omitted 

    if [ $os_version != "rhel4" ];
    then
    	/usr/bin/python << EOF

import os, sys
from snack import *

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())

title = "Terremark Linux Build System"
buttons = ['Ok', 'Cancel']
allowCancel = 1
width = 40
entryWidth = 20
help = "None"
scroll = 1
height = -1
default = "None"

textItems = "Hello!"
text = "Confirm options"
set_tty(1)
screen = SnackScreen()
ButtonChoiceWindow(screen, title, textItems, ['Start Build', 'Re-input Items'], width, 0,0,help)
screen.finish()
set_tty(3)

EOF
    fi

    if [ $os_version = "rhel4" ];
    then
		chvt 3
		echo "Build system: "
		read BLAH
		chvt 1
    fi

touch /tmp/pre
fi


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