tag:blogger.com,1999:blog-7024729.post4525736306786204242..comments2023-05-05T19:39:34.669+10:00Comments on Successlessness: Ambient Email Notifier (some code)Tomhttp://www.blogger.com/profile/06694547908603725128noreply@blogger.comBlogger17125tag:blogger.com,1999:blog-7024729.post-34910914674251616492009-05-26T16:46:08.224+10:002009-05-26T16:46:08.224+10:00Good to hear you got the RSS stuff straightened ou...Good to hear you got the RSS stuff straightened out. Good luck with the circuit, that's the fun bit :)<br /><br />As for the beer money, I appreciate the thought but don't worry about it, it is my pleasure to help out. If you insist on spending some money, find a charity or open source project, they'll have a better use for it than me.Tomhttps://www.blogger.com/profile/06694547908603725128noreply@blogger.comtag:blogger.com,1999:blog-7024729.post-26088549461802626392009-05-26T04:49:21.746+10:002009-05-26T04:49:21.746+10:00Got it to work now, but only by burning another fe...Got it to work now, but only by burning another feed containing the gmail feed with "feedburner". This new feed now can be read by "feedparser.parse" without problems, even SSH authorization is no problem (luckily).<br />It seems that my original "gmail" atom feed is sub-standard..<br /><br />Now I'll try to set up email forwarding and build a circuit to test the com.write part<br /><br />Do you have a paypal acc Tom? Then I'd like to pay you a beer or something.Dennishttps://www.blogger.com/profile/14843736797323763877noreply@blogger.comtag:blogger.com,1999:blog-7024729.post-22143990160263828422009-05-26T02:08:25.409+10:002009-05-26T02:08:25.409+10:00I'm sorry for having bothered you, as it seems the...I'm sorry for having bothered you, as it seems the python script runs fantastically whereas my gmail atom feed does not - at least not in the way/syntax I have named it.<br /><br />using <I>print "debug ", inbox</I> <br />inside the msgCount function, I get the following output:<br /><br />debug {'feed': {}, 'encoding': 'utf-8', 'bozo': 1, 'version': None, 'entries': [], 'bozo_exception': URLError(gaierror(-2, 'Name or service not known'),)}Dennishttps://www.blogger.com/profile/14843736797323763877noreply@blogger.comtag:blogger.com,1999:blog-7024729.post-40366961458766067492009-05-25T23:45:39.992+10:002009-05-25T23:45:39.992+10:00hm, changing msgCount to the simpler variant didn'...hm, changing msgCount to the simpler variant didn't do it. I get back <br />"message count: 0" when trying to run the script.<br /><br />when I open "https://username:password@mail.google.com/mail/feed/atom/" with firefox, the feed is there, now with four unread messages. If I append something like "/inbox" to above url I still see the feed page but with no messages.<br /><br />I suspect that in my case, feedparser browses either wrong or nonexistent email folders to retrieve its "inbox" value, and thus contains this "0" value..<br /><br />The sourcecode of my rss mail feed has a tag "fullcount" that is incremented with each new incoming mail so it should be possible for feedparser to read this tag?<br /><br /><br />Any ideas how to make feedparser read the amnt of mails properly?Dennishttps://www.blogger.com/profile/14843736797323763877noreply@blogger.comtag:blogger.com,1999:blog-7024729.post-72427194821597711642009-05-25T22:59:26.494+10:002009-05-25T22:59:26.494+10:00First, not sure why you're getting a count of 0, w...First, not sure why you're getting a count of 0, when you have 3 unread messages. Occassionally I have noticed I have email but the feed is empty, so maybe that's happening in this case for you too. It's never lasted long enough to force me to debug it.<br /><br />Second, there's a bug in that code I gave you, the easiest fix is to change the last line of the msgCount function to just:<br /><br />return len(inbox["entries"])<br /><br />Sorry about that, some stuff still left around from when I had the system tray notifier going too.Tomhttps://www.blogger.com/profile/06694547908603725128noreply@blogger.comtag:blogger.com,1999:blog-7024729.post-46249017957873629692009-05-25T22:51:28.847+10:002009-05-25T22:51:28.847+10:00I've no idea how to monitor the serial port in Lin...I've no idea how to monitor the serial port in Linux, but I'm guessing you can redirect it or open a terminal to it or something... <br /><br />The notifier is essentially a hardware serial port "sniffer", but it has no buffering and shows only the lower 3 bits of the byte transmitted.<br /><br />I did all the development of this in Windows, and tested that the "receiver" side was working by sending data to the email notifier with HyperTerminal.<br /><br />Sending a single byte was never reliable, so that's why the loop is there to just send it 10 times. I'm sure there's a better way, changing buffer sizes or something like that, but it worked fine like that as there is only one byte in each message.Tomhttps://www.blogger.com/profile/06694547908603725128noreply@blogger.comtag:blogger.com,1999:blog-7024729.post-25423427282831881342009-05-25T22:50:15.477+10:002009-05-25T22:50:15.477+10:00Hmm. "print "message count: ", inbox"
gives "messa...Hmm. "print "message count: ", inbox"<br />gives "message count: (0, [])" as output.<br /><br />Guess it doesn't work properly since there are three unread mails in my inbox?<br /><br />This is how I modified the feed URL:<br /> inbox = feedparser.parse("https://%s:%s@mail.google.com/mail/feed/atom%s" % (uid, pwd, filter))<br /> return (len(inbox["entries"]), ["%s: %s"%(e["author_detail"]["name"], e["title"]) for e in inbox["entries"]])<br /><br />if I paste the url in firefox and replace the %s with my username I can see the feed!Dennishttps://www.blogger.com/profile/14843736797323763877noreply@blogger.comtag:blogger.com,1999:blog-7024729.post-31582746078470451872009-05-25T22:36:14.418+10:002009-05-25T22:36:14.418+10:00Ok figured it takes approx five seconds then the s...Ok figured it takes approx five seconds then the script terminates properly.<br /><br />I also noticed there are five TX packets sent via pppd when running the script. Should there be more traffic or is this ok as is? can I monitor the serial port somehow to see if the byte is sent?<br /><br />thanksDennishttps://www.blogger.com/profile/14843736797323763877noreply@blogger.comtag:blogger.com,1999:blog-7024729.post-32343801399603131562009-05-25T22:34:57.365+10:002009-05-25T22:34:57.365+10:00Nice work. Though I wouldn't expect it to hang......Nice work. Though I wouldn't expect it to hang...<br /><br />In case you haven't already, a quick check would be to put a couple of print statements in there so you can see how it's doing, like:<br /><br />print "message count: ", inboxTomhttps://www.blogger.com/profile/06694547908603725128noreply@blogger.comtag:blogger.com,1999:blog-7024729.post-85982830081313462002009-05-25T22:27:45.840+10:002009-05-25T22:27:45.840+10:00:D milllion thanks!
Now I've installed python-f...:D milllion thanks!<br /><br />Now I've installed python-feedparser and pyserial, slightly modified the gmail feed URL line to fit my locale needs, changed the virtual serial port to the one I'm using ("/dev/ttyUSB3") and and replaced the "username" and "password" in the "msgCount" call with my own ones.<br /><br />When I call my "emailcheck.py" script nothing happens, console window hangs.<br /><br />Guess its time to start building the hardware now, right? :)Dennishttps://www.blogger.com/profile/14843736797323763877noreply@blogger.comtag:blogger.com,1999:blog-7024729.post-83992186288674871632009-05-25T21:35:34.915+10:002009-05-25T21:35:34.915+10:00Hi Dennis,
To clarify, the code in the post is c...Hi Dennis, <br /><br />To clarify, the code in the post is cut down from the real script as the other bits are/were particular to my situation and not going to help anyone in general. I.e. it's setup for my GMail labels and did have stuff in there for the Windows system tray.<br /><br />To answer you question, cutting and pasting won't work as is, you'll need to "glue" it together into something that suits your circumstances. And the multiple calls I refered to are to GMail to get unread message counts in multiple labels, there is only one call to update the serial port.<br /><br />I'd suggest something like the following as a starting point:<br /><br />#!/usr/bin/python<br /># check gmail inbox and send signal via COM port<br />import feedparser, serial<br /><br />def msgCount(uid, pwd, filter):<br /> inbox = feedparser.parse("https://%s:%s@gmail.google.com/gmail/feed/atom%s" % (uid, pwd, filter))<br /> return (len(inbox["entries"]), ["%s: %s"%(e["author_detail"]["name"], e["title"]) for e in inbox["entries"]])<br /><br />def triggerAmbient(colour):<br /> com = serial.Serial("/dev/ttyUSB0", 2400, timeout=0.25)<br /> for attempt in range(0,10):<br /> com.write("%c" % (colour) )<br /> com.close()<br /><br />if __name__ == "__main__":<br /> inbox = msgCount("user name", "password", "") # unread messages in inbox<br /> colour = 7 if inbox > 0 else 0 # low three bits specify RGB leds<br /> triggerAmbient(colour)Tomhttps://www.blogger.com/profile/06694547908603725128noreply@blogger.comtag:blogger.com,1999:blog-7024729.post-30946615077513478252009-05-25T21:17:50.441+10:002009-05-25T21:17:50.441+10:00Hi,
Thanks for your quick reply. So if I just copy...Hi,<br />Thanks for your quick reply. So if I just copy & paste the three given code blocks the script will work? I ask since you mention calling some kind of function and sending serial data several times, I bet additional code is needed for this?<br /><br />The USB virtual serial port, pySerial and linux specific details should be no problem, just the python script is a miracle to me.Dennishttps://www.blogger.com/profile/14843736797323763877noreply@blogger.comtag:blogger.com,1999:blog-7024729.post-3656344401202821072009-05-25T20:40:44.369+10:002009-05-25T20:40:44.369+10:00Dennis, I posted an update regarding running this ...Dennis, I posted an <A HREF="http://successlessness.blogspot.com/2008/05/ambient-email-notifier-in-linux.html" REL="nofollow">update regarding running this in Linux</A>. It works fine, it's not really Windows specific.Tomhttps://www.blogger.com/profile/06694547908603725128noreply@blogger.comtag:blogger.com,1999:blog-7024729.post-73533784112357592742009-05-25T20:28:50.726+10:002009-05-25T20:28:50.726+10:00Hi all,
I'd like to build something like this...Hi all,<br /><br />I'd like to build something like this myself, but I'm not familiar with python at all..<br /><br />Nerval (or anyone), can I ask you to help me a bit with this maybe? The circuitry and picaxe progging should be no problem for me but I don't know where to start for a python script. I reckon Tom has posted some code snippets here on this blog for use as a gmail notifier with windows, but I'd rather like to have the pidgin notifier you mention. I further plan to build some nice email notification LED into my eeepc netbook at a later time, but first need to get things working with some kind of prototype before I open up my eeepc (obvious).<br /><br />I'd even try to learn python language for this, but currently my free time is spare due to having to mess with Softgrid and SQL server at work so learning a language would take forever until I'd arrive at something useful I'm afraid...<br /><br />If anyone can help me w/coding or preferably supply me with a working standalone python script to check for mail annd send data via serial port I'd be very grateful.<br /><br />I promise I'll build & donate a free email LED notifier (built in SMD form factor on tiny custom PCB) to the person helping me with this project.<br /><br />Now thats an offer isn't it!?<br /><br /><br />If you'd like to help out, please contact me at<br /><br />emailfuerdennis at web dot de<br /><br /><br />ThanksDennishttp://eeegadgets.blogspot.comnoreply@blogger.comtag:blogger.com,1999:blog-7024729.post-33612218059418637062008-08-01T23:06:00.000+10:002008-08-01T23:06:00.000+10:00I've just used this blog to make something similar...I've just used this blog to make something similar :)<BR/><BR/>It will display the build status of our subversion repo in the end but for now it's responding to a python dbus script which watches dbus for events from Pidgin and flashes an LED red for a new IM from an employee or green for an IM from anyone else :)<BR/><BR/>Handy when you've got 12 virtual desktops on the go :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7024729.post-27875516550082422722008-04-25T10:25:00.000+10:002008-04-25T10:25:00.000+10:00Will the picaxe has some really neat servo control...Will the picaxe has some really neat servo controls built into it. I bet you could do this very simply with a cheap servo.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7024729.post-44893501256170184582008-03-01T03:04:00.000+11:002008-03-01T03:04:00.000+11:00thanks i will try to start this project in a week ...thanks i will try to start this project in a week or 2 i am interested in making a little mailbox to mount onto of my flat screen monitor when there is mail the little arm swings up when ii have mail and after i have read the mail it flips down again im sure this will require harder coding but im sure one of my teachers could help me if im stuck could you possibly help me? <BR/><BR/>thanks again willWill Pricehttps://www.blogger.com/profile/10286527085817679928noreply@blogger.com