Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 38 additions & 22 deletions nuclearesrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,41 @@ def find_nucleares():
presence.connect()
print("Connected. Press Ctrl+C to Exit")
while 1:
dvars = get_all_vars(url)
if dvars["CORE_TEMP"] <= 50:
details = "Reactor Offline"
else:
details = f"Reactor Online: {round(dvars['CORE_TEMP'])}C"
pwr = dvars["GENERATOR_0_KW"] + dvars["GENERATOR_1_KW"] + dvars["GENERATOR_2_KW"]
if pwr > 0:
status = f"Producing {pwr} kW"
else:
status = "Generator Offline"
if dvars["CORE_IMMINENT_FUSION"] == "TRUE":
details = "Imminent Meltdown"
presence.update(
pid=proc.pid,
start=round(starttime),
details=details,
state=status,
)
#print(
# f"Sent Update: Core = {dvars['CORE_TEMP']} - Total Pwr = {pwr} - Panic = {dvars['CORE_IMMINENT_FUSION']}"
#)
time.sleep(15)
try:
dvars = get_all_vars(url)
if dvars["CORE_TEMP"] <= 50:
details = "Reactor Offline"
else:
details = f"Reactor Online: {round(dvars['CORE_TEMP'])}C"
pwr = round(dvars["GENERATOR_0_KW"] + dvars["GENERATOR_1_KW"] + dvars["GENERATOR_2_KW"])
if pwr > 0:
status = f"Producing {pwr} kW"
else:
status = "Generator Offline"
if dvars["CORE_IMMINENT_FUSION"] == "TRUE":
details = "Imminent Meltdown"
presence.update(
pid=proc.pid,
start=round(starttime),
details=details,
state=status,
large_image="nucleares"
)
#print(
# f"Sent Update: Core = {dvars['CORE_TEMP']} - Total Pwr = {pwr} - Panic = {dvars['CORE_IMMINENT_FUSION']}"
#)
time.sleep(15)
except requests.ConnectionError:
print("Webserver connection lost, trying to re-establish...")
if find_nucleares() is None:
print("Nucleares is closed, RPC will close...")
exit(0)
while 1:
try:
# Try to query data until it succeeds
requests.get(url, {"Variable": "CORE_TEMP"})
break
except requests.ConnectionError as e:
time.sleep(5)
print("Connected!")
continue