From 216f675e1e53f42212ad458382fa67e65ff3d026 Mon Sep 17 00:00:00 2001 From: Johannes Schumann <johannes.schumann@fau.de> Date: Sat, 12 Dec 2020 03:31:50 +0100 Subject: [PATCH] Update import handling wrt the error types --- km3buu/output.py | 5 +++-- km3buu/tests/test_output.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/km3buu/output.py b/km3buu/output.py index 1526195..5d89d83 100644 --- a/km3buu/output.py +++ b/km3buu/output.py @@ -33,8 +33,9 @@ try: libpath = environ.get("KM3NET_LIB") if libpath: libpath = Config().km3net_lib_path - ROOT.gSystem.Load(join(libpath, "libKM3NeTROOT.so")) -except: + if ROOT.gSystem.Load(join(libpath, "libKM3NeTROOT.so")) != 0: + raise ModuleNotFoundError("KM3NeT dataformat library not found!") +except ModuleNotFoundError: import warnings warnings.warn("KM3NeT dataformat library was not loaded.", ImportWarning) diff --git a/km3buu/tests/test_output.py b/km3buu/tests/test_output.py index 2932dc8..0387b24 100644 --- a/km3buu/tests/test_output.py +++ b/km3buu/tests/test_output.py @@ -32,7 +32,7 @@ try: libpath = Config().km3net_lib_path KM3NET_LIB_AVAILABLE = (ROOT.gSystem.Load(join(libpath, "libKM3NeTROOT.so")) == 0) -except ImportError: +except ModuleNotFoundError: KM3NET_LIB_AVAILABLE = False -- GitLab