All pastes #1908018 Raw Edit

Simple Reboot Conformation v1.0

public python v1 · immutable
#1908018 ·published 2010-07-25 14:23 UTC
rendered paste body
#!/usr/bin/python"""    This program 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 3 of the License, or    (at your option) any later version.    This program 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."""__author__ = "David A. Chapman" # WEBSITE: http://dchapman.servehttp.com/__module_name__ = "Simple Reboot Conformation"__module_version__ = "1.0"__module_description__ = "A simple reboot conformation program for the Ubuntu/Debian Linux operating system. This program requires that /sbin/shutdown's permissions be set to chmod u+s, or reboot as root."# For an example in which one can use this, consider the fact that I run fluxbox, the graphical X11 # windows manager for Ubuntu/Debian Linux. When you edit /etc/X11/fluxbox/fluxbox-menu to include an # executable reboot option this script comes in handy. To have this exectuable option work # correctly, I would suggest running 'sudo chmod u+s /sbin/shutdown' so that everyone has the option# of restarting or shutting down the computer. Considering this, one might click the added reboot # option by mistake and instantly find their computer going down for a rebound... # The solution: Simple Reboot Conformation v1.0# From the example, one would add something like this to /etc/X11/fluxbox/fluxbox-menu: # [exec] (Reboot) {__THE__Reboot__COMMAND__} <__ICON__FOR__THE__OPTION__>## In my case I use the Simple Reboot Conformation program like this:# [exec] (Reboot) {xterm -e python ~/.fluxbox/scripts/reboot.py} <>import os, string# Set XTerm's title to the program's name via an escape sequence represented by octalsprint "\033]2;Simple Reboot Conformation v1.0\007";# Ask the user if they really want to reboot their computer,# and store the user's choice in a variable for conforamtion.ask = "Are you sure you want to reboot the computer [Y/n]? "confirm = raw_input(ask)# Use deduction to see if the user really wants to restart their machine.if confirm == "Y" or confirm == "y":	print string.upper("Restarting the machine!")	os.system("/sbin/shutdown -r now Restarting the machine")	# To run as root use:	"""os.system("sudo /sbin/shutdown -r now Restarting the machine!")"""else:	os.system("exit")#EOF