PyROOT hijacks --help

Hi,

PyROOT hijacks my --help option. I’m doing nothing except importing argparse, adding an option and then trying to print it. Executing -h gives me PyROOT’s help message. I’ve testing this by importing a .so file and immedialy having main exit. Even then this is the effect:

[code]gbesjes@groesbeek:~/work/HistFitter $ ./scripts/HistFitter.py -h
Usage: python [-l] [-b] [-n] [-q] [dir] [[file:]data.root] [file1.C … fileN.C]
Options:
-b : run in batch mode without graphics
-x : exit on exception
-n : do not execute logon and logoff macros as specified in .rootrc
-q : exit after processing command line macro files
-l : do not show splash screen
dir : if dir is a valid directory cd to it before executing

-? : print usage
-h : print usage
–help : print usage
-config : print ./configure options
-memstat : run with memory usage monitoring

[/code]

Also I see stuff like

gbesjes@groesbeek:~/work/HistFitter $ ./scripts/HistFitter.py -config ROOT ./configure options: QTDIR=/usr/lib64/qt-3.3 --all

How can I prevent this behaviour? I’m not at all interested in PyROOT’s help messages, but want to display useful stuff to users.

Again, all that I do is

[code]
gbesjes@groesbeek:~/work/HistFitter $ cat scripts/HistFitter.py
#!/usr/bin/env python
from ROOT import gROOT,gSystem,gDirectory,RooAbsData,RooRandom,RooWorkspace
gSystem.Load(“libSusyFitter.so”)
from ROOT import ConfigMgr
gROOT.Reset()
import sys

[…]

if name == “main”:
sys.exit()[/code]
(ConfigMgr is a C++ class that we wrote and exposed.)

Regards,
Geert-Jan

1 Like

Hi,

the full sys.argv is handed to TApplication, which expects it. That’s where the help message comes from. You can use:import ROOT ROOT.PyConfig.IgnoreCommandLineOptions = Trueto pre-empt that behavior, or adjust sys.argv in detail for perusal by both your script and TApplication.

Cheers,
Wim