def get_exception_name(output):
    """
    Reads the traceback from a Python program and grabs the
    fully qualified exception name.
    """
    lines = output.split('\n')
    cue = False
    result = '(unknown)'
    for line in lines[1:]:
        line = line.rstrip()
        if not line:
            continue
        if line[0] == ' ':
            cue = True
            continue
        if cue:
            cue = False
            return line.partition(':')[0]
    return result
