Show output when shutting down
This commit is contained in:
parent
51692795c6
commit
ae7846887d
1 changed files with 14 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue