Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def test_pipeline_builder_cloud_engine_init(self):

pipeline = DeviceDetectionCloudPipelineBuilder(resource_key = self.resource_key).build()

self.assertTrue(pipeline.flow_elements[0].datakey == "cloud")
self.assertTrue(pipeline.flow_elements[1].datakey == "device")
self.assertIn("cloud", pipeline.flow_elements_list)
self.assertIn("device", pipeline.flow_elements_list)

def test_properties_cloud(self):
"""!
Expand All @@ -69,7 +69,7 @@ def test_properties_cloud(self):

pipeline = DeviceDetectionCloudPipelineBuilder(resource_key = self.resource_key).build()

properties = pipeline.flow_elements[1].get_properties()
properties = pipeline.get_element("device").get_properties()

self.assertTrue(len(properties.keys()) > 0)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ def main(argv):
# somewhere in the project space, or you may specify another file as
# a command line parameter.
#
# Note that the Lite data file is only used for illustration, and has
# limited accuracy and capabilities. The example shows the properties
# Note that the Lite data file is only used for illustration, and has a small
# number of Properties. The example shows the properties
# only the Enterprise data file has as needing it. Contact us for a copy
# of the Enterprise data file:
# https://51degrees.com/contact-us?utm_source=code&utm_medium=example&utm_campaign=51degrees-python&utm_content=fiftyone_devicedetection_examples-src-fiftyone_devicedetection_examples-onpremise-gettingstarted_console.py&utm_term=main
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ def main(argv):
# somewhere in the project space, or you may specify another file as
# a command line parameter.
#
# Note that the Lite data file is only used for illustration, and has
# limited accuracy and capabilities.
# Note that the Lite data file is only used for illustration, and has a small
# number of Properties.
# Contact us for a copy of the Enterprise data file:
# https://51degrees.com/contact-us?utm_source=code&utm_medium=example&utm_campaign=51degrees-python&utm_content=fiftyone_devicedetection_examples-src-fiftyone_devicedetection_examples-onpremise-match_metrics.py&utm_term=main
data_file = argv[0] if len(argv) > 0 else ExampleUtils.find_file(LITE_DATAFILE_NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ def main(argv):
# somewhere in the project space, or you may specify another file as
# a command line parameter.
#
# Note that the Lite data file is only used for illustration, and has
# limited accuracy and capabilities.
# Note that the Lite data file is only used for illustration, and has a small
# number of Properties.
# Contact us for a copy of the Enterprise data file:
# https://51degrees.com/contact-us?utm_source=code&utm_medium=example&utm_campaign=51degrees-python&utm_content=fiftyone_devicedetection_examples-src-fiftyone_devicedetection_examples-onpremise-metadata_console.py&utm_term=main
data_file = argv[0] if len(argv) > 0 else ExampleUtils.find_file(LITE_DATAFILE_NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ def main(argv):
# somewhere in the project space, or you may specify another file as
# a command line parameter.
#
# Note that the Lite data file is only used for illustration, and has
# limited accuracy and capabilities.
# Note that the Lite data file is only used for illustration, and has a small
# number of Properties.
# Contact us for a copy of the Enterprise data file:
# https://51degrees.com/contact-us?utm_source=code&utm_medium=example&utm_campaign=51degrees-python&utm_content=fiftyone_devicedetection_examples-src-fiftyone_devicedetection_examples-onpremise-offlineprocessing.py&utm_term=main
data_file = argv[0] if len(argv) > 0 else ExampleUtils.find_file(LITE_DATAFILE_NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,9 @@ def process_internal(self, flow_data):

evidence = EvidenceDeviceDetectionSwig()

# The native evidence takes text, and the Sequence Element adds a number.
for key, value in flow_data.evidence.get_all().items():
evidence.__setitem__(key, value)
evidence.__setitem__(key, str(value))

result = self.engine.process(evidence)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_on_premise_data_update_url(self):
with pipeline.create_flowdata() as flowdata:
flowdata.process()

flow_element_data_file = pipeline.flow_elements[0].data_file
flow_element_data_file = pipeline.get_element("device").data_file
self.assertIsInstance(flow_element_data_file, DeviceDetectionDataFile)
self.assertFalse(flow_element_data_file.verify_md5)
self._assertSignedUrl(flow_element_data_file.get_update_url())
Expand All @@ -92,7 +92,7 @@ def test_on_premise_data_old_property_data_file_update_base_url(self):
with pipeline.create_flowdata() as flowdata:
flowdata.process()

flow_element_data_file = pipeline.flow_elements[0].data_file
flow_element_data_file = pipeline.get_element("device").data_file
self.assertIsInstance(flow_element_data_file, DeviceDetectionDataFile)
self.assertFalse(flow_element_data_file.verify_md5)
self._assertSignedUrl(flow_element_data_file.get_update_url())
Expand All @@ -114,7 +114,7 @@ def test_on_premise_data_update_url_config(self):
with pipeline.create_flowdata() as flowdata:
flowdata.process()

flow_element_data_file = pipeline.flow_elements[0].data_file
flow_element_data_file = pipeline.get_element("device").data_file
self.assertIsInstance(flow_element_data_file, DeviceDetectionDataFile)
self.assertFalse(flow_element_data_file.verify_md5)
self._assertSignedUrl(flow_element_data_file.get_update_url())
Expand All @@ -136,7 +136,7 @@ def test_on_premise_data_config_old_property_data_file_update_base_url(self):
with pipeline.create_flowdata() as flowdata:
flowdata.process()

flow_element_data_file = pipeline.flow_elements[0].data_file
flow_element_data_file = pipeline.get_element("device").data_file
self.assertIsInstance(flow_element_data_file, DeviceDetectionDataFile)
self.assertFalse(flow_element_data_file.verify_md5)
self._assertSignedUrl(flow_element_data_file.get_update_url())
Expand All @@ -155,7 +155,7 @@ def test_on_premise_data_update_verify_md5(self):
with pipeline.create_flowdata() as flowdata:
flowdata.process()

flow_element_data_file = pipeline.flow_elements[0].data_file
flow_element_data_file = pipeline.get_element("device").data_file
self.assertIsInstance(flow_element_data_file, DeviceDetectionDataFile)
self.assertTrue(flow_element_data_file.verify_md5)
self._assertSignedUrl(flow_element_data_file.get_update_url())
Expand All @@ -174,7 +174,7 @@ def test_on_premise_data_update_verify_md5_old_property(self):
with pipeline.create_flowdata() as flowdata:
flowdata.process()

flow_element_data_file = pipeline.flow_elements[0].data_file
flow_element_data_file = pipeline.get_element("device").data_file
self.assertIsInstance(flow_element_data_file, DeviceDetectionDataFile)
self.assertTrue(flow_element_data_file.verify_md5)
self._assertSignedUrl(flow_element_data_file.get_update_url())
Expand All @@ -196,7 +196,7 @@ def test_on_premise_data_update_verify_md5_config(self):
with pipeline.create_flowdata() as flowdata:
flowdata.process()

flow_element_data_file = pipeline.flow_elements[0].data_file
flow_element_data_file = pipeline.get_element("device").data_file
self.assertIsInstance(flow_element_data_file, DeviceDetectionDataFile)
self.assertTrue(flow_element_data_file.verify_md5)
self._assertSignedUrl(flow_element_data_file.get_update_url())
Expand All @@ -218,7 +218,7 @@ def test_on_premise_data_update_verify_md5_config_old_property(self):
with pipeline.create_flowdata() as flowdata:
flowdata.process()

flow_element_data_file = pipeline.flow_elements[0].data_file
flow_element_data_file = pipeline.get_element("device").data_file
self.assertIsInstance(flow_element_data_file, DeviceDetectionDataFile)
self.assertTrue(flow_element_data_file.verify_md5)
self._assertSignedUrl(flow_element_data_file.get_update_url())
Expand All @@ -238,7 +238,7 @@ def test_on_premise_data_update_use_url_formatter(self):
with pipeline.create_flowdata() as flowdata:
flowdata.process()

flow_element_data_file = pipeline.flow_elements[0].data_file
flow_element_data_file = pipeline.get_element("device").data_file
self.assertIsInstance(flow_element_data_file, DeviceDetectionDataFile)
self._assertNotSignedUrl(flow_element_data_file.get_update_url())

Expand All @@ -260,7 +260,7 @@ def test_on_premise_data_update_use_url_formatter_config(self):
with pipeline.create_flowdata() as flowdata:
flowdata.process()

flow_element_data_file = pipeline.flow_elements[0].data_file
flow_element_data_file = pipeline.get_element("device").data_file
self.assertIsInstance(flow_element_data_file, DeviceDetectionDataFile)
self._assertNotSignedUrl(flow_element_data_file.get_update_url())

Expand All @@ -278,7 +278,7 @@ def test_on_premise_data_update_status_rate_limit(self):
with pipeline.create_flowdata() as flowdata:
flowdata.process()

flow_element_data_file = pipeline.flow_elements[0].data_file
flow_element_data_file = pipeline.get_element("device").data_file
self.assertIsInstance(flow_element_data_file, DeviceDetectionDataFile)
self.assertTrue(flow_element_data_file.verify_md5)
self._assertSignedUrl(flow_element_data_file.get_update_url())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_pipeline_builder_shareusage_init(self):
data_file_path=data_file, licence_keys="").build()
self.addCleanup(pipeline.close)

self.assertTrue(pipeline.flow_elements[0].datakey == "shareusage")
self.assertIn("shareusage", pipeline.flow_elements_list)

def test_on_premise_engine_datafile(self):
"""!
Expand All @@ -75,7 +75,7 @@ def test_on_premise_engine_datafile(self):
self.addCleanup(pipeline.close)

