mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-13 07:47:14 +03:00
EDMC: Get -n
working again
* eddn: Don't schedule `queue_check_and_send()` if EDMC_NO_UI. * `export_(commodites|outfitting|shipyard)` lost the `is_odyssey` argument in 556ace5306bebbcf34c1a56a9023a822218a73f1 . * EDDNSender: Helper `set_ui_status()` in which the check for EDMC_NO_UI is performed. Used in `send_message()`. In the EDMC_NO_UI case it will INFO log the text instead.
This commit is contained in:
parent
79bbc8917f
commit
e245a75e61
6
EDMC.py
6
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')
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user