-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_log.py
More file actions
54 lines (41 loc) · 1.36 KB
/
Copy pathclient_log.py
File metadata and controls
54 lines (41 loc) · 1.36 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import zlib
import zmq
import simplejson
import sys
import time
"""
" Configuration
"""
__relayEDDN = 'tcp://eddn.edcd.io:9500'
__timeoutEDDN = 600000
"""
" Start
"""
def main():
context = zmq.Context()
subscriber = context.socket(zmq.SUB)
subscriber.setsockopt(zmq.SUBSCRIBE, b"")
subscriber.setsockopt(zmq.RCVTIMEO, __timeoutEDDN)
while True:
try:
subscriber.connect(__relayEDDN)
while True:
__message = subscriber.recv()
if __message == False:
subscriber.disconnect(__relayEDDN)
break
__message = zlib.decompress(__message)
__json = simplejson.loads(__message)
# call dumps() to ensure double quotes in output
try:
if "FSDJump" in __json['message']['event']:
open("client_log.jsonl", "a").write(f"\n{simplejson.dumps(__json)}")
except Exception:
i = 1
except zmq.ZMQError as e:
print ('ZMQSocketException: ' + str(e))
sys.stdout.flush()
subscriber.disconnect(__relayEDDN)
time.sleep(5)
if __name__ == '__main__':
main()