cryptonas/plugins/shutdown/shutdown.py
lars 76e5366619 finished unittests for plugin date
finished unittests for plugin disks
finished unittests for plugin help
finished unittests for plugin language_selection
finished unittests for plugin logs
finished unittests for plugin network
finished unittests for plugin plugin_manager
finished unittests for plugin shutdown
finished unittests for plugin system_preferences
finished unittests for plugin user_manager
added english 'translations' to all plugins (by copying msgid to msgstr)
2006-11-30 14:36:53 +00:00

73 lines
2.1 KiB
Python

#
# Copyright 2006 sense.lab e.V.
#
# This file is part of the CryptoBox.
#
# The CryptoBox is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# The CryptoBox is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the CryptoBox; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
import cryptobox.plugins.base
REDIRECT_DELAY = 180
class shutdown(cryptobox.plugins.base.CryptoBoxPlugin):
pluginCapabilities = [ "system" ]
pluginVisibility = [ "preferences", "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