Example #1
0
class ReportSchema(OptionalMappingSchema):

    carrier = OptionalStringNode()
    homeMobileCountryCode = OptionalIntNode()
    homeMobileNetworkCode = OptionalIntNode()
    radioType = OptionalStringVocabularyNode(vocabulary=RADIO_STRINGS)
    timestamp = OptionalNode(UnixTimeFromInteger())

    bluetoothBeacons = BluetoothBeaconsSchema(missing=())
    wifiAccessPoints = WifiAccessPointsSchema(missing=())

    def deserialize(self, data):
        data = super(ReportSchema, self).deserialize(data)
        if (data is colander.drop
                or data is colander.null):  # pragma: no cover
            return colander.drop

        if not (data.get('bluetoothBeacons') or data.get('cellTowers')
                or data.get('wifiAccessPoints')):
            return colander.drop

        top_radio = data.get('radioType', None)
        for cell in data.get('cellTowers', ()):
            if top_radio and ('radioType' not in cell
                              or not cell['radioType']):
                cell['radioType'] = top_radio
            if cell.get('radioType') == 'umts':
                cell['radioType'] = 'wcdma'

        if 'radioType' in data:
            del data['radioType']

        return data
Example #2
0
class ReportSchema(OptionalMappingSchema):

    carrier = OptionalStringNode()
    homeMobileCountryCode = OptionalIntNode()
    homeMobileNetworkCode = OptionalIntNode()
    radioType = OptionalStringVocabularyNode(vocabulary=RADIO_STRINGS)
    timestamp = OptionalNode(UnixTimeFromInteger())

    bluetoothBeacons = BluetoothBeaconsSchema(missing=())
    wifiAccessPoints = WifiAccessPointsSchema(missing=())

    def deserialize(self, data):
        data = super(ReportSchema, self).deserialize(data)
        if data is colander.drop or data is colander.null:
            return colander.drop

        if not (
            data.get("bluetoothBeacons")
            or data.get("cellTowers")
            or data.get("wifiAccessPoints")
        ):
            return colander.drop

        top_radio = data.get("radioType", None)
        for cell in data.get("cellTowers", ()):
            if top_radio and ("radioType" not in cell or not cell["radioType"]):
                cell["radioType"] = top_radio
            if cell.get("radioType") == "umts":
                cell["radioType"] = "wcdma"

        if "radioType" in data:
            del data["radioType"]

        return data
Example #3
0
class BluetoothBeaconSchema(OptionalMappingSchema):

    macAddress = OptionalStringNode()

    age = OptionalIntNode()
    name = OptionalStringNode()
    signalStrength = OptionalIntNode()

    def deserialize(self, data):
        data = super(BluetoothBeaconSchema, self).deserialize(data)
        if 'macAddress' not in data:
            return colander.drop
        return data
Example #4
0
class BlueV0Schema(OptionalMappingSchema):

    key = OptionalStringNode(to_name='macAddress')

    age = OptionalIntNode()
    name = OptionalStringNode()
    signal = OptionalIntNode(to_name='signalStrength')

    def deserialize(self, data):
        data = super(BlueV0Schema, self).deserialize(data)
        if 'macAddress' not in data:
            return colander.drop
        return data
Example #5
0
class CellV1Schema(OptionalMappingSchema):

    radio = OptionalStringNode(internal_name='radioType')
    mcc = OptionalIntNode(internal_name='mobileCountryCode')
    mnc = OptionalIntNode(internal_name='mobileNetworkCode')
    lac = OptionalIntNode(internal_name='locationAreaCode')
    cid = OptionalIntNode(internal_name='cellId')

    age = OptionalIntNode()
    asu = OptionalIntNode()
    psc = OptionalIntNode(internal_name='primaryScramblingCode')
    serving = OptionalIntNode()
    signal = OptionalIntNode(internal_name='signalStrength')
    ta = OptionalIntNode(internal_name='timingAdvance')
Example #6
0
class CellV0Schema(OptionalMappingSchema):

    radio = OptionalStringVocabularyNode(vocabulary=RADIO_STRINGS,
                                         to_name="radioType")
    mcc = OptionalIntNode(to_name="mobileCountryCode")
    mnc = OptionalIntNode(to_name="mobileNetworkCode")
    lac = OptionalIntNode(to_name="locationAreaCode")
    cid = OptionalIntNode(to_name="cellId")

    age = OptionalIntNode()
    asu = OptionalIntNode()
    psc = OptionalIntNode(to_name="primaryScramblingCode")
    serving = OptionalIntNode()
    signal = OptionalIntNode(to_name="signalStrength")
    ta = OptionalIntNode(to_name="timingAdvance")
Example #7
0
class CellTowerSchema(OptionalMappingSchema):

    radioType = OptionalStringVocabularyNode(vocabulary=RADIO_STRINGS)
    mobileCountryCode = OptionalIntNode()
    mobileNetworkCode = OptionalIntNode()
    locationAreaCode = OptionalIntNode()
    cellId = OptionalIntNode()

    age = OptionalIntNode()
    asu = OptionalIntNode()
    serving = OptionalIntNode()
    signalStrength = OptionalIntNode()
    timingAdvance = OptionalIntNode()
