spacepaste

  1.  
  2. #!/usr/bin/python
  3. from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate
  4. from subprocess import *
  5. from time import sleep, strftime
  6. from datetime import datetime
  7. lcd = Adafruit_CharLCDPlate()
  8. cmd = "ip addr show wlan0 | grep inet | awk '{print $2}' | cut -d/ -f1"
  9. lcd.begin(16,1)
  10. def run_cmd(cmd):
  11. p = Popen(cmd, shell=True, stdout=PIPE)
  12. output = p.communicate()[0]
  13. return output
  14. while 1:
  15. col = (lcd.RED, lcd.YELLOW, lcd.GREEN, lcd.TEAL, lcd.BLUE, lcd.VIOLET, lcd.ON, lcd.OFF)
  16. for c in col:
  17. lcd.backlight(c)
  18. lcd.clear()
  19. ipaddr = run_cmd(cmd)
  20. lcd.message(datetime.now().strftime('%b %d %l:%M %p\n'))
  21. lcd.message('IP %s' % ( ipaddr ) )
  22. sleep(60)
  23.