Beispiel #1
0
def _create_session():
    key, pilot = _parse_user()
    if not pilot:
        raise NotFound('No pilot found with tracking key `{:X}`.'.format(key))

    session_id = _parse_session_id()

    if session_id & 0x00FFFFFF != key & 0x00FFFFFF:
        raise BadRequest(
            'The right three bytes must match the userid (tracking key).')

    session = TrackingSession()
    session.pilot = pilot
    session.lt24_id = session_id
    session.ip_created = request.remote_addr

    # Client application
    if 'client' in request.values:
        session.client = request.values['client'][:32]
    if 'v' in request.values:
        session.client_version = request.values['v'][:8]

    # Device information
    if 'phone' in request.values:
        session.device = request.values['phone'][:32]
    if 'gps' in request.values:
        session.gps_device = request.values['gps'][:32]

    # Aircraft model and type
    if 'vname' in request.values:
        session.aircraft_model = request.values['vname'][:64]
    if 'vtype' in request.values:
        try:
            session.aircraft_type = int(request.values['vtype'])
        except ValueError:
            raise BadRequest('`vtype` has to be a valid integer.')

    db.session.add(session)
    db.session.commit()
    return 'OK'
Beispiel #2
0
def _create_session():
    key, pilot = _parse_user()
    if not pilot:
        raise NotFound("No pilot found with tracking key `{:X}`.".format(key))

    session_id = _parse_session_id()

    if session_id & 0x00FFFFFF != key & 0x00FFFFFF:
        raise BadRequest(
            "The right three bytes must match the userid (tracking key).")

    session = TrackingSession()
    session.pilot = pilot
    session.lt24_id = session_id
    session.ip_created = request.remote_addr

    # Client application
    if "client" in request.values:
        session.client = request.values["client"][:32]
    if "v" in request.values:
        session.client_version = request.values["v"][:8]

    # Device information
    if "phone" in request.values:
        session.device = request.values["phone"][:32]
    if "gps" in request.values:
        session.gps_device = request.values["gps"][:32]

    # Aircraft model and type
    if "vname" in request.values:
        session.aircraft_model = request.values["vname"][:64]
    if "vtype" in request.values:
        try:
            session.aircraft_type = int(request.values["vtype"])
        except ValueError:
            raise BadRequest("`vtype` has to be a valid integer.")

    db.session.add(session)
    db.session.commit()
    return "OK"
Beispiel #3
0
def _create_session():
    key, pilot = _parse_user()
    if not pilot:
        raise NotFound('No pilot found with tracking key `{:X}`.'.format(key))

    session_id = _parse_session_id()

    if session_id & 0x00FFFFFF != key & 0x00FFFFFF:
        raise BadRequest('The right three bytes must match the userid (tracking key).')

    session = TrackingSession()
    session.pilot = pilot
    session.lt24_id = session_id
    session.ip_created = request.remote_addr

    # Client application
    if 'client' in request.values:
        session.client = request.values['client'][:32]
    if 'v' in request.values:
        session.client_version = request.values['v'][:8]

    # Device information
    if 'phone' in request.values:
        session.device = request.values['phone'][:32]
    if 'gps' in request.values:
        session.gps_device = request.values['gps'][:32]

    # Aircraft model and type
    if 'vname' in request.values:
        session.aircraft_model = request.values['vname'][:64]
    if 'vtype' in request.values:
        try:
            session.aircraft_type = int(request.values['vtype'])
        except ValueError:
            raise BadRequest('`vtype` has to be a valid integer.')

    db.session.add(session)
    db.session.commit()
    return 'OK'
def _create_session():
    key, pilot = _parse_user()
    if not pilot:
        raise NotFound("No pilot found with tracking key `{:X}`.".format(key))

    session_id = _parse_session_id()

    if session_id & 0x00FFFFFF != key & 0x00FFFFFF:
        raise BadRequest("The right three bytes must match the userid (tracking key).")

    session = TrackingSession()
    session.pilot = pilot
    session.lt24_id = session_id
    session.ip_created = request.remote_addr

    # Client application
    if "client" in request.values:
        session.client = request.values["client"][:32]
    if "v" in request.values:
        session.client_version = request.values["v"][:8]

    # Device information
    if "phone" in request.values:
        session.device = request.values["phone"][:32]
    if "gps" in request.values:
        session.gps_device = request.values["gps"][:32]

    # Aircraft model and type
    if "vname" in request.values:
        session.aircraft_model = request.values["vname"][:64]
    if "vtype" in request.values:
        try:
            session.aircraft_type = int(request.values["vtype"])
        except ValueError:
            raise BadRequest("`vtype` has to be a valid integer.")

    db.session.add(session)
    db.session.commit()
    return "OK"