Home | News | Documentation | Download

Why is PyRoot parsing argv?

Dear all,

these few lines of code:

#!/bin/env python2.5
import ROOT
print "a"
ROOT.TH1 # (or anything else using a root type).
print “b”

executed like this
./my_pyrootargv.py --someargument ‘$,^’

gives this results:

a
Error in TSystem::ExpandFileName: input: $,^, output: $,^
Error in TSystem::ExpandFileName: input: $,^, output: $,^
Error in TSystem::ExpandFileName: input: /afs/cern.ch/user/j/jlundber/example/scripts/./$,^, output: /afs/cern.ch/user/j/jlundber/example/scripts/./$,^
Error in TSystem::ExpandFileName: input: /afs/cern.ch/sw/lcg/app/releases/ROOT/5.22.00d/slc4_ia32_gcc34/root/macros/$,^, output: /afs/cern.ch/sw/lcg/app/releases/ROOT/5.22.00d/slc4_ia32_gcc34/root/macros/$,^
b

Inserting sys.argv[1:]=[] quiets the root module. I have some comments/questions:

To me it’s very strange if not wrong that root is parsing argv when loaded as a python module. The argv options are not for root.

Can I turn off or catch this kind of messages from the root module? I mean in general.

Who is trying to interpret my options as filenames?

Hi,

the command line is handed to TApplication (see its ctor, which takes both argv and argc). To tell it not to, do:import ROOT ROOT.PyConfig.IgnoreCommandLineOptions = True
HTH,
Wim

Hi Wim,

[quote=“wlav”] To tell it not to, do:import ROOT ROOT.PyConfig.IgnoreCommandLineOptions = True
[/quote]

In what version of Root is this first available?

Thanks,
Charles

Charles,

browsing through ViewVC, I see it first in v5-24 (it went in in May last year). Note that since the handling is pure python, it can be backported locally.

Cheers,
Wim