diff --git a/main.py b/main.py index e69de29..f82a4a1 100644 --- a/main.py +++ b/main.py @@ -0,0 +1,25 @@ +from CommandRunner import CommandRunner as Runner +import importlib +import os + + +def get_modules(): + modules = [] + for folder in os.listdir("./modules"): + print("Module found: " + folder) + curr_module = importlib.import_module('.' + folder, package="modules") + print("Try to load module: " + folder) + modules.append(curr_module.getModule()) + print("Module loaded successfully: " + folder) + return modules + + +print("Loading modules: \n") + +modules = get_modules() + +print("\nRunning all modules \n") + +cmdRunner = Runner() +for module in modules: + cmdRunner.run(module) diff --git a/modules/sample/__init__.py b/modules/sample/__init__.py new file mode 100644 index 0000000..80f166e --- /dev/null +++ b/modules/sample/__init__.py @@ -0,0 +1,5 @@ +from .sampleModule import SampleModule + + +def getModule(): + return SampleModule() diff --git a/modules/sample/sampleModule.py b/modules/sample/sampleModule.py new file mode 100644 index 0000000..8b45a5d --- /dev/null +++ b/modules/sample/sampleModule.py @@ -0,0 +1,14 @@ +from IModule import IModule + + +class SampleModule(IModule): + """docstring for SampleModule.""" + + def __init__(self): + super(SampleModule, self).__init__() + + def getCommand(self): + return [ + "command 1", + "command 2" + ]