3 import sys, glob, subprocess, tarfile
14 print(
" Running: %s\n" % (command))
15 stdout, stderr = subprocess.Popen(command, shell=
True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
16 print(
"OUTPUT: \n%s" % (stdout.decode(
'ascii')))
17 print(
"ERRORS: %s" % (
"NONE" if stderr.decode(
'ascii')==
'' else "\n"+stderr.decode(
'ascii')))
30 print(
"Uncompressing files:")
32 for file
in runArgs.inputTARFile:
34 tarfile.open(file).extractall(
".")
36 print(
"ERROR: Failed uncompressing TAR file\n",e)
40 nextstep(
"Generating the tracktuple and StrawStatus file")
43 command =
'TRTCalib_bhadd merged_histo.root %s' % (
"".
join((
"%s " %
str(file))
for file
in glob.glob(
"*.basic.root") ))
44 tryError(command,
"ERROR: Failed in process TRTCalib_bhadd\n")
47 nextstep(
"Renaming Binary output file")
50 command =
'mv -v merged_histo.root.part0 %s.basic.root' % (runArgs.outputTAR_MERGEDFile)
51 tryError(command,
"ERROR: Renaming binary file \"merged_histo.root.part0\"\n")
54 nextstep(
"Merging *.tracktuple.root files")
57 command =
'hadd -f %s.tracktuple.root %s' % (runArgs.outputTAR_MERGEDFile,
"".
join((
"%s " %
str(file))
for file
in glob.glob(
"*.tracktuple.root") ))
58 tryError(command,
"ERROR: Failed in process merging *.tracktuple.root files\n")
61 nextstep(
"Merging *.straw.txt files")
64 command =
'TRTCalib_StrawStatus_merge %s.merged.straw.txt %s' % (runArgs.outputTAR_MERGEDFile,
"".
join((
"%s " %
str(file))
for file
in glob.glob(
"*.straw.txt") ))
65 tryError(command,
"ERROR: Failed in process merging *.straw.txt files\n")
73 files_list=glob.glob(runArgs.outputTAR_MERGEDFile+
".*")
75 tar = tarfile.open(runArgs.outputTAR_MERGEDFile,
"w:gz")
76 print(
"\nCompressing files in %s output file:" % runArgs.outputTAR_MERGEDFile)
77 for file
in files_list:
82 print(
"ERROR: Failed compressing the output files\n",e)
87 print(
"\nListing files:")
88 for file
in sorted(glob.glob(
"./*", recursive=
True)):