Python newbie here. Therefore, please excuse me if this was specified earlier in a different format.
I am trying to replicate the following perl fragment in Python using the win32com module. This snippet has been provided by Qualcomm to simplify the automation of their tools.
use Win32::OLE;
use Win32::OLE::Variant;
$prod_id = "QPSTAtmnServer.Application";
eval{ $qpst = Win32::OLE->GetActiveObject($prod_id)};
die "$prod_id not installed" if $@;
unless (defined $qpst) { $qpst = Win32::OLE->new($prod_id, sub {$_[0]->Quit;}) or die "Cannot start $prod_id";}
if (defined $qpst)
{
$port = $qpst->GetPort("COM30001");
}
The python code block that I have so far looks like this:
import win32com.client
import time
import os
cmd = 'cls'
os.system(cmd)
cmd = 'start C:\\LAB\\exe\\pskill.exe QPSTConfig'
os.system(cmd)
cmd = 'start C:\\LAB\\exe\\pskill.exe QPSTServer'
os.system(cmd)
cmd = 'start C:\\LAB\\exe\\pskill.exe AtmnServer'
os.system(cmd)
time.sleep(2)
_path = os.getcwd()
qpst = win32com.client.Dispatch('QPSTAtmnServer.Application')
time.sleep(5)
if (qpst is None):
print('Darn!')
else:
port = qpst.GetPort('30001')
print(port)
and it produces the following error:
Traceback (last last call):
File "xxxx.py", line 20, in the module
port = qpst.GetPort('30001')
TypeError: object "NoneType" cannot be called
After reading a few posts, it seems that the method (GetPort) is not registered as a method in the end.
Is this the correct analysis?
If so, how can I get Python to interpret it as a method?
, ?
!