Skip to content

Commit

Permalink
catch corrupted files with size>0
Browse files Browse the repository at this point in the history
  • Loading branch information
perrozzi committed Sep 3, 2015
1 parent 2e3dc31 commit 785e2ab
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CMGTools/WMass/analysis/launch_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
import string, os, shutil, sys, subprocess

def file_exists_and_is_not_empty(fpath):
return (os.path.isfile(fpath) and (os.path.getsize(fpath) > 0))
if not (os.path.isfile(fpath) and (os.path.getsize(fpath) > 0)): return False
if fpath.endswith('.root'):
f = ROOT.TFile(fpath)
if f.GetNkeys() == 0 or f.TestBit(ROOT.TFile.kRecovered) or f.IsZombie():
return False
return True

## ==============================================================
## STEERING PARAMETERS
Expand Down

3 comments on commit 785e2ab

@perrozzi
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@12345ieee mi permetto di dire che questa e' una bella chicca ;-)

@12345ieee
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pyROOT, I suppose.
A occhio manca un import ROOT all'inizio.
Bel lavoro, comunque.

@perrozzi
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dott. Stacchiotti non le sfugge nulla! avevo dimenticato di copiarlo.
pero' forse le era scappato questo ;-)
2e3dc31

Please sign in to comment.