Skip to content

Commit

Permalink
Fix script loading when using python > 3.12. find_module has been rem…
Browse files Browse the repository at this point in the history
…oved.
  • Loading branch information
kkthxbye-code committed Nov 1, 2024
1 parent 066e873 commit 899fdc1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion netbox_script_manager/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import subprocess
import sys
import threading
import importlib

from django.conf import settings
from utilities.querydict import normalize_querydict
Expand Down Expand Up @@ -73,7 +74,9 @@ def load_scripts():

try:
# Manually load the module
module = importer.find_module(module_name).load_module(module_name)
spec = importer.find_spec(module_name)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
except Exception as e:
failed_modules[module_name] = e
logger.warning(f"Failed to load module {module_name}: {e}")
Expand Down

0 comments on commit 899fdc1

Please sign in to comment.