Next / Previous / Contents / TCC Help System / NM Tech homepage

11. buildServerRow(): Format one row of the server table

Given a System instance and a ClientSet with configuration data, this function attempts to build one row of the server table.

It may happen that a server is unknown to the GetHardware interface. In that case, a message is written to the standard error stream.

hwscan3.py
# - - -   b u i l d S e r v e r R o w

def buildServerRow ( tbody, system, clientSet ):
    '''Build one row of the server table on the start page.

      [ (tbody is an et.Element) and
        (system is a System instance) and
        (clientSet is a ClientSet instance) ->
          if system.nodename is known to clientSet ->
            tbody  +:=  a tr element for system with
                configuration data from clientSet
          else ->
            sys.stderr  +:=  message about unknown server ]
    '''
    #-- 1 --
    # [ if clientSet knows about (system) ->
    #     clientConfig  :=  a ClientConfig instance that
    #         describes system's configuration
    #   else ->
    #     sys.stderr  +:=  message about unknown server
    #     return ]
    try:
        clientConfig  =  clientSet.lookupClient ( system.nodename )
    except KeyError:
        print >>sys.stderr, ( "*** GetHardware does not know about "
            "server '%s'." % system.nodename )
        return

Formatting the table row is straightforward. For the XHTML, see Section 3.1, “XHTML for the start page”.

hwscan3.py
    #-- 2 --
    # [ tr  :=  a new tr et.Element representing the hardware
    #           configuration data for clientConfig ]
    tr  =  E.tr (
        E.td ( L_ALIGN, E.tt ( clientConfig.hostName ) ),
        E.td ( R_ALIGN, clientConfig.nCpus ),
        E.td ( R_ALIGN, clientConfig.speed ),
        E.td ( L_ALIGN, clientConfig.arch ),
        E.td ( R_ALIGN, clientConfig.memory ) )
          
    #-- 3 --
    # [ tbody  +:=  tr ]
    tbody.append ( tr )