def system_menu(sys_id): while True: details = systemanager.get_system_properties(sys_id, mdb) clear() print(systemanager.print_system_details(details)) print(f' New - Add new item') print(f' Del - Delete an item') print(f'Exit - Return to main menu') action = input('\nSelect item an option: ') if action.isdigit() and int(action) < (len(details)): update_system_item(sys_id, details[int(action)]) elif action.lower() == 'exit': break elif action.lower() == 'new': new_system_item(sys_id) elif action.lower() == 'del': delete_system_item(sys_id) else: print('Please enter a valid option!\n') sleep(2) return None
def select_system(): clear() print_systems() print(f'\n New - Add new system') print(f' Del - Delete a system') print(f'Exit - Exit program') return input('\nPlease select an option: ')
def del_system(): systems_list = systemanager.load_systems_list(mdb) clear() print_systems() print(f'\nExit - Exit program') sys_del = input('\nPlease select system to DELETE: ') if sys_del.isdigit() and int(sys_del) < (len(systems_list)): systemanager.remove_system(systems_list[int(sys_del)]["_id"], mdb) elif sys_del.lower() == 'exit': pass else: print(f'not a valid option. Aborting delete') sleep(2) return True
def delete_system_item(sys_id): print(sys_id) details = systemanager.get_system_properties(sys_id, mdb) clear() print(systemanager.print_system_details(details)) print(f'Exit - to abort DELETE') del_item = input(f'Select item to be DELETED: ') if del_item.isdigit() and int(del_item) < (len(details)): systemanager.remove_system_item(sys_id, details[int(del_item)][0], mdb) elif del_item.lower() == 'exit': pass else: print(f'not a valid option. Aborting delete') sleep(2) return True
def new_system(): clear() system = input('Please enter the system name:') systemanager.add_system({'system': system}, mdb)
def new_system_item(sys_id): clear() item = input(f'enter new item name: ') value = input(f'enter item value: ') systemanager.update_system_item(sys_id, item, value, mdb)
def update_system_item(sys_id, item): clear() print(f'Changing value for {item[0]}.\nCurrent value: {item[1]}\n') new_value = input(f'Enter new value:') systemanager.update_system_item(sys_id, item[0], new_value, mdb)
elif sys_del.lower() == 'exit': pass else: print(f'not a valid option. Aborting delete') sleep(2) return True params = get_sys_db_params('config.ini') # dbpass = input("Enter master password:"******"_id"]) elif option.lower() == 'exit': break elif option.lower() == 'new': new_system() elif option.lower() == 'del': del_system() continue else: print('Please enter a valid option!\n') sleep(2)