File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ RUN pip3 install -U setuptools
2424RUN pip3 install cffi
2525RUN pip3 install cairocffi==0.6
2626RUN pip3 install pyserial pusher
27+ RUN pip3 install balena-sdk
2728#pip also install - git+https://github.com/resin-io/resin-sdk-python.git
2829
2930# Set our working directory
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 ()
1214
1315os .environ ['TZ' ] = 'Europe/London' #SetTimezone
1416def log (message ):
@@ -22,17 +24,17 @@ def log(message):
2224def reboot ():
2325 #Use Resin.io api to reboot
2426 log ("Rebooting" )
25- rebooturl = str ( os . environ . get ( 'BALENA_SUPERVISOR_ADDRESS' )) + '/v1/ reboot?apikey=' + str ( os . environ . get ( 'BALENA_SUPERVISOR_API_KEY' ) )
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( )
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 )
3234 return False #basically put itself into a loop
33- time .sleep (300 )
34- reboot ()
3535
36+ time .sleep (120 )
37+ reboot ()
3638
3739serialport = "/dev/ttyUSB0"
3840baudrate = 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