This repository has been archived by the owner on Jan 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
journalwatcher.py
60 lines (43 loc) · 1.51 KB
/
journalwatcher.py
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
55
56
57
58
59
import time
global lastJournalText
global firstRun
global lastCarrierRequest
global lastUsedFileName
firstRun = True
lastJournalText = ""
lastCarrierRequest = ""
def process_journal(file_name):
global lastJournalText
global firstRun
global lastCarrierRequest
global lastUsedFileName
lastUsedFileName = file_name
#print("Hello from thread!")
journal = open(file_name, "r")
journalText = journal.read()
journal.close()
if journalText != lastJournalText and not firstRun:
newText = journalText.replace(lastJournalText, "").strip()
for line in newText.split("\n"):
event = line.split(':')[4].split('"')[1].strip()
#print(event)
if event == "Music":
track = line.split(':')[5].split('"')[1].strip()
#print("Music track: " + track)
if track == "MainMenu":
print("Game has crashed!!")
return False
if event == "Shutdown":
print("Game has crashed!!")
return False
elif event == "CarrierJumpRequest":
destination = line.split(':')[6].split('"')[1].strip()
print("Carrier destination: " + destination)
if not firstRun: lastCarrierRequest = destination
lastJournalText = journalText
firstRun = False
return True
def last_carrier_request():
global lastCarrierRequest
process_journal(lastUsedFileName)
return lastCarrierRequest