# Get some basic modules import sys,time,string try: import ihPython # This fails on very old versions. except: pass import ihBrowser, ihDoc, ihMarkup, ihURL # Function to insert dynamic text into document. Given an existing # HTML tree and a dictionary mapping from names to HTML text, insert # that text into the sections of the HTML tree marked by # tag pairs. def insert_text(tree,dict): global ihMarkup #print 'ihMarkup module:', dir(ihMarkup) cursor = ihMarkup.NewHTMLCursor(tree) while cursor.MoveNextTag(ihMarkup.Tag.A): name = cursor.NodeAttr.ID if name and dict.has_key(name): cursor.PasteAfter(ihMarkup.NewHTMLTree(dict[name])) elif type(name) == type("") and name[:13] == "IHTML_PYTHON:": # Definitely a hack, but fun. :) # [When we are able to delete markup nodes, we'll put the # program inside the group, evaluate it, and replace # it with the results. And -that- will be cool. ;)] try: cursor.PasteAfter(ihMarkup.NewHTMLTree(eval(name[13:]))) except: cursor.PasteAfter(ihMarkup.NewHTMLTree( str(sys.get_exception()))) class ihMain(ihDoc.Document): def get_cap(self,name): cap = getattr(self.Capabilities,name) if( cap ): return "Yes" else: return "No" def __init__(self,**args): apply(ihDoc.Document.__init__,(self,),args) # For quick and easy reference dochtml = self.VisHTMLTree # Insert data into the document # Pick a picture based on the host name user_name = ihBrowser.UserName host_name = ihBrowser.HostName disp_pic = "s_jazzfromhell.gif" if host_name == "nwacse-h1r5e" or host_name == "nwacse-h4r5e": disp_pic = "s_manfromutopia.gif" elif host_name == "nwacse-h2r5e" or host_name == "nwacse-h5r5e": disp_pic = "s_yellowsharkback.gif" elif host_name == "nwacse-h3r5e": disp_pic = "s_youarewhatyouis.gif" if self.Capabilities.disp_color > 0: color_disp = "Yes (" + `self.Capabilities.disp_color` \ + " distinct pens)" else: color_disp = "No" if self.Capabilities.disp_true > 0: true_disp = "Yes (" + `self.Capabilities.disp_true` + \ " bits per pixel)" else: true_disp = "No" ih_version = '0' ih_revision = '0' ih_subbuild = '0' ih_builddate = '?' try: ih_version = str(ihPython.Version) ih_revision = str(ihPython.Revision) ih_subbuild = str(ihPython.SubBuild) ih_builddate = ihPython.BuildDate except: pass insert_text(dochtml, { "IH_VERSION": str(ihBrowser.IHVersion), "IH_REVISION": str(ihBrowser.IHRevision), "IH_SUBBUILD": str(ihBrowser.IHSubBuild), "BR_NAME": str(ihBrowser.BRFullName), "BR_CODE": str(ihBrowser.BRName), "BR_VERSION": str(ihBrowser.BRVersion), "BR_REVISION": str(ihBrowser.BRRevision), "BUILDDATE": str(ihBrowser.BuildDate), "PY_VERSION": ih_version, "PY_REVISION": ih_revision, "PY_SUBBUILD": ih_subbuild, "PY_BUILDDATE": ih_builddate, "PY_LANGVER": sys.version, "PY_LANGCOPY": sys.copyright, "PY_PLATFORM": sys.platform, "PY_MAXINT": str(sys.maxint), "PY_MODULES": str(sys.builtin_module_names), "USER_NAME": ihBrowser.UserName, "USER_MACHINE": ihURL.GetHostName() + " (" \ + ihURL.GetHostByName(ihURL.GetHostName()) \ + ")", "SOCKETS": self.get_cap("sockets"), "MOSAIC": self.get_cap("mosaic"), "TEXT_DISP": self.get_cap("disp_text"), "GFX_DISP": self.get_cap("disp_graphics"), "COLOR_DISP": color_disp, "TRUE_DISP": true_disp, "VIEW_WIDTH": str(self.ViewWidth), "VIEW_HEIGHT": str(self.ViewHeight), "DISP_PIC": '' } ) self.ShowProgress() # Display the document. self.VisHTMLTree = dochtml self.Reformat() __export__ = ['ihMain']
Dianne Kyra Hackborn <hackbod@angryredplanet.com> | Last modified: Wed Aug 14 14:54:38 PDT 1996 |