File tree Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change 99import json #To parse response
1010import sqlite3 #Database
1111import pusher #Pusher.com
12- from balena import Balena #rebooting
13- balena = Balena ()
1412
1513os .environ ['TZ' ] = 'Europe/London' #SetTimezone
1614def log (message ):
@@ -24,18 +22,15 @@ def log(message):
2422def reboot ():
2523 #Use Resin.io api to reboot
2624 log ("Rebooting" )
27- rebootResult = balena . models . supervisor . reboot ( )
28- log ( rebootResult )
29- if rebootResult [ 'DATA' ] != 'OK' :
30- log ( "Reboot Failed" )
31- else :
32- log ( "Reboot worked" )
33- time . sleep ( 43200 )
25+ rebooturl = str ( os . environ . get ( 'BALENA_SUPERVISOR_ADDRESS' )) + '/v1/ reboot?apikey=' + str ( os . environ . get ( 'BALENA_SUPERVISOR_API_KEY' ) )
26+ try :
27+ os . system ( 'curl -X POST --header "Content-Type:application/json" "' + rebooturl + '"' )
28+ time . sleep ( 43200 )
29+ except :
30+ time . sleep ( 600 ) #Just in case that api call fails as it sometimes does
31+ reboot ( )
3432 return False #basically put itself into a loop
3533
36- time .sleep (120 )
37- reboot ()
38-
3934serialport = "/dev/ttyUSB0"
4035baudrate = os .environ .get ('baudRate' , 19200 ) #Set the Baudrate to 19200 which is a nice default for the davis logger
4136try :
You can’t perform that action at this time.
0 commit comments