Beispiel #1
0
 def send_pln(self, msg_name, flight_id, init_order):
     flight = self.session.query(
         mod.Flight).filter(mod.Flight.id == flight_id).first()
     if init_order == "now":
         starting_time = self.current_time
         starting_beacon = None
     elif init_order == "origin":
         starting_beacon = None
         starting_time = None
     elif len(init_order.split(':')) > 1:
         starting_beacon = None
         starting_time = utils.str_to_sec(init_order)
     else:
         starting_beacon = init_order
         starting_time = None
     route = utils.extract_route(flight.flight_plan, starting_beacon,
                                 starting_time)
     msg_pln = "Pln %s Flight=%d Time=%s CallSign=%s AircraftType=%s Ssr=%d Speed=%d Rfl=%d Dep=%s Arr=%s Rvsm=%s Tcas=%s Adsb=%s DLink=%s List=%s" % \
                     (msg_name, flight.id, utils.sec_to_str(self.current_time), flight.callsign, flight.type, flight.ssr, flight.v, flight.fl, flight.dep, flight.arr,
                      flight.rvsm, flight.tcas, flight.adsb, flight.dlink, route.strip())
     flight.pln_event = 1
     IvySendMsg(msg_pln)
Beispiel #2
0
    f'Servidor escutando em (ctrl+click): http://{SERVER_HOST}:{SERVER_PORT}')

# serve para que o servidor seja capaz de responder mais do que uma requisição
#podemos recarregar a página no navegador quantas vezes quisermos e ela continuará a ser recebida.
while True:
    client_connection, client_address = server_socket.accept()

    # lendo os dados enviados pelo cliente.
    # No comando utilizado indicamos que queremos ler no máximo 1024 bytes
    # O .decode() deixa a requisicao possivel de entender
    # é o cabeçalho (header) da requisição ou resposta
    request = client_connection.recv(1024).decode()

    print(request)

    route = extract_route(request)

    filepath = CUR_DIR / route

    print("\n route: ", route)
    print("filepath: ", filepath, "\n")

    # se GET /templates/assets/css/getit.css HTTP/1.1
    if filepath.is_file():
        response = build_response() + read_file(filepath)
    # se GET / HTTP/1.1 ou POST / HTTP/1.1
    elif route == '':
        response = index(request)
    else:
        response = build_response()
Beispiel #3
0
 def test_extract_root_from_request(self):
     request = REQUEST_TEMPLATE.format(method='GET', route='/')
     self.assertEqual('', utils.extract_route(request))