2019-12-16 22:51:40 +01:00
|
|
|
from PyInquirer import prompt
|
2019-12-14 04:11:32 +01:00
|
|
|
import importlib
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
2019-12-16 22:51:40 +01:00
|
|
|
def load_modules():
|
|
|
|
print("Loading modules")
|
2020-01-05 17:56:53 +01:00
|
|
|
loaded_modules = {}
|
2019-12-16 22:51:40 +01:00
|
|
|
for folder in os.listdir("./modules"):
|
|
|
|
try:
|
|
|
|
curr_module = importlib.import_module('.' + folder, package="modules")
|
2020-01-05 17:56:53 +01:00
|
|
|
loaded_modules[folder] = curr_module.get_module()
|
2019-12-16 22:51:40 +01:00
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
print("Modules loaded successfully.\n")
|
2020-01-05 17:56:53 +01:00
|
|
|
return loaded_modules
|
2019-12-14 04:11:32 +01:00
|
|
|
|
|
|
|
|
2020-01-05 17:56:53 +01:00
|
|
|
def open_module_selection(module_names):
|
2019-12-16 22:51:40 +01:00
|
|
|
print("Available Modules:")
|
|
|
|
module_selection = [
|
|
|
|
{
|
|
|
|
'type': 'checkbox',
|
|
|
|
'message': 'Select modules',
|
|
|
|
'name': 'modules',
|
2020-01-05 17:56:53 +01:00
|
|
|
'choices': list(map(lambda x: {"name": x}, list(module_names)))
|
2019-12-16 22:51:40 +01:00
|
|
|
}
|
|
|
|
]
|
2020-01-05 17:56:53 +01:00
|
|
|
return prompt(module_selection)['modules']
|
2019-12-14 04:11:32 +01:00
|
|
|
|
2019-12-16 22:51:40 +01:00
|
|
|
|
|
|
|
modules = load_modules()
|
|
|
|
|
2020-01-05 17:56:53 +01:00
|
|
|
[modules[module].run() for module in open_module_selection(modules.keys())]
|