Guest User

tg_actions.py

a guest
Jan 30th, 2016
112
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2.  
  3. import sys
  4. import os
  5. from datetime import timedelta
  6.  
  7. if sys.argv[1] == "shutdown":
  8. print ("Das System wird heruntergefahren")
  9. os.system("shutdown now")
  10. elif sys.argv[1] == "reboot":
  11. print ("Das System wird neugestartet")
  12. os.system("shutdown -r now")
  13. elif sys.argv[1] == "uptime":
  14. with open('/proc/uptime', 'r') as f:
  15. uptime_seconds = float(f.readline().split()[0])
  16. uptime_string = str(timedelta(seconds = uptime_seconds))
  17. print(uptime_string[:-7])
  18. #else:
  19. #falls kein Argument zutrifft
RAW Paste Data