helperFunctions.uid web_interface

helperFunctions.web_interface.apply_filters_to_query(request, query)

Add a filter, selected in the web interface (vendor or device class), to the given query and return it. If the filter was already present in the query, it is updated.

Parameters:
  • request – A given request (represented by the Flask object).

  • query (str) – A JSON MongoDB query.

Returns:

The updated query.

Return type:

dict

helperFunctions.web_interface.cap_length_of_element(hid_element, maximum=55)

Limit the length of an HID element of the “Virtual File Path”, so that it can be displayed in the web interface without errors

Parameters:
  • hid_element (str) – An element of the virtual file path.

  • maximum (int) – The length after witch the element is capped.

Returns:

The capped string.

Return type:

str

helperFunctions.web_interface.filter_out_illegal_characters(string)

Filter out any illegal characters from a given string.

Parameters:

string (str | None) – The string to be filtered.

Returns:

The filtered string.

Return type:

str | None

helperFunctions.web_interface.format_time(seconds)

Format a duration value to be displayed in the web interface.

Parameters:

seconds (float) – The duration in seconds.

Returns:

The formatted duration.

Return type:

str

helperFunctions.web_interface.get_alternating_color_list(number, limit=10)

Get a list of alternating color values (beginning with blue and alternating with yellow) as a hexadecimal string compatible to HTML.

Parameters:
  • number (int) – The number of colors in the returned list (with a cap of limit).

  • limit (int) – The maximum number of returned colors.

Returns:

A list of alternating hex color values.

Return type:

list[str]

helperFunctions.web_interface.get_color_list(number, limit=10)

Get a list of (different) color values as a hexadecimal string compatible to HTML (e.g. #00ff00 for green).

Parameters:
  • number (int) – The number of colors in the returned list (with a cap of limit).

  • limit (int) – The maximum number of returned colors.

Returns:

A list of hex color values.

Return type:

list[str]

helperFunctions.web_interface.get_template_as_string(view_name)

Get the content of template view_name from the template directory as string.

Parameters:

view_name (str) – The name of the template file.

Returns:

The contents of the template file as string.

Return type:

str

Check whether a given password is erroneously identified as an hashed password string (which might cause unexpected behavior).

Parameters:

pw (str) – The password string.

Returns:

True if the password is accepted and False otherwise.

Return type:

bool