Skip to content

Commit f8d3f4d

Browse files
committed
Debugging
1 parent 4b2fcdc commit f8d3f4d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

WeatherStationCoreLink/main.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import sys #To kill app
3+
import subprocess #To read if it was killed
34
import serial
45
import time #For time.sleep
56
import struct #To merge two bytes in an integer
@@ -22,12 +23,16 @@ def reboot():
2223
#Use Resin.io api to reboot
2324
log("Rebooting")
2425
rebooturl = str(os.environ.get('BALENA_SUPERVISOR_ADDRESS')) + '/v1/reboot?apikey=' + str(os.environ.get('BALENA_SUPERVISOR_API_KEY'))
25-
os.system('curl -X POST --header "Content-Type:application/json" "' + rebooturl + '"')
26-
time.sleep(60) #Just in case that api call fails as it sometimes does
27-
os.system('curl -X POST --header "Content-Type:application/json" "' + rebooturl + '"')
28-
time.sleep(60) # Just in case that api call fails AGAIN as it sometimes does
29-
reboot()
26+
result = subprocess.check_output('curl -X POST --header "Content-Type:application/json" "' + rebooturl + '"', shell=True)
27+
log(result)
28+
#time.sleep(60) #Just in case that api call fails as it sometimes does
29+
#os.system('curl -X POST --header "Content-Type:application/json" "' + rebooturl + '"')
30+
#time.sleep(60) # Just in case that api call fails AGAIN as it sometimes does
31+
#reboot()
3032
return False #basically put itself into a loop
33+
time.sleep(300)
34+
reboot()
35+
3136

3237
serialport = "/dev/ttyUSB0"
3338
baudrate = os.environ.get('baudRate', 19200) #Set the Baudrate to 19200 which is a nice default for the davis logger

0 commit comments

Comments
 (0)