Integrate single module runner in main file
This commit is contained in:
parent
907d9ff33f
commit
440d72896f
37
main.py
37
main.py
@ -2,28 +2,27 @@ from CommandRunner import CommandRunnerDebug as Runner
|
||||
import importlib
|
||||
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():
|
||||
modules = []
|
||||
for folder in os.listdir("./modules"):
|
||||
# skipping sample module
|
||||
if folder == "sample":
|
||||
continue
|
||||
print("Available Modules:")
|
||||
for mod in modules.keys():
|
||||
print(mod)
|
||||
|
||||
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
|
||||
print()
|
||||
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user