embedded/raspberry/server/traffic_light/views.py
def change_lights():
    '''
    POST /change_lights
    -------------------
    Sets the traffic lights to display certain passed animations.
    '''

    global STOP_FLAG
    STOP_FLAG = True
    STOP_FLAG = False

    available_animations = [x.split('.')[0]
                            for x in os.listdir('server/static/animations/')]

    if not (request.args.get('red') and request.args.get('yellow') and request.args.get('green')):
        return "Missing arguments.", 400

    global LIGHTS_STATUS
    LIGHTS_STATUS['red'] = request.args.get('red')
    LIGHTS_STATUS['yellow'] = request.args.get('yellow')
    LIGHTS_STATUS['green'] = request.args.get('green')

    if LIGHTS_STATUS['red'] in available_animations:
        load_animation(LIGHTS_STATUS['red'], LEDBoard.RED)
    else:
        return "Invalid animation passed for \"red\".", 400

    if LIGHTS_STATUS['yellow'] in available_animations:
        load_animation(LIGHTS_STATUS['yellow'], LEDBoard.RED)
    else:
        return "Invalid animation passed for \"yellow\".", 400

    if LIGHTS_STATUS['green'] in available_animations:
        load_animation(LIGHTS_STATUS['green'], LEDBoard.GREEN)
    else:
        return "Invalid animation passed for \"green\".", 400

    return status()

    POST /change_lights
    -------------------
    Sets the traffic lights to display certain passed animations.
    
POST /change_lights
Sets the traffic lights to display certain passed animations.
POST / change_lights Sets the traffic lights to display certain passed animations .
def change_lights():
    global STOP_FLAG
    STOP_FLAG = True
    STOP_FLAG = False
    available_animations = [x.split('.')[0]
                            for x in os.listdir('server/static/animations/')]
    if not (request.args.get('red') and request.args.get('yellow') and request.args.get('green')):
        return "Missing arguments.", 400
    global LIGHTS_STATUS
    LIGHTS_STATUS['red'] = request.args.get('red')
    LIGHTS_STATUS['yellow'] = request.args.get('yellow')
    LIGHTS_STATUS['green'] = request.args.get('green')
    if LIGHTS_STATUS['red'] in available_animations:
        load_animation(LIGHTS_STATUS['red'], LEDBoard.RED)
    else:
        return "Invalid animation passed for \"red\".", 400
    if LIGHTS_STATUS['yellow'] in available_animations:
        load_animation(LIGHTS_STATUS['yellow'], LEDBoard.RED)
    else:
        return "Invalid animation passed for \"yellow\".", 400
    if LIGHTS_STATUS['green'] in available_animations:
        load_animation(LIGHTS_STATUS['green'], LEDBoard.GREEN)
    else:
        return "Invalid animation passed for \"green\".", 400
    return status()
def change_lights ( ) : global STOP_FLAG STOP_FLAG = True STOP_FLAG = False available_animations = [ x . split ( '.' ) [ 0 ] for x in os . listdir ( 'server/static/animations/' ) ] if not ( request . args . get ( 'red' ) and request . args . get ( 'yellow' ) and request . args . get ( 'green' ) ) : return "Missing arguments." , 400 global LIGHTS_STATUS LIGHTS_STATUS [ 'red' ] = request . args . get ( 'red' ) LIGHTS_STATUS [ 'yellow' ] = request . args . get ( 'yellow' ) LIGHTS_STATUS [ 'green' ] = request . args . get ( 'green' ) if LIGHTS_STATUS [ 'red' ] in available_animations : load_animation ( LIGHTS_STATUS [ 'red' ] , LEDBoard . RED ) else : return "Invalid animation passed for \"red\"." , 400 if LIGHTS_STATUS [ 'yellow' ] in available_animations : load_animation ( LIGHTS_STATUS [ 'yellow' ] , LEDBoard . RED ) else : return "Invalid animation passed for \"yellow\"." , 400 if LIGHTS_STATUS [ 'green' ] in available_animations : load_animation ( LIGHTS_STATUS [ 'green' ] , LEDBoard . GREEN ) else : return "Invalid animation passed for \"green\"." , 400 return status ( )
POST /change_lights
Sets the traffic lights to display certain passed animations.
POST / change_lights Sets the traffic lights to display certain passed animations .
'''
    POST /change_lights
    -------------------
    Sets the traffic lights to display certain passed animations.
    '''