17 November 2009
Small Django patch to add full traceback for wrapper exception during template rendering
Here is a patch that I'm tending to apply to my Django (currently v1.1.1) trees to give me a full traceback on the wrapped exception when getting an exception during template processing. Without this patch you only get the string summary of the underlying exception -- often far from enough info to track down the actual bug. With this patch the result isn't that pretty (a full Python traceback as the string summary of the TemplateSyntaxError), but the info sure is helpful.
Read more »tags: django, patch, programming
0 comments11 November 2009
using gmail for outbound email on Mac OS X
Why?
At work I run a number of cron jobs: web log analysis scripts, metrics
gathering, db migration for beta versions of some sites, etc. However, one
thing I've been unable to use effectively on my Mac machines 1 is
the MAILTO facility of cron. Given a foo.cron script like this:
#!/bin/sh
export MAILTO=me@example.com
export SUBJECT="do some daily stuff"
...
that is run like this:
0 0 * * * $HOME/.../foo.cron > $HOME/var/log/do-some-daily-stuff.log
any output to stderr with be mailed to "me@example.com". That is, it would if outgoing email was setup for the currently running MTA (mail transfer agent) on that machine.
How?
On Mac OS X (since Leopard, I think) the default MTA is Postfix, and Postfix's terminology for "handle outbound email" is to set the "relayhost". This post explains how to configure Postfix on Mac OS X 10.5 (Tiger). What follows is my summary of the commands -- slightly different than the other post for clarity -- plus a few thoughts. Please read the other post for extra details.
# Create `/etc/postfix/relay_password` with auth information like this:
# smtp.gmail.com YOURNAME@gmail.com:YOURPASSWORD
$ sudo vi /etc/postfix/relay_password
$ cat /etc/postfix/relay_password
smtp.gmail.com YOURNAME@gmail.com:YOURPASSWORD
# Compile this to a Postfix lookup table...
$ sudo postmap /etc/postfix/relay_password
# ... and test it.
$ sudo postmap -q smtp.gmail.com /etc/postfix/relay_password
YOURNAME@gmail.com:YOURPASSWORD
# Download the Thawte root certificates from
# <https://www.verisign.com/support/roots.html> and setup
# a certificate for Postfix.
$ firefox https://www.verisign.com/support/roots.html
$ cd ~/Downloads
$ unzip -q roots.zip
$ sudo mkdir /etc/postfix/certs
$ sudo cp ~/Downloads/Thawte\ Root\ Certificates/Thawte\ Root\ Certificates/thawte\ Premium\ Server\ CA/Thawte\ Premium\ Server\ CA.pem /etc/postfix/certs
$ sudo c_rehash /etc/postfix/certs/
Doing /etc/postfix/certs/
Thawte Premium Server CA.pem => d44d72e8.0
# Add the following lines to `/etc/postfix/main.cf`:
relayhost = smtp.gmail.com:587
# auth
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/relay_password
smtp_sasl_security_options = noanonymous
# tls
smtp_tls_security_level = may
smtp_tls_CApath = /etc/postfix/certs
smtp_tls_session_cache_database = btree:/etc/postfix/smtp_scache
smtp_tls_session_cache_timeout = 3600s
smtp_tls_loglevel = 1
tls_random_source = dev:/dev/urandom
# Re-start the Postfix service. (Note: You can also do the re-starting via
# `launchctl`.)
sudo postfix stop
sudo postfix start
# Now test this by sending email with `mail`:
$ /usr/bin/mail -s "testing 1 2 3" recipient@example.com
Howdy, from Postfix on your Mac!
.
EOT
Now recipient@example.com should have received your test email. If not
check "/var/log/mail.log". Here is a successful log message:
Nov 10 23:33:26 mower postfix/smtp[56627]: ED1265BBA2A: to=<recipient@example.com>, relay=smtp.gmail.com[74.125.155.109]:587, delay=2.9, delays=0.44/0.94/0.56/0.96, dsn=2.0.0, status=sent (250 2.0.0 OK 1257924806 20sm930503pxi.15)
Here is a failing log message (in this case because I'd incorrectly mixed using "smtp.googlemail.com" instead of "smtp.gmail.com"):
Nov 10 21:32:14 mower postfix/smtp[55593]: C028D5BB6F8: to=<recipient@example.com>, relay=smtp.googlemail.com[74.125.155.16]:587, delay=0.33, delays=0.05/0.02/0.24/0.02, dsn=5.5.1, status=bounced (host smtp.googlemail.com[74.125.155.16] said: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257 20sm817933pxi.3 (in reply to MAIL FROM command))
A couple thoughts
This setup requires putting your Gmail password in plaintext in
/etc/postfix/relay_password, which I'm not too happy about. So I've created a
separate Gmail account with a different password to use for this.
One of the beauties of this setup is that there is a record of all the emails that have been sent this way in that Gmail account's "Sent mail".
-
I have a Macbook that is my main machine and a Mac Pro that is used for running most of our Komodo builds and some of the heavy log analysis scripts that I run. ↩
tags: macosx
0 comments22 October 2009
moving this blog to blogger
Meta note: I'm moving this blog to blogger (http://trentmick.blogspot.com/). Just test content there now. Hope to have that done in the next few days. If everything goes well, redirects should just make everything work.
Update: Mostly moved. Just working on redirects now.
tags: General
0 comments27 July 2009
Hannah Catherine Mick
Originally uploaded by trento.
I've been remiss in not blogging about my new daughter until now... tada! A lovely little girl. 7lb 4oz. Born on July 4th. All the appropriate bits. Everyone healthy. At times ominous hospital experience, but all good in the end. Ewan's (her almost 2 year old brother) latest thing is to kiss her on the forehead repeatedly. Big wet ones.
tags: General
3 comments04 June 2009
pleasant things work better
I watched Don Norman's TED Talk "3 ways good design makes you happy" last night:
This part of his talk really stuck out for me (transcription errors mine):
I really had the feeling that pleasant things work better and that never made any sense to me, until I finally figured it out. Look:
I'm gonna put a plank on the ground. So imagine I have a plank about 2' wide and 30' long. And I'm going to walk on it. See I can walk on it without looking, and go back and forth, and I can jump up and down. No problem. Now I'm going to put the plank 300' feet in the air... and I'm not going to go near it, thank you. Intense fear paralyzes you. It actually affects the way your brain works.
...
If you're happy, things work better because you're more creative. You get a little problem, you say "Ah, I'll figure it out. No big deal."
Read more »
tags: activestate, mozilla, personal, ui
3 comments26 May 2009
How to install MySQL-python 1.2.3c1 on Mac OS X
Introduction
Just a quick note on getting MySQL-python (aka import MySQLdb) 1.2.3c1 (the current latest version) to build and install on Mac OS X, because I hit something that I didn't see mentioned in a number of similar posts.
Here are some links that discuss getting MySQL-python to build on Mac OS X:
- MySQL-Python and Apple OSX 10.5 (Leopard)
- How to install Django with MySQL on Mac OS X
- Install MySQL-python on Mac OS X (leopard)
What follows are the steps (slightly different) that I needed to get MySQL-python to install.
Read more »tags: activestate, install, python
2 comments29 April 2009
Komodo 5.1.3 released
We (ActiveState) released Komodo 5.1.3 today. Get it here:
Or, if you are currently running any previous Komodo 5, click "Help > Check for Updates...". This is a bug fix release and is recommended for all users. See below for details.
Read more »tags: activestate, komodo, l10n, mozilla, programming, python
6 comments