self.assertTrue(isinstance(
pipeline.flow_elements[0].data_file, DeviceDetectionDataFile))
pipeline.get_element("device").data_file, DeviceDetectionDataFile))

def test_properties_onpremise(self):
"""!
Expand All @@ -87,7 +87,7 @@ def test_properties_onpremise(self):
data_file_path=data_file, usage_sharing=False, licence_keys="").build()
self.addCleanup(pipeline.close)

properties = pipeline.flow_elements[0].get_properties()
properties = pipeline.get_element("device").get_properties()

self.assertTrue(len(properties.keys()) > 0)

Expand All @@ -100,7 +100,7 @@ def test_evidencekey_filter_onpremise(self):
data_file_path=data_file, usage_sharing=False, licence_keys="").build()
self.addCleanup(pipeline.close)

evidence_key_filter = pipeline.flow_elements[0].get_evidence_key_filter(
evidence_key_filter = pipeline.get_element("device").get_evidence_key_filter(
)

self.assertFalse(evidence_key_filter.filter_evidence_key("test.test"))
Expand Down Expand Up @@ -310,7 +310,7 @@ def test_evidencekey_filter_contains_user_agent(self):
data_file_path=data_file, usage_sharing=False, licence_keys="").build()
self.addCleanup(pipeline.close)

evidence_key_filter = pipeline.flow_elements[0].get_evidence_key_filter(
evidence_key_filter = pipeline.get_element("device").get_evidence_key_filter(
)

self.assertTrue(
Expand All @@ -325,7 +325,7 @@ def test_evidencekey_filter_contains_device_stock_ua(self):
data_file_path=data_file, usage_sharing=False, licence_keys="").build()
self.addCleanup(pipeline.close)

evidence_key_filter = pipeline.flow_elements[0].get_evidence_key_filter(
evidence_key_filter = pipeline.get_element("device").get_evidence_key_filter(
)

self.assertTrue(evidence_key_filter.filter_evidence_key(
Expand All @@ -340,7 +340,7 @@ def test_evidencekey_filter_contains_query_params(self):
data_file_path=data_file, usage_sharing=False, licence_keys="").build()
self.addCleanup(pipeline.close)

evidence_key_filter = pipeline.flow_elements[0].get_evidence_key_filter(
evidence_key_filter = pipeline.get_element("device").get_evidence_key_filter(
)

self.assertTrue(evidence_key_filter.filter_evidence_key(
Expand All @@ -357,7 +357,7 @@ def test_evidencekey_filter_case_insensitive_keys(self):
data_file_path=data_file, usage_sharing=False, licence_keys="").build()
self.addCleanup(pipeline.close)

evidence_key_filter = pipeline.flow_elements[0].get_evidence_key_filter(
evidence_key_filter = pipeline.get_element("device").get_evidence_key_filter(
)

self.assertTrue(
Expand All @@ -378,7 +378,7 @@ def test_evidencekey_filter_overrides(self):
data_file_path=data_file, usage_sharing=False, licence_keys="").build()
self.addCleanup(pipeline.close)

evidence_key_filter = pipeline.flow_elements[0].get_evidence_key_filter(
evidence_key_filter = pipeline.get_element("device").get_evidence_key_filter(
)

self.assertTrue(evidence_key_filter.filter_evidence_key(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,9 @@ def process_internal(self, flow_data):

evidence = EvidenceIpiSwig()

# The native evidence takes text, and the Sequence Element adds a number.
for key, value in flow_data.evidence.get_all().items():
evidence.__setitem__(key, value)
evidence.__setitem__(key, str(value))

result = self.engine.process(evidence)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,13 @@ def process_internal(self, flowdata):
for key, value in self.settings.items():
variables[key] = value

variables["_jsonObject"] = json.dumps(flowdata.jsonbundler.json)
# The JSON is written into a script element, so the characters that
# could end the element or the script are written as escapes.
variables["_jsonObject"] = (
json.dumps(flowdata.jsonbundler.json)
.replace("<", "\\u003c")
.replace(">", "\\u003e")
.replace("&", "\\u0026"))

# Generate URL and autoUpdate params

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def process_internal(self, flowdata):
for flow_element in flowdata.pipeline.flow_elements:

if (flow_element.datakey == "jsonbundler" or
flow_element.datakey == "sequence" or
flow_element.datakey == "javascriptbuilder" or
flow_element.datakey == "set-headers"):
continue
Expand Down
Loading
Loading