@@ -93,14 +93,7 @@ def handle_wifi():
9393@app .route ("/update" , methods = ["GET" ])
9494def handle_update ():
9595 logging .info ("updating system.start" )
96- out_os = subprocess .check_output (["./scripts/update_os.sh" ],
97- stderr = subprocess .STDOUT )
98- logging .info ("updating system.os: " + str (out_os ))
99-
100- out_bot = subprocess .check_output (["./scripts/update_coderbot.sh" ],
101- stderr = subprocess .STDOUT )
102- logging .info ("updating system.bot: " + str (out_bot ))
103- return out_os + out_bot
96+ return Response (execute ("./scripts/update_coderbot.sh" ), mimetype = 'text/plain' )
10497
10598@app .route ("/bot" , methods = ["GET" ])
10699def handle_bot ():
@@ -270,6 +263,17 @@ def handle_program_status():
270263def handle_tutorial ():
271264 return redirect ("/blockly-tutorial/apps/index.html" , code = 302 )
272265
266+ def execute (command ):
267+ process = subprocess .Popen (command , shell = True , stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
268+
269+ # Poll process for new output until finished
270+ while True :
271+ nextline = process .stdout .readline ()
272+ if nextline == '' and process .poll () != None :
273+ break
274+ logging .info (nextline )
275+ yield nextline
276+
273277def button_pushed ():
274278 if app .bot_config .get ('button_func' ) == "startstop" :
275279 if app .prog and app .prog .is_running ():
0 commit comments