Device Detection services for 51Degrees Pipeline

fiftyone_devicedetection_examples.example_utils.ExampleUtils Class Reference

Static Public Member Functions

 get_resource_key_from_config (config)
 set_resource_key_in_config (config, key)
 get_data_file_from_config (config)
 set_data_file_in_config (config, file)
 get_human_readable (device, property)
 Format a property value for display.
 get_profiles (hardware)
 Read the list of hardware profiles from the "hardware" element data.
 get_no_profiles_message ()
 The line printed when a lookup returned no device profiles at all.
 get_resource_key ()
 get_license_key ()
 The licence key from the environment, or an empty string.
 get_missing_resource_key_message ()
 The message shown when no resource key is set, naming the variable that was wanted rather than leaving the reader to guess.
 get_data_file_path ()
 get_cloud_endpoint ()
 find_file (file_name)
 get_data_file_date (engine)
 data_file_is_old (engine)
 get_data_file_tier (engine)
 is_lite_data_file (engine)
 True when the engine uses the free Lite data file.
 has_property (engine, name)
 True when the engine's data file has the property.
 get_enterprise_value (engine, device, property)
 Format a property for display, or say that it needs the Enterprise data file when the engine's data file does not have it.
 get_enterprise_note (contact_us)
 Where to ask for a copy of the Enterprise data file, written after an example has shown properties that the data file in use does not have.
 get_enterprise_offer (contact_us)
 What the Enterprise data file adds and where to ask for a copy, written after an example that shows no properties has run on the free Lite data file.
 check_data_file (pipeline, logger)
 Log the data file in use, and a warning if it is old.

Static Public Attributes

int FIND_FILES_TIMEOUT_S = 5
int DATA_FILE_AGE_WARNING = 30
str RESOURCE_KEY_ENV_VAR = "_51DEGREES_RESOURCE_KEY"
str LEGACY_RESOURCE_KEY_ENV_VAR = "resource_key"
str LICENSE_KEY_ENV_VAR = "_51DEGREES_LICENSE_KEY"
str LEGACY_LICENSE_KEY_ENV_VAR = "license_key"
str CLOUD_ENDPOINT_ENV_VAR = "_51DEGREES_CLOUD_ENDPOINT"
str ENDPOINT_ENV_VAR = "cloud_endpoint"
str DD_PATH_ENV_VAR = "_51DEGREES_DD_PATH"
str DATA_FILE_ENV_VAR = "51DEGREES_DD_PATH"
 DATA_FOLDER = os.path.join("cxx", "data", "device-detection")
str DOWNLOAD_SOURCE = "examples-51degrees-python"
str NEEDS_ENTERPRISE = "needs the Enterprise data file"

Member Function Documentation

◆ check_data_file()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.check_data_file ( pipeline,
logger )
static

Log the data file in use, and a warning if it is old.

An example run on the free Lite data file says what the Enterprise data file adds in its own output.

◆ data_file_is_old()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.data_file_is_old ( engine)
static

◆ find_file()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.find_file ( file_name)
static

◆ get_cloud_endpoint()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.get_cloud_endpoint ( )
static

◆ get_data_file_date()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.get_data_file_date ( engine)
static

◆ get_data_file_from_config()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.get_data_file_from_config ( config)
static

◆ get_data_file_path()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.get_data_file_path ( )
static

◆ get_data_file_tier()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.get_data_file_tier ( engine)
static

◆ get_enterprise_note()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.get_enterprise_note ( contact_us)
static

Where to ask for a copy of the Enterprise data file, written after an example has shown properties that the data file in use does not have.

The link is tagged with the example's file, so that an enquiry can be traced to the example.

◆ get_enterprise_offer()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.get_enterprise_offer ( contact_us)
static

What the Enterprise data file adds and where to ask for a copy, written after an example that shows no properties has run on the free Lite data file.

◆ get_enterprise_value()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.get_enterprise_value ( engine,
device,
property )
static

Format a property for display, or say that it needs the Enterprise data file when the engine's data file does not have it.

The value is only read when the data file has the property.

◆ get_human_readable()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.get_human_readable ( device,
property )
static

Format a property value for display.

A property can be unavailable for three reasons, and each one reads differently so the person running the example can tell them apart. The property may have a value, it may have no value with the cloud service giving a reason (most often that the resource key is not entitled to it), or it may not be in the results at all.

