Migrate code to py24.

Changes:
  * with statment -> with_ decorator
  * urllib2 .getcode() -> .code
  * except T as e -> except T, e
Catch and log unexpected errors in daemon mode.