Tobii Pro SDK Python API
apply_licenses.py
1 def execute(eyetracker):
2  license_file_path = "../licenses/se_internal_license_for_system_tests"
3 
4  # <BeginExample>
5  import tobii_research as tr
6 
7  print("Applying license from {0}.".format(license_file_path))
8  with open(license_file_path, "rb") as f:
9  license = f.read()
10 
11  failed_licenses_applied_as_list_of_keys = eyetracker.apply_licenses([tr.LicenseKey(license)])
12  failed_licenses_applied_as_list_of_bytes = eyetracker.apply_licenses([license])
13  failed_licenses_applied_as_key = eyetracker.apply_licenses(tr.LicenseKey(license))
14  failed_licenses_applied_as_bytes = eyetracker.apply_licenses(license)
15 
16  if len(failed_licenses_applied_as_list_of_keys) == 0:
17  print("Successfully applied license from list of keys.")
18  else:
19  print("Failed to apply license from list of keys. Validation result: {0}.".
20  format(failed_licenses_applied_as_list_of_keys[0].validation_result))
21 
22  if len(failed_licenses_applied_as_list_of_bytes) == 0:
23  print("Successfully applied license from list of bytes.")
24  else:
25  print("Failed to apply license from list of bytes. Validation result: {0}.".
26  format(failed_licenses_applied_as_list_of_bytes[0].validation_result))
27 
28  if len(failed_licenses_applied_as_key) == 0:
29  print("Successfully applied license from single key.")
30  else:
31  print("Failed to apply license from single key. Validation result: {0}.".
32  format(failed_licenses_applied_as_key[0].validation_result))
33 
34  if len(failed_licenses_applied_as_bytes) == 0:
35  print("Successfully applied license from bytes object.")
36  else:
37  print("Failed to apply license from bytes object. Validation result: {0}.".
38  format(failed_licenses_applied_as_bytes[0].validation_result))
39  # <EndExample>