[PythonCE] PythonCE and SSL

Adam Walley adam.walley at gmail.com
Tue Mar 30 17:18:54 CEST 2010


Success!

Using the TLSLite package I was able to achieve what I was aiming for - that
is to access Gmail programmatically from PythonCE. For anyone interested,
this is how I got there (after quite a bit of puzzling and trawling through
the net):

Having downloaded the TLSLite-0.3.8 package, I placed the 'tlslite' folder
into my 'Lib/site-packages' without any modifications. Now it would be
accessible to any of my PythonCE scripts. Next, I wrote the following
script:

------ Example PythonCE code ------

import base64, string
from tlslite.api import *

user="anyuser"
passwd="whatever"
h=HTTPTLSConnection("mail.google.com",443)
auth="Basic "+string.strip(base64.encodestring(user+":"+passwd))
h.putrequest("GET","/mail/feed/atom")
h.putheader("Authorization",auth)
h.endheaders()
r=h.getresponse()
txt=r.read()
msgs=txt[txt.index("<fullcount>")+11:txt.index("</fullcount>")]
raw=raw_input("inbox("+msgs+")")

------ Example PythonCE code ------

the above simply connects on port 443 (https) to the Gmail atom feed and
returns an XML message about new messages in the inbox, which is then
searched for the number of new messages. It's not the fastest thing in the
world, but it works.

Adam.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythonce/attachments/20100330/9ded6fb0/attachment.html>


More information about the PythonCE mailing list