mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-09 03:42:16 +03:00
Sort EDDN messages
This commit is contained in:
parent
d0cba6f4c4
commit
6e256bed87
52
eddn.py
52
eddn.py
@ -99,13 +99,15 @@ class EDDN:
|
|||||||
else:
|
else:
|
||||||
uploaderID = cmdr.encode('utf-8')
|
uploaderID = cmdr.encode('utf-8')
|
||||||
|
|
||||||
msg['header'] = {
|
msg = OrderedDict([
|
||||||
'softwareName' : '%s [%s]' % (applongname, platform=='darwin' and "Mac OS" or system()),
|
('$schemaRef', msg['$schemaRef']),
|
||||||
'softwareVersion' : appversion,
|
('header', OrderedDict([
|
||||||
'uploaderID' : uploaderID,
|
('softwareName', '%s [%s]' % (applongname, platform=='darwin' and "Mac OS" or system())),
|
||||||
}
|
('softwareVersion', appversion),
|
||||||
if not msg['message'].get('timestamp'): # already present in journal messages
|
('uploaderID', uploaderID),
|
||||||
msg['message']['timestamp'] = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(config.getint('querytime') or int(time.time())))
|
])),
|
||||||
|
('message', msg['message']),
|
||||||
|
])
|
||||||
|
|
||||||
r = self.session.post(self.UPLOAD, data=json.dumps(msg), timeout=timeout)
|
r = self.session.post(self.UPLOAD, data=json.dumps(msg), timeout=timeout)
|
||||||
if __debug__ and r.status_code != requests.codes.ok:
|
if __debug__ and r.status_code != requests.codes.ok:
|
||||||
@ -178,11 +180,13 @@ class EDDN:
|
|||||||
if commodities:
|
if commodities:
|
||||||
self.send(data['commander']['name'], {
|
self.send(data['commander']['name'], {
|
||||||
'$schemaRef' : 'https://eddn.edcd.io/schemas/commodity/3' + (is_beta and '/test' or ''),
|
'$schemaRef' : 'https://eddn.edcd.io/schemas/commodity/3' + (is_beta and '/test' or ''),
|
||||||
'message' : {
|
'message' : OrderedDict([
|
||||||
'systemName' : data['lastSystem']['name'],
|
('timestamp', time.strftime('%Y-%m-%dT%H:%M:%SZ',
|
||||||
'stationName' : data['lastStarport']['name'],
|
time.gmtime(config.getint('querytime') or int(time.time())))),
|
||||||
'commodities' : commodities,
|
('systemName', data['lastSystem']['name']),
|
||||||
}
|
('stationName', data['lastStarport']['name']),
|
||||||
|
('commodities', commodities),
|
||||||
|
]),
|
||||||
})
|
})
|
||||||
|
|
||||||
def export_outfitting(self, data, is_beta):
|
def export_outfitting(self, data, is_beta):
|
||||||
@ -190,11 +194,13 @@ class EDDN:
|
|||||||
if data['lastStarport'].get('modules'):
|
if data['lastStarport'].get('modules'):
|
||||||
self.send(data['commander']['name'], {
|
self.send(data['commander']['name'], {
|
||||||
'$schemaRef' : 'https://eddn.edcd.io/schemas/outfitting/2' + (is_beta and '/test' or ''),
|
'$schemaRef' : 'https://eddn.edcd.io/schemas/outfitting/2' + (is_beta and '/test' or ''),
|
||||||
'message' : {
|
'message' : OrderedDict([
|
||||||
'systemName' : data['lastSystem']['name'],
|
('timestamp', time.strftime('%Y-%m-%dT%H:%M:%SZ',
|
||||||
'stationName' : data['lastStarport']['name'],
|
time.gmtime(config.getint('querytime') or int(time.time())))),
|
||||||
'modules' : sorted([module['name'] for module in data['lastStarport']['modules'].itervalues() if module_re.search(module['name']) and module.get('sku') in [None, 'ELITE_HORIZONS_V_PLANETARY_LANDINGS'] and module['name'] != 'Int_PlanetApproachSuite']),
|
('systemName', data['lastSystem']['name']),
|
||||||
}
|
('stationName', data['lastStarport']['name']),
|
||||||
|
('modules', sorted([module['name'] for module in data['lastStarport']['modules'].itervalues() if module_re.search(module['name']) and module.get('sku') in [None, 'ELITE_HORIZONS_V_PLANETARY_LANDINGS'] and module['name'] != 'Int_PlanetApproachSuite'])),
|
||||||
|
]),
|
||||||
})
|
})
|
||||||
|
|
||||||
def export_shipyard(self, data, is_beta):
|
def export_shipyard(self, data, is_beta):
|
||||||
@ -202,11 +208,13 @@ class EDDN:
|
|||||||
if data['lastStarport'].get('ships'):
|
if data['lastStarport'].get('ships'):
|
||||||
self.send(data['commander']['name'], {
|
self.send(data['commander']['name'], {
|
||||||
'$schemaRef' : 'https://eddn.edcd.io/schemas/shipyard/2' + (is_beta and '/test' or ''),
|
'$schemaRef' : 'https://eddn.edcd.io/schemas/shipyard/2' + (is_beta and '/test' or ''),
|
||||||
'message' : {
|
'message' : OrderedDict([
|
||||||
'systemName' : data['lastSystem']['name'],
|
('timestamp', time.strftime('%Y-%m-%dT%H:%M:%SZ',
|
||||||
'stationName' : data['lastStarport']['name'],
|
time.gmtime(config.getint('querytime') or int(time.time())))),
|
||||||
'ships' : sorted([ship['name'] for ship in data['lastStarport']['ships']['shipyard_list'].values() + data['lastStarport']['ships']['unavailable_list']]),
|
('systemName', data['lastSystem']['name']),
|
||||||
}
|
('stationName', data['lastStarport']['name']),
|
||||||
|
('ships', sorted([ship['name'] for ship in data['lastStarport']['ships']['shipyard_list'].values() + data['lastStarport']['ships']['unavailable_list']])),
|
||||||
|
]),
|
||||||
})
|
})
|
||||||
|
|
||||||
def export_journal_entry(self, cmdr, is_beta, entry):
|
def export_journal_entry(self, cmdr, is_beta, entry):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user