Python and SDK5.1 are just terrific!!!
Siggi
smusnmrNOSPAM at yahoo.com
Sat Jan 6 14:00:24 EST 2007
Thanks, Jussi, for your post, but I found that PythonWin's SDK5.0 option
works well with MS SDk5.1.
Just had an Email read for me using a small Python program: correct English,
even the date such as 12/06/06 was correctly transformed into the names of
the month and year. Python is great1
Siggi
"Jussi Salmela" <tiedon_jano at hotmail.com> schrieb im Newsbeitrag
news:0Kynh.432$sE.358 at read3.inet.fi...
> Siggi kirjoitti:
>> Gabriel Genellina wrote:
>>
>>> After you download and install version 5.1, it should appear on the
>>> list.
>>
>> It should, but it does not! Shutting down and starting the WinXP Home
>> system anew did not help.
>> The SDK 5.1 installation went smoothly, however. What can I do to find
>> out
>> what is wrong?
>>
>> siggi
>>
>
>
> (Sorry for the long post!)
>
>
> Unfortunately I can't comment on this 5.0/5.1 issue but if you look at
> page
> http://www.cs.unc.edu/~parente/tech/tr02.shtml
> you'll find the pyTTS system. I've used it and everything works.
>
> The funny thing is that the page has a link named "Microsoft SAPI 5.1
> redistributable" which links to
> http://www.cs.unc.edu/Research/assist/packages/SAPI5SpeechInstaller.msi
> ie. a SAPI 5 installer. So I'm starting to wonder if it matters at all
> whether the speech kit is a version 5 or 5.1.
>
> Anyway: pyTTS works with Python 2.4 as advertized in the accompanying
> examples. I've used it to resolve the following dilemma: how to guarantee
> that I'm aware of new mail appearing on my ISP.
>
> I had an unfortunate experience where a guy I was working with sent me (to
> my home) mail that I didn't expect to receive just at the moment and to
> which I would have liked to react immediately. Why I didn't notice the
> mail coming: I was outside my house pumping more air to my wife's bicycle
> tires! The mail notification was shown and erased and one more icon among
> the more than dozen icons on my Windows System Tray didn't account for
> much.
>
> So I figured out that a voice to remind me would be nice. I have a low
> rate inbox, usually only a maximum of hald a dozen messages per day so I
> wouldn't have to listen the voice all day long. So the voice keeps
> repeating that I have new mail at my ISP until I download the mail and
> otherwise keeps quiet. So here is my program and a skeleton of the INI
> file it uses. The program is not finished (I have a few ideas still) but
> it runs all day long on my computer keeping me happy.
>
> ==========================
> New Email Notifier.py
> ==========================
> #!/usr/bin/python
>
> '''
> License: MIT License. See License.txt. If that file is not attached,
> the license is http://www.opensource.org/licenses/mit-license.php,
> where
> <year> = 2006 and <copyright holders> = Jussi Salmela, Turku, Finland
> '''
>
> # This program checks for new email at ISP and notifies if new email is
> found
>
> import win32serviceutil
> import win32service
> import win32event
> import pyTTS, sys, os, poplib, logging, time
> import ConfigParser,pywintypes
>
> print '\nThis is the New Mail Notifier window\n'
> notifierDirectory = r'C:\Python\OMAT___PROJEKTIT\New Email Notifier
> Service'
> logging.basicConfig(level=logging.DEBUG,
> format='%(asctime)s %(levelname)-8s %(message)s',
> filename=notifierDirectory+r'\error.log')
> logging.info('=========================================================')
> logging.info('New Email Notifier Service started')
> config = ConfigParser.ConfigParser()
> config.readfp(open(notifierDirectory+r'\New Email Notifier.INI'))
> POP3Server = config.get('POP3','server')
> POP3Account = config.get('POP3','account')
> POP3Password = config.get('POP3','password')
> totalMessagesFormat = config.get('messages','total_message')
> newMessagesFormat = config.get('messages','new_message')
> wakeupMessageFormat = config.get('messages','wakeup_message')
>
> tts = pyTTS.Create()
> #set the speech volume percentage (0-100%)
> tts.Volume = 100
> #explicitly set a voice
> tts.SetVoiceByName(u'MSMary')
>
> uidDict = {}
> # We wait to be stopped and check for new email every maxTimeToWait
> seconds
> maxTimeToWait = 1 # First check after 1 second
> while True:
> time.sleep(maxTimeToWait)
> maxTimeToWait = 60 # Rest of the checks after 60 second
> try:
> # Connect to the ISP
> a = poplib.POP3(POP3Server,110)
> answer = a.getwelcome()
> if answer[0:3] != '+OK':
> raise ValueError,'a.getwelcome returned: ' + answer
> answer = a.user(POP3Account)
> if answer[0:3] != '+OK':
> raise ValueError,'a.user returned: ' + answer
> if answer[4:] == 'Password required':
> answer = a.pass_(POP3Password)
> if answer[0:3] != '+OK':
> raise ValueError,'a.pass_ returned: ' + answer
> answer = a.uidl()
> if answer[0][0:3] != '+OK':
> raise ValueError,'a.uidl returned: ' + repr(answer)
> a.quit()
> # Connection closed. Start handling the unique message identifiers
> #logging.info('Connection succesfully opened, used and closed!')
> print 'answer', answer, time.asctime()
> uidList = [e.split()[1] for e in answer[1]]
> print 'uidList', uidList
> totalMessages = len(uidList)
> uidDictNew = {}
> for e in uidList: uidDictNew[e] = True
> uidList = [e for e in uidList if e not in uidDict]
> uidDict = uidDictNew
> if totalMessages:
> tts.Speak(totalMessagesFormat % totalMessages)
> newMessages = len(uidList)
> if newMessages:
> tts.Speak(newMessagesFormat % newMessages)
> except Exception,inst:
> errorMsg = 'Unexpected error: %s' % sys.exc_info()[0]
> logging.error(errorMsg)
> logging.error(inst)
> try:
> tts.Speak(wakeupMessageFormat)
> tts.Speak('I repeat: ' + wakeupMessageFormat)
> tts.Speak(errorMsg)
> tts.Speak(inst)
> except pywintypes.com_error,inst:
> errorMsg = 'Unexpected error: %s' % sys.exc_info()[0]
> logging.error(errorMsg)
> logging.error(inst)
>
> ==========================
> New Email Notifier.INI
> ==========================
> [POP3]
> server: myPOPserver
> account: myAcoount
> password: myPassword
> [messages]
> total_message: Your eemail server has. a total of %d messages. for you to
> download
> new_message: The number of new messages. since the last check. is %d
> wakeup_message: Wake up, Youssi! This is your new eemail notifier,
> reporting the following error!
>
> HTH,
> Jussi
More information about the Python-list
mailing list