Changeset 2752 for package_branches/invirt-web
- Timestamp:
- Dec 21, 2009, 1:11:31 AM (15 years ago)
- Location:
- package_branches/invirt-web/ajaxterm-rebased/code
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
package_branches/invirt-web/ajaxterm-rebased/code/main.py
r2751 r2752 406 406 hostname=cherrypy.request.local.name) 407 407 return d 408 409 @cherrypy.expose 410 def at(self, machine_id, k=None, c=0): 411 machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine 412 if machine_id in self.atsessions: 413 term = self.atsessions[machine_id] 414 else: 415 print >>sys.stderr, "spawning new session for terminal to ",machine_id 416 term = self.atsessions[machine_id] = self.atmulti.create( 417 ["ssh", "-e","none", "-l", machine.name, config.console.hostname] 418 ) 419 if k: 420 self.atmulti.proc_write(term,k) 421 time.sleep(0.002) 422 dump=self.atmulti.dump(term,c) 423 cherrypy.response.headers['Content-Type']='text/xml' 424 if isinstance(dump,str): 425 return dump 426 else: 427 del self.atsessions[machine_id] 428 return '<?xml version="1.0"?><idem></idem>' 408 429 409 430 machine = MachineView() -
package_branches/invirt-web/ajaxterm-rebased/code/static/ajaxterm/ajaxterm.js
r2747 r2752 1 1 ajaxterm={}; 2 ajaxterm.Terminal_ctor=function(id, width,height) {2 ajaxterm.Terminal_ctor=function(id,machine_id) { 3 3 var ie=0; 4 4 if(window.ActiveXObject) 5 5 ie=1; 6 var sid=""+Math.round(Math.random()*1000000000);7 var query0=" s="+sid+"&w="+width+"&h="+height;6 var base_path="machine/"+machine_id+"/at"; 7 var query0=""; 8 8 var query1=query0+"&c=1&k="; 9 9 var buf=""; … … 104 104 var query=query1+send; 105 105 if(opt_get.className=='on') { 106 r.open("GET", "u?"+query,true);106 r.open("GET",base_path+"?"+query,true); 107 107 if(ie) { 108 108 r.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); 109 109 } 110 110 } else { 111 r.open("POST", "u",true);111 r.open("POST",base_path,true); 112 112 } 113 113 r.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); … … 274 274 init(); 275 275 } 276 ajaxterm.Terminal=function(id, width,height) {277 return new this.Terminal_ctor(id, width,height);276 ajaxterm.Terminal=function(id,machine_id) { 277 return new this.Terminal_ctor(id,machine_id); 278 278 } 279 279 -
package_branches/invirt-web/ajaxterm-rebased/code/templates/terminal.mako
r2751 r2752 21 21 <script type="text/javascript"> 22 22 window.onload=function() { 23 t=ajaxterm.Terminal("term", 80,25);23 t=ajaxterm.Terminal("term", ${machine.machine_id}); 24 24 } 25 25 </script> … … 27 27 28 28 <div id="term"></div> 29 <div style="clear: both;"></div>
Note: See TracChangeset
for help on using the changeset viewer.