def __init__(self): signal.signal(signal.SIGTERM,self._stop_signal_handling) signal.signal(signal.SIGQUIT,self._stop_signal_handling) signal.signal(signal.SIGINT,self._stop_signal_handling) signal.signal(signal.SIGCHLD,self._child_death) self._outputs_subscribers = [] # instances that want to receive output text from controller self._outputs_queue = Queue() # queue for text to be output by instances to controller self._commands_queue = Queue() # queue for commands to be output by instances to controller self._config() # Starting the thread that will receive text to process (display/save/send) self._receive_outputs_thread = mythreading.ReceiveQueueThread(self.output_text,self._outputs_queue) self._receive_outputs_thread.start() # Loading modules and starting instances configured for auto start self._modules = BotModules(self._MODULE_PATH) self.translator = BotCommandTranslator(self._modules) #TODO: add more controller commands self._commands = {} self.add_command(BotCommand(name='shutdown',command='self.shutdown()')) self.add_command(BotCommand(name='list',command='self.list_modules()')) command = BotCommand(name='start',command='self.start(arguments)') command.add_argument('module', '.+') self.add_command(command) command = BotCommand(name='stop',command='self.stop(arguments)') command.add_argument('module', '.+') self.add_command(command) command = BotCommand(name='reload',command='self.reload(arguments)') command.add_argument('module', '.+') self.add_command(command)
def add_command(self,name,command,arguments): command = BotCommand(self.name,name,command) for argument in arguments: command.add_argument(argument[0], argument[1]) self._commands[name]=command