Ignore:
Timestamp:
Dec 21, 2009, 1:12:05 AM (14 years ago)
Author:
broder
Message:

Use browser-based dupe suppression, so multiple clients can connect to the same terminal and not miss updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • package_branches/invirt-web/ajaxterm-rebased/code/ajaxterm.py

    r2753 r2761  
    33""" Ajaxterm """
    44
    5 import array,cgi,fcntl,glob,mimetypes,optparse,os,pty,random,re,signal,select,sys,threading,time,termios,struct,pwd
     5import array,cgi,fcntl,glob,hashlib,mimetypes,optparse,os,pty,random,re,signal,select,sys,threading,time,termios,struct,pwd
    66
    77os.chdir(os.path.normpath(os.path.dirname(__file__)))
     
    101101                self.buf=""
    102102                self.outbuf=""
    103                 self.last_html=""
    104103        def peek(self,y1,x1,y2,x2):
    105104                return self.scr[self.width*y1+x1:self.width*y2+x2]
     
    321320        def dumplatin1(self):
    322321                return self.dump().translate(self.trl1)
    323         def dumphtml(self,color=1,force=False):
     322        def dumphtml(self,color=1,last_hash=None):
    324323                h=self.height
    325324                w=self.width
     
    343342                        if i%w==w-1:
    344343                                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:
    347347                        return '<?xml version="1.0"?><idem></idem>'
    348348                else:
    349                         self.last_html=r
    350 #                       print self
    351349                        return r
    352350        def __repr__(self):
     
    437435                except (IOError,OSError):
    438436                        self.proc_kill(fd)
    439         def dump(self,fd,color=1,force=False):
     437        def dump(self,fd,color=1,last_hash=None):
    440438                try:
    441                         return self.proc[fd]['term'].dumphtml(color, force)
     439                        return self.proc[fd]['term'].dumphtml(color, last_hash)
    442440                except KeyError:
    443441                        return False
Note: See TracChangeset for help on using the changeset viewer.