[gst-devel] gst-python includes help ?!

David I. Lehn dlehn at vt.edu
Mon Feb 23 13:53:07 CET 2004


* Alexandre CONRAD <aconrad.tlv at magic.fr> [2004-02-23T16:04:06-0500]:
> i've been trying to add options to my python program using the module 
> "optparse" :
...
> parser = optparse.OptionParser()
> parser.add_option("-f", "--file", dest="filename")
...
> but here I have an error message :
> 
> ./live_server.py -f foo.txt
> Error on option -f: unknown option.
> Run './live_server.py --help' to see a full list of available command 
> line options.
> Segmentation fault
> 
> Okay. My program tells me to run --help... how friendly... (I didn't 
> know I had AI programing capabilities) :
...
> So because of gstreamer, I can't add my options here. Is there a work 
> around ? This shouldn't be there, right ?

I think this is a hard problem.  I still don't know how to properly
solve it.  I think it's an issue with every pygtk app too so maybe
someone from that community has a good solution.  I think your first
problem with handling options should work?  I'm fairly sure I've done
that before.  Not sure why it didn't work for you.

The problem is that both gnome+gst and python want to handle arguments.
Right now the gst binding init code calls the appropriate gst init
function with the arguments so gnome gets first crack at them.

I thought this part worked fine with one exception: help options.  The
GNOME and optparse code both have similar behavior for -h: print out
help and quit.  Which is exactly what we don't want.  We actually want
to print out gnome+gst help _and_ print out optparse help.

There are a few ways to solve this that involve some tricky code I
think.  Perhaps the best would be to trap the exit signal from gnome
popt land.  That would let the optparse help code run second and really
quit there.  The other is to run optparse help code first and catch the
exit exception, then run the popt code.  That involves some rework since
currently the gst_init code is run during module load and has no user
control.

Another is to specifically strip out the -h/--help options before they
get to gst_init and then have custom code in optparse that would know on
help options to call popt help printing function.

Anyway, it's kind of confusing and non-obvious to me how to solve this
with minimal code.

-dave




More information about the gstreamer-devel mailing list