summaryrefslogtreecommitdiff
path: root/python/vyos/utils/system.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-06-27 15:40:23 +0200
committerGitHub <noreply@github.com>2024-06-27 15:40:23 +0200
commitda1515c704e5170cdec420bbd7ce0e4cdb4da868 (patch)
treea67f8ff4fbded2079ecd470667386df7e1078a1b /python/vyos/utils/system.py
parentb3b1d59d86af510c454da446f013b514389f5c7f (diff)
parent5502a75b1747caf94e2b69982c89088281c8ca1f (diff)
downloadveeos-1x-da1515c704e5170cdec420bbd7ce0e4cdb4da868.tar.gz
veeos-1x-da1515c704e5170cdec420bbd7ce0e4cdb4da868.zip
Merge pull request #3692 from jestabro/revise-migration
T6007: revise migration system
Diffstat (limited to 'python/vyos/utils/system.py')
-rw-r--r--python/vyos/utils/system.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/python/vyos/utils/system.py b/python/vyos/utils/system.py
index f427032a4..fca93d118 100644
--- a/python/vyos/utils/system.py
+++ b/python/vyos/utils/system.py
@@ -99,6 +99,18 @@ def load_as_module(name: str, path: str):
spec.loader.exec_module(mod)
return mod
+def load_as_module_source(name: str, path: str):
+ """ Necessary modification of load_as_module for files without *.py
+ extension """
+ import importlib.util
+ from importlib.machinery import SourceFileLoader
+
+ loader = SourceFileLoader(name, path)
+ spec = importlib.util.spec_from_loader(name, loader)
+ mod = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(mod)
+ return mod
+
def get_uptime_seconds():
""" Returns system uptime in seconds """
from re import search
@@ -127,4 +139,3 @@ def get_load_averages():
res[15] = float(matches["fifteen"]) / core_count
return res
-