# Buggy code
def paint_node_status(emitter, ursula, start_time):
    ursula.mature()  # Just to be sure

    # Build Learning status line
    learning_status = "Unknown"
    if ursula._learning_task.running:
        learning_status = "Learning at {}s Intervals".format(
            ursula._learning_task.interval
        )
    elif not ursula._learning_task.running:
        learning_status = "Not Learning"

    teacher = "Current Teacher ..... No Teacher Connection"
    if ursula._current_teacher_node:
        teacher = "Current Teacher ..... {}".format(ursula._current_teacher_node)

    # Build FleetState status line
    fleet_state = build_fleet_state_status(ursula=ursula)

    stats = [
        "⇀URSULA {}↽".format(ursula.nickname_icon),
        "{}".format(ursula),
        "Uptime .............. {}".format(maya.now() - start_time),
        "Start Time .......... {}".format(start_time.slang_time()),
        "Fleet State.......... {}".format(fleet_state),
        "Learning Status ..... {}".format(learning_status),
        "Learning Round ...... Round #{}".format(ursula._learning_round),
        "Operating Mode ...... {}".format(
            "Federated" if ursula.federated_only else "Decentralized"
        ),
        "Rest Interface ...... {}".format(ursula.rest_url()),
        "Node Storage Type ... {}".format(ursula.node_storage._name.capitalize()),
        "Known Nodes ......... {}".format(len(ursula.known_nodes)),
        "Work Orders ......... {}".format(len(ursula.work_orders())),
        teacher,
    ]

    if not ursula.federated_only:
        worker_address = "Worker Address ...... {}".format(ursula.worker_address)
        current_period = (
            f"Current Period ...... {ursula.staking_agent.get_current_period()}"
        )
        stats.extend([current_period, worker_address])

    if ursula._availability_sensor:
        if ursula._availability_sensor.running:
            score = "Availability Score .. {} ({} responders)".format(
                ursula._availability_sensor.score,
                len(ursula._availability_sensor.responders),
            )
        else:
            score = "Availability Score .. Disabled"

        stats.append(score)

    emitter.echo("\n" + "\n".join(stats) + "\n")


# Traceback (ValueError)
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]: Unhandled error in Deferred:
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]: Traceback (most recent call last):
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:   File "/home/ubuntu/nucypher-venv/lib/python3.6/site-packages/twisted/internet/base.py", line 1283, in run
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:     self.mainLoop()
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:   File "/home/ubuntu/nucypher-venv/lib/python3.6/site-packages/twisted/internet/base.py", line 1292, in mainLoop
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:     self.runUntilCurrent()
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:   File "/home/ubuntu/nucypher-venv/lib/python3.6/site-packages/twisted/internet/base.py", line 913, in runUntilCurrent
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:     call.func(*call.args, **call.kw)
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:   File "/home/ubuntu/nucypher-venv/lib/python3.6/site-packages/twisted/internet/task.py", line 239, in __call__
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:     d = defer.maybeDeferred(self.f, *self.a, **self.kw)
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]: --- <exception caught here> ---
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:   File "/home/ubuntu/nucypher-venv/lib/python3.6/site-packages/twisted/internet/defer.py", line 654, in _runCallbacks
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:     current.result = callback(current.result, *args, **kw)
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:   File "/home/ubuntu/nucypher/nucypher/network/sensors.py", line 89, in handle_measurement_errors
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:     failure.raiseException()
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:   File "/home/ubuntu/nucypher-venv/lib/python3.6/site-packages/twisted/python/failure.py", line 488, in raiseException
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:     raise self.value.with_traceback(self.tb)
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:   File "/home/ubuntu/nucypher-venv/lib/python3.6/site-packages/twisted/internet/defer.py", line 151, in maybeDeferred
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:     result = f(*args, **kw)
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:   File "/home/ubuntu/nucypher/nucypher/network/sensors.py", line 138, in maintain
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:     self.measure()
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:   File "/home/ubuntu/nucypher/nucypher/network/sensors.py", line 191, in measure
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:     certificate_filepath=certificate_filepath)
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:   File "/home/ubuntu/nucypher/nucypher/network/middleware.py", line 248, in check_rest_availability
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:     certificate_filepath=certificate_filepath)
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:   File "/home/ubuntu/nucypher/nucypher/network/middleware.py", line 114, in method_wrapper
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]:     raise ValueError("Don't try to pass a node with a certificate_filepath while also passing a"
Apr 02 17:02:28 ip-172-31-19-8 nucypher[29582]: builtins.ValueError: Don't try to pass a node with a certificate_filepath while also passing a different certificate_filepath.  What do you even expect?
Apr 03 00:02:29 ip-172-31-19-8 nucypher[29582]: Broadcasting CONFIRMACTIVITY Transaction (264369 gwei @ 3000000000)...

# Fixed code
def paint_node_status(emitter, ursula, start_time):
    ursula.mature()  # Just to be sure

    # Build Learning status line
    learning_status = "Unknown"
    if ursula._learning_task.running:
        learning_status = "Learning at {}s Intervals".format(
            ursula._learning_task.interval
        )
    elif not ursula._learning_task.running:
        learning_status = "Not Learning"

    teacher = "Current Teacher ..... No Teacher Connection"
    if ursula._current_teacher_node:
        teacher = "Current Teacher ..... {}".format(ursula._current_teacher_node)

    # Build FleetState status line
    fleet_state = build_fleet_state_status(ursula=ursula)

    stats = [
        "⇀URSULA {}↽".format(ursula.nickname_icon),
        "{}".format(ursula),
        "Uptime .............. {}".format(maya.now() - start_time),
        "Start Time .......... {}".format(start_time.slang_time()),
        "Fleet State.......... {}".format(fleet_state),
        "Learning Status ..... {}".format(learning_status),
        "Learning Round ...... Round #{}".format(ursula._learning_round),
        "Operating Mode ...... {}".format(
            "Federated" if ursula.federated_only else "Decentralized"
        ),
        "Rest Interface ...... {}".format(ursula.rest_url()),
        "Node Storage Type ... {}".format(ursula.node_storage._name.capitalize()),
        "Known Nodes ......... {}".format(len(ursula.known_nodes)),
        "Work Orders ......... {}".format(len(ursula.work_orders())),
        teacher,
    ]

    if not ursula.federated_only:
        worker_address = "Worker Address ...... {}".format(ursula.worker_address)
        current_period = (
            f"Current Period ...... {ursula.staking_agent.get_current_period()}"
        )
        stats.extend([current_period, worker_address])

    if ursula._availability_tracker:
        if ursula._availability_tracker.running:
            score = "Availability Score .. {} ({} responders)".format(
                ursula._availability_tracker.score,
                len(ursula._availability_tracker.responders),
            )
        else:
            score = "Availability Score .. Disabled"

        stats.append(score)

    emitter.echo("\n" + "\n".join(stats) + "\n")