def start(self): """ The entry method to start MCDR Try to start the server. if succeeded the console thread will start and MCDR will start ticking :raise: IllegalStateError if MCDR is in wrong state :raise: ServerStartError if the server is already running or start_server has been called by other """ if not self.mcdr_in_state(MCDReforgedState.INITIALIZED): if self.mcdr_in_state(MCDReforgedState.INITIALIZING): raise IllegalStateError('This instance is not fully initialized') else: raise IllegalStateError('MCDR can only start once') self.__main_loop() return self.process
def assert_state(self, states, extra_message=None): if not self.in_states(states): msg = '{} state assertion failed, excepts {} but founded {}.'.format( repr(self), states, self.state) if extra_message is not None: msg += ' ' + extra_message raise IllegalStateError(msg)
def attach_mcdr_server(self, mcdr_server): if self.__mcdr_server is not None: raise IllegalStateError( 'An Info instance can only attach the MCDR server once') self.__mcdr_server = mcdr_server
def __assert_attached(self): if self.__mcdr_server is None: raise IllegalStateError( 'MCDR server is not attached to this Info instance yet')