def main(): """ Main function to run the eratosthened database system """ welcome_message = '\nWelcome to Eratosthenes!\n' help_message = '\nPossible commands:\n'\ '\tq\t Quit the program\n'\ '\tadd\t Add a new entry\n'\ '\tsearch\t Search the database\n'\ '\tget\t Retrieve a document\n'\ '\tdelete\t Delete an entry' print(welcome_message) print(help_message) status = '' while (status != 'q' or status != 'quit' or status != 'exit'): status = input('Please enter a command:\t') if status == 'add': new_entry = interfaces.create_entry() db_actions.add_entry_to_db(new_entry) print('\nDone!\n\n') elif status == 'search': interfaces.search() elif status == 'display': db_actions.display() elif status == 'get': interfaces.get() elif status == 'delete': interfaces.delete() elif (status == 'q' or status == 'quit' or status == 'exit'): break else: print(help_message)
def start(parser, iflist=interfaces.avail()): # starts one thread for each interface # CmdServer automatically starts a new server thread when received a new # command global server_threads server_threads = [] # if restarted, clear all old threads for interface in iflist: thread = CmdServer(parser, interfaces.get(interface)) server_threads.append(thread) thread.start()
def send_message(self, msg): interface = interfaces.get(self.interface_name) return interface.send_message(self, msg)
def get_display_name(self): interface = interfaces.get(self.interface_name) return interface.get_display_name(self)