1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-05-31 23:59:38 +03:00

Send blackmarket messages to EDDN

This commit is contained in:
Jonathan Harris 2016-09-15 17:03:42 +01:00
parent 4d3fe1808c
commit 6f4a3b37a3
2 changed files with 41 additions and 17 deletions

View File

@ -3,6 +3,7 @@
import sys import sys
from sys import platform from sys import platform
from collections import OrderedDict
from functools import partial from functools import partial
import json import json
from os import mkdir from os import mkdir
@ -526,13 +527,11 @@ class AppWindow:
self.w.after(int(SERVER_RETRY * 1000), self.getandsend) self.w.after(int(SERVER_RETRY * 1000), self.getandsend)
# Send interesting events to EDDN # Send interesting events to EDDN
if (config.getint('output') & config.OUT_SYS_EDDN and monitor.cmdr and try:
(entry['event'] == 'FSDJump' and system_changed or if (config.getint('output') & config.OUT_SYS_EDDN and monitor.cmdr and
entry['event'] == 'Docked' and station_changed or (entry['event'] == 'FSDJump' and system_changed or
entry['event'] == 'Scan' and monitor.system)): entry['event'] == 'Docked' and station_changed or
try: entry['event'] == 'Scan' and monitor.system)):
self.status['text'] = _('Sending data to EDDN...')
# strip out properties disallowed by the schema # strip out properties disallowed by the schema
for thing in ['CockpitBreach', 'BoostUsed', 'FuelLevel', 'FuelUsed', 'JumpDist']: for thing in ['CockpitBreach', 'BoostUsed', 'FuelLevel', 'FuelUsed', 'JumpDist']:
entry.pop(thing, None) entry.pop(thing, None)
@ -544,20 +543,38 @@ class AppWindow:
if 'StarSystem' not in entry: if 'StarSystem' not in entry:
entry['StarSystem'] = monitor.system entry['StarSystem'] = monitor.system
self.status['text'] = _('Sending data to EDDN...')
eddn.export_journal_entry(monitor.cmdr, monitor.is_beta, entry) eddn.export_journal_entry(monitor.cmdr, monitor.is_beta, entry)
self.status['text'] = '' self.status['text'] = ''
except requests.exceptions.RequestException as e: elif (config.getint('output') & config.OUT_MKT_EDDN and monitor.cmdr and
if __debug__: print_exc() entry['event'] == 'MarketSell' and entry.get('BlackMarket')):
self.status['text'] = _("Error: Can't connect to EDDN") # Construct blackmarket message
if not config.getint('hotkey_mute'): msg = OrderedDict([
hotkeymgr.play_bad() ('systemName', monitor.system),
('stationName', monitor.station),
('timestamp', entry['timestamp']),
('name', entry['Type']),
('sellPrice', entry['SellPrice']),
('prohibited' , entry.get('IllegalGoods', False)),
])
self.status['text'] = _('Sending data to EDDN...')
eddn.export_blackmarket(monitor.cmdr, monitor.is_beta, msg)
self.status['text'] = ''
except requests.exceptions.RequestException as e:
if __debug__: print_exc()
self.status['text'] = _("Error: Can't connect to EDDN")
if not config.getint('hotkey_mute'):
hotkeymgr.play_bad()
except Exception as e:
if __debug__: print_exc()
self.status['text'] = unicode(e)
if not config.getint('hotkey_mute'):
hotkeymgr.play_bad()
except Exception as e:
if __debug__: print_exc()
self.status['text'] = unicode(e)
if not config.getint('hotkey_mute'):
hotkeymgr.play_bad()
def edsmpoll(self): def edsmpoll(self):
result = self.edsm.result result = self.edsm.result

View File

@ -151,5 +151,12 @@ class _EDDN:
'message' : entry 'message' : entry
}) })
def export_blackmarket(self, cmdr, is_beta, msg):
self.send(cmdr, {
'$schemaRef' : 'http://schemas.elite-markets.net/eddn/blackmarket/1' + (is_beta and '/test' or ''),
'message' : msg
})
# singleton # singleton
eddn = _EDDN() eddn = _EDDN()