Feature Request: Graceful Shutdown

NEVER confuse me with someone that knows! :wink:

All I can recall is that I used popen in the release manager and I think I needed to. It works and the machine turns off… there’s not much more than that we need it to do and even if its not the pythonic way, the machine is turned off and it can’t hurt anything… I think :slight_smile:

I guess I’m like a really bad duck hunter when it comes to programming. I shotgun in every direction until the duck gets tired of flying around and lands so I think I shot it.

I likely have a pull request ready to submit off of the main branch for just this button add. Do you think it wise to specify the shutdown specifically for the raspberry pi? We don’t necessarily want windows to shut down with this or a mac to shut off with this. Windows would error because it is incorrect syntax and if you are using the program locally likely on a mac, push the button. I think permissions might be a bigger deal on std linux systems where the sudo user has to enter the password the first time sudo is run.

I shotgun as well, but try to remember which way I pointed last time I hit the target.

This should be limited to RPI and there needs to be checks to make sure the button doesn’t appear unless the system is an RPI.

what other buttons or web page options are platform specific? GPIO? I’m not sure where to check the platform to show or not show the button.

I seem to remember that there was a /boot/config.txt option now that you could
specify a GPIO pin to trigger a shutdown.

David Lang

try data.pyInstallPlatform… if it equals “rpi” then the platform should be raspbian… and therefore a witch! (sorry for bad humor)

To make the button appear or not appear requires work in WebPageProcessor and then the template file for actions.html.

I know how to get the platform info, I don’t know how to pass it to the html/js to turn the button on and off / block/hide/show or however that is done. The functionality is there, the show part of it isn’t. Who’s been doing all the feather css updates? Do they know how to do that?

Here’s an example of the html code that is used to disable a button depending upon if enableHoley is true or false (it’s in the actions.html file):

<button type=“button” class=“btn btn-lg btn-block btn-secondary” {{‘’ if enableHoley else ‘data-toggle=“tooltip” title=“Holey Firmware Required”’ | safe}} onclick=“requestPage(‘holeyCalibration’);$(‘#contentModal’).modal(‘hide’);” {{‘’ if enableHoley else ‘disabled’}}>Holey Calibration

Webcontrol uses jinja2 template language and duplicating this above (with mods) should work. But you could (I think) change the ‘disabled’ to ‘display:none’ and it would hide the button altogether, which is preferred.

In WebpageProcessor, you’ll see for the actions page that it already tests for whether the platform is an RPI or not, but what that is doing is actually testing it to see if its a docker container and I think its broken anyway. Since that button is getitng updated that uses the docker variable, I’d go ahead and change that conditional statement to test for data.pyInstallPlatform instead and change docker to enableShutdown or something. Then in the render_template, change docker=docker to enableShutdown=enableShutdown. In the html file modify the code to use shutdownEnable (i.e., if using above as a guide, change enableHoley to enableShutdown)

good instructions. I found the docker variable and the data.py platform = RPI, so I put in an enableRPI variable next to docker so when/if docker ever goes completely away, this one won’t. The ‘display:none’ didn’t work and neither did ‘display:block’,
, but if I falsify the platform check, the button does disable:


Google suggested that ‘hidden’ was a property, so I tried that and SHAZAAM:
After changing the flag a couple times, the button appears and disappears as it should. The last check is the password request failure. There isn’t really any code in there for that. I’ll submit a pull request and you can check it out.

This is an experimental release with code from @orob. Please give it a shot. If you’re running 0.932, make sure you enable experimental releases to see it.

2 Likes

Thank you, I finally got a chance to test it out and it works great.
You guys are amazing.

2 Likes