using os.popen leaves you potentially vulnerable to attack.  I would use a 
mail API that way you reduce the possibility of shell injection.  If 
someone is crafty enough they may be able to break out of your mail 
notification and execute arbitrary commands as your web user.

Neat approach, I would just consider that.

My $0.02

On Friday, September 28, 2012 7:02:48 PM UTC-4, Michael Toomim wrote:
>
> If you want a realtime solution, you can trigger an email on each error. 
> Here's a sketch:
>
> 1. Add an error handler to routes.py:
>
> routes_onerror = [
>     ('appname/*', '/appname/default/show_error')
>     ]
>
> 2. and in default.py:
>
> def show_error():
>     Scheduler.insert(function_name='send_self_email',
>                      vars=sj.dumps({ticket=request.vars.ticket}))
>     return 'Server Error.  Super sorry about that!  We be lookin into it.'
>
> 3. Now in a models file add the scheduler email function:
>
> def send_self_email(ticket):
>     message = 'http://%s:%s/admin/default/ticket/%s' % 
> (server,port,ticket)
>     SENDMAIL = "/usr/sbin/sendmail" # sendmail location
>     import os
>     p = os.popen("%s -t" % SENDMAIL, "w")
>     p.write("To: " + email_address + "\n")
>     p.write("Subject: " + subject + "\n")
>     p.write("\n") # blank line separating headers from body
>     p.write(message)
>     p.write("\n")
>     status = p.close()
> Scheduler(db)
>
> 4. Run the scheduler with the server with python web2py.py -K appname -X
>
> On Thursday, September 27, 2012 5:32:36 AM UTC-7, Hassan Alnatour wrote:
>>
>> Dear ALL ,
>>
>> Is there a way to make all the error be sent to my email when it happens ?
>>
>> Best regards,
>>
>

-- 



Reply via email to