in radlab-launcher/radlab.py [0:0]
def list_modules():
modules = [s.replace(os.path.dirname(os.getcwd()) + '/modules/', "") for s in glob.glob(os.path.dirname(os.getcwd()) + '/modules/*')]
modules = sorted(modules)
c = 1
print_list = ''
# Printing List of Modules
for module in modules:
first_line = ''
# Fetch Module name
try:
with open(os.path.dirname(os.getcwd()) + '/modules/' + module + '/README.md', "r") as file:
first_line = file.readline()
except:
print(Fore.RED + 'Missing README.md file for module: ' + module + Style.RESET_ALL)
print_list = print_list + "[" + str(c) + "] " + first_line.strip() + Fore.GREEN + " (" + module + ")\n" + Style.RESET_ALL
c = c + 1
# Selecting Module
try:
selected_module = input("\nList of available RAD Lab modules:\n" + print_list + "[" + str(c) + "] Exit\n" + Fore.YELLOW + Style.BRIGHT + "Choose a number for the RAD Lab Module" + Style.RESET_ALL + ': ').strip()
selected_module = int(selected_module)
except:
sys.exit(Fore.RED + "\nInvalid module")
# Validating User Module selection
if selected_module > 0 and selected_module < c:
# print(modules)
module_name = modules[selected_module - 1]
print("\nRAD Lab Module (selected) : " + Fore.GREEN + Style.BRIGHT + module_name + Style.RESET_ALL)
return module_name
elif selected_module == c:
sys.exit(Fore.GREEN + "\nExiting Installer")
else:
sys.exit(Fore.RED + "\nInvalid module")