@@ -0,0 +1,1451 @@
+from boxlift_api import Command, BoxLift%0Afrom pprint import pprint%0A%0Abox_lift = BoxLift('Lolevator', 'training_1', 'aywang31@gmail.com', '13247', event_name='pycon2015', sandbox_mode=True)%0A%0Apprint(box_lift.send_commands())%0A%0Aelevator_states = %7B%7D%0Afor elevator in state%5B'elevators'%5D:%0A    elevator_states%5Belevator%5B'id'%5D%5D = %7B'speed': 0%7D%0A%0Adef get_state_for_elevator(elevator_id, state):%0A    for elevator in state%5B'elevators'%5D:%0A        if elevator%5B'id'%5D == elevator_id:%0A            return elevator%0A    raise %22Unknown elevator %25s%22 %25 elevator_id%0A%0Adef direction(elevator):%0A    if elevator%5B'direction'%5D == 1:%0A        if max(elevator%5B'buttons_pressed'%5D) %3E elevator%5B'floor'%5D:%0A            return 1%0A        else:%0A            return -1%0A    elif elevator%5B'direction'%5D == -1:%0A        if min(elevator%5B'buttons_pressed'%5D) %3C elevator%5B'floor'%5D:%0A            return -1%0A        else:%0A            return 1%0A    else:%0A        return 'Error - unknown elevator direction'%0A%0Adef stop_elevator_on_floor(elevator_id, floor, state):%0A    elevator = get_state_for_elevator(elevator_id)%0A    if floor == elevator%5B'floor'%5D and elevator%5B'speed'%5D == 1:%0A        return Command(elevator_id, direction(elevator), 0)%0A    elif floor == elevator%5B'floor'%5D and elevator%5B'speed'%5D == 0:%0A        raise 'Error - elevator has not dropped off passengers'%0A    elif direction(elevator) in %5B1, -1%5D:%0A        return Command(elevator_id, direction(elevator), 1)%0A    else:%0A        return Command(elevator_id, 1, 0)%0A

Add temp file