Batch process and ProcessLine

Dear rooters,

I am using python to run in batch mode several scripts whose produce various images; even if i have know that in a future version of ROOT even the “gif” format will be available in batch mode, for now i hae to make it works anyay… so I save the images in “eps”.
For this reasons all the scripts have an option where the user can chose the format of the image output.

All the functions have a structure similar to
XXX([…], TString format = “gif” )

The problem is that if I execute from the ROOT’s command line , for instance
.L S4Scan.c
S4Scan(//home//nagni//filesFromYoda//maurizio00", format = “eps”)
it works correctly

if i execute the script or from the python prompt (from there comes the output below…)

gROOT.LoadMacro("/home/pamela_yoda/scriptdef/S4Scan.c)
gROOT.ProcessLine(‘S4Scan("//home//nagni//filesFromYoda//maurizio00", format = “eps”)’)
Error: Function S4Scan("//home//nagni//filesFromYoda//maurizio00",format=“eps”) is not defined in current scope FILE:(tmpfile) LINE:1
Possible candidates are…
filename line:size busy function type and name
/home/pamela_yoda/scriptdef/S4Scan.c 36:54 0 public: void S4Scan(TString base,int num=0,TString autoSc=“true”,TString outDirectory="",TString format=“gif”);
*** Interpreter error recovered ***

Is there any solution without being forced to set “eps” as default in the function?

Thanks
Maurizio

Hi,
this is just due to a syntax error - you’re not writing C++. This is how to call a method:
S4Scan("//home//nagni//filesFromYoda//maurizio00", “eps”)
Axel.

sorry… but if you have noticed the declaration of the function (which is exposed in the error message) inside the script

void S4Scan(TString base,int num=0,TString autoSc=“true”,TString outDirectory="",TString format=“gif”);

function have more than 2 parameters… i don’t believe (neither you i suppose) the function can understand that i want to set just the “format” parameter to “eps”… on the other hand I am 100% sure that the way i told you works command line… any other suggestion?

Yes, still: write proper C++ :-] Invoke your method as
S4Scan("//home//nagni//filesFromYoda//maurizio00",0,“true”,"", “eps”);
In C++, there is no way to make the compiler use default args up to a certain arg, only starting from a certain arg, i.e.
S4Scan("//home//nagni//filesFromYoda//maurizio00",0,“true”);
works.
Axel.

sorry friend but we are still missing a point

  1. I said that on ROOT command line it works ALSO in that way; so perhaps is CINT feature.

  2. it remain anyway the problem on calling from PYTHON in this shape

from ROOT import gROOT
gROOT.LoadMacro(“S4Scan.c”)
gROOT.ProcessLine(‘S4Scan("//home//nagni//filesFromYoda//maurizio00", 0, “true”, “eps”)’)

and thats what i care most :slight_smile:
The chance that i could do “parName = value” as on ROOT prompt could be great but even if I cannot do in that way, I neither can in the other way beacause the “gROOT.ProcessLine” command always call the default parameter “gif” no matter what and how many parameters I write beetween the parenthesis.

anyway thanks :slight_smile:
Maurizio

Maurizio,

it’s a bit hard to tackle because I don’t have your script, but an educated guess leads
me to ask you to instead of:

do the following (note the added ‘r’ in front of the ProcessLine argument):

The use of a python raw string instructs the interpreter to properly escape the
internal double quotes. See tutorials/demo.py for another example.

HTH,
Wim