So I was trying to make a physical Gmail notifier . Using a 330 ohm resistor and an LED to blink when I have unread mail. This is proving to be tougher then I thought. I keep getting this output when I go to execute the python code.
raspi_gmail.py:34: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(PIN_mail, GPIO.OUT)
Traceback (most recent call last):
File "raspi_gmail.py", line 45, in <module>
newmails = int(feedparser.parse("https://" + USERNAME + ":" + PASSWORD + "@mail.google.com/gmail/feed/atom")["feed"]["fullcount"])
File "/usr/local/lib/python2.7/dist-packages/feedparser.py", line 356, in __getitem__
return dict.__getitem__(self, key)
KeyError: 'fullcount'
This is the Code I'm using , with the credentials cut out of course.
from os.path import exists
import RPi.GPIO as GPIO, feedparser
GPIO.setmode(GPIO.BCM)
file=".unreadmail.txt"
# insert your username and password
USERNAME="[USERNAME]@gmail.com"
PASSWORD="[PASSWORD]"
# if .unreadmail.txt doesn't exists the script wont work
# the following lines check if the file exists and create it if needed
if exists(file) == False:
data = open(file, 'w')
data.write("0")
data.close()
# edit these two value depending on your pin wiring
PIN_mail=6
PIN_check=18
data = open(file, 'r')
status=int(data.read())
data.close()
GPIO.setup(PIN_mail, GPIO.OUT)
GPIO.setup(PIN_check, GPIO.OUT)
GPIO.output(PIN_check, False)
if status == 0:
GPIO.output(PIN_mail, True)
else:
GPIO.output(PIN_mail, False)
newmails = int(feedparser.parse("https://" + USERNAME + ":" + PASSWORD + "@mail.google.com/gmail/feed/atom")["feed"]["fullcount"])
# output on .unreadmail.txt and GPIO
data = open(file, 'w')
if newmails > 0:
GPIO.output(PIN_mail, False)
data.write("1")
else:
GPIO.output(PIN_mail, True)
data.write("0")
GPIO.output(PIN_check, True)
data.close()
Any help would be appreciated , I'm kind of a newbie to this whole aspect.