def update_location(event: Dict[str, Any] = None) -> None: """ Update other plugins with our response to system and station changes. :param event: Unused and ignored, defaults to None """ if this.lastlocation: for plugin in plug.provides('inara_notify_location'): plug.invoke(plugin, None, 'inara_notify_location', this.lastlocation)
def update_ship(event: Dict[str, Any] = None) -> None: """ Update other plugins with our response to changing. :param event: Unused and ignored, defaults to None """ if this.lastship: for plugin in plug.provides('inara_notify_ship'): plug.invoke(plugin, None, 'inara_notify_ship', this.lastship)
def updateshipurl(self, name=None, *args) -> None: self.lastship = self.selectedship.get() shipid = "" match = re.match(r'^\s*(\d+):',self.selectedship.get()) if match: shipid = match.group(1) if shipid and self.shipdata[shipid] and self.shipdata[shipid]["loadout"]: url = plug.invoke(config.get('shipyard_provider'), 'EDSY', 'shipyard_url', self.shipdata[shipid]["loadout"], self.is_beta) self.label.configure(url=url) else: logger.debug("No loadout for {ship}".format(ship=self.lastship)) self.label.configure(url="http://coriolis.io")
def _edsm_callback_received(_event=None): """Proxy callbacks to plugins that support them. You should filter the responses you need out yourself. You can pre-filter specific api's and endpoints by implementing specific callbacks for each: * edsm_querier_response_api_system_v1_bodies: will only receive api-system-v1 bodies responses. * edsm_querier_response_api_system_v1: will receive all api-system-v1 responses. * edsm_querier_response: will receive all responses. If any of these returns `True`, the remaining more generic methods will be skipped for your plugin. """ log(LOG_DEBUG, 'edsm callback received') while True: response = this.edsmQueries.get_response() if response is None: break # LOGGER.debug(this, 'response: {resp}'.format(resp=pformat(response))) (request, reply) = response (api, endpoint, _method, _request_params) = request api_callbacks = _edsmquery_callbacks(api, endpoint) for plugin in plug.PLUGINS: # We loop over the plugins first so that each plugin can interrupt further callbacks # from being called only to itself. for api_callback in api_callbacks: log( LOG_DEBUG, "checking for function: '{func}' on {plugin}".format( func=api_callback, plugin=plugin.name, )) if hasattr(plugin.module, api_callback): response = plug.invoke(plugin.name, None, api_callback, request, reply) log( LOG_DEBUG, 'calling {func} on {plugin}: {response}'.format( func=api_callback, plugin=plugin, response=str(response), )) if response is True: break
def cmdr_data(data, is_beta): system = data['lastSystem']['name'] if not this.system['text']: this.system['text'] = system this.system['image'] = '' this.system.update_idletasks() # Send ship info to EDSM if config.getint('edsm_out') and not is_beta and not this.multicrew and credentials(data['commander']['name']): ship = companion.ship(data) if ship != this.lastship: cmdr = data['commander']['name'] timestamp = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime()) if 'Coriolis' not in this.discardedEvents: this.queue.put((cmdr, { 'event': 'Coriolis', 'timestamp': timestamp, '_shipId': data['ship']['id'], 'url': plug.invoke('Coriolis', None, 'shipyard_url', {}, is_beta, data) })) this.lastship = ship
def station_url(self, station): return plug.invoke(config.get('station_provider'), 'eddb', 'station_url', monitor.system, monitor.station)
def system_url(self, system): return plug.invoke(config.get('system_provider'), 'EDSM', 'system_url', monitor.system)
def shipyard_url(self, shipname): return plug.invoke(config.get('shipyard_provider'), 'EDSY', 'shipyard_url', monitor.ship(), monitor.is_beta)
def update_status(event=None): for plugin in plug.provides('edsm_notify_system'): plug.invoke(plugin, None, 'edsm_notify_system', this.lastlookup)
def journal_entry(cmdr, is_beta, system, station, entry, state): # Update display if this.system['text'] != system: this.system['text'] = system or '' this.system['image'] = '' this.system.update_idletasks() this.multicrew = bool(state['Role']) if 'StarPos' in entry: this.coordinates = entry['StarPos'] elif entry['event'] == 'LoadGame': this.coordinates = None if entry['event'] in ['LoadGame', 'Commander', 'NewCommander']: this.newgame = True this.newgame_docked = False this.navbeaconscan = 0 elif entry['event'] == 'StartUp': this.newgame = False this.newgame_docked = False this.navbeaconscan = 0 elif entry['event'] == 'Location': this.newgame = True this.newgame_docked = entry.get('Docked', False) this.navbeaconscan = 0 elif entry['event'] == 'NavBeaconScan': this.navbeaconscan = entry['NumBodies'] # Send interesting events to EDSM if config.getint('edsm_out') and not is_beta and not this.multicrew and credentials(cmdr) and entry['event'] not in this.discardedEvents: # Introduce transient states into the event transient = { '_systemName': system, '_systemCoordinates': this.coordinates, '_stationName': station, '_shipId': state['ShipID'], } entry.update(transient) if entry['event'] == 'LoadGame': # Synthesise Materials events on LoadGame since we will have missed it materials = { 'timestamp': entry['timestamp'], 'event': 'Materials', 'Raw': [ { 'Name': k, 'Count': v } for k,v in state['Raw'].iteritems() ], 'Manufactured': [ { 'Name': k, 'Count': v } for k,v in state['Manufactured'].iteritems() ], 'Encoded': [ { 'Name': k, 'Count': v } for k,v in state['Encoded'].iteritems() ], } materials.update(transient) this.queue.put((cmdr, materials)) this.queue.put((cmdr, entry)) if entry['event'] == 'Loadout' and 'EDShipyard' not in this.discardedEvents: url = plug.invoke('EDSY', None, 'shipyard_url', entry, is_beta) if this.lastloadout != url: this.lastloadout = url this.queue.put((cmdr, { 'event': 'EDShipyard', 'timestamp': entry['timestamp'], '_shipId': state['ShipID'], 'url': this.lastloadout }))
def update_location(event=None): if this.lastlocation: for plugin in plug.provides('inara_notify_location'): plug.invoke(plugin, None, 'inara_notify_location', this.lastlocation)
def update_ship(event=None): if this.lastship: for plugin in plug.provides('inara_notify_ship'): plug.invoke(plugin, None, 'inara_notify_ship', this.lastship)
def update_status(event=None) -> None: """Update listening plugins with our response to StartUp, Location, FSDJump, or CarrierJump.""" for plugin in plug.provides('edsm_notify_system'): plug.invoke(plugin, None, 'edsm_notify_system', this.lastlookup)