diff --git a/EDMC.py b/EDMC.py index 1f9afefb..4daf4af3 100755 --- a/EDMC.py +++ b/EDMC.py @@ -433,9 +433,9 @@ sys.path: {sys.path}''' try: eddn_sender = eddn.EDDN(None) logger.debug('Sending Market, Outfitting and Shipyard data to EDDN...') - eddn_sender.export_commodities(data, monitor.is_beta, monitor.state['Odyssey']) - eddn_sender.export_outfitting(data, monitor.is_beta, monitor.state['Odyssey']) - eddn_sender.export_shipyard(data, monitor.is_beta, monitor.state['Odyssey']) + eddn_sender.export_commodities(data, monitor.is_beta) + eddn_sender.export_outfitting(data, monitor.is_beta) + eddn_sender.export_shipyard(data, monitor.is_beta) except Exception: logger.exception('Failed to send data to EDDN') diff --git a/monitor.py b/monitor.py index 4a7a2369..126e04c7 100644 --- a/monitor.py +++ b/monitor.py @@ -1710,7 +1710,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below pass else: - logger.info(f"Parsed {self.state['GameVersion']=} into {self.version_semantic=}") + logger.debug(f"Parsed {self.state['GameVersion']=} into {self.version_semantic=}") self.is_beta = any(v in self.version.lower() for v in ('alpha', 'beta')) # type: ignore except KeyError: diff --git a/plugins/eddn.py b/plugins/eddn.py index ec13dafe..2f2ccc78 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -180,7 +180,8 @@ class EDDNSender: "plugin.eddn.send", f"First queue run scheduled for {self.eddn.REPLAY_STARTUP_DELAY}ms from now" ) - self.eddn.parent.after(self.eddn.REPLAY_STARTUP_DELAY, self.queue_check_and_send, True) + if not os.getenv("EDMC_NO_UI"): + self.eddn.parent.after(self.eddn.REPLAY_STARTUP_DELAY, self.queue_check_and_send, True) def sqlite_queue_v1(self) -> sqlite3.Connection: """ @@ -371,6 +372,19 @@ class EDDNSender: return False + def set_ui_status(self, text: str) -> None: + """ + Set the UI status text, if applicable. + + When running as a CLI there is no such thing, so log to INFO instead. + :param text: The status text to be set/logged. + """ + if os.getenv('EDMC_NO_UI'): + logger.INFO(text) + return + + self.eddn.parent.children['status']['text'] = text + def send_message(self, msg: str) -> bool: """ Transmit a fully-formed EDDN message to the Gateway. @@ -394,7 +408,6 @@ class EDDNSender: logger.warning('eddn.send has been disabled via killswitch. Returning.') return False - status: tk.Widget = self.eddn.parent.children['status'] # Even the smallest possible message compresses somewhat, so always compress encoded, compressed = text.gzip(json.dumps(new_data, separators=(',', ':')), max_size=0) headers: None | dict[str, str] = None @@ -435,16 +448,16 @@ class EDDNSender: else: # This should catch anything else, e.g. timeouts, gateway errors - status['text'] = self.http_error_to_log(e) + self.set_ui_status(self.http_error_to_log(e)) except requests.exceptions.RequestException as e: logger.debug('Failed sending', exc_info=e) # LANG: Error while trying to send data to EDDN - status['text'] = _("Error: Can't connect to EDDN") + self.set_ui_status(_("Error: Can't connect to EDDN")) except Exception as e: logger.debug('Failed sending', exc_info=e) - status['text'] = str(e) + self.set_ui_status(str(e)) return False