08-07-2023 08:52 AM
Hello Community,
I am using TestStand 2017 and the ActiveX API for
programming in Python.
The goal is to load a sequence file and change its format (mostly binary) to xml. so far, I have found the following:
engine =win32com.client.Dispatch("TestStand.Engine")
seqFile = engine.GetSequenceFile("file.seq")
xmlFile = seqFile.AsPropertyObjectFile.FileWritingFormat(3)
The following error occur:
AttributeError: 'function' object has no attribute 'FileWritingFormat'.
The 'FileWritingFormat' method can be used in the TestStand GUI, but why doesn't it work when using the ActiveX?
Thank you in advance 🙏
Solved! Go to Solution.
08-08-2023 12:40 AM
You want to set a property, so this should be an assignment rather than a method call
I guess
seqFile.AsPropertyObjectFile.FileWritingFormat = 3
should do what you want to
08-08-2023 05:20 AM
Hello Oli,
thank you very much, that works fine. However, a ' PropertyObjects were not released' error occurs. I have executed the following to close the engine after the API:
engine.UnloadAllModules()
engine.ReleaseSequenceFileEx(seq_file, 0x0)
seq_file = None
engine.ShutDown(True)# someone suggested to not use, it doesn’t make any difference
I found a solution on this page, however only the cumbersome way via the GUI works for me. There under Debug-Options you can uncheck 'Report Object Leaks ... '. Then everything works. But, it is only the dialog window is not shown, the error still remains.
Thanks again. 🙏
08-08-2023 05:56 AM
Simply put:
each object created has to be released again. In my experience, it's best to have the release sequence just opposite to the sequence in which you instantiate objects.
I am usually working with the API in TestSatnd itself, so I don't really know what it exactly looks like in Python.
Is it possible you are opening further object refences?
I am shutting down the engine every time, since I consider this a good practice
08-11-2023 03:08 AM
Good morning, Oli,
thank you for the hint. The code flow in Python is very similar to the one in TestStand. Apparently, you have to execute following when closing:
Engine.ReleaseSequenceFileEx(sequence_file, 0x4)
Engine.UnloadAllModules()
sequence_file = None
Engine.ShutDown(True)
Then the release leak error doesn't come anymore 🙂
08-11-2023 03:39 AM
Good Job! Thanks for sharing your findings 😊