Example #8
0
class WifiAccessPointSchema(OptionalMappingSchema):

    macAddress = OptionalStringNode()

    age = OptionalIntNode()
    channel = OptionalIntNode()
    frequency = OptionalIntNode()
    radioType = OptionalStringNode()
    signalStrength = OptionalIntNode()
    signalToNoiseRatio = OptionalIntNode()
    ssid = OptionalStringNode()

    def deserialize(self, data):
        data = super(WifiAccessPointSchema, self).deserialize(data)
        if 'macAddress' not in data:
            return colander.drop
        return data
Example #9
0
class WifiV1Schema(OptionalMappingSchema):

    key = OptionalStringNode(internal_name='macAddress')

    age = OptionalIntNode()
    channel = OptionalIntNode()
    frequency = OptionalIntNode()
    radio = OptionalStringNode(internal_name='radioType')
    signal = OptionalIntNode(internal_name='signalStrength')
    signalToNoiseRatio = OptionalIntNode()
    ssid = OptionalStringNode()

    def deserialize(self, data):
        data = super(WifiV1Schema, self).deserialize(data)
        if 'macAddress' not in data:
            return colander.null
        return data
Example #10
0
class WifiV0Schema(OptionalMappingSchema):

    key = OptionalStringNode(to_name="macAddress")

    age = OptionalIntNode()
    channel = OptionalIntNode()
    frequency = OptionalIntNode()
    radio = OptionalStringNode(to_name="radioType")
    signal = OptionalIntNode(to_name="signalStrength")
    signalToNoiseRatio = OptionalIntNode()
    ssid = OptionalStringNode()

    def deserialize(self, data):
        data = super(WifiV0Schema, self).deserialize(data)
        if "macAddress" not in data:
            return colander.drop
        return data
Example #11
0
class PositionSchema(OptionalMappingSchema):

    latitude = OptionalBoundedFloatNode()
    longitude = OptionalBoundedFloatNode()

    accuracy = OptionalBoundedFloatNode()
    age = OptionalIntNode()
    altitude = OptionalBoundedFloatNode()
    altitudeAccuracy = OptionalBoundedFloatNode()
    heading = OptionalBoundedFloatNode()
    pressure = OptionalBoundedFloatNode()
    speed = OptionalBoundedFloatNode()
    source = OptionalStringVocabularyNode(vocabulary=SOURCE_STRINGS)
Example #12
0
class PositionSchema(OptionalMappingSchema):

    latitude = OptionalBoundedFloatNode()
    longitude = OptionalBoundedFloatNode()

    accuracy = OptionalBoundedFloatNode()
    age = OptionalIntNode()
    altitude = OptionalBoundedFloatNode()
    altitudeAccuracy = OptionalBoundedFloatNode()
    heading = OptionalBoundedFloatNode()
    pressure = OptionalBoundedFloatNode()
    speed = OptionalBoundedFloatNode()
    source = OptionalStringNode()
Example #13
0
class BaseReportV1Schema(OptionalMappingSchema):

    lat = OptionalBoundedFloatNode(internal_name='latitude')
    lon = OptionalBoundedFloatNode(internal_name='longitude')

    time = OptionalNode(UnixTimeFromString(), internal_name='timestamp')
    accuracy = OptionalBoundedFloatNode()
    age = OptionalIntNode()
    altitude = OptionalBoundedFloatNode()
    altitude_accuracy = OptionalBoundedFloatNode(
        internal_name='altitudeAccuracy')
    heading = OptionalBoundedFloatNode()
    pressure = OptionalBoundedFloatNode()
    radio = OptionalStringNode(internal_name='radioType')
    speed = OptionalBoundedFloatNode()
    source = OptionalStringNode()
Example #14
0
class BaseReportV0Schema(OptionalMappingSchema):

    lat = OptionalBoundedFloatNode(to_name="latitude")
    lon = OptionalBoundedFloatNode(to_name="longitude")

    time = OptionalNode(UnixTimeFromString(), to_name="timestamp")
    accuracy = OptionalBoundedFloatNode()
    age = OptionalIntNode()
    altitude = OptionalBoundedFloatNode()
    altitude_accuracy = OptionalBoundedFloatNode(to_name="altitudeAccuracy")
    heading = OptionalBoundedFloatNode()
    pressure = OptionalBoundedFloatNode()
    radio = OptionalStringVocabularyNode(vocabulary=RADIO_STRINGS,
                                         to_name="radioType")
    speed = OptionalBoundedFloatNode()
    source = OptionalStringVocabularyNode(
        vocabulary=SOURCE_STRINGS, validator=colander.OneOf(SOURCE_STRINGS))
Example #15
0
        class SequenceItem(CellTowerSchema):

            psc = OptionalIntNode(to_name='primaryScramblingCode')
Example #16
0
    class SequenceItem(CellTowerSchema):

        primaryScramblingCode = OptionalIntNode()