Commit ae784688 authored by Joel Collins's avatar Joel Collins
Browse files

Show output when shutting down

parent 51692795
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -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