mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
modules_from_path always return all information with filepaths
This commit is contained in:
parent
0b5acc75e9
commit
f2ecff2688
3 changed files with 9 additions and 12 deletions
|
|
@ -618,13 +618,13 @@ class ApplicationLaunchContext:
|
|||
)
|
||||
continue
|
||||
|
||||
modules = modules_from_path(path)
|
||||
for _module in modules:
|
||||
modules, _crashed = modules_from_path(path)
|
||||
for _filepath, module in modules:
|
||||
all_classes["pre"].extend(
|
||||
classes_from_module(PreLaunchHook, _module)
|
||||
classes_from_module(PreLaunchHook, module)
|
||||
)
|
||||
all_classes["post"].extend(
|
||||
classes_from_module(PostLaunchHook, _module)
|
||||
classes_from_module(PostLaunchHook, module)
|
||||
)
|
||||
|
||||
for launch_type, classes in all_classes.items():
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ log = logging.getLogger(__name__)
|
|||
PY3 = sys.version_info[0] == 3
|
||||
|
||||
|
||||
def modules_from_path(folder_path, return_crashed=False):
|
||||
def modules_from_path(folder_path):
|
||||
"""Get python scripts as modules from a path.
|
||||
|
||||
Arguments:
|
||||
|
|
@ -72,7 +72,7 @@ def modules_from_path(folder_path, return_crashed=False):
|
|||
|
||||
module.__file__ = full_path
|
||||
|
||||
modules.append(module)
|
||||
modules.append((full_path, module))
|
||||
|
||||
except Exception:
|
||||
crashed.append((full_path, sys.exc_info()))
|
||||
|
|
@ -82,9 +82,7 @@ def modules_from_path(folder_path, return_crashed=False):
|
|||
)
|
||||
continue
|
||||
|
||||
if return_crashed:
|
||||
return modules, crashed
|
||||
return modules
|
||||
return modules, crashed
|
||||
|
||||
|
||||
def recursive_bases_from_class(klass):
|
||||
|
|
|
|||
|
|
@ -64,13 +64,13 @@ class FtrackServer:
|
|||
register_functions = []
|
||||
for path in paths:
|
||||
# Get all modules with functions
|
||||
modules, crashed = modules_from_path(path, return_crashed=True)
|
||||
modules, crashed = modules_from_path(path)
|
||||
for filepath, exc_info in crashed:
|
||||
log.warning("Filepath load crashed {}.\n{}".format(
|
||||
filepath, traceback.format_exception(*exc_info)
|
||||
))
|
||||
|
||||
for module in modules:
|
||||
for filepath, module in modules:
|
||||
register_function = None
|
||||
for name, attr in module.__dict__.items():
|
||||
if (
|
||||
|
|
@ -80,7 +80,6 @@ class FtrackServer:
|
|||
register_function = attr
|
||||
break
|
||||
|
||||
filepath = os.path.abspath(module.__file__)
|
||||
if not register_function:
|
||||
log.warning(
|
||||
"\"{}\" - Missing register method".format(filepath)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue