From terry.y.davis at gmail.com Mon Jan 27 18:33:15 2020 From: terry.y.davis at gmail.com (Terry Davis) Date: Mon, 27 Jan 2020 15:33:15 -0800 Subject: [python-win32] [win32com] Meaning of "TypeError: Only com_record objects can be used as records"? Message-ID: Hi all, I tried searching the mailing list archives for "com_record" but didn't find anything relevant. For context, I'm trying to access a COM interface defined in a .tlb file. Here's a skeleton of the script I'm using to expose this interface: import pythoncom from win32com.client import gencache lib_GUID = "{}" lib_major = 1 lib_minor = 0 lib_pyITypelib = pythoncom.LoadRegTypeLib(lib_GUID, lib_major, lib_minor) lib = gencache.EnsureModuleForTypelibInterface(_lib_pyITypelib) ccs = lib.CControlServer() # CControlServer is a CoClass eid, *other = ccs.LoadExperiment(**path to file**) # Works ccs.GetSoftwareInfo() # Fails with exception below. ccs.GetSolvent(eid) # also fails I can't dig down in the debugger to find the source of the exception, so I'm hoping someone here can help! Exception: def GetSoftwareInfo(self, info=pythoncom.Missing): in ----> 1 ccs.GetSoftwareInfo() ~\AppData\Local\Temp\gen_py\3.7\x0x1x0.py in GetSoftwareInfo(self, info) 279 def GetSoftwareInfo(self, info=pythoncom.Missing): 280 'method GetSoftwareInfo' --> 281 return self._ApplyTypes_(13, 1, (24, 0), ((36, 2),), 'GetSoftwareInfo', None,info 282 ) 283 C:\Python37\lib\site-packages\win32com\client\__init__.py in _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, *args) 465 def _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, *args): 466 return self._get_good_object_( --> 467 self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), 468 user, resultCLSID) 469 TypeError: Only com_record objects can be used as records -------------- next part -------------- An HTML attachment was scrubbed... URL: From terry.y.davis at gmail.com Mon Jan 27 19:31:08 2020 From: terry.y.davis at gmail.com (Terry Davis) Date: Mon, 27 Jan 2020 16:31:08 -0800 Subject: [python-win32] [win32com] Meaning of "TypeError: Only com_record objects can be used as records"? In-Reply-To: References: Message-ID: Update: The functions that don't work return Record types, and the ones that do work just return multiple values (a tuple). Do I need to pass in the appropriate Record type (or an empty record) during each function call? If so, how do I get to the Record types that I see in the python object browser (python -m win32com.client.combrowse)? Thanks, Terry On Mon, Jan 27, 2020 at 3:33 PM Terry Davis wrote: > Hi all, > > I tried searching the mailing list archives for "com_record" but didn't > find anything relevant. > > For context, I'm trying to access a COM interface defined in a .tlb file. > > Here's a skeleton of the script I'm using to expose this interface: > import pythoncom > from win32com.client import gencache > > lib_GUID = "{}" > lib_major = 1 > lib_minor = 0 > lib_pyITypelib = pythoncom.LoadRegTypeLib(lib_GUID, lib_major, lib_minor) > lib = gencache.EnsureModuleForTypelibInterface(_lib_pyITypelib) > > ccs = lib.CControlServer() # CControlServer is a CoClass > eid, *other = ccs.LoadExperiment(**path to file**) # Works > ccs.GetSoftwareInfo() # Fails with exception below. > ccs.GetSolvent(eid) # also fails > > I can't dig down in the debugger to find the source of the exception, so > I'm hoping someone here can help! > > > Exception: > > def GetSoftwareInfo(self, info=pythoncom.Missing): > > > in > ----> 1 ccs.GetSoftwareInfo() > > ~\AppData\Local\Temp\gen_py\3.7\x0x1x0.py in GetSoftwareInfo(self, > info) > 279 def GetSoftwareInfo(self, info=pythoncom.Missing): > 280 'method GetSoftwareInfo' > --> 281 return self._ApplyTypes_(13, 1, (24, 0), ((36, > 2),), 'GetSoftwareInfo', None,info > 282 ) > 283 > > C:\Python37\lib\site-packages\win32com\client\__init__.py in > _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, > *args) > 465 def _ApplyTypes_(self, dispid, wFlags, retType, argTypes, > user, resultCLSID, *args): > 466 return self._get_good_object_( > --> 467 self._oleobj_.InvokeTypes(dispid, 0, > wFlags, retType, argTypes, *args), > 468 user, resultCLSID) > 469 > > TypeError: Only com_record objects can be used as records > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Frank.Degerdon at ps.rolls-royce.com Tue Jan 28 02:07:45 2020 From: Frank.Degerdon at ps.rolls-royce.com (Frank.Degerdon at ps.rolls-royce.com) Date: Tue, 28 Jan 2020 07:07:45 +0000 Subject: [python-win32] Problem with pywin32 and Python 3.8 on Windows Server 2016 Message-ID: <8801b1a40b8a4cfcab98679857540368@ps.rolls-royce.com> Hello, i have implemented a windows service in the past with python 2.7 and 3.7. I worked fine with this versions. Now I have to switch the version to 3.8. And with this environment, I have problems. Below find the sourcecode for my implementation to install an run the service: #!/usr/bin/env python # -*- coding: utf-8 -*- """Run application as windows service Usage : python