def getSGEHosts():
    """get sun grid engine hosts."""
    try:
        x = subprocess.Popen( "qhost", 
                              shell=True,
                              stdout=subprocess.PIPE,
                              )

    except OSError, e:
        E.fail( cmd % "Execution of %s failed")
        raise
    
    hosts = []
    for line in x.stdout:
        if line.startswith("HOSTNAME"): continue
        if line.startswith("global"): continue
        if line.startswith("-"): continue
        x = HOST( *re.split( "\s+", line[:-1] ) )
        if x.ncpu == "-" or x.arch == "-": continue

        try: x = x._replace( ncpu = int(x.ncpu ),  )
        except ValueError: pass

        assert x.memtot.endswith("G")
        x = x._replace( memtot = float(x.memtot[:-1] ) )

        hosts.append( x )

    return hosts
dataset/ETHPy150Open CGATOxford/cgat/obsolete/benchmark_cluster.py/getSGEHosts/swapped operands of `%`