Changeset 2454 for package_branches/invirt-web/cherrypy/code/ajaxterm.py
- Timestamp:
- Aug 21, 2009, 12:42:41 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
package_branches/invirt-web/cherrypy/code/ajaxterm.py
r2435 r2454 3 3 """ Ajaxterm """ 4 4 5 import array,cgi,fcntl,glob, mimetypes,optparse,os,pty,random,re,signal,select,sys,threading,time,termios,struct,pwd5 import array,cgi,fcntl,glob,hashlib,mimetypes,optparse,os,pty,random,re,signal,select,sys,threading,time,termios,struct,pwd 6 6 7 7 os.chdir(os.path.normpath(os.path.dirname(__file__))) … … 101 101 self.buf="" 102 102 self.outbuf="" 103 self.last_html=""104 103 def peek(self,y1,x1,y2,x2): 105 104 return self.scr[self.width*y1+x1:self.width*y2+x2] … … 321 320 def dumplatin1(self): 322 321 return self.dump().translate(self.trl1) 323 def dumphtml(self,color=1, force=False):322 def dumphtml(self,color=1,last_hash=None): 324 323 h=self.height 325 324 w=self.width … … 343 342 if i%w==w-1: 344 343 span+='\n' 345 r='<?xml version="1.0" encoding="ISO-8859-1"?><pre class="term">%s</pre>'%r 346 if self.last_html==r and not force: 344 hash = hashlib.md5(r).hexdigest() 345 r='<?xml version="1.0" encoding="ISO-8859-1"?><pre class="term" id="%s">%s</pre>'% (hash,r) 346 if last_hash == hash: 347 347 return '<?xml version="1.0"?><idem></idem>' 348 348 else: 349 self.last_html=r350 # print self351 349 return r 352 350 def __repr__(self): … … 437 435 except (IOError,OSError): 438 436 self.proc_kill(fd) 439 def dump(self,fd,color=1, force=False):437 def dump(self,fd,color=1,last_hash=None): 440 438 try: 441 return self.proc[fd]['term'].dumphtml(color, force)439 return self.proc[fd]['term'].dumphtml(color, last_hash) 442 440 except KeyError: 443 441 return False
Note: See TracChangeset
for help on using the changeset viewer.