@@ -93,14 +93,7 @@ def handle_wifi():
93
93
@app .route ("/update" , methods = ["GET" ])
94
94
def handle_update ():
95
95
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' )
104
97
105
98
@app .route ("/bot" , methods = ["GET" ])
106
99
def handle_bot ():
@@ -270,6 +263,17 @@ def handle_program_status():
270
263
def handle_tutorial ():
271
264
return redirect ("/blockly-tutorial/apps/index.html" , code = 302 )
272
265
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
+
273
277
def button_pushed ():
274
278
if app .bot_config .get ('button_func' ) == "startstop" :
275
279
if app .prog and app .prog .is_running ():
0 commit comments