Show output when shutting down

This commit is contained in:
Joel Collins 2020-02-11 17:31:56 +00:00
parent 51692795c6
commit ae7846887d

View file

@ -25,9 +25,14 @@ class ShutdownAPI(View):
"""
Attempt to shutdown the device
"""
subprocess.Popen(["sudo", "shutdown", "-h", "now"])
p = subprocess.Popen(
["sudo", "shutdown", "-h", "now"],
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
)
return "{}", 201
out, err = p.communicate()
return {"out": out, "err": err}, 201
@ThingAction
@ -41,6 +46,11 @@ class RebootAPI(View):
"""
Attempt to reboot the device
"""
subprocess.Popen(["sudo", "shutdown", "-r", "now"])
p = subprocess.Popen(
["sudo", "shutdown", "-r", "now"],
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
)
return "{}", 201
out, err = p.communicate()
return {"out": out, "err": err}, 201