use mod name instead of passed-in name

This commit is contained in:
NichtJens
2025-11-03 12:44:33 +01:00
committed by Auf keinen Fall Jens
parent 4002f6889b
commit fbe6ecb882
+6 -4
View File
@@ -249,7 +249,7 @@ class DetectorManager:
code = request["code"]
fn = write_code_to_file(name, code, beamline)
func = load_proc_from_file(fn, name)
func = load_proc_from_file(fn)
test_run(func)
# commit to git ... or delete and complain
@@ -382,13 +382,15 @@ def write_code_to_file(name, code, beamline):
return fn
def load_proc_from_file(fn, name):
def load_proc_from_file(fn):
mod = load_module(fn)
proc_func_name = "proc"
func = getattr(mod, proc_func_name, None) or getattr(mod, name, None)
mod_name = mod.__name__
func = getattr(mod, proc_func_name, None) or getattr(mod, mod_name, None)
if func is None:
raise AttributeError(f'module "{mod.__name__}" contains neither "{proc_func_name}" nor "{name}" function')
raise AttributeError(f'module "{mod_name}" contains neither "{proc_func_name}" nor "{mod_name}" function')
return func