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

35
main.py
View File

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