Skip to content

new helper function run_commandline()

David Keitel requested to merge (removed):run_commandline into master

Hi Greg,

another convenience issue I noticed is that the call to lalapps_Makefakedata_v5 is not properly error-checked: if I call pyfstat.Writer from a script (originally derived from your examples, I think), and lalapps fails, it will print the LAL error messages, but the script will continue running afterwards. E.g. this contrived example with duration=0:

14:55 INFO : No SFT file matching fake_tCW_Tobs_86400_tau_8640.0_h0_1e-24/H-0_H1_1800SFT_faketCW-1000086400-0.sft found 14:55 INFO : Executing: lalapps_Makefakedata_v5 --outSingleSFT=TRUE --outSFTdir="fake_tCW_Tobs_86400_tau_8640.0_h0_1e-24" --outLabel="faketCW" --IFOs="H1" --sqrtSX="1e-23" --startTime=1000086400 --duration=0 --fmin=29.9 --Band=0.2 --Tsft=1800 --injectionSources="fake_tCW_Tobs_86400_tau_8640.0_h0_1e-24/faketCW.cff" XLAL Error - XLALMakeTimestamps (SFTutils.c:372): Check failed: Tspan > 0 XLAL Error - XLALMakeTimestamps (SFTutils.c:372): Input domain error XLAL Error - XLALMakeMultiTimestamps (SFTutils.c:430): Check failed: (ret->data[X] = XLALMakeTimestamps ( tStart, Tspan, Tsft, Toverlap ) ) != ((void *)0) XLAL Error - XLALMakeMultiTimestamps (SFTutils.c:430): Internal function call failed: Input domain error XLAL Error - XLALInitMakefakedata (makefakedata_v5.c:479): Check failed: ( cfg->multiTimestamps = XLALMakeMultiTimestamps ( uvar->startTime, uvar->duration, uvar->Tsft, uvar->SFToverlap, cfg->multiIFO.length )) != ((void *)0) XLAL Error - XLALInitMakefakedata (makefakedata_v5.c:479): Internal function call failed: Input domain error XLAL Error - main (makefakedata_v5.c:180): Check failed: XLALInitMakefakedata ( &GV, &uvar ) == XLAL_SUCCESS XLAL Error - main (makefakedata_v5.c:180): Internal function call failed: Input domain error Running and timing search next... And after the last line, it continues to start the search, and only then actually fails with a runtime error.

As I noticed that you have a few more commandline calls throughout, which are not quite consisteny anyway (variously with os.system() and subprocess, and not all try-except-ed), I tried a more general solution in this commit, introducing a run_commandline() helper function that wraps the whole try-except so that it is used consistently throughout.

(Most of the diff lines are from renaming all "cl"-like strings to something unique, just for better debuggability, as at one point I had gotten the check_cached_data_okay_to_use() confused. I hope it's still readable enough. And I haven't tested the PFS calls.)

Greetings, David

commit:

 -try-except wrapper for subprocess.check_output()
 -use this for MFDv5 call (properly terminate at error!)
 -and for other small utility calls
 -use unique variable names for cl strings too

Merge request reports