Python 物理Gmail通知器Led

Python 物理Gmail通知器Led,python,raspberry-pi,email-notifications,Python,Raspberry Pi,Email Notifications,所以我试着制作一个物理的Gmail通知程序。使用一个330欧姆的电阻器和一个LED在我未读邮件时闪烁。事实证明,这比我想象的要难。当我开始执行python代码时,我一直得到这个输出 raspi_gmail.py:34: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings. GPIO.setup(PIN_ma

所以我试着制作一个物理的Gmail通知程序。使用一个330欧姆的电阻器和一个LED在我未读邮件时闪烁。事实证明,这比我想象的要难。当我开始执行python代码时,我一直得到这个输出

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'

任何帮助都将不胜感激,我是这方面的新手

你能打印出
feedparser.parse(“https://“+USERNAME+”:“+PASSWORD+”@mail.google.com/gmail/feed/atom”)[“feed”]
?我该怎么做?你的第一个警告是,当你上次运行程序时,GPIO端口已经绑定。您可以通过将GPIO.cleanup()添加到应用程序的底部()来解决此问题。经过进一步研究,feedparser模块似乎已经过时。我想现在每个人都在使用Imap。你能打印出
feedparser.parse(“https://“+USERNAME+”:“+PASSWORD+”@mail.google.com/gmail/feed/atom”)[“feed”]
?我该怎么做?你的第一个警告是因为你上次运行程序时GPIO端口已经绑定了。您可以通过将GPIO.cleanup()添加到应用程序的底部()来解决此问题。经过进一步研究,feedparser模块似乎已经过时。我想现在每个人都使用Imap。
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()