Lookup a command in PATH. For example::

        >>> lookup('ls')
        '/usr/bin/ls'
        >>> lookup('usermod')
        '/usr/sbin/usermod'
        >>> lookup('foobar')
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        ValueError: Invalid command

    This function is incredibly dumb, and does not search for an executable
    file.

def lookup(command):
    """
    Lookup a command in PATH. For example::

        >>> lookup('ls')
        '/usr/bin/ls'
        >>> lookup('usermod')
        '/usr/sbin/usermod'
        >>> lookup('foobar')
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        ValueError: Invalid command

    This function is incredibly dumb, and does not search for an executable
    file.
    """
    for path in os.environ.get('PATH', '').split(':'):
        fname = os.path.join(path, command)
        if os.path.exists(fname):
            return fname
    raise ValueError("Invalid command")