◆ get_license_key()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.get_license_key ( )
static

The licence key from the environment, or an empty string.

The old name is also read in upper case, as it was before.

◆ get_missing_resource_key_message()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.get_missing_resource_key_message ( )
static

The message shown when no resource key is set, naming the variable that was wanted rather than leaving the reader to guess.

◆ get_no_profiles_message()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.get_no_profiles_message ( )
static

The line printed when a lookup returned no device profiles at all.

◆ get_profiles()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.get_profiles ( hardware)
static

Read the list of hardware profiles from the "hardware" element data.

An empty list is returned when the resource key has no access to the hardware aspect at all, because reading a property that is not there raises rather than returning an empty list.

◆ get_resource_key()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.get_resource_key ( )
static

◆ get_resource_key_from_config()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.get_resource_key_from_config ( config)
static

◆ has_property()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.has_property ( engine,
name )
static

True when the engine's data file has the property.

The Lite data file leaves out the properties only the Enterprise data file has, such as HardwareVendor, HardwareName and DeviceType. The data file's own list is read, because the engine's properties are only those it was built to give.

◆ is_lite_data_file()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.is_lite_data_file ( engine)
static

True when the engine uses the free Lite data file.

◆ set_data_file_in_config()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.set_data_file_in_config ( config,
file )
static

◆ set_resource_key_in_config()

fiftyone_devicedetection_examples.example_utils.ExampleUtils.set_resource_key_in_config ( config,
key )
static

Member Data Documentation

◆ CLOUD_ENDPOINT_ENV_VAR

str fiftyone_devicedetection_examples.example_utils.ExampleUtils.CLOUD_ENDPOINT_ENV_VAR = "_51DEGREES_CLOUD_ENDPOINT"
static

◆ DATA_FILE_AGE_WARNING

int fiftyone_devicedetection_examples.example_utils.ExampleUtils.DATA_FILE_AGE_WARNING = 30
static

◆ DATA_FILE_ENV_VAR

str fiftyone_devicedetection_examples.example_utils.ExampleUtils.DATA_FILE_ENV_VAR = "51DEGREES_DD_PATH"
static

◆ DATA_FOLDER

fiftyone_devicedetection_examples.example_utils.ExampleUtils.DATA_FOLDER = os.path.join("cxx", "data", "device-detection")
static

◆ DD_PATH_ENV_VAR

str fiftyone_devicedetection_examples.example_utils.ExampleUtils.DD_PATH_ENV_VAR = "_51DEGREES_DD_PATH"
static

◆ DOWNLOAD_SOURCE

str fiftyone_devicedetection_examples.example_utils.ExampleUtils.DOWNLOAD_SOURCE = "examples-51degrees-python"
static

◆ ENDPOINT_ENV_VAR

str fiftyone_devicedetection_examples.example_utils.ExampleUtils.ENDPOINT_ENV_VAR = "cloud_endpoint"
static

◆ FIND_FILES_TIMEOUT_S

int fiftyone_devicedetection_examples.example_utils.ExampleUtils.FIND_FILES_TIMEOUT_S = 5
static

◆ LEGACY_LICENSE_KEY_ENV_VAR

str fiftyone_devicedetection_examples.example_utils.ExampleUtils.LEGACY_LICENSE_KEY_ENV_VAR = "license_key"
static

◆ LEGACY_RESOURCE_KEY_ENV_VAR

str fiftyone_devicedetection_examples.example_utils.ExampleUtils.LEGACY_RESOURCE_KEY_ENV_VAR = "resource_key"
static

◆ LICENSE_KEY_ENV_VAR

str fiftyone_devicedetection_examples.example_utils.ExampleUtils.LICENSE_KEY_ENV_VAR = "_51DEGREES_LICENSE_KEY"
static

◆ NEEDS_ENTERPRISE

str fiftyone_devicedetection_examples.example_utils.ExampleUtils.NEEDS_ENTERPRISE = "needs the Enterprise data file"
static

◆ RESOURCE_KEY_ENV_VAR

str fiftyone_devicedetection_examples.example_utils.ExampleUtils.RESOURCE_KEY_ENV_VAR = "_51DEGREES_RESOURCE_KEY"
static