Advertisement
Guest User

Python Code

a guest
Jul 14th, 2013
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. import subprocess
  2. import time
  3. from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate
  4.  
  5. lcd = Adafruit_CharLCDPlate()
  6.  
  7. while 1:
  8.     lcd.clear()
  9.     p = subprocess.Popen("ping -c 1 64.114.87.90", shell=True, stdout=subprocess.PIPE)
  10.     out, err = p.communicate()
  11.     if not err:
  12.         r = out.split('\n') [4].split(', ')[2]
  13.         if r == '0% packet loss':
  14.             msg = "NAS Online\n"
  15.         else:
  16.             msg = 'NAS Offline\n'
  17.     p = subprocess.Popen("df -h | awk 'NR==9{print $5}'", shell=True, stdout=subprocess.PIPE)
  18.     out, err = p.communicate()
  19.     if not err:
  20.         msg += out.strip() + " space used"
  21.     lcd.message(msg)
  22.     lcd.backlight(lcd.TEAL)
  23.     n = time.time()
  24. while time.time() - n < 60:
  25.     continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement