Integrate single module runner in main file

This commit is contained in:
Marcel Schwarz 2019-12-15 06:31:18 +01:00
parent 907d9ff33f
commit 440d72896f

37
main.py
View File

@ -2,28 +2,27 @@ from CommandRunner import CommandRunnerDebug as Runner
import importlib import importlib
import os import os
print("Loading modules")
modules = {}
for folder in os.listdir("./modules"):
curr_module = importlib.import_module('.' + folder, package="modules")
modules[folder] = curr_module.get_module()
print("Modules loaded successfully.\n")
def get_modules(): print("Available Modules:")
modules = [] for mod in modules.keys():
for folder in os.listdir("./modules"): print(mod)
# skipping sample module
if folder == "sample":
continue
print("Module found: " + folder) print()
curr_module = importlib.import_module('.' + folder, package="modules")
print("Try to load module: " + folder)
modules.append(curr_module.get_module())
print("Module loaded successfully: " + folder)
return modules
while True:
chosen_module = input("Please specify your module: ")
if chosen_module in modules.keys():
break
else:
print("Module was not found.")
print("Loading modules: \n") print("\nChosen Module to run: " + chosen_module)
modules = get_modules() Runner().run(modules[chosen_module])
print("\nRunning all modules \n")
cmdRunner = Runner()
for module in modules:
cmdRunner.run(module)