joey boggs wrote:
I'm not sure I understand what you're doing, but maybe you'll find the
following somewhat useful:
.... def raw_input(self, prompt=None):
.... # override input function
.... while 1:
.... text = raw_input(promp t)
.... if text.startswith ("DROP"):
.... # deal with custom command
.... print "CUSTOM DROP COMMAND", text
.... else:
.... return text
....
Python 2.5.2 [...]
Type "help", "copyright" , "credits" or "license" for more information.
(MyInterpreter)
hello
CUSTOM DROP COMMAND DROP something
30
CUSTOM DROP COMMAND DROP something else
</F>
In the end I'd like to be able to run a custom interpreter and just feed
it one command and a directory. The end result in the kickstart
something like this:
>
%post --interpreter #!/usr/bin/myinterpreter
DROP /tmp/directory
DROP /tmp/directory2
>
How would I setup the interpreter to take the DROP command? I've been
reading and searching all day but I haven't found anything close to what
I'm doing. I realize that using custom commands in this case is overkill
but in the end is used to make the users life easier. If anyone can
point me to some documentation I would be more than grateful.
it one command and a directory. The end result in the kickstart
something like this:
>
%post --interpreter #!/usr/bin/myinterpreter
DROP /tmp/directory
DROP /tmp/directory2
>
How would I setup the interpreter to take the DROP command? I've been
reading and searching all day but I haven't found anything close to what
I'm doing. I realize that using custom commands in this case is overkill
but in the end is used to make the users life easier. If anyone can
point me to some documentation I would be more than grateful.
following somewhat useful:
>>import code
>>class MyInterpreter(c ode.Interactive Console):
>>class MyInterpreter(c ode.Interactive Console):
.... # override input function
.... while 1:
.... text = raw_input(promp t)
.... if text.startswith ("DROP"):
.... # deal with custom command
.... print "CUSTOM DROP COMMAND", text
.... else:
.... return text
....
>>i = MyInterpreter()
>>i.interact( )
>>i.interact( )
Type "help", "copyright" , "credits" or "license" for more information.
(MyInterpreter)
>>print "hello"
>>DROP something
>>x = 10
>>y = 20
>>x + y
>>y = 20
>>x + y
>>DROP something else
>>>