From dccbaa357ad83cbebb2db419e51eef0b6fb6eb47 Mon Sep 17 00:00:00 2001 From: Ludger Kueperkoch Date: Tue, 22 Sep 2020 10:30:48 +0200 Subject: [PATCH] Check if data directory exists to avoid program abortion. --- PyLoT.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/PyLoT.py b/PyLoT.py index 6f6ba278..f0fd1f50 100755 --- a/PyLoT.py +++ b/PyLoT.py @@ -3807,13 +3807,16 @@ class Project(object): datapaths.append(event.datapath) for datapath in datapaths: datapath = os.path.join(self.rootpath, datapath) - for filename in os.listdir(datapath): - filename = os.path.join(datapath, filename) - if os.path.isfile(filename) and filename.endswith(fext): - try: - self.read_eventfile_info(filename) - except Exception as e: - print('Failed on reading eventfile info from file {}: {}'.format(filename, e)) + if os.path.isdir(datapath): + for filename in os.listdir(datapath): + filename = os.path.join(datapath, filename) + if os.path.isfile(filename) and filename.endswith(fext): + try: + self.read_eventfile_info(filename) + except Exception as e: + print('Failed on reading eventfile info from file {}: {}'.format(filename, e)) + else: + print("Directory %s does not exist!" % datapath) def getPaths(self): '''