~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 09:18:02 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:877
pulldown_subj/__init__.py: Added "enrol_user" function which pulls down a user
    and also enrols them in the database.
Added script enrolallusers.py which scriptulously performs automatic
enrolments of all users in the system, similar to remakeallusers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
import socket
28
28
import traceback
29
29
 
30
 
class Terminate(Exception):
31
 
    """Exception thrown when server is to be shut down. It will attempt to sned 
32
 
    the final_response to the client and then exits"""
33
 
    def __init__(self, final_response=None):
34
 
        self.final_response = final_response
35
 
 
36
 
    def __str__(self):
37
 
        return repr(self.final_response)
38
 
 
39
 
 
40
30
def start_server(port, magic, daemon_mode, handler, initializer = None):
41
31
    # Attempt to open the socket.
42
32
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
86
76
            conn.sendall(cjson.encode(response))
87
77
 
88
78
            conn.close()
89
 
 
90
 
        except Terminate, t:
91
 
            # Try and send final response and then terminate
92
 
            if t.final_response:
93
 
                conn.sendall(cjson.encode(t.final_response))
94
 
            conn.close()
95
 
            sys.exit(0)
96
79
        except Exception:
97
80
            # Make a JSON object full of exceptional goodness
98
81
            tb_dump = cStringIO.StringIO()