def send_event(self, session_key, event): event_handler = EventHandler() sim_client = SimClient(session_key, self.ip, self.port, '%s:80' % self.ip, event_handler.handle_event) sim_client.authenticate() auth_event = event_handler.events.get(True, 10) if not auth_event.authenticated: raise Exception('Could not authenticate against the simulator pool') sim_client.send_event(event) sim_client.close()
def fetch_pool_info(self, session_key): try: event_handler = EventHandler() sim_client = SimClient(session_key, self.ip, self.port, '%s:80' % self.ip, event_handler.handle_event) sim_client.authenticate() event = event_handler.events.get(True, 10) if not event.authenticated: raise Exception('Could not authenticate against the simulator pool') sim_client.request_pool_info() event = event_handler.events.get(True, 10) sim_client.close() return event.infos except: traceback.print_exc() return []