How to transmit a crash report ?

Stef Mientki stef.mientki at gmail.com
Tue Feb 23 22:54:36 CET 2010


On 23-02-2010 15:21, Thomas wrote:
> On Feb 22, 9:27 pm, MRAB<pyt... at mrabarnett.plus.com>  wrote:
>    
>> Stef Mientki wrote:
>>      
>>> hello,
>>>        
>>      
>>> in my python desktop applications,
>>> I'ld like to implement a crash reporter.
>>> By redirecting the sys.excepthook,
>>> I can detect a crash and collect the necessary data.
>>> Now I want that my users sends this information to me,
>>> and I can't find a good way of doing this.
>>>        
>>      
>>> The following solutions came into my mind:
>>> (most of my users are on Windows, and the programs are written in Python
>>> 2.6)
>>>        
>>      
>>> 1. mailto:
>>> doesn't work if the the user didn't install a default email client,
>>> or if the user uses a portable email client (that isn't started yet)
>>> Besides this limits the messages to small amounts of data.
>>>        
>>      
>>> 2.other mail options: smtp
>>> AFAIK such a solution needs smtp authorization, and therefor I've to put
>>> my username and password in the desktop application.
>>>        
>> Try reading the documentation for Python's smtplib module.
>>
>> You don't need to provide any password.
>>
>>
>>
>>      
>>> 3. http-post
>>> Although post is also limited in size,
>>> I could store information in cookies (don't know yet how), and cookies
>>> are sent parallel to the post message.
>>> On the server site I can use a small php script, that stores the
>>> post-data, cookies and/or send's a (long) email.
>>>        
>>      
>>> are there better options ?- Hide quoted text -
>>>        
>> - Show quoted text -- Hide quoted text -
>>
>> - Show quoted text -
>>      
> Try http://code.activestate.com/recipes/442459/
>    

Apparently there's something terrible wrong on my system, because I do 
need username and password :-(

First, a script that works without username and password.
I guess it works, because the smtp_server is the smtp server of my 
provider, and I'm in that domain of my provider,
so it won't work for a random user of my program.
   if Test ( 4 ) :
     import smtplib
     from email.mime.text      import MIMEText
     from email.mime.multipart import MIMEMultipart

     body     = 'test_body'
     subject  = 'test_subject'
     mail_to  = 's.mientki at ru.nl'
     mail_from = 'stef.mientki at gmail.com'

     msg = MIMEMultipart ( 'alternative' )
     msg [ 'To'      ] = mail_to
     msg [ 'From'    ] = mail_from
     msg [ 'Subject' ] = subject

     part1 = MIMEText ( body, 'plain' )
     msg.attach ( part1 )

     smtp_server = 'mail.upcmail.nl'
     session = smtplib.SMTP ( smtp_server )
     session.sendmail ( mail_from, [mail_to], msg.as_string() )


Using smtp on google , works only if I support username and password:
   if Test ( 5 ) :
     import smtplib
     from email.mime.text      import MIMEText
     from email.mime.multipart import MIMEMultipart

     body     = 'test_body'
     subject  = 'test_subject'
     mail_to  = 's.mientki at ru.nl'
     mail_from = 'stef.mientki at gmail.com'

     msg = MIMEMultipart ( 'alternative' )
     msg [ 'To'      ] = mail_to
     msg [ 'From'    ] = mail_from
     msg [ 'Subject' ] = subject

     part1 = MIMEText ( body, 'plain' )
     msg.attach ( part1 )

     smtp_server = 'smtp.gmail.com'
     session = smtplib.SMTP ( smtp_server, 587 )
     session.ehlo ( mail_from )
     session.starttls ()
     session.ehlo ( mail_from )
     session.login (username, password )
     session.sendmail ( mail_from, [mail_to], msg.as_string() )


And her a number of different tries with localhost / mail :
   if Test ( 6 ) :
     import smtplib
     from email.mime.text      import MIMEText
     from email.mime.multipart import MIMEMultipart

     body     = 'test_body'
     subject  = 'test_subject'
     mail_to  = 's.mientki at ru.nl'
     mail_from = 'stef.mientki at gmail.com'

     msg = MIMEMultipart ( 'alternative' )
     msg [ 'To'      ] = mail_to
     msg [ 'From'    ] = mail_from
     msg [ 'Subject' ] = subject

     part1 = MIMEText ( body, 'plain' )
     msg.attach ( part1 )

     session = smtplib.SMTP ( 'localhost' )
     """
Traceback (most recent call last):
   File "D:\Data_Python_25\support\mail_support.py", line 375, in <module>
     session = smtplib.SMTP ( smtp_server )
   File "P:\Python26\lib\smtplib.py", line 239, in __init__
     (code, msg) = self.connect(host, port)
   File "P:\Python26\lib\smtplib.py", line 295, in connect
     self.sock = self._get_socket(host, port, self.timeout)
   File "P:\Python26\lib\smtplib.py", line 273, in _get_socket
     return socket.create_connection((port, host), timeout)
   File "P:\Python26\lib\socket.py", line 514, in create_connection
     raise error, msg
error: [Errno 10061] No connection could be made because the target 
machine actively refused it
     """
     #session = smtplib.SMTP ( 'localhost', 25 )
     #session = smtplib.SMTP ( 'mail', 25 )
     session = smtplib.SMTP ( 'mail', 1025 )
     """
Traceback (most recent call last):
   File "D:\Data_Python_25\support\mail_support.py", line 377, in <module>
     session = smtplib.SMTP ( 'mail', 1025 )
   File "P:\Python26\lib\smtplib.py", line 239, in __init__
     (code, msg) = self.connect(host, port)
   File "P:\Python26\lib\smtplib.py", line 295, in connect
     self.sock = self._get_socket(host, port, self.timeout)
   File "P:\Python26\lib\smtplib.py", line 273, in _get_socket
     return socket.create_connection((port, host), timeout)
   File "P:\Python26\lib\socket.py", line 500, in create_connection
     for res in getaddrinfo(host, port, 0, SOCK_STREAM):
gaierror: [Errno 11001] getaddrinfo failed
     """
     session.sendmail ( mail_from, [mail_to], msg.as_string() )


What am I doing wrong ?

cheers,
Stef

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100223/99e0ea8d/attachment.html>


More information about the Python-list mailing list