def input_loop(queues: Dict[bytes, 'Queue[bytes]'], settings: 'Settings', gateway: 'Gateway', contact_list: 'ContactList', group_list: 'GroupList', master_key: 'MasterKey', onion_service: 'OnionService', stdin_fd: int) -> NoReturn: """Get input from user and process it accordingly. Running this loop as a process allows handling different functions including inputs, key exchanges, file loading and assembly packet generation, separate from assembly packet output. """ sys.stdin = os.fdopen(stdin_fd) window = TxWindow(contact_list, group_list) while True: with ignored(EOFError, FunctionReturn, KeyboardInterrupt): readline.set_completer( get_tab_completer(contact_list, group_list, settings, gateway)) readline.parse_and_bind('tab: complete') window.update_window(group_list) while not onion_service.is_delivered: export_onion_service_data(contact_list, settings, onion_service, gateway) while not contact_list.has_local_contact(): new_local_key(contact_list, settings, queues) while not contact_list.has_contacts(): add_new_contact(contact_list, group_list, settings, queues, onion_service) while not window.is_selected(): window.select_tx_window(settings, queues, onion_service, gateway) user_input = get_input(window, settings) if user_input.type == MESSAGE: queue_message(user_input, window, settings, queues) elif user_input.type == FILE: queue_file(window, settings, queues) elif user_input.type == COMMAND: process_command(user_input, window, contact_list, group_list, settings, queues, master_key, onion_service, gateway)
def test_valid_command(self): self.assertIsNone(process_command(UserInput('about'), *self.args))