This example shows how the 51Degrees device detection engine deals with
evidence that does not match any known device.
In this scenario, 'HasValue' can be used to check if the property has been
populated by the engine. If it hasn't then 'NoValueMessage' can be used
to get the reason why.
38 from fiftyone_devicedetection_onpremise.devicedetection_onpremise_pipelinebuilder
import DeviceDetectionOnPremisePipelineBuilder
39 from fiftyone_devicedetection_examples.example_utils
import ExampleUtils
43 data_file = ExampleUtils.find_file(
"51Degrees-LiteV4.1.hash")
45 pipeline = DeviceDetectionOnPremisePipelineBuilder(
46 data_file_path = data_file,
48 performance_profile =
'MaxPerformance',
49 auto_update=
False).build()
54 flowdata1 = pipeline.create_flowdata()
58 iphone_ua =
"Mozilla/5.0 (iPhone; CPU iPhone OS 11_2 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Mobile/15C114" 60 flowdata1.evidence.add(
"header.user-agent", iphone_ua)
71 print(
"Is User-Agent " + iphone_ua +
" a mobile device?: ")
72 if flowdata1.device.ismobile.has_value():
73 print(flowdata1.device.ismobile.value())
76 print(flowdata1.device.ismobile.no_value_message())
82 flowdata2 = pipeline.create_flowdata()
84 flowdata2.evidence.add(
"header.user-agent", badUA)
88 print(
"Is User-Agent " + badUA +
" a mobile device?: ")
89 if flowdata2.device.ismobile.has_value():
90 print(flowdata2.device.ismobile.value())
93 print(flowdata2.device.ismobile.no_value_message())