I’m trying to use argparse to deal with command line arguments to my application, bur I’ve been having some trouble with gstreamer (which my application uses). When I give the -h option for my application, instead of it showing the help message I defined for the arguments of my program, it show a weird gstreamer help message, omitting the help for my arguments.
I have the following parser definition in my code:
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--capture", help="Specifies the capture device.\n 0 - Webcam \n 1 - Kinect", type=int, choices=[0, 1], default=0)
parser.add_argument("-i", "--interval", help="Specifies the capture interval in seconds when the auto-capture is on", type=int, choices=[4, 5, 6, 7, 8], default=4)
args = parser.parse_args()
and the message I get when I start my program with -h is (my locale is in Brazilian-Portuguese, but it’s enough to see the general structure of the help message and the lack of help for my optional arguments)
Uso:
FasTracker.py [OPÇÃO...] - GStreamer initialization
Opções de ajuda:
-h, --help Exibe opções de ajuda
--help-all Exibe todas as opções de ajuda
--help-gst Exibir opções do GStreamer
Am I doing something wrong, or is there a way to supress the Gstreamer help message?
Thanks in advance
I also had the same problem. I am using ubuntu 10.10 + python 2.6 + python-gst0.10 package.
Finally I tracked down the bug to this:
import gstbeforeparser.parse_args()modifiessys. To reproduce, put the following code intomain.py:and run
python main.py -h. This produces the following buggy output:If we remove
import gst(or move the statement afterparse_args), then the output is correct: