- Timestamp:
- Dec 21, 2009, 1:11:45 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
package_branches/invirt-web/ajaxterm-rebased/code/main.py
r2754 r2756 1 1 #!/usr/bin/python 2 2 """Main CGI script for web interface""" 3 4 from __future__ import with_statement 3 5 4 6 import base64 … … 11 13 import sha 12 14 import sys 15 import threading 13 16 import time 14 17 import urllib … … 392 395 atmulti = ajaxterm.Multiplex() 393 396 atsessions = {} 397 atsessions_lock = threading.Lock() 394 398 395 399 @cherrypy.expose … … 411 415 def at(self, machine_id, k=None, c=0, force=0): 412 416 machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine 413 if machine_id in self.atsessions: 414 term = self.atsessions[machine_id] 415 else: 416 print >>sys.stderr, "spawning new session for terminal to ",machine_id 417 term = self.atsessions[machine_id] = self.atmulti.create( 418 ["ssh", "-e","none", "-l", machine.name, config.console.hostname] 419 ) 420 if k: 421 self.atmulti.proc_write(term,k) 422 time.sleep(0.002) 423 dump=self.atmulti.dump(term,c,int(force)) 424 cherrypy.response.headers['Content-Type']='text/xml' 425 if isinstance(dump,str): 426 return dump 427 else: 428 print "Removing session for", machine_id 429 del self.atsessions[machine_id] 430 return '<?xml version="1.0"?><idem></idem>' 417 with self.atsessions_lock: 418 if machine_id in self.atsessions: 419 term = self.atsessions[machine_id] 420 else: 421 print >>sys.stderr, "spawning new session for terminal to ",machine_id 422 term = self.atsessions[machine_id] = self.atmulti.create( 423 ["ssh", "-e","none", "-l", machine.name, config.console.hostname] 424 ) 425 if k: 426 self.atmulti.proc_write(term,k) 427 time.sleep(0.002) 428 dump=self.atmulti.dump(term,c,int(force)) 429 cherrypy.response.headers['Content-Type']='text/xml' 430 if isinstance(dump,str): 431 return dump 432 else: 433 print "Removing session for", machine_id 434 del self.atsessions[machine_id] 435 return '<?xml version="1.0"?><idem></idem>' 431 436 432 437 machine = MachineView()
Note: See TracChangeset
for help on using the changeset viewer.