mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-06 02:13:41 +03:00
Merge pull request #1754 from EDCD/fix/1720/EDMC_-n
EDMC.py quietening and fixes
This commit is contained in:
commit
d48501c37b
6
EDMC.py
6
EDMC.py
@ -433,9 +433,9 @@ sys.path: {sys.path}'''
|
|||||||
try:
|
try:
|
||||||
eddn_sender = eddn.EDDN(None)
|
eddn_sender = eddn.EDDN(None)
|
||||||
logger.debug('Sending Market, Outfitting and Shipyard data to EDDN...')
|
logger.debug('Sending Market, Outfitting and Shipyard data to EDDN...')
|
||||||
eddn_sender.export_commodities(data, monitor.is_beta, monitor.state['Odyssey'])
|
eddn_sender.export_commodities(data, monitor.is_beta)
|
||||||
eddn_sender.export_outfitting(data, monitor.is_beta, monitor.state['Odyssey'])
|
eddn_sender.export_outfitting(data, monitor.is_beta)
|
||||||
eddn_sender.export_shipyard(data, monitor.is_beta, monitor.state['Odyssey'])
|
eddn_sender.export_shipyard(data, monitor.is_beta)
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception('Failed to send data to EDDN')
|
logger.exception('Failed to send data to EDDN')
|
||||||
|
@ -1710,7 +1710,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
else:
|
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
|
self.is_beta = any(v in self.version.lower() for v in ('alpha', 'beta')) # type: ignore
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
@ -180,6 +180,7 @@ class EDDNSender:
|
|||||||
"plugin.eddn.send",
|
"plugin.eddn.send",
|
||||||
f"First queue run scheduled for {self.eddn.REPLAY_STARTUP_DELAY}ms from now"
|
f"First queue run scheduled for {self.eddn.REPLAY_STARTUP_DELAY}ms from now"
|
||||||
)
|
)
|
||||||
|
if not os.getenv("EDMC_NO_UI"):
|
||||||
self.eddn.parent.after(self.eddn.REPLAY_STARTUP_DELAY, self.queue_check_and_send, True)
|
self.eddn.parent.after(self.eddn.REPLAY_STARTUP_DELAY, self.queue_check_and_send, True)
|
||||||
|
|
||||||
def sqlite_queue_v1(self) -> sqlite3.Connection:
|
def sqlite_queue_v1(self) -> sqlite3.Connection:
|
||||||
@ -371,6 +372,19 @@ class EDDNSender:
|
|||||||
|
|
||||||
return False
|
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:
|
def send_message(self, msg: str) -> bool:
|
||||||
"""
|
"""
|
||||||
Transmit a fully-formed EDDN message to the Gateway.
|
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.')
|
logger.warning('eddn.send has been disabled via killswitch. Returning.')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
status: tk.Widget = self.eddn.parent.children['status']
|
|
||||||
# Even the smallest possible message compresses somewhat, so always compress
|
# Even the smallest possible message compresses somewhat, so always compress
|
||||||
encoded, compressed = text.gzip(json.dumps(new_data, separators=(',', ':')), max_size=0)
|
encoded, compressed = text.gzip(json.dumps(new_data, separators=(',', ':')), max_size=0)
|
||||||
headers: None | dict[str, str] = None
|
headers: None | dict[str, str] = None
|
||||||
@ -435,16 +448,16 @@ class EDDNSender:
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
# This should catch anything else, e.g. timeouts, gateway errors
|
# 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:
|
except requests.exceptions.RequestException as e:
|
||||||
logger.debug('Failed sending', exc_info=e)
|
logger.debug('Failed sending', exc_info=e)
|
||||||
# LANG: Error while trying to send data to EDDN
|
# 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:
|
except Exception as e:
|
||||||
logger.debug('Failed sending', exc_info=e)
|
logger.debug('Failed sending', exc_info=e)
|
||||||
status['text'] = str(e)
|
self.set_ui_status(str(e))
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user