forked from awendt/pyrelacs
[repos] adding check for spec.loader
This commit is contained in:
parent
5dadf1bd7c
commit
8b02b9083f
@ -8,9 +8,9 @@ import nixio as nix
|
||||
import importlib.util
|
||||
|
||||
from pyrelacs.util.logging import config_logging
|
||||
|
||||
log = config_logging()
|
||||
|
||||
from IPython import embed
|
||||
|
||||
class Repro:
|
||||
"""
|
||||
@ -25,7 +25,6 @@ class Repro:
|
||||
def run_repro(
|
||||
self, nix_file: nix.File, name: str, file: pathlib.Path, *args, **kwargs
|
||||
) -> None:
|
||||
|
||||
spec = importlib.util.spec_from_file_location("rep", file)
|
||||
if not spec:
|
||||
log.error("Could not load the file")
|
||||
@ -35,7 +34,10 @@ class Repro:
|
||||
log.error("Could not load the module of the repro")
|
||||
else:
|
||||
sys.modules[name] = module
|
||||
spec.loader.exec_module(module)
|
||||
if spec.loader is not None:
|
||||
spec.loader.exec_module(module)
|
||||
else:
|
||||
log.error(f"{spec.loader} is None")
|
||||
if hasattr(module, name):
|
||||
rep_class = getattr(module, name)
|
||||
rep_class.run(nix_file)
|
||||
|
Loading…
Reference in New Issue
Block a user