cryptonas/plugins/date/network_restart.py

75 lines
2.0 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
#
"""Change date and time.
"""
__revision__ = "$Id: date.py 916 2007-03-21 18:35:31Z lars $"
import cryptobox.plugins.base
class network_restart(cryptobox.plugins.base.CryptoBoxPlugin):
"""The network restart feature of the CryptoBox.
"""
plugin_capabilities = [ "system" ]
# this plugin is per default invisible
plugin_visibility = [ ]
request_auth = True
rank = 31
def do_action(self, restart=None):
"""Show the user interface.
"""
self.cbox.log.debug("executing network_restart plugin")
if restart == "yes":
if self.__net_restart():
self.cbox.log.info("network restarted")
self.hdf["Data.Success"] = "Plugins.network_restart.Restart"
else:
self.cbox.log.error("failure while restarting network")
self.hdf["Data.Warning"] = "Plugins.network_restart.RestartFailed"
return "network_restart"
def get_status(self):
"""
"""
return
def __net_restart(self):
"""Restart all local network connections.
"""
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.plugin_dir, "root_action.py")])
proc.wait()
return proc.returncode == 0