python custom command interpreter?

joey boggs jboggs7 at
Wed Aug 20 22:57:41 CEST 2008

That's kinda what I'm looking for, but it can't be interactive as
there's no way to send input during the installation.
It should pass the DROP statements to the interpreter and the
interpreter takes the input and runs os.rmdir() or something similar.
This way the backend does all the work and the frontend
is easily configured for any user to add directories.

* %post --interpreter #!/usr/bin/myinterpreter
** DROP /tmp/directory
** DROP /tmp/directory2*

joey boggs wrote:

>* 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.
I'm not sure I understand what you're doing, but maybe you'll find the
following somewhat useful:

 >>> import code
 >>> class MyInterpreter(code.InteractiveConsole):
...     def raw_input(self, prompt=None):
...         # override input function
...         while 1:
...             text = raw_input(prompt)
...             if text.startswith("DROP"):
...                 # deal with custom command
...                 print "CUSTOM DROP COMMAND", text
...             else:
...                 return text
 >>> i = MyInterpreter()
 >>> i.interact()
Python 2.5.2 [...]
Type "help", "copyright", "credits" or "license" for more information.
 >>> print "hello"
 >>> DROP something
 >>> x = 10
 >>> y = 20
 >>> x + y
 >>> DROP something else

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list