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
|
import importlib.util
|
||||||
|
|
||||||
from pyrelacs.util.logging import config_logging
|
from pyrelacs.util.logging import config_logging
|
||||||
|
|
||||||
log = config_logging()
|
log = config_logging()
|
||||||
|
|
||||||
from IPython import embed
|
|
||||||
|
|
||||||
class Repro:
|
class Repro:
|
||||||
"""
|
"""
|
||||||
@ -25,7 +25,6 @@ class Repro:
|
|||||||
def run_repro(
|
def run_repro(
|
||||||
self, nix_file: nix.File, name: str, file: pathlib.Path, *args, **kwargs
|
self, nix_file: nix.File, name: str, file: pathlib.Path, *args, **kwargs
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
spec = importlib.util.spec_from_file_location("rep", file)
|
spec = importlib.util.spec_from_file_location("rep", file)
|
||||||
if not spec:
|
if not spec:
|
||||||
log.error("Could not load the file")
|
log.error("Could not load the file")
|
||||||
@ -35,7 +34,10 @@ class Repro:
|
|||||||
log.error("Could not load the module of the repro")
|
log.error("Could not load the module of the repro")
|
||||||
else:
|
else:
|
||||||
sys.modules[name] = module
|
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):
|
if hasattr(module, name):
|
||||||
rep_class = getattr(module, name)
|
rep_class = getattr(module, name)
|
||||||
rep_class.run(nix_file)
|
rep_class.run(nix_file)
|
||||||
|
Loading…
Reference in New Issue
Block a user