linux-tools/main.py
2020-01-05 17:56:53 +01:00

35 lines
908 B
Python

from PyInquirer import prompt
import importlib
import os
def load_modules():
print("Loading modules")
loaded_modules = {}
for folder in os.listdir("./modules"):
try:
curr_module = importlib.import_module('.' + folder, package="modules")
loaded_modules[folder] = curr_module.get_module()
except AttributeError:
pass
print("Modules loaded successfully.\n")
return loaded_modules
def open_module_selection(module_names):
print("Available Modules:")
module_selection = [
{
'type': 'checkbox',
'message': 'Select modules',
'name': 'modules',
'choices': list(map(lambda x: {"name": x}, list(module_names)))
}
]
return prompt(module_selection)['modules']
modules = load_modules()
[modules[module].run() for module in open_module_selection(modules.keys())]