Create main file with sample module

This commit is contained in:
Marcel Schwarz 2019-12-14 04:11:32 +01:00
parent e1e3549e53
commit 88514af6f9
3 changed files with 44 additions and 0 deletions

25
main.py
View File

@ -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)

View File

@ -0,0 +1,5 @@
from .sampleModule import SampleModule
def getModule():
return SampleModule()

View File

@ -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"
]