Reference Python Package
A python package is included to help users getting started with windPRO SCRIPTING.
This consists of the main class WindProApi
that lets you start windPRO and interact with its services.
Some additional functions are included that makes working with python and this underlying library easier.
For example to get an easily interpretable layer structure (get_layer_dict
) or compare objects to find which properties are different (compare_objects
).
These functions are provided for convenience but might not handle all possible inputs correctly.
The underlying zeep python library cannot handle None
values.
Those need to be replaced with a library specific object.
This is done with nan_to_skipvalue
and needs to be applied to objects that contain None
values before setting with scripting.
Find below the documentation for the functionality provided in the python package
windproapi-4.0-py3-none-any.whl
.
- class windproapi.windproapi.WindProApi(version='4.0', api_port=50904, windpro_path=None)
Bases:
object
Class for interacting with windPRO via desctop scripting. WindProApi gives access to windPRO scripting features.
- Parameters
version (str) – version number of windPRO
api_port (int) – API port to use when calling windPRO
windpro_path (str) – windPRO path. Optional to overwrite automatically finding windPRO path from version.
- close_windpro()
Close windPRO.
- get_factory(service_name)
Getting windPRO factory by name for generating complex data structures.
- Parameters
service_name (str) – name of the factory
- Returns
zeep.client.Factory object
- get_service(service_name)
Getting windPRO service by name. Refer to documentation for available services. :param str service_name: name of the service :return: zeep.proxy.ServiceProxy object with the specified service
- is_windpro_running(max_time=120)
Test if windPRO is responsive to scripting services.
- service_operations(service)
Get a list of operations available in this service.
- Parameters
service (zeep.proxy.ServiceProxy) – windPRO service from WindProApi.get_service
- Returns
list describing the operations in the service
- start_windpro_random_port()
Starting windPRO wind a random free port.
- start_windpro_with_port(check_windpro_start=True, time_to_windpro_start=30)
Starting windPRO with the specified port. :param check_windpro_start: Check windpro has started by trying to activate a service :param time_to_windpro_start: Wait time in seconds if check_windpro_start is set to False
- windproapi.windproapi.compare_objects(zeep_dict, zeep_dict_compare)
Check for differences in objects
- Parameters
zeep_dict (zeep.objects.WINDPROOBJECT) – First object
zeep_dict_compare (zeep.objects.WINDPROOBJECT) – Compared object
- Returns
dictionay with keys and values of the differences between objects.
- windproapi.windproapi.get_layer_dict(objservice)
Getting all layers in a dictionary for easier access
- Parameters
objservice (zeep.proxy.ServiceProxy) – object service form WindProApi.get_service(‘ObjectsService’)
- Returns
dictionary with the structure key == layer with ‘’ to indicate folders and value as Handle.
- windproapi.windproapi.nan_to_skipvalue(zeep_dict)
Replacing Nan with zeep.xsd.SkipValue to avoid error when sending data via zeep.
- Parameters
zeep_dict (zeep.objects.WINDPROOBJECT) – object where Nans are replaced
- windproapi.utils.get_windpro_path(version)
Getting the path were windPRO is installed
- Parameters
version (str) – windPRO version: format examlple 3.6
- Returns
path were windpro is installed
- windproapi.utils.get_windpro_sample_path(version)
Getting the path were windPRO is installed
- Parameters
version (str) – windPRO version: format examlple 3.6
- Returns
path windpro samples are located