File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 11import os
22import sys #To kill app
3+ import subprocess #To read if it was killed
34import serial
45import time #For time.sleep
56import 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
3237serialport = "/dev/ttyUSB0"
3338baudrate = os .environ .get ('baudRate' , 19200 ) #Set the Baudrate to 19200 which is a nice default for the davis logger
You can’t perform that action at this time.
0 commit comments