# Buggy code
def get_measurement(self):
    """Gets the rpm"""
    pi = pigpio.pi()
    try:
        read_rpm = ReadRPM(pi, self.pin, self.weighting, self.rpm_pulses_per_rev)
        rpm = read_rpm.RPM()
        if rpm:
            return int(rpm + 0.5)
    finally:
        p.cancel()
        pi.stop()
    return None


# Traceback (UndefinedError)
Error 500: Internal Server Error

Something bad happened but it's probably not your fault. Letting the developers know about these issues is crucial to supporting Mycodo. Please submit a new issue on GitHub with the following error traceback (copy the entire traceback):

Error (Full Traceback):

Traceback (most recent call last):
File "/var/www/mycodo/env/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/var/www/mycodo/env/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/var/www/mycodo/env/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/var/www/mycodo/env/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/var/www/mycodo/env/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/var/www/mycodo/env/lib/python2.7/site-packages/flask_login/utils.py", line 228, in decorated_view
return func(*args, **kwargs)
File "/var/www/mycodo/mycodo/mycodo_flask/page_routes.py", line 612, in page_live
sensorDisplayOrderSorted=sensor_order_sorted)
File "/var/www/mycodo/env/lib/python2.7/site-packages/flask/templating.py", line 134, in render_template
context, ctx.app)
File "/var/www/mycodo/env/lib/python2.7/site-packages/flask/templating.py", line 116, in _render
rv = template.render(context)
File "/var/www/mycodo/env/lib/python2.7/site-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/var/www/mycodo/env/lib/python2.7/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/var/www/mycodo/mycodo/mycodo_flask/templates/pages/live.html", line 3, in top-level template code
{% set help_page = ["live-measurements", _('Live Leasurements')] %}
File "/var/www/mycodo/mycodo/mycodo_flask/templates/layout.html", line 187, in top-level template code
{%- block body %}{% endblock -%}
File "/var/www/mycodo/mycodo/mycodo_flask/templates/pages/live.html", line 116, in block "body"
{% if measurement_units[each_measure]['meas'] == 'temperature' %}
File "/var/www/mycodo/env/lib/python2.7/site-packages/jinja2/environment.py", line 411, in getitem
return obj[argument]
UndefinedError: 'dict object' has no attribute u''

# Fixed code
def get_measurement(self):
    """Gets the rpm"""
    try:
        pi = pigpio.pi()
        read_rpm = ReadRPM(pi, self.pin, self.weighting, self.rpm_pulses_per_rev)
    except Exception:
        return 0

    try:
        rpm = read_rpm.RPM()
        if rpm:
            return int(rpm + 0.5)
    except Exception:
        logger.exception(1)
    finally:
        read_rpm.cancel()
        pi.stop()
    return 0