4 log = logging.getLogger(__name__)
7 """Return list of all keys in 'dir' (recursively)"""
12 """Do the recursive traversal"""
13 dirList = dir.GetListOfKeys()
16 if k.GetClassName()==
"TDirectoryFile" or k.GetClassName()==
"TDirectory":
18 dols(ROOT.gDirectory, keys)
20 keys += [dir.GetPath()+
"/"+kname]
26 basedir = dir.GetPath().rstrip(
"/") +
"/"
30 return sorted([k.replace(basedir,
"")
for k
in keys])
35 log.info(
'Checking file {}'.
format(path))
36 rfile = ROOT.TFile.Open(path,
"READ")
38 log.error(
'ERROR: {}: Failed to open file'.
format(path))
41 log.error(
'ERROR: {}: Zombie'.
format(path))
43 if rfile.TestBit(ROOT.TFile.kRecovered):
44 log.error(
'ERROR: {}: Recovered'.
format(path))
51 from subprocess
import Popen, PIPE
55 p = Popen([
'python',
"-c",
"from TrigValTools.TrigRootUtils import check_file; check_file('{}')".
format(path)], stdout=PIPE, stderr=PIPE)
57 stdout, stderr = p.communicate()
61 if "error" in stdout.decode(
'utf-8').lower()
or "error" in stderr.decode(
'utf-8').lower():
63 log.error(
'ERROR: Detected errors when opening root file')
65 log.error(stdout.decode(
'utf-8'))
66 log.error(stderr.decode(
'utf-8'))