I have a python script that connects to TestStand and retrieves certain data from a .seq (sequence) file.
import win32com.client
import pythoncom
TestStandEngine = win32com.client.Dispatch("TestStand.Engine")
Seqfile = TestStandEngine .GetSequenceFileEx("Seq_File.seq")
Main = Seqfile.GetSequenceByName("MainSequence") #Get's the main sequence of the file
I had installed both the x32 and x64 versions of Test Stand 2014, and the script ran just fine. After uninstalling the x64 version (because it was not needed),the script now gives this error:
Traceback (most recent call last):
File "C:\ts\Main.py", line 9, in <module>
TestStandEngine = win32com.client.Dispatch("TestStand.Engine")
File "C:\LegacyApp\Python_2.7\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\LegacyApp\Python_2.7\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\LegacyApp\Python_2.7\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
com_error: (-2147221005, 'Invalid class string', None, None)
After doing some research , I think I know what causes the problem but I couldn't find any way to fix it.
-The Python instalation on my computer is 32 bit
>>> import platform
>>> platform.architecture()
('32bit', 'WindowsPE')
-The only installed Test Stand on my computer is the 32 bit version.
-The OS : Windows x64 bit OS
Here's my guess: I think that when it Dispatches the Teststand.Engine it tries to use the x64 version of it that is no longer installed; I've tried by adding the clsctx parameter, but same result:
win32com.client.Dispatch("TestStand.Engine",clsctx=pythoncom.CLSCTX_LOCAL_SERVER)
Is there any way to 'force' it to launch the 32 bit version ? If the TestStand is on 32bit and Python is on 32bit shouldn't it return a 32bit COM object that should work with python 32bit?
Update: So after running this in PowerShell it returned a list of all valid names of COM but 'Teststand.Engine' is not on the list. The only TestStand related object in the list is TestStand.ExLauncher (which I can dispatch, but it does not have the same attributes/use as the TestStand.Engine