forked from aarronc/hutton-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cargo.old
39 lines (32 loc) · 1.21 KB
/
cargo.old
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
Cargo Submission for Mission Helper
"""
import sys
import zlib
import time
import json
import data
import plugin
import xmit
cargodump = {}
class CargoPlugin(plugin.HuttonHelperPlugin):
"Forwards cargo data to the Helper back end and other plugins within the helper"
hidden = True # invisible
ready = True # always
def journal_entry(self, cmdr, is_beta, system, station, entry, state):
"Called when Elite Dangerous writes to the commander's journal."
if entry['event'] == 'Cargo':
dump_path = data.get_journal_path('Cargo.json')
# sys.stderr.write("Reading cargo data from: {}\r\n".format(dump_path))
with open(dump_path, 'r') as dump:
dump = dump.read()
dump = json.loads(dump)
cargodump = dump
dump['commandername'] = cmdr
compress_json = json.dumps(dump)
cargo_data = zlib.compress(compress_json.encode('utf-8'))
# sys.stderr.write("Posting it...\r\n")
xmit.post('/missioncargo', cargo_data, headers=xmit.COMPRESSED_OCTET_STREAM)
# self.helper.status("Market data posted.")
else:
return