~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to lib/common/chat.py

  • Committer: mattgiuca
  • Date: 2008-07-15 07:19:34 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:875
Added "migrations" directory, which contains incremental database update
    scripts.
Updated users.sql, uniqueness key on offering table.
Added migration matching this update to the migrations directory. Mm handy!

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import cjson
23
23
import cStringIO
24
24
import md5
 
25
import sys
25
26
import os
26
27
import socket
 
28
import traceback
27
29
 
28
30
def start_server(port, magic, daemon_mode, handler, initializer = None):
29
31
    # Attempt to open the socket.
74
76
            conn.sendall(cjson.encode(response))
75
77
 
76
78
            conn.close()
77
 
        except Exception, e:
78
 
            conn.sendall(cjson.encode(repr(e)))
 
79
        except Exception:
 
80
            # Make a JSON object full of exceptional goodness
 
81
            tb_dump = cStringIO.StringIO()
 
82
            e_type, e_val, e_tb = sys.exc_info()
 
83
            traceback.print_tb(e_tb, file=tb_dump)
 
84
            json_exc = {
 
85
                "type": e_type.__name__,
 
86
                "value": str(e_val),
 
87
                "traceback": tb_dump.getvalue()
 
88
            }
 
89
            conn.sendall(cjson.encode(json_exc))
79
90
            conn.close()
80
91
 
81
92