We show the code, using the mean and lean QP web framework for future reference.
More details are avaiable from the link Digital Explorations, our main blog site.
from qp.sites.extreme.lib.config import image_dir, homeurl
__version__ = "0.0.1 2008.10.23"
__date__    = "2008.10.23"
__catalog__ = "SERV-NETTOOLS-001"
__author__  = "ernesto.adorio@gmail.com"
__url__     = homeurl + "services/nettools/"
__title__   = "NetTools Service Page"
from qp.fill.css        import BASIC_FORM_CSS
from qp.fill.directory  import Directory
from quixote.errors     import PublishError
from quixote.util       import dump_request
from qp.fill.form       import Form
from qp.fill.widget    import CheckboxWidget,StringWidget,SingleSelectWidget, StringWidget, TextWidget
from qp.pub.common      import header, footer, page, redirect
from   qp.sites.extreme.lib.uicommon import renderheader, renderfooter, processheader, processfooter
import time
import urllib
import urllib, urllib2, os
from  qp.sites.extreme.lib.webutils  import before, after
from  qp.sites.extreme.lib import config
def getstatusoutput(command):
     """
     Fredrick Lundh 
     http://mail.python.org/pipermail/python-list/2006-October/406444.html 
     """
     from subprocess import Popen, PIPE, STDOUT
     p = Popen(command, stdout=PIPE, stderr=STDOUT, shell=True)
     s = p.stdout.read().split("\n")
     return p.wait(), s
def isAddressOK(Address):
    """
    Check for bad addresses.
    """
    #Quickie checks.
    if " " in Address:
       return False,"Embedded blanks are not allowed inside addresses"
    if "." not in Address:
       return False
    if Address.startswith("-"): # attempt to hack?
       return False, "Addresses do not start with a dash (-)."
    #Pure numeric address?
    return True, "Ok"
class NetToolsPage(Directory):
    def get_exports(self):
        yield '', 'index', 'NetTools server', None
    def index (self):
        form  = Form(enctype = "multipart/form-data")  # enctype for file upload
 form.add(StringWidget, name = "Address", value = "www.adorio-research.org", size = 30)
        
 form.add(SingleSelectWidget, name = "service",
        value = "ping",  options=[("ping", "ping"),
        ("whois", "whois"), 
        ("nslookup", "nslookup"),
        ("traceroute","traceroute"),
        ("dig", "dig")])
                 
 form.add_hidden("time",   value = time.time()) 
        form.add_submit("submit", "submit")
 
 def render [html] ():
            renderheader(__title__)
     
            """
| %s | Address or domain name | 
| %s | Service command | 
"""
                  for line in output:
                     "\n%s
" % line
                  """"""
            else:
               """
               Something is wrong with the input Address.
[%s]
               Setting status to -1.
        """ % errormessage
               status = -1
            if status: 
               "Error in processing command[%s], exit code =%s
" % (command, status)
               """Check for valid addresses. Embedded blanks are not allowed
                  and must contain a dot "." and must not start with a "-"."""
            processfooter(form, calctime_start, homeurl, __url__)
        return process()
Visitors to this web service will be naturally curious what IP address of their ISP is. We will add this feature SOON!
We just did! Take a look at the first screen shot. The second screenshot is the output page.
I just imported the get_sesson from qp.pub.common and made the call
remote_address= get_session.get_remote_address()
You can see the result in the first image above.

