def normalize_stdout(stdout):
    """Make subprocess output easier to consume

    Decode bytes to str, strip unnecessary newlines produced by most commands.

    :param stdout: return value of `subprocess.check_output` or similar

    >>> normalize_stdout(b'/foo/bar\n')
    '/foo/bar'
    """
    return stdout.decode().strip()