Answer Question
PSCAD Automation API: How to check for available licenses at license host using Python and the automation library?
Hello everybody,
At my university, we are using a PSCAD license host to activate a PSCAD session at startup. The screenshot below shows how it looks like, when no license is available at program start. As I am using the Automation Library for running most of my simulations, I noticed that simulations are not executed when there is no license available at the automated start of PSCAD - however, and that is my issue, the Automation does not stop when there is temporarily no license available, leading to incomplete results.
In the docuementation, I have found the License Certificate (https://hvdc.ca/webhelp/al-help/automation/licensing.html) method of the mhrc.automation.certificate.Certificate class, and was wondering, whether it is possible to use this to check the number of available licenses, and then to only continue the simulation when the result is > 0.
Unfortunately, I haven't been successful yet in making this feature work for my case:
I have tried the following commands:
# Import the library
sys.path.append(r"C:\Program Files (x86)\PSCAD\Automation\Lib\mhrc")
import automation.certificate
cert = automation.certificate.Certificate
cert.available()
...and get the following error message:
Traceback (most recent call last):
File "<ipython-input-18-607f189286c4>", line 1, in <module>
cert.available()
TypeError: available() missing 1 required positional argument: 'self'
I am grateful for any help regarding the correct application of this class.
The official documentation does currently provide too less information and examples for me (or I am simply not experienced enough with Python).
(Please note: Alternative solutions to check for available license are also welcome, if they can be implemented in Python.)
Thanks in advance to everybody reading this & best regards
Hendrik