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

« back to all changes in this revision

Viewing changes to console/python-console

  • Committer: dilshan_a
  • Date: 2008-01-25 03:09:19 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:304
Added documentation of output of TestSuite.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
        Thread.__init__(self)
38
38
 
39
39
    def run(self):
40
 
        globs = {}
41
 
        globs['__builtins__'] = globals()['__builtins__']
42
 
        locls = {}
 
40
        self.init_state()
43
41
        compiler = codeop.CommandCompiler()
44
 
        curr_cmd = ''
45
42
 
46
43
        while True:
47
44
            l = self.lineQ.get()
48
 
            if curr_cmd == '':
49
 
                curr_cmd = l
 
45
            if self.curr_cmd == '':
 
46
                self.curr_cmd = l
50
47
            else:
51
 
                curr_cmd = curr_cmd + '\n' + l
 
48
                self.curr_cmd = self.curr_cmd + '\n' + l
52
49
            try:
53
 
                cmd = compiler(curr_cmd)
 
50
                cmd = compiler(self.curr_cmd)
54
51
                if cmd is None:
55
52
                    # The command was incomplete,
56
53
                    # so send back a None, so the
73
70
                self.cmdQ.put({"exc":str(exc)})
74
71
                curr_cmd = ''
75
72
 
 
73
    def init_state(self):
 
74
        self.globs = {}
 
75
        self.globs['__builtins__'] = globals()['__builtins__']
 
76
        self.locls = {}
 
77
        self.curr_cmd = ''
 
78
 
76
79
urls = (
77
80
    '/',            'index',
78
81
    '/index.html',  'index',
116
119
        # Authenticate
117
120
        digest = md5.new(inp.text + magic).digest().encode('hex')
118
121
        if inp.digest != digest:
 
122
            web.output("401 Unauthorized")
119
123
            web.ctx.status = '401 Unauthorized'
120
124
            return
121
125
 
132
136
interpThread = PythonRunner(cmdQ, lineQ)
133
137
 
134
138
if __name__ == "__main__":
135
 
    # FIXME jail!
136
139
    magic = sys.argv[2]
 
140
    interpThread.setDaemon(True)
137
141
    interpThread.start()
138
142
    web.run(urls, globals())