I wrote a Python script to check my email and turn on an LED when I have new mail. After about 1 hour, I got the error:
Traceback (most recent call last):
File "checkmail.py", line 10, in <module>
B = int(feedparser.parse("https://" + U + ":" + P + "@mail.google.com/gmail/feed/atom")["feed"]["fullcount"])
File "/usr/local/lib/python2.7/dist-packages/feedparser.py", line 375, in __getitem__
return dict.__getitem__(self, key)
KeyError: 'fullcount'
I looked here and didn't find an answer. Here is my code:
#!/usr/bin/env python
import RPi.GPIO as GPIO, feedparser, time
U = "username"
P = "password"
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
A = 23
GPIO.setup(A, GPIO.OUT)
while True:
B = int(feedparser.parse("https://" + U + ":" + P + "@mail.google.com/gmail/feed/atom")["feed"]["fullcount"])
if B > 0:
GPIO.output(A, True)
else:
GPiO.output(A, False)
time.sleep(60)
I'm running this on a Raspberry Pi. Thanks in advance for any help.