From Ross.Boylan at ucsf.edu Tue Jan 8 16:46:29 2019 From: Ross.Boylan at ucsf.edu (Boylan, Ross) Date: Tue, 8 Jan 2019 21:46:29 +0000 Subject: [python-win32] Making a COM server that accepts COM objects Message-ID: I have a Python 3.7, 32 bit, COM server and am calling it from 32 bit Office 2010 in VBA. I am attempting to pass some COM objects from VBA to Python. The trace collector full output appears below, but I think the key clues are several messages like in ._QueryInterface_ with unsupported IID {00000003-0000-0000-C000-000000000046} ({00000003-0000-0000-C000-000000000046}) and, later, rst = fedb.OpenRecordset("foo") AttributeError: 'PyIDispatch' object has no attribute 'OpenRecordset' I think this means that the objects passed in have unrecognized types, and therefore type-specific methods don't work on them (though it seems odd they aren't dynamically dispatched). What can I do to fix or debug this? Based on this theory, I used the makepy tool from the GUI to import the DAO 3.6 library, which I believe defines both types. But this didn't seem to help. I found some documentation saying to use win32com.client.Dispatch to get the right interface--it also mentioned that the IDispatch object would only repond to the 2 methods it knows--but I don't know how. All the examples I've seen with Dispatch use it to create a new object. I can't find any documentation on it (as opposed to tutorials illustratin it use); I think com\win32com\client\__init__.py has the relevant definition in the source code, but it is not apparent to me whether handing it an IDispatch object rather "Company.Class" will cause the appropriate object to be created. Running on 64 bit Win 7, with quite a few installations of versions of Python floating around. Using a LocalServer because of earlier problems with in process servers. In particular, the invoking path in the registry for my class is C:\PROGRA~2\PYTHON~1\pythonw.exe "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\localserver.py" even though I just installed pywin32 and it said it was putting things under "c:\Program Files (x86)". Both locations (with suitable additions to the Program Files path) have localserver.py --------------------------------------------------- test code in VBA ---------------------------------------- Public Function medium() Dim srv As Object Set srv = CreateObject("Fahy.BST") medium = srv.Barney(DBEngine.Workspaces(0), CurrentDb()) End Function --------------------------------------------------------------------- ------------------------ python server code BSTImport.py --------------------------- import atexit, csv, sys import pythoncom, win32com.client from win32com.server.exception import COMException from win32com.client import constants from win32com.server.register import UseCommandLine TmpTable = "aatmpt_bst" # table to import csv into #pdb.set_trace() # fields in csv file I use now are # 'Sample Barcode', 'Participant ID', 'Initials', 'Visit ID', # 'Collection Date', 'Sample Type', 'Site Comment', # 'Shipment Comment', 'Shipment ID # BST Import already name of form in VB class BSTImport: # COM Support _public_methods_ = ['Fred', 'Barney'] _reg_clsid_ = "{050321C2-9B99-4CD0-B5E9-B636DFD94C4D}" _reg_desc_ = "BST Test Com Server in Python 32 bit" _reg_progid_ = "Fahy.BST" # for unknown reasons the inprocess server isn't working _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER def Barney(self, ws, fedb): """ws is the workspace with which a transaction has already been initiated fedb is the database used by the frontend""" rst = fedb.OpenRecordset("foo") rst.AddNew() fld = rst("foolish") fld.Value = "python.Barney" rst.Update() rst.Close() rst = None return True # other methods omitted if __name__ == "__main__": UseCommandLine(BSTImport) ------------------------------------------------------------------------------------------- --------------------------------------- trace --------------------------------------------- Object with win32trace dispatcher created (object=None) in ._QueryInterface_ with unsupported IID {00000003-0000-0000-C000-000000000046} ({00000003-0000-0000-C000-000000000046}) in ._QueryInterface_ with unsupported IID {0000001B-0000-0000-C000-000000000046} ({0000001B-0000-0000-C000-000000000046}) in ._QueryInterface_ with unsupported IID {00000018-0000-0000-C000-000000000046} ({00000018-0000-0000-C000-000000000046}) in ._QueryInterface_ with unsupported IID b'IExternalConnection' ({00000019-0000-0000-C000-000000000046}) in ._QueryInterface_ with unsupported IID {4C1E39E1-E3E3-4296-AA86-EC938D896E92} ({4C1E39E1-E3E3-4296-AA86-EC938D896E92}) in ._QueryInterface_ with unsupported IID b'IPersistStreamInit' ({7FD52380-4E07-101B-AE2D-08002B2EC713}) in ._QueryInterface_ with unsupported IID b'IPersistPropertyBag' ({37D84F60-42CB-11CE-8135-00AA004BB851}) in ._QueryInterface_ with unsupported IID {1C733A30-2A1C-11CE-ADE5-00AA0044773D} ({1C733A30-2A1C-11CE-ADE5-00AA0044773D}) in _GetIDsOfNames_ with '('Barney',)' and '1033' in _Invoke_ with 1001 1033 3 (, ) Traceback (most recent call last): File "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\dispatcher.py", line 47, in _Invoke_ return self.policy._Invoke_(dispid, lcid, wFlags, args) File "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\policy.py", line 278, in _Invoke_ return self._invoke_(dispid, lcid, wFlags, args) File "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\policy.py", line 283, in _invoke_ return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None) File "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\policy.py", line 586, in _invokeex_ return func(*args) File "C:\Users\rdboylan\Documents\Wk devel\BSTImport.py", line 36, in Barney rst = fedb.OpenRecordset("foo") AttributeError: 'PyIDispatch' object has no attribute 'OpenRecordset' pythoncom error: Python error invoking COM method. Traceback (most recent call last): File "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\dispatcher.py", line 163, in _Invoke_ return DispatcherBase._Invoke_(self, dispid, lcid, wFlags, args) File "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\dispatcher.py", line 49, in _Invoke_ return self._HandleException_() File "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\dispatcher.py", line 47, in _Invoke_ return self.policy._Invoke_(dispid, lcid, wFlags, args) File "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\policy.py", line 278, in _Invoke_ return self._invoke_(dispid, lcid, wFlags, args) File "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\policy.py", line 283, in _invoke_ return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None) File "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\policy.py", line 586, in _invokeex_ return func(*args) File "C:\Users\rdboylan\Documents\Wk devel\BSTImport.py", line 36, in Barney rst = fedb.OpenRecordset("foo") AttributeError: 'PyIDispatch' object has no attribute 'OpenRecordset' in ._QueryInterface_ with unsupported IID IProvideClassInfo ({B196B283-BAB4-101A-B69C-00AA00341D07}) in ._QueryInterface_ with unsupported IID {CACC1E85-622B-11D2-AA78-00C04F9901D2} ({CACC1E85-622B-11D2-AA78-00C04F9901D2}) in _GetTypeInfo_ with index=0, lcid=1033 in _GetTypeInfo_ with index=0, lcid=0 ------------------------------------------------------------------------------------------------- From Ross.Boylan at ucsf.edu Tue Jan 8 17:04:29 2019 From: Ross.Boylan at ucsf.edu (Boylan, Ross) Date: Tue, 8 Jan 2019 22:04:29 +0000 Subject: [python-win32] Edit with pythonwin context menu entry not quite working Message-ID: On MS Win 7 when I right click on a .py file the MS Windows Explorer, the context menu offers "Open with Pythonwin" as a choice. When I click on it Pythonwin opens up, but the file I selected is not open in the application. Expected behavior: the file would be open and in the foreground. Complications: 32 bit python on 64 bit OS. Multiple version of python, at various bitnesses (?) are installed, some as part of Visual Studio. There was at least one previous install of pywin32 via pip; it was not completely set up. Variety of security software is running. Just installed pywin32 from pywin32-224.win32-py3.7.exe. From timr at probo.com Wed Jan 9 13:05:53 2019 From: timr at probo.com (Tim Roberts) Date: Wed, 9 Jan 2019 10:05:53 -0800 Subject: [python-win32] Making a COM server that accepts COM objects In-Reply-To: References: Message-ID: <956c19be-b9a3-caa0-1f35-4494801e2f17@probo.com> Boylan, Ross wrote: > I have a Python 3.7, 32 bit, COM server and am calling it from 32 bit Office 2010 in VBA. I am attempting to pass some COM objects from VBA to Python. The trace collector full output appears below, but I think the key clues are several messages like > > in ._QueryInterface_ with unsupported IID {00000003-0000-0000-C000-000000000046} ({00000003-0000-0000-C000-000000000046}) Those are not important.? The COM framework is just probing to find out what extras you support.? 00000003-etc is IMarshal and 0000001B-etc is IStandardMarshal; both can be used to help in the RPC process. > and, later, > rst = fedb.OpenRecordset("foo") > AttributeError: 'PyIDispatch' object has no attribute 'OpenRecordset' You can't just pass an Access database object to another process and expect it to work.? The support pieces aren't there.? Thus, the crux of your problem is this: > _reg_progid_ = "Fahy.BST" > # for unknown reasons the inprocess server isn't working > _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER That's the problem you need to chase.? You need to be an in-process server if you want to share state with the original code.? What happens when you register yourself as in-process? Note that the registry has to look different for this. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3980 bytes Desc: S/MIME Cryptographic Signature URL: From Ross.Boylan at ucsf.edu Fri Jan 11 17:43:37 2019 From: Ross.Boylan at ucsf.edu (Boylan, Ross) Date: Fri, 11 Jan 2019 22:43:37 +0000 Subject: [python-win32] Making a COM server that accepts COM objects In-Reply-To: <956c19be-b9a3-caa0-1f35-4494801e2f17@probo.com> References: , <956c19be-b9a3-caa0-1f35-4494801e2f17@probo.com> Message-ID: I changed to an InProcess server, which doesn't seem to work any better or worse than the LocalServer. Here's the trace: --------------------------------------------------------------------------------------------------- Object with win32trace dispatcher created (object=None) in ._QueryInterface_ with unsupported IID b'IPersistStreamInit' ({7FD52380-4E07-101B-AE2D-08002B2EC713}) in ._QueryInterface_ with unsupported IID b'IPersistPropertyBag' ({37D84F60-42CB-11CE-8135-00AA004BB851}) in _GetIDsOfNames_ with '('Barney',)' and '1033' in _Invoke_ with 1001 1033 3 (, ) Traceback (most recent call last): File "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\dispatcher.py", line 47, in _Invoke_ return self.policy._Invoke_(dispid, lcid, wFlags, args) File "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\policy.py", line 278, in _Invoke_ return self._invoke_(dispid, lcid, wFlags, args) File "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\policy.py", line 283, in _invoke_ return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None) File "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\policy.py", line 586, in _invokeex_ return func(*args) File "C:\Users\rdboylan\Documents\Wk devel\BSTImport.py", line 37, in Barney rst = fedb.OpenRecordset("foo") AttributeError: 'PyIDispatch' object has no attribute 'OpenRecordset' pythoncom error: Python error invoking COM method. Traceback (most recent call last): File "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\dispatcher.py", line 163, in _Invoke_ return DispatcherBase._Invoke_(self, dispid, lcid, wFlags, args) File "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\dispatcher.py", line 49, in _Invoke_ return self._HandleException_() File "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\dispatcher.py", line 47, in _Invoke_ return self.policy._Invoke_(dispid, lcid, wFlags, args) File "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\policy.py", line 278, in _Invoke_ return self._invoke_(dispid, lcid, wFlags, args) File "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\policy.py", line 283, in _invoke_ return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None) File "C:\Users\rdboylan\AppData\Roaming\Python\Python37\site-packages\win32com\server\policy.py", line 586, in _invokeex_ return func(*args) File "C:\Users\rdboylan\Documents\Wk devel\BSTImport.py", line 37, in Barney rst = fedb.OpenRecordset("foo") AttributeError: 'PyIDispatch' object has no attribute 'OpenRecordset' --------------------------------------------------- To try to ensure that the old LocalServer wasn't active I did --unregister first, and restarted the calling program after that. I first tried commenting out #_reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER when that didn't work I renamed the registry key LocalServer32 (I think; it's gone now) to NoLocalServer32. when that didn't work I set _reg_clsctx_ = pythoncom.CLSCTX_INPROC_SERVER and did the unregister/register, verifying there was no reference to the local server in the registry after. Ross ________________________________________ From: python-win32 on behalf of Tim Roberts Sent: Wednesday, January 9, 2019 10:05:53 AM To: Python-Win32 List Subject: Re: [python-win32] Making a COM server that accepts COM objects Boylan, Ross wrote: > I have a Python 3.7, 32 bit, COM server and am calling it from 32 bit Office 2010 in VBA. I am attempting to pass some COM objects from VBA to Python. The trace collector full output appears below, but I think the key clues are several messages like > > in ._QueryInterface_ with unsupported IID {00000003-0000-0000-C000-000000000046} ({00000003-0000-0000-C000-000000000046}) Those are not important. The COM framework is just probing to find out what extras you support. 00000003-etc is IMarshal and 0000001B-etc is IStandardMarshal; both can be used to help in the RPC process. > and, later, > rst = fedb.OpenRecordset("foo") > AttributeError: 'PyIDispatch' object has no attribute 'OpenRecordset' You can't just pass an Access database object to another process and expect it to work. The support pieces aren't there. Thus, the crux of your problem is this: > _reg_progid_ = "Fahy.BST" > # for unknown reasons the inprocess server isn't working > _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER That's the problem you need to chase. You need to be an in-process server if you want to share state with the original code. What happens when you register yourself as in-process? Note that the registry has to look different for this. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rvc69 at free.fr Mon Jan 21 01:15:54 2019 From: rvc69 at free.fr (rvc69 at free.fr) Date: Mon, 21 Jan 2019 07:15:54 +0100 (CET) Subject: [python-win32] Bug - Passing byref an array to a com method interpreted as a single element In-Reply-To: <412038919.1064128672.1548051278511.JavaMail.root@zimbra9-e2.priv.proxad.net> Message-ID: <2124088560.1064134526.1548051354992.JavaMail.root@zimbra9-e2.priv.proxad.net> Hello, I'm trying to translate a VBA application to Python. I cannot change the COM Server as its works also with others programs. It seems I have a problem with win32com.client by passing an array of double to a COM method. VBA allows to pass arrays to COM server byref on the first element of the array VBA WORKS : ' com object knows ALREADY the number of values to read or write from array ReDim Preserve Values(0 To nbvalues - 1) ' array of nbvalues double ' setting values, obj.SetValues Values(0) ' passing byref the address of the first element of the array to read in ' reverse method reading back values obj.GetValues Values(0) ' passing byref the first address of the array to write in >From typelib COM interface [id(0x00000007), helpstring("M?thode GetValues")] HRESULT GetValues([in, out] double* pValues); # pointer on array of double [id(0x00000008), helpstring("M?thode SetValues")] HRESULT SetValues([in] double* pValues); For Python win32com.client values=[1.0]*nbvalues # array of nbvalues values to set # setting values, PYTHON complains for typeerror and expect just a float. It is not possible to pass the array of double obj.SetValues (values[0]) # values[0] is pass byval as a single float to com server #getting values, obj.GetValues (values[0]) # PYTHON expect just a float, and worst PYTHON exit as the com server tries to write an array of float Trying to pass to SetValues / GetValues something else than a float gives : return self._oleobj_.InvokeTypes(8, LCID, 1, (24, 0), ((16389, 1),),pValues TypeError: float() argument must be a string or a number, not 'VARIANT' It seems win32client do not interpret correctly the type expected by the COM server, here float() instead of pointer on an array of float. Do you have any ideas of workaround to bypass the Type control and pass byref the adress of the array and not byval the value of the first element ? Python 3.6 32 bits, pywin32-224 best regards -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Mon Jan 21 12:57:27 2019 From: timr at probo.com (Tim Roberts) Date: Mon, 21 Jan 2019 09:57:27 -0800 Subject: [python-win32] Bug - Passing byref an array to a com method interpreted as a single element In-Reply-To: <2124088560.1064134526.1548051354992.JavaMail.root@zimbra9-e2.priv.proxad.net> References: <2124088560.1064134526.1548051354992.JavaMail.root@zimbra9-e2.priv.proxad.net> Message-ID: rvc69 at free.fr wrote: > > I'm trying to translate a VBA application to Python. I cannot change > the COM Server as its works also with others programs. > It seems I have a problem with win32com.client by passing an array of > double to a COM method. > > VBA allows to pass arrays to COM server byref on the first element of > the array > ...|| > > From typelib COM interface > > |[id(0x00000007), helpstring("M?thode GetValues")] HRESULT > GetValues([in, out] double* pValues); # pointer on array of double > [id(0x00000008), helpstring("M?thode SetValues")] HRESULT > SetValues([in] double* pValues);| ... > It seems win32client do not interpret correctly the type expected by > the COM server, here float() instead of pointer on an array of float. > That statement is not accurate.? The fault is not in win32client.? The root of the problem is that the function definition in your type library is not COM-compliant.? There are rules that need to be followed in order for a COM interface to work seamlessly across languages, and you have violated those rules.? The proper way to pass an array is to use a SAFEARRAY. Your definition, for example, cannot possibly work in an out-of-process server, because there is no way for the marashaling code to know how much data to send across.? The GetValues case is doubly hopeless.? How can the server know how large the buffer is?? How can the client know how much data will be returned?? You are simply not allowed in COM to have that be assumed. Win32client is quite correct in interpreting your definition as it does.? The fact that it works in VBA is an lucky accident.? If you want this to work reliably, you need to change the interface. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Mon Jan 21 14:05:40 2019 From: timr at probo.com (Tim Roberts) Date: Mon, 21 Jan 2019 11:05:40 -0800 Subject: [python-win32] Bug - Passing byref an array to a com method interpreted as a single element In-Reply-To: References: <2124088560.1064134526.1548051354992.JavaMail.root@zimbra9-e2.priv.proxad.net> Message-ID: <5afae4d5-0bff-f688-76c0-798c59dac3c5@probo.com> Tim Roberts wrote: > rvc69 at free.fr wrote: >> >> It seems win32client do not interpret correctly the type expected by >> the COM server, here float() instead of pointer on an array of float. >> > > That statement is not accurate.? The fault is not in win32client. The > root of the problem is that the function definition in your type > library is not COM-compliant.? There are rules that need to be > followed in order for a COM interface to work seamlessly across > languages, and you have violated those rules.? The proper way to pass > an array is to use a SAFEARRAY. Your definition, for example, cannot > possibly work in an out-of-process server, because there is no way for > the marashaling code to know how much data to send across.? The > GetValues case is doubly hopeless.? How can the server know how large > the buffer is?? How can the client know how much data will be > returned?? You are simply not allowed in COM to have that be assumed. > > Win32client is quite correct in interpreting your definition as it > does.? The fact that it works in VBA is an lucky accident.? If you > want this to work reliably, you need to change the interface. Having said all that, you may be able to do what you need with the "comtypes" module, which allows lower-level access to COM interfaces. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3980 bytes Desc: S/MIME Cryptographic Signature URL: From rvc69 at free.fr Tue Jan 22 01:07:17 2019 From: rvc69 at free.fr (rvc69) Date: Tue, 22 Jan 2019 07:07:17 +0100 Subject: [python-win32] Bug - Passing byref an array to a com method interpreted as a single element In-Reply-To: Message-ID: <20190122060730.4A0EE834736@smtpfb1-g21.free.fr> Hello TimThank you for your response and time.Best regardsHerve? Envoy? depuis mon smartphone Samsung Galaxy. -------- Message d'origine --------De : Tim Roberts Date : 21/01/2019 18:57 (GMT+01:00) ? : Python-Win32 List Objet : Re: [python-win32] Bug - Passing byref an array to a com method interpreted as a single element rvc69 at free.fr wrote: > > I'm trying to translate a VBA application to Python. I cannot change > the COM Server as its works also with others programs. > It seems I have a problem with win32com.client by passing an array of > double to a COM method. > > VBA allows to pass arrays to COM server byref on the first element of > the array > ...|| > > From typelib COM interface > > |[id(0x00000007), helpstring("M?thode GetValues")] HRESULT > GetValues([in, out] double* pValues); # pointer on array of double > [id(0x00000008), helpstring("M?thode SetValues")] HRESULT > SetValues([in] double* pValues);| ... > It seems win32client do not interpret correctly the type expected by > the COM server, here float() instead of pointer on an array of float. > That statement is not accurate.? The fault is not in win32client.? The root of the problem is that the function definition in your type library is not COM-compliant.? There are rules that need to be followed in order for a COM interface to work seamlessly across languages, and you have violated those rules.? The proper way to pass an array is to use a SAFEARRAY. Your definition, for example, cannot possibly work in an out-of-process server, because there is no way for the marashaling code to know how much data to send across.? The GetValues case is doubly hopeless.? How can the server know how large the buffer is?? How can the client know how much data will be returned?? You are simply not allowed in COM to have that be assumed. Win32client is quite correct in interpreting your definition as it does.? The fact that it works in VBA is an lucky accident.? If you want this to work reliably, you need to change the interface. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org https://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From Pascal.Marchand at Honeywell.com Tue Jan 22 09:15:17 2019 From: Pascal.Marchand at Honeywell.com (Marchand, Pascal) Date: Tue, 22 Jan 2019 14:15:17 +0000 Subject: [python-win32] win32print + cx_freeze or pyinstaller, a print job which works with scrypt doesn't work when frozen. Message-ID: Hello, I posted my issue on stackoverflow: https://stackoverflow.com/questions/54239295/when-using-win32print-cx-freeze-print-instruction-doesnt-work-without-produc/54249518#54249518 Where you can found all the code if needed. Some people helps me, but we have not found the solution until now that's why I'm posting the question to the win32 mailing list. My question is: do you see any reason why the script runs fine but the frozen version doesn't work? Note that when the .exe runs, it generates 2 print jobs without printing and it puts them in "pause" mode but the only action possible is to cancel them (see below). I tried to add .dll and other win32 modules (win32api, win32con) to the package without any success until now. Maybe I'm not using well the module for printing with frozen progs. and the fact to use the script version generates some additional thing that make it correct. If you see something to test or to do, your advices are welcome. Thanks for your help. [cid:image001.png at 01D4B264.262FFD60] pascal.marchand at honeywell.com -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.png Type: image/png Size: 9400 bytes Desc: image001.png URL: From cnkhanh1986 at gmail.com Wed Jan 23 07:16:18 2019 From: cnkhanh1986 at gmail.com (ng khanh) Date: Wed, 23 Jan 2019 06:16:18 -0600 Subject: [python-win32] [Help] add all event definitions programmatically to event handler class Message-ID: Hi, I tried the basic example for win32com.client to just record how many times events have been fired? I want to test which event types would be fired by addition to self.seen_events dictionary. self.event_methods_hash get all available events definition name ('OnWorkbookOpen',' OnWorkbookAfterSave', etc..). While all user_event_class definitions do a similar task I wonder how to add all available definitions programmatically? class ExcelEvents: ## def __init__(self): self.seen_events = {} self.event_methods_hash = self._dispid_to_func_ def init_events(self,key_): if key_ not in self.seen_events.keys(): self.seen_events[key_] = 0 else: self.seen_events[key_] += 1 def OnWorkbookOpen(self, *args): key_ = "OnWorkbookOpen" self.init_events(key_) def OnWorkbookAfterSave(self,*args): key_ = "OnWorkbookAfterSave" self.init_events(key_) event_names = ["OnWorkbookOpen"] wait_time = 1 import win32com.client as win32 excel # => excel.Visible = True excel_events = win32.WithEvents(excel, ExcelEvents) f_path_out = 'HHW_last_out.xlsx' try: book = excel.Workbooks.Open(f_path_out) book_autorecover_status = book.EnableAutoRecover book.EnableAutoRecover = False book.Save() book.EnableAutoRecover = book_autorecover_status except Exception as e: print("Something Wrong") print(e) else: print("Finished Properly") print(excel_events.seen_events) finally: excel_events.close() Thanks Khanh Ng -------------- next part -------------- An HTML attachment was scrubbed... URL: From erhard.glueck.austria at gmail.com Thu Jan 24 13:52:11 2019 From: erhard.glueck.austria at gmail.com (=?UTF-8?Q?Erhard_Gl=C3=BCck?=) Date: Thu, 24 Jan 2019 19:52:11 +0100 Subject: [python-win32] file_created - what is it? Message-ID: Hello! I want build debug version of pywin32-master from source without the extensions exchange and exchdapi. Had build without Admin rights and got the message *The pywin32 extensions were successfully installed* But with not unusable* import win32ui *and unusable* Pythonwin_d.exe* If I start setup.py with Admin rights, the script pywin32_postinstall.py is not started. Now I want start pywin32_postinstall.py alone with admin rights I have problems with the *file_created* statements, which are not defined. Thank you for advice Erhy -------------- next part -------------- An HTML attachment was scrubbed... URL: From neerajchhabrascs at gmail.com Mon Jan 28 23:25:38 2019 From: neerajchhabrascs at gmail.com (Neeraj Chhabra) Date: Tue, 29 Jan 2019 09:55:38 +0530 Subject: [python-win32] Facing issue while connecting to alm via python Message-ID: Hi team, I have one requirement, in which i need to connect to HP ALM and log a defect in jira using python. i tried to connect to alm through pywin32. but getting error. please check below code snippet and error - *code -* import win32com from win32com.client import Dispatch qcServer = "" qcUser = "" qcPassword = "" qcDomain = "" qcProject = "" td = win32com.client.Dispatch("TDApiOle80.TDConnection.1") #Starting to connect td.InitConnectionEx(qcServer) td.Login(qcUser, qcPassword) td.Connect(qcDomain, qcProject) if td.Connected is True: print("Connected to " + qcProject) else: print("Connection failed") *Error* - IDispatch = pythoncom.connect(IDispatch) pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:/Users/Ajit_Mallick/PycharmProjects/Test/almcon.py", line 11, in td = win32com.client.Dispatch("TDApiOle80.TDConnection.1") File "C:\Users\Ajit_Mallick\PycharmProjects\Test\venv\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\Users\Ajit_Mallick\PycharmProjects\Test\venv\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Users\Ajit_Mallick\PycharmProjects\Test\venv\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2147221164, 'Class not registered', None, None) Process finished with exit code 1 Regards, Neeraj Chhabra -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Jan 29 12:41:36 2019 From: timr at probo.com (Tim Roberts) Date: Tue, 29 Jan 2019 09:41:36 -0800 Subject: [python-win32] Facing issue while connecting to alm via python In-Reply-To: References: Message-ID: <69f96b29-bf61-9e2a-d2dc-8243eface948@probo.com> Neeraj Chhabra wrote: > > I have one requirement, in which i need to connect to HP ALM and log a > defect in jira using python. i tried to connect to alm through > pywin32. but getting error. please check below code snippet and error - > ... > IDispatch = pythoncom.connect(IDispatch) > pywintypes.com_error: (-2147221021, 'Operation unavailable', None, > None) During handling of the above exception, another exception > occurred: ... pywintypes.com_error: (-2147221164, 'Class not > registered', None, None) It's likely that you are using a 64-bit Python but your ALM installation is 32-bit.? An in-process COM server has to match the bittedness of the caller.? Do you have the option of installing a 32-bit Python to see if it works from there? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3980 bytes Desc: S/MIME Cryptographic Signature URL: