Exemple #1
0
def update_location_activity(obj):
    try:
        error_if_missing(obj, 'location_name')
        location_name = obj.location_name
        lm = LocationManager()
        response = lm.update_location_activity(location_name)
        print response
    except Exception as exc:
        click.echo("Error: %s" % str(exc))
        exit(2)
Exemple #2
0
def monitor_motion(obj):
    try:
        error_if_missing(obj, 'location_name')
        location_name = obj.location_name
        pir = MotionSensor(4)
        i = 0

        while True:
            t_end = time.time() + 15
            while time.time() < t_end:
                if pir.motion_detected:
                    i = i + 1
            if i > 100000:
                location_name = obj.location_name
                lm = LocationManager()
                lm.update_location_activity(location_name)
                print "Updating activity for " + location_name
            i = 0
    except Exception as exc:
        click.echo("Error: %s" % str(exc))
        exit(2)