From 1366b53c207870a065847f19ce1a5cbeff094ad0 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Sat, 14 Dec 2019 05:18:04 +0100 Subject: [PATCH] Add class to run a single module --- SingleModuleRunner.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 SingleModuleRunner.py diff --git a/SingleModuleRunner.py b/SingleModuleRunner.py new file mode 100644 index 0000000..063a01b --- /dev/null +++ b/SingleModuleRunner.py @@ -0,0 +1,18 @@ +import os +import importlib + + +def run_module(name): + for folder in os.listdir("./modules"): + if folder == name: + print("Module found: " + folder) + curr_module = importlib.import_module('.' + folder, package="modules") + print("Try to load module: " + folder) + instance = curr_module.get_module() + print("Module loaded successfully: " + folder) + instance.get_command() + return + raise FileNotFoundError("The specified module was not found.") + + +run_module(input("Please specify module: "))