Guest User

tg_actions.py

a guest
May 16th, 2015
56
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. import RPi.GPIO as GPIO
  6. from time import sleep
  7. from datetime import timedelta
  8.  
  9. GPIO.setmode(GPIO.BOARD)
  10. GPIO.setup(13, GPIO.OUT)
  11.  
  12. if sys.argv[1] == "shutdown":
  13.         print "Das System wird heruntergefahren"
  14.         os.system("shutdown now")
  15. elif sys.argv[1] == "reboot":
  16.         print "Das System wird neugestartet"
  17.         os.system("shutdown -r now")
  18. elif sys.argv[1] == "t1h":
  19.         print "Tor 1 wird geöffnet!"
  20.         with open('/home/pi/tor1auf')
  21. elif sys.argv[1] == "uptime":
  22.         with open('/proc/uptime', 'r') as f:
  23.             uptime_seconds = float(f.readline().split()[0])
  24.             uptime_string = str(timedelta(seconds = uptime_seconds))
  25.         print(uptime_string[:-7])
  26. #else:
  27.         #falls kein Argument zutrifft
RAW Paste Data