mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
jumbo patch
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import io
|
||||
import os
|
||||
import contextlib
|
||||
import importlib.util
|
||||
import modules.errors as errors
|
||||
from installer import setup_logging
|
||||
|
||||
|
||||
preloaded = []
|
||||
@@ -10,13 +13,18 @@ def load_module(path):
|
||||
module_spec = importlib.util.spec_from_file_location(os.path.basename(path), path)
|
||||
module = importlib.util.module_from_spec(module_spec)
|
||||
try:
|
||||
module_spec.loader.exec_module(module)
|
||||
stdout = io.StringIO()
|
||||
with contextlib.redirect_stdout(stdout):
|
||||
module_spec.loader.exec_module(module)
|
||||
setup_logging() # reset since scripts can hijaack logging
|
||||
for line in stdout.getvalue().splitlines():
|
||||
if len(line) > 0:
|
||||
errors.log.info(f'Extension: script={os.path.relpath(path)} {line.strip()}')
|
||||
except Exception as e:
|
||||
errors.display(e, f'Module load: {path}')
|
||||
return module
|
||||
|
||||
|
||||
|
||||
def preload_extensions(extensions_dir, parser):
|
||||
if not os.path.isdir(extensions_dir):
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user