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

« back to all changes in this revision

Viewing changes to services/python-console

  • Committer: David Coles
  • Date: 2010-02-26 10:42:31 UTC
  • Revision ID: coles.david@gmail.com-20100226104231-nm6tfvkgox7xulz7
interpret: Fix execute_raw's printing of stderr - can't read pipe after communicate returns.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
import cPickle
9
9
import cStringIO
10
10
import md5
 
11
import os
11
12
import Queue
12
13
import signal
13
14
import socket
170
171
 
171
172
    def run(self):
172
173
        # Set up global space and partial command buffer
173
 
        self.globs = {'__name__': '__main__'}
 
174
        self.globs = {}
174
175
        self.curr_cmd = ''
175
176
 
176
177
        # Set up I/O to use web interface
262
263
    def handle_globals(self, params):
263
264
        # Unpickle the new space (if provided)
264
265
        if isinstance(params, dict):
265
 
            self.globs = {'__name__': '__main__'}
 
266
            self.globs = {}
266
267
            for g in params:
267
268
                try:
268
269
                    self.globs[g] = cPickle.loads(params[g])
420
421
if __name__ == "__main__":
421
422
    port = int(sys.argv[1])
422
423
    magic = sys.argv[2]
 
424
    
 
425
    # Sanitise the Enviroment
 
426
    os.environ = {}
 
427
    os.environ['PATH'] = '/usr/local/bin:/usr/bin:/bin'
 
428
 
 
429
    if len(sys.argv) >= 4:
 
430
        # working_dir
 
431
        os.chdir(sys.argv[3])
 
432
        os.environ['HOME'] = sys.argv[3]
423
433
 
424
434
    # Make python's search path follow the cwd
425
435
    sys.path[0] = ''