Skip to content

Commit cd2138c

Browse files
committed
Fix for case when no ROOT files are found
1 parent a638f85 commit cd2138c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

source/Python/omegatomo/io/loadData.py

+11
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,17 @@ def loadROOT(options, store_coordinates = False):
136136
else:
137137
files = glob.glob(os.path.join(options.fpath, '*.root'))
138138
nFiles = len(files)
139+
if nFiles == 0:
140+
print('No files found! Please select a ROOT file')
141+
import tkinter as tk
142+
from tkinter.filedialog import askopenfilename
143+
root = tk.Tk()
144+
root.withdraw()
145+
filename = askopenfilename(title='Select first ROOT file',filetypes=([('ROOT Files','*.root')]))
146+
if not filename:
147+
raise ValueError('No file was selected')
148+
files = glob.glob(os.path.join(os.path.split(filename)[0], '*.root'))
149+
nFiles = len(files)
139150

140151

141152

0 commit comments

Comments
 (0)