lars
80337411ae
svn:keywords set fixed: shutdown - delay reboot/poweroff by some seconds to finish the web page before added: format_fs - show link to umount in case of active device added: new plugin "language_selection" fixed: recently introduced syntax error in 'network' added: "volume_props" mentions encryption support via "format_fs" (including link) updated: plugin-interface.txt fixed: broken test case for date plugin (caused by twill, I guess) added: "partition" plugin - better handling of config partition
51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
import CryptoBoxPlugin
|
|
|
|
REDIRECT_DELAY = 180
|
|
|
|
class shutdown(CryptoBoxPlugin.CryptoBoxPlugin):
|
|
|
|
pluginCapabilities = [ "system", "menu" ]
|
|
requestAuth = False
|
|
rank = 90
|
|
|
|
def doAction(self, type=None):
|
|
if not type:
|
|
return "form_shutdown"
|
|
elif type == "shutdown":
|
|
if self.__doShutdown("shutdown"):
|
|
self.hdf["Data.Success"] = "Plugins.shutdown.Shutdown"
|
|
return "progress_shutdown"
|
|
else:
|
|
self.hdf["Data.Warning"] = "Plugins.shutdown.ShutdownFailed"
|
|
return "form_shutdown"
|
|
elif type == "reboot":
|
|
if self.__doShutdown("reboot"):
|
|
self.hdf["Data.Success"] = "Plugins.shutdown.Reboot"
|
|
self.hdf["Data.Redirect.URL"] = ""
|
|
self.hdf["Data.Redirect.Delay"] = REDIRECT_DELAY
|
|
return "progress_reboot"
|
|
else:
|
|
self.hdf["Data.Warning"] = "Plugins.shutdown.RebootFailed"
|
|
return "form_shutdown"
|
|
else:
|
|
return "form_shutdown"
|
|
|
|
|
|
def getStatus(self):
|
|
return "the box is up'n'running"
|
|
|
|
|
|
def __doShutdown(self, action):
|
|
import subprocess
|
|
import os
|
|
proc = subprocess.Popen(
|
|
shell = False,
|
|
args = [
|
|
self.cbox.prefs["Programs"]["super"],
|
|
self.cbox.prefs["Programs"]["CryptoBoxRootActions"],
|
|
"plugin",
|
|
os.path.join(self.pluginDir, "root_action.py"),
|
|
action])
|
|
proc.wait()
|
|
return proc.returncode == 0
|
|
|