Email Notifier Tutorial

Talk about Adafruit Raspberry Pi® accessories!

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Email Notifier Tutorial

Postby Exigent » Sat Jan 05, 2013 2:24 pm

tried this as my first project on RPi but getting this error when i run the script:

File "./raspi-gmail.py", line 2
SyntaxError: Non-ASCII character '\xc2' in file ./raspi-gmail.py on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

this is what i used to create the file by just copy/paste :

cat <<! > raspi-gmail.py
#!/usr/bin/env python

import RPi.GPIO as GPIO, feedparser, time

DEBUG = 1

USERNAME = "username" # just the part before the @ sign, add yours here
PASSWORD = "password"

NEWMAIL_OFFSET = 1 # my unread messages never goes to zero, yours might
MAIL_CHECK_FREQ = 60 # check mail every 60 seconds

GPIO.setmode(GPIO.BCM)
GREEN_LED = 18
RED_LED = 23
GPIO.setup(GREEN_LED, GPIO.OUT)
GPIO.setup(RED_LED, GPIO.OUT)

while True:

newmails = int(feedparser.parse("https://" + USERNAME + ":" + PASSWORD +"@mail.google.com/gmail/feed/atom")["feed"]["fullcount"])

if DEBUG:
print "You have", newmails, "new emails!"

if newmails > NEWMAIL_OFFSET:
GPIO.output(GREEN_LED, True)
GPIO.output(RED_LED, False)
else:
GPIO.output(GREEN_LED, False)
GPIO.output(RED_LED, True)

time.sleep(MAIL_CHECK_FREQ)
!

Any ideas? Can I just delete the file and start over ?
Exigent
 
Posts: 1
Joined: Thu Dec 20, 2012 7:46 am

Re: Email Notifier Tutorial

Postby Killerspec » Fri Feb 15, 2013 2:39 pm

Hi

Looking for some help! I have put together this project and I know that the e-mail thing is working as in Putty window it is showing the updates. My problem is that my LED's stay on all the time no matter what I do I even tried to change the out puts from 18 and 23 to 21 and 24 but no joy please help.

Thanks a million in advance.

Matthew
Killerspec
 
Posts: 1
Joined: Tue Feb 22, 2011 10:51 am

Re: Email Notifier Tutorial

Postby Wanders11 » Fri Feb 22, 2013 10:03 am

I am having a lot of problems running this script, BUT I have found and solved my instance of the problem you have.

I don't know what the origin of it was, but there were unprintable characters showing up in my raspi-gmail.py after I created it and tried to run it.

I both cut and pasted or handwrote the script using either nano or Leafpad. I removed blank lines and the problem would disappear (for that line - only to be replaced by the same error in the next blank line) SO: What I found were unprintable characters (possibly formatting or control codes) that were carried into the script. Removing the line and reinserting it cured the problem - even when there was a "blank" line. It turns out that the line wasn't blank, just unprintable.

I hope this helps.
Wanders11
 
Posts: 1
Joined: Sat Jan 19, 2013 11:59 am

Raspberry Pi E-mail Notifier Using LEDs

Postby Ron2222 » Wed Mar 06, 2013 4:08 pm

I am also have a problem making the Gmail Python working. when I run the program here is what I get:
pi@raspberrypi ~ $ sudo ./raspi-gmail.py
Traceback (most recent call last):
File "./raspi-gmail.py", line 21, in <module>
newmails = int(feedparser.parse("https://" + USERNAME + ":" + PASSWORD +"@ma il.google.com/gmail/feed/atom")["feed"]["fullcount"])
File "/usr/local/lib/python2.7/dist-packages/feedparser.py", line 375, in __ge titem__
return dict.__getitem__(self, key)
KeyError: 'fullcount'

I am new to the Raspberry Pi and Python. If someone would be so kind to help me
Thanks Ron
Ron2222
 
Posts: 2
Joined: Fri Feb 15, 2013 7:01 pm


Return to Adafruit Raspberry Pi® accessories

Who is online

Users browsing this forum: No registered users and 0 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [102]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]