Skip to content

Commit 8ea45d8

Browse files
committed
update scripts
1 parent c73df82 commit 8ea45d8

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

main.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,7 @@ def handle_wifi():
9393
@app.route("/update", methods=["GET"])
9494
def 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"])
10699
def handle_bot():
@@ -270,6 +263,17 @@ def handle_program_status():
270263
def 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+
273277
def button_pushed():
274278
if app.bot_config.get('button_func') == "startstop":
275279
if app.prog and app.prog.is_running():

scripts/update_os.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
sudo rpi-update
33
sudo apt-get update -qy
44
sudo apt-get upgrade -qy
5-
5+
echo "OS update completed"

0 commit comments

Comments
 (0)