Create main file with sample module
This commit is contained in:
parent
e1e3549e53
commit
88514af6f9
25
main.py
25
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)
|
5
modules/sample/__init__.py
Normal file
5
modules/sample/__init__.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from .sampleModule import SampleModule
|
||||||
|
|
||||||
|
|
||||||
|
def getModule():
|
||||||
|
return SampleModule()
|
14
modules/sample/sampleModule.py
Normal file
14
modules/sample/sampleModule.py
Normal 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"
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user