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

« back to all changes in this revision

Viewing changes to services/python-console

  • Committer: Matt Giuca
  • Date: 2010-03-22 06:05:32 UTC
  • Revision ID: matt.giuca@gmail.com-20100322060532-5365361xrx9mh32v
Changed database.py get_svn_url to take a req; include the req.user.login in the Subversion URL. This allows you to check out repositories without separately supplying the IVLE URL (as Subversion won't ask for a username by default). Also removed --username= from the lecturer project view, as it's redundant now. This fixes Launchpad bug #543936.

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
12
11
import Queue
13
12
import signal
14
13
import socket
181
180
 
182
181
        # Handlers for each action
183
182
        actions = {
 
183
            'splash': self.handle_splash,
184
184
            'chat': self.handle_chat,
185
185
            'block': self.handle_block,
186
186
            'globals': self.handle_globals,
198
198
                response = {'error': repr(e)}
199
199
            finally:
200
200
                self.cmdQ.put(response)
201
 
                   
 
201
 
 
202
    def handle_splash(self, params):
 
203
        # Initial console splash screen
 
204
        python_version = '.'.join(str(v) for v in sys.version_info[:3])
 
205
        splash_text = ("""IVLE %s Python Console (Python %s)
 
206
Type "help", "copyright", "credits" or "license" for more information.
 
207
""" % (ivle.__version__, python_version))
 
208
        return {'output': splash_text}
 
209
 
202
210
    def handle_chat(self, params):
203
211
        # Set up the partial cmd buffer
204
212
        if self.curr_cmd == '':
369
377
    """Handles response from signals"""
370
378
    global terminate
371
379
    if signum == signal.SIGXCPU:
372
 
        terminate = "CPU Time Limit Exceeded"
 
380
        terminate = "CPU time limit exceeded"
373
381
 
374
382
def dispatch_msg(msg):
375
383
    global terminate
376
384
    if msg['cmd'] == 'terminate':
377
 
        terminate = "User requested console be terminated"
 
385
        terminate = "User requested restart"
378
386
    if terminate:
379
387
        raise ivle.chat.Terminate({"terminate":terminate})
380
388
    expiry.ping()
399
407
    for o in object:
400
408
        try:
401
409
            flat[o] = cPickle.dumps(object[o], PICKLEVERSION)
402
 
        except TypeError:
 
410
        except (TypeError, cPickle.PicklingError):
403
411
            try:
404
412
                o_type = type(object[o]).__name__
405
413
                o_name = object[o].__name__
412
420
if __name__ == "__main__":
413
421
    port = int(sys.argv[1])
414
422
    magic = sys.argv[2]
415
 
    
416
 
    # Sanitise the Enviroment
417
 
    os.environ = {}
418
 
    os.environ['PATH'] = '/usr/local/bin:/usr/bin:/bin'
419
 
 
420
 
    if len(sys.argv) >= 4:
421
 
        # working_dir
422
 
        os.chdir(sys.argv[3])
423
 
        os.environ['HOME'] = sys.argv[3]
424
423
 
425
424
    # Make python's search path follow the cwd
426
425
    sys.path[0] = ''