The misc.py module#

Summary#

is_windows

Check if the host machine is on Windows.

get_mechanical_bin

Get the path for the Mechanical executable file based on the release version.

threaded

Decorate a function with this decorator to call it using a thread.

threaded_daemon

Decorate a function with this decorator to call it using a daemon thread.

check_valid_ip

Check if the IP address is valid.

check_valid_port

Check if the port is valid.

check_valid_start_instance

Check if the value obtained from the environmental variable is valid.

is_float

Check if a string can be converted to a float.

Description#

Contain miscellaneous functions and methods at the module level.

Module detail#

misc.is_windows()#

Check if the host machine is on Windows.

Returns:
True if the host machine is on Windows, False otherwise.
misc.get_mechanical_bin(release_version)#

Get the path for the Mechanical executable file based on the release version.

Parameters:
release_version: str

Mechanical version using the three-digit format. For example, "242" for 2024 R2.

misc.threaded(func)#

Decorate a function with this decorator to call it using a thread.

misc.threaded_daemon(func)#

Decorate a function with this decorator to call it using a daemon thread.

misc.check_valid_ip(ip)#

Check if the IP address is valid.

Parameters:
ipstr

IP address to check.

misc.check_valid_port(port, lower_bound=1000, high_bound=60000)#

Check if the port is valid.

Parameters:
portint

Port to check.

lower_boundint, optional

Lowest possible value for the port. The default is 1000.

high_boundint, optional

Highest possible value for the port. The default is 60000.

misc.check_valid_start_instance(start_instance)#

Check if the value obtained from the environmental variable is valid.

Parameters:
start_instancestr, bool

Value obtained from the corresponding environment variable.

Returns:
bool

True if start_instance is True or "True", False otherwise.

misc.is_float(input_string)#

Check if a string can be converted to a float.

Parameters:
input_stringstr

String to check.

Returns:
bool

True when conversion is possible, False otherwise.