From cwalou at gmail.com Wed May 3 10:00:13 2023 From: cwalou at gmail.com (cwalou at gmail.com) Date: Wed, 3 May 2023 16:00:13 +0200 Subject: [python-win32] GetNetworkConnections fails since a Windows update Message-ID: <41fec475-eb5f-ac33-ae55-acb0afe0017c@gmail.com> Hello. After a recent update on Windows 10, I not able to tell exactly which, I've a strange behavior on a program that works fine since 2015 on thousands of machines... * With this code : def networks_private(): NETWORK_CATEGORIES = {1: "PRIVATE",0: "PUBLIC", 2: "DOMAIN"} m = win32com.client.Dispatch("{DCB00C01-570F-4A9B-8D69-199FDBA5723B}") more = 1 pos = 1 connections = m.GetNetworkConnections() while more: connection, more = connections.Next(pos) if connection: network = connection.GetNetwork() category = network.GetCategory() try: log('switching network interface in private mode') network.SetCategory(1) except: log("error switching network interface in private mode") pos += 1 * I get this error : Traceback (most recent call last): [...] File "Frame1.pyo", line 163, in _init_ File "fonctions.pyo", line 201, in networks_private File "win32com\client\dynamic.pyo", line 522, ingetattr_ AttributeError: Next.GetNetwork Regards, thanks. From steven at manross.net Wed May 3 15:12:10 2023 From: steven at manross.net (Steven Manross) Date: Wed, 3 May 2023 19:12:10 +0000 Subject: [python-win32] GetNetworkConnections fails since a Windows update In-Reply-To: <41fec475-eb5f-ac33-ae55-acb0afe0017c@gmail.com> References: <41fec475-eb5f-ac33-ae55-acb0afe0017c@gmail.com> Message-ID: <50f02cbe522d4ca79c8109046d63481a@manross.net> That happens here too in Win10/Win11 using your code. It looks like Microsoft altered the COM object for you not to be able to do a GetNetwork or GetCategory on the connection object, but that seems odd since it basically renders the object pointless. P.S. some powershell code doesn't seem to be able to access the GetNetwork function either. $networkListManager = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]"{DCB00C01-570F-4A9B-8D69-199FDBA5723B}")) $connections = $networkListManager.GetNetworkConnections() $connections |foreach { $_.GetNetwork() } Element not found. (Exception from HRESULT: 0x8002802B (TYPE_E_ELEMENTNOTFOUND)) At line:2 char:5 + $_.GetNetwork() + ~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (:) [], COMException + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException Steven -----Original Message----- From: python-win32 On Behalf Of cwalou at gmail.com Sent: Wednesday, May 3, 2023 7:00 AM To: python-win32 at python.org Subject: [python-win32] GetNetworkConnections fails since a Windows update Hello. After a recent update on Windows 10, I not able to tell exactly which, I've a strange behavior on a program that works fine since 2015 on thousands of machines... * With this code : def networks_private(): NETWORK_CATEGORIES = {1: "PRIVATE",0: "PUBLIC", 2: "DOMAIN"} m = win32com.client.Dispatch("{DCB00C01-570F-4A9B-8D69-199FDBA5723B}") more = 1 pos = 1 connections = m.GetNetworkConnections() while more: connection, more = connections.Next(pos) if connection: network = connection.GetNetwork() category = network.GetCategory() try: log('switching network interface in private mode') network.SetCategory(1) except: log("error switching network interface in private mode") pos += 1 * I get this error : Traceback (most recent call last): [...] File "Frame1.pyo", line 163, in _init_ File "fonctions.pyo", line 201, in networks_private File "win32com\client\dynamic.pyo", line 522, ingetattr_ AttributeError: Next.GetNetwork Regards, thanks. _______________________________________________ python-win32 mailing list python-win32 at python.org https://mail.python.org/mailman/listinfo/python-win32 From pranav.pawar9119 at gmail.com Wed May 17 05:39:35 2023 From: pranav.pawar9119 at gmail.com (Pranav S Pawar) Date: Wed, 17 May 2023 15:09:35 +0530 Subject: [python-win32] (no subject) Message-ID: Hello Team, I am getting an error while using persistence_units.CloseAll() method of persistence_units module. of win32com Error: AttributeError: '' object has no attribute 'CloseAll' Below is my code where i am trying to access and erwin datamodel , check connection and close connection. i *mport win32com.client as win32# Create an instance of the erwin APIerwin_api = win32.Dispatch("erwin9.SCAPI")# Connect to erwin Data Modeler Mart or local repository# Get the PersistenceUnits collectionpersistence_units = erwin_api.PersistenceUnits# Open an existing persistence unitexisting_persistence_unit = persistence_units.Add(r"D:\\testdm.erwin")print("Opened existing persistence unit:", existing_persistence_unit.Name)# Close all persistence unitspersistence_units.CloseAll()print("Closed all persistence units")# Save changes to all persistence units#persistence_units.SaveAll()print("Saved changes to all persistence units")* Can you please let me know, what is the correct method if CloseAll is not the correct method. Is there any link where I can get all the methods of erwin_api.PersistenceUnits ? Thanks, Pranav -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Wed May 17 08:50:56 2023 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 17 May 2023 08:50:56 -0400 Subject: [python-win32] (no subject) In-Reply-To: References: Message-ID: I'm sorry, but you are very unlikely to find anyone on this list with erwin experience. pywin32 is a general purpose library that allows talking to *any* COM object, so there are literally hundreds and hundreds of different apps it can work with. I've never even heard of erwin and have no idea what it does :( You might fine someone else on this list has, and can help you, but in the meantime... You really need to find support for the erwin app, not pywin32. Because COM works in any language, you might find the help you need is written in terms of a language other than Python, but the answer should translate across to Python. Good luck, Mark On 2023-05-17 5:39 a.m., Pranav S Pawar wrote: > Hello Team, > > I am getting an error while using persistence_units.CloseAll() method > of persistence_units module. of win32com > > Error: AttributeError: ' Client API Type Library.ISCPersistenceUnitCollection instance at > 0x3171750852880>' object has no attribute 'CloseAll' > > Below is my code where i am trying to access and erwin datamodel?, > check connection and close connection. > > i/mport win32com.client as win32 > > # Create an instance of the erwin API > erwin_api = win32.Dispatch("erwin9.SCAPI") > > # Connect to erwin Data Modeler Mart or local repository > # Get the PersistenceUnits collection > persistence_units = erwin_api.PersistenceUnits > > # Open an existing persistence unit > existing_persistence_unit = persistence_units.Add(r"D:\\testdm.erwin") > print("Opened existing persistence unit:", existing_persistence_unit.Name) > > # Close all persistence units > persistence_units.CloseAll() > print("Closed all persistence units") > > # Save changes to all persistence units > #persistence_units.SaveAll() > print("Saved changes to all persistence units")/ > > Can you please let me know, what is the correct method if CloseAll is > not the correct method. > Is there any link where I can get all the methods of > erwin_api.PersistenceUnits ? > > Thanks, > > Pranav > > _______________________________________________ > 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 pranav.pawar9119 at gmail.com Thu May 18 01:56:43 2023 From: pranav.pawar9119 at gmail.com (Pranav S Pawar) Date: Thu, 18 May 2023 11:26:43 +0530 Subject: [python-win32] (no subject) In-Reply-To: References: Message-ID: Hello Mark, Thank you for the response. Just to share Erwin is an Data Modelling tool. I wanted to access Erwin through python and perform manipulations on DataModel through it. Regards, Pranav On Wed, May 17, 2023 at 6:21?PM Mark Hammond wrote: > I'm sorry, but you are very unlikely to find anyone on this list with > erwin experience. pywin32 is a general purpose library that allows talking > to *any* COM object, so there are literally hundreds and hundreds of > different apps it can work with. I've never even heard of erwin and have no > idea what it does :( You might fine someone else on this list has, and can > help you, but in the meantime... > > You really need to find support for the erwin app, not pywin32. Because > COM works in any language, you might find the help you need is written in > terms of a language other than Python, but the answer should translate > across to Python. > > Good luck, > > Mark > On 2023-05-17 5:39 a.m., Pranav S Pawar wrote: > > Hello Team, > > I am getting an error while using persistence_units.CloseAll() method of > persistence_units module. of win32com > > Error: AttributeError: ' API Type Library.ISCPersistenceUnitCollection instance at 0x3171750852880>' > object has no attribute 'CloseAll' > > Below is my code where i am trying to access and erwin datamodel , check > connection and close connection. > > i > > > > > > > > > > > > > > > > > > > *mport win32com.client as win32 # Create an instance of the erwin API > erwin_api = win32.Dispatch("erwin9.SCAPI") # Connect to erwin Data Modeler > Mart or local repository # Get the PersistenceUnits collection > persistence_units = erwin_api.PersistenceUnits # Open an existing > persistence unit existing_persistence_unit = > persistence_units.Add(r"D:\\testdm.erwin") print("Opened existing > persistence unit:", existing_persistence_unit.Name) # Close all persistence > units persistence_units.CloseAll() print("Closed all persistence units") # > Save changes to all persistence units #persistence_units.SaveAll() > print("Saved changes to all persistence units")* > > Can you please let me know, what is the correct method if CloseAll is not > the correct method. > Is there any link where I can get all the methods of > erwin_api.PersistenceUnits ? > > Thanks, > > Pranav > > _______________________________________________ > python-win32 mailing listpython-win32 at python.orghttps://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pranav.pawar9119 at gmail.com Mon May 22 11:05:15 2023 From: pranav.pawar9119 at gmail.com (Pranav S Pawar) Date: Mon, 22 May 2023 20:35:15 +0530 Subject: [python-win32] Win32: -2147418113, 'Catastrophic failure' Message-ID: Hello Team, My code was working fine from one week in jupyter notebook. Today i just did a kernel restart in jupyter notebook and my code stopped working. Not sure what happened after restart. Tried all options but not able to resolve. So through to get help from here. Basically i am trying to get erwin api through => win32com.client.Dispatch("erwin9.SCAPI") but getting error. Giving Code as well as error below. Please advise what corrective action should be taken. I have tried to upgrade pywin32 module but still same error. *Code:* import win32com.client erwin = win32com.client.Dispatch("erwin9.SCAPI") print('Connected') *Error:* com_error Traceback (most recent call last) File C:\Python310\lib\site-packages\win32com\client\dynamic.py:84, in _GetGoodDispatch(IDispatch, clsctx) 83 try:---> 84 IDispatch = pythoncom.connect(IDispatch) 85 except pythoncom.ole_error: com_error: (-2147221021, 'Operation unavailable', None, None) During handling of the above exception, another exception occurred: com_error Traceback (most recent call last) Input In [17], in () 1 import win32com.client----> 3 erwin = win32com.client.Dispatch("erwin9.SCAPI") 5 print('Connected') File C:\Python310\lib\site-packages\win32com\client\__init__.py:118, in Dispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString, clsctx) 116 """Creates a Dispatch based COM object.""" 117 assert UnicodeToString is None, "this is deprecated and will go away"--> 118 dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch, userName, clsctx) 119 return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx) File C:\Python310\lib\site-packages\win32com\client\dynamic.py:104, in _GetGoodDispatchAndUserName(IDispatch, userName, clsctx) 101 ## ??? else userName remains None ??? 102 else: 103 userName = str(userName)--> 104 return (_GetGoodDispatch(IDispatch, clsctx), userName) File C:\Python310\lib\site-packages\win32com\client\dynamic.py:86, in _GetGoodDispatch(IDispatch, clsctx) 84 IDispatch = pythoncom.connect(IDispatch) 85 except pythoncom.ole_error:---> 86 IDispatch = pythoncom.CoCreateInstance( 87 IDispatch, None, clsctx, pythoncom.IID_IDispatch 88 ) 89 else: 90 # may already be a wrapped class. 91 IDispatch = getattr(IDispatch, "_oleobj_", IDispatch) com_error: (-2147418113, 'Catastrophic failure', None, None) Thanks & Best Regards, Pranav -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Tue May 23 11:39:11 2023 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 23 May 2023 11:39:11 -0400 Subject: [python-win32] Win32: -2147418113, 'Catastrophic failure' In-Reply-To: References: Message-ID: <3afca26e-dea9-2bb0-555e-25379abfe0f8@skippinet.com.au> On 2023-05-22 11:05 a.m., Pranav S Pawar wrote: > Hello Team, > > My code was working fine from one week in jupyter notebook. > Today i just did a kernel restart in jupyter notebook?and my code > stopped working. > > Not sure what happened after restart. Tried all options but not able > to resolve. > So through?to get help from here. > > Basically i am trying to get erwin api through => > win32com.client.Dispatch("erwin9.SCAPI") Again, this sounds like an issue with erwin, not python/pywin32. Cheers, Mark > > but getting error. > > Giving Code as well as error below. > Please advise what corrective action should be taken. > I have tried to upgrade pywin32 module?but still same error. > > *Code:* > import win32com.client > erwin = win32com.client.Dispatch("erwin9.SCAPI") > print('Connected') > > *Error:* > > com_error Traceback (most recent call last) > FileC:\Python310\lib\site-packages\win32com\client\dynamic.py:84, in_GetGoodDispatch(IDispatch, clsctx) > 83 try: > ---> 84 IDispatch= pythoncom.connect(IDispatch) > 85 except pythoncom.ole_error: > > com_error: (-2147221021, 'Operation unavailable', None, None) > > During handling of the above exception, another exception occurred: > > com_error Traceback (most recent call last) > InputIn [17], in() > 1 import win32com.client > ----> 3 erwin= win32com.client.Dispatch("erwin9.SCAPI") > 5 print('Connected') > > FileC:\Python310\lib\site-packages\win32com\client\__init__.py:118, inDispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString, > clsctx) > 116 """Creates a Dispatch based COM object.""" > 117 assert UnicodeToStringis None,"this is deprecated and will go away" > --> 118 dispatch, userName= dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) > 119 return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx) > > FileC:\Python310\lib\site-packages\win32com\client\dynamic.py:104, in_GetGoodDispatchAndUserName(IDispatch, userName, clsctx) > 101 ## ??? else userName remains None ??? > 102 else: > 103 userName= str(userName) > --> 104 return (_GetGoodDispatch(IDispatch,clsctx), userName) > > FileC:\Python310\lib\site-packages\win32com\client\dynamic.py:86, in_GetGoodDispatch(IDispatch, clsctx) > 84 IDispatch= pythoncom.connect(IDispatch) > 85 except pythoncom.ole_error: > ---> 86 IDispatch= pythoncom.CoCreateInstance( > 87 IDispatch,None,clsctx,pythoncom.IID_IDispatch > 88 ) > 89 else: > 90 # may already be a wrapped class. > 91 IDispatch= getattr(IDispatch,"_oleobj_", IDispatch) > > com_error: (-2147418113, 'Catastrophic failure', None, None) > > Thanks & Best Regards, > > Pranav -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven at manross.net Tue May 23 13:04:41 2023 From: steven at manross.net (Steven Manross) Date: Tue, 23 May 2023 17:04:41 +0000 Subject: [python-win32] Win32: -2147418113, 'Catastrophic failure' In-Reply-To: References: Message-ID: <7edfaf52f20048ca984fb5e1152026df@manross.net> And just to reiterate what Mark said, but also validate that this is the case from code: You should be able to run this without issue? (and validate pywin32 works fine) mydict = win32com.client.Dispatch("Scripting.Dictionary") ? since the ?Scripting.Dictionary? COM class lives on every windows installation since Windows 2000 (or earlier). Steven From: python-win32 On Behalf Of Pranav S Pawar Sent: Monday, May 22, 2023 8:05 AM To: Mark Hammond ; python-win32 at python.org Subject: [python-win32] Win32: -2147418113, 'Catastrophic failure' Hello Team, My code was working fine from one week in jupyter notebook. Today i just did a kernel restart in jupyter notebook and my code stopped working. Not sure what happened after restart. Tried all options but not able to resolve. So through to get help from here. Basically i am trying to get erwin api through => win32com.client.Dispatch("erwin9.SCAPI") but getting error. Giving Code as well as error below. Please advise what corrective action should be taken. I have tried to upgrade pywin32 module but still same error. Code: import win32com.client erwin = win32com.client.Dispatch("erwin9.SCAPI") print('Connected') Error: com_error Traceback (most recent call last) File C:\Python310\lib\site-packages\win32com\client\dynamic.py:84, in _GetGoodDispatch(IDispatch, clsctx) 83 try: ---> 84 IDispatch = pythoncom.connect(IDispatch) 85 except pythoncom.ole_error: com_error: (-2147221021, 'Operation unavailable', None, None) During handling of the above exception, another exception occurred: com_error Traceback (most recent call last) Input In [17], in () 1 import win32com.client ----> 3 erwin = win32com.client.Dispatch("erwin9.SCAPI") 5 print('Connected') File C:\Python310\lib\site-packages\win32com\client\__init__.py:118, in Dispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString, clsctx) 116 """Creates a Dispatch based COM object.""" 117 assert UnicodeToString is None, "this is deprecated and will go away" --> 118 dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch, userName, clsctx) 119 return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx) File C:\Python310\lib\site-packages\win32com\client\dynamic.py:104, in _GetGoodDispatchAndUserName(IDispatch, userName, clsctx) 101 ## ??? else userName remains None ??? 102 else: 103 userName = str(userName) --> 104 return (_GetGoodDispatch(IDispatch, clsctx), userName) File C:\Python310\lib\site-packages\win32com\client\dynamic.py:86, in _GetGoodDispatch(IDispatch, clsctx) 84 IDispatch = pythoncom.connect(IDispatch) 85 except pythoncom.ole_error: ---> 86 IDispatch = pythoncom.CoCreateInstance( 87 IDispatch, None, clsctx, pythoncom.IID_IDispatch 88 ) 89 else: 90 # may already be a wrapped class. 91 IDispatch = getattr(IDispatch, "_oleobj_", IDispatch) com_error: (-2147418113, 'Catastrophic failure', None, None) Thanks & Best Regards, Pranav -------------- next part -------------- An HTML attachment was scrubbed... URL: From kristiine.silinja at gmail.com Thu May 25 08:29:32 2023 From: kristiine.silinja at gmail.com (Kristiine Silinja) Date: Thu, 25 May 2023 15:29:32 +0300 Subject: [python-win32] pywin32 does not have win32ui under MSYS2 Message-ID: Hi! I am running MSYS2 on Windows 10 (64bit) with Python 3.10.11. I was able to install https://packages.msys2.org/base/mingw-w64-python-pywin32 using pacman. However, it seems that the installation is missing the win32ui library. I see files for other modules, but no mention of win32ui. win32api, win32print, win32con can be imported, but win32ui import, as expected, throws ModuleNotFoundError. Has anyone encountered this issue in the MSYS2 environment? Is there a way to fix it? Note: pywin32 306 build installed. pip under MSYS2 gives python -m pip install --upgrade pywin32 ERROR: Could not find a version that satisfies the requirement pywin32 (from versions: none) With best regards, *-Kristiine Silinja* -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Thu May 25 09:20:00 2023 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 25 May 2023 09:20:00 -0400 Subject: [python-win32] pywin32 does not have win32ui under MSYS2 In-Reply-To: References: Message-ID: win32ui is a wrapper around the MS "MFC" library. I suspect that there are reasons that can't be built for MSYS2, but you'd need to ask whoever packages that version up - it's not released by the pywin32 project. Cheers, Mark On 2023-05-25 8:29 a.m., Kristiine Silinja wrote: > Hi! > > I am running?MSYS2 on Windows 10 (64bit) with Python 3.10.11. I was > able to install > https://packages.msys2.org/base/mingw-w64-python-pywin32 using?pacman. > However, it seems that the installation is missing the win32ui > library. I see files for other modules, but no mention of win32ui. > win32api, win32print, win32con can be imported, but win32ui import, as > expected, throws ModuleNotFoundError. > > Has anyone encountered this issue in the MSYS2 environment? Is there a > way to fix it? > > Note: pywin32 306 build installed. > > pip under MSYS2 gives > python -m pip install --upgrade pywin32 > ERROR: Could not find a version that satisfies the requirement pywin32 > (from versions: none) > > With best regards, > /-Kristiine Silinja/ > > _______________________________________________ > 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 kristiine.silinja at gmail.com Thu May 25 10:04:18 2023 From: kristiine.silinja at gmail.com (Kristiine Silinja) Date: Thu, 25 May 2023 17:04:18 +0300 Subject: [python-win32] pywin32 does not have win32ui under MSYS2 In-Reply-To: References: Message-ID: Thank you for a quick response. Will get in touch with msys2-packages. With best regards, *-Kristiine Silinja* On Thu, May 25, 2023 at 4:20?PM Mark Hammond wrote: > win32ui is a wrapper around the MS "MFC" library. I suspect that there are > reasons that can't be built for MSYS2, but you'd need to ask whoever > packages that version up - it's not released by the pywin32 project. > > Cheers, > > Mark > On 2023-05-25 8:29 a.m., Kristiine Silinja wrote: > > Hi! > > I am running MSYS2 on Windows 10 (64bit) with Python 3.10.11. I was able > to install https://packages.msys2.org/base/mingw-w64-python-pywin32 > using pacman. > However, it seems that the installation is missing the win32ui library. I > see files for other modules, but no mention of win32ui. win32api, > win32print, win32con can be imported, but win32ui import, as expected, > throws ModuleNotFoundError. > > Has anyone encountered this issue in the MSYS2 environment? Is there a way > to fix it? > > Note: pywin32 306 build installed. > > pip under MSYS2 gives > python -m pip install --upgrade pywin32 > ERROR: Could not find a version that satisfies the requirement pywin32 > (from versions: none) > > With best regards, > *-Kristiine Silinja* > > _______________________________________________ > python-win32 mailing listpython-win32 at python.orghttps://mail.python.org/mailman/listinfo/python-win32 > > _______________________________________________ > 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 namezero911 at yahoo.com Mon May 29 09:01:54 2023 From: namezero911 at yahoo.com (name zero) Date: Mon, 29 May 2023 13:01:54 +0000 (UTC) Subject: [python-win32] Setting Focus Assist Mode via COM References: <485248794.3882013.1685365314860.ref@mail.yahoo.com> Message-ID: <485248794.3882013.1685365314860@mail.yahoo.com> Hi, could someone help me out with first steps for how to set Focus Assist via COM, which https://gist.github.com/riverar/085d98ffb1343e92225a10817109b2e3 demonstrates for a C++ code base? Something like win32com.client.Dispatch('{6bff4732-81ec-4ffb-ae67-b6c1bc29631f}', clsctx=pythoncom.CLSCTX_LOCAL_SERVER) fails with "pywintypes.com_error: (-2147221164, 'Class not registered', None, None)" Thank you and best regards! -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladimir.alexiev at ontotext.com Mon May 29 02:28:15 2023 From: vladimir.alexiev at ontotext.com (Vladimir Alexiev) Date: Mon, 29 May 2023 09:28:15 +0300 Subject: [python-win32] win32clipboard.SetClipboardData doesn't support Unicode Message-ID: Hi everyone! I've posted https://github.com/mhammond/pywin32/issues/2061 with full info about the bug. It uses the program listed at https://stackoverflow.com/questions/76175244/how-to-put-formatted-text-on-clipboard-with-python-and-avoid-conflict-with-ditto I think the critical line is this: win32clipboard.SetClipboardData(self.GetCfHtml(), src.encode('utf-8')) The data is obtained from stdin and is already in UTF8 -------------- next part -------------- An HTML attachment was scrubbed... URL: From martintrujillor at gmail.com Mon May 29 15:05:02 2023 From: martintrujillor at gmail.com (=?UTF-8?Q?Mart=C3=ADn_Trujillo_Raddatz?=) Date: Mon, 29 May 2023 15:05:02 -0400 Subject: [python-win32] unknow solution Message-ID: i ve using the library for some time now without any trouble...... but a few days ago the script for a conversion in word from doc to pdf respond with this error sometimes, other works fine, the error is random, i cant figure out why occurs. the error is: Traceback (most recent call last): File "C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\dynamic.py", line 81, in _GetGoodDispatch IDispatch = pythoncom.connect(IDispatch) pywintypes.com_error: (-2147221021, 'Operaci?n no disponible', None, None) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\inetpub\wwwroot\ruc2docs\r2d2documento.py", line 14, in __init__ self.save_as_('pdf') File "C:\inetpub\wwwroot\ruc2docs\r2d2documento.py", line 25, in save_as_ word = win32.gencache.EnsureDispatch('Word.Application') File "C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\gencache.py", line 524, in EnsureDispatch disp = win32com.client.Dispatch(prog_id) File "C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\dynamic.py", line 83, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2146959355, 'Error en la ejecuci?n de servidor', None, None) the code to execute the conversion is: def save_as_(self, tipo): import win32com.client as win32 from win32com.client import constants # self.registrar_conversion() word = win32.gencache.EnsureDispatch('Word.Application') doc = word.Documents.Open(self.ruta, ReadOnly=True, AddToRecentFiles=False, Revert=True, Visible=False) doc.Activate() if tipo == 'pdf': word.ActiveDocument.SaveAs(self.ruta[:-4] + '.pdf', FileFormat=constants.wdFormatPDF) elif tipo == 'docx': word.ActiveDocument.SaveAs(self.ruta[:-4] + '.doc', FileFormat=constants.wdFormatXMLDocument) doc.Close(SaveChanges=constants.wdDoNotSaveChanges) word.Quit() Thank you! *----------------------------------------* *Mart?n Trujillo Raddatz Puerto Montt - Chile Tel?fono: +56 9 96427814 * *----------------------------------------* -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven at manross.net Tue May 30 13:44:28 2023 From: steven at manross.net (Steven Manross) Date: Tue, 30 May 2023 17:44:28 +0000 Subject: [python-win32] makepy.py "Some COM library" Message-ID: <28e49ca1495c4b02b70947b61861fb89@manross.net> Command I ran: C:\Python311\Lib\site-packages\win32com\client>python makepy.py "ADODB.Connection.6.0" Output: Generating to C:\Users\someuser\AppData\Local\Temp\13\gen_py\3.11\B691E011-1797-432E-907A-4D8C69339129x0x6x1.py Building definitions from type library... Generating... Importing module --- I am running the command above, and if I do this, my Classic ASP does not see the resulting B691E011-1797-432E-907A-4D8C69339129x0x6x1.py file because it saved the file in the user temp directory as opposed to in the site-packages directory structure. * When I installed Python, I told it to install the application for "All Users" (Default Directory = C:\Program Files\Python311 -- but I removed the Program Files portion for the installation) Is there some way to make it save the file in the correct place for the python installation from the command line so I don't have to move the files it generates? Keep in mind that the files it generates seems to live in a 3.11 directory, but python seems to want it in: C:\Python311\Lib\site-packages\win32com\gen_py\B691E011-1797-432E-907A-4D8C69339129x0x6x1.py C:\Python311\Lib\site-packages\win32com\gen_py\dicts.dat C:\Python311\Lib\site-packages\win32com\gen_py\__init__.py I saw the -o parameter in the makepy.py script but if I use that, it doesn't seem to build the dicts.dat or __init__.py files - which already exist (is that a problem?). Please and thank you for any comments, Steven -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Tue May 30 14:01:04 2023 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 30 May 2023 14:01:04 -0400 Subject: [python-win32] makepy.py "Some COM library" In-Reply-To: <28e49ca1495c4b02b70947b61861fb89@manross.net> References: <28e49ca1495c4b02b70947b61861fb89@manross.net> Message-ID: <475c5346-7af2-e32c-ea6f-b9c593bb4e75@skippinet.com.au> Does something like `python -c "from win32com.client.gencache import EnsureDispatch; EnsureDispatch('ADODB.Connection.6.0');` work? That should generate directly into the expected output directory. Mark On 2023-05-30 1:44 p.m., Steven Manross wrote: > > Command I ran: > > C:\Python311\Lib\site-packages\win32com\client>python makepy.py > "ADODB.Connection.6.0" > > Output: > > Generating to > C:\Users\someuser\AppData\Local\Temp\13\gen_py\3.11\B691E011-1797-432E-907A-4D8C69339129x0x6x1.py > > Building definitions from type library... > > Generating... > > Importing module > > --- > > I am running the command above, and if I do this, my Classic ASP does > not see the resulting B691E011-1797-432E-907A-4D8C69339129x0x6x1.py > file because it saved the file in the user temp directory as opposed > to in the site-packages directory structure. > > * When I installed Python, I told it to install the application for > ?All Users? (Default Directory = C:\Program Files\Python311 -- but > I removed the Program Files portion for the installation) > > Is there some way to make it save the file in the correct place for > the python installation from the command line so I don?t have to move > the files it generates? > > Keep in mind that the files it generates seems to live in a 3.11 > directory, but python seems to want it in: > > C:\Python311\Lib\site-packages\win32com\gen_py\B691E011-1797-432E-907A-4D8C69339129x0x6x1.py > > C:\Python311\Lib\site-packages\win32com\gen_py\dicts.dat > > C:\Python311\Lib\site-packages\win32com\gen_py\__init__.py > > I saw the -o parameter in the makepy.py script but if I use that, it > doesn?t seem to build the dicts.dat or __init__.py files ? which > already exist (is that a problem?). > > Please and thank you for any comments, > > Steven > > > _______________________________________________ > 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 steven at manross.net Tue May 30 14:23:49 2023 From: steven at manross.net (Steven Manross) Date: Tue, 30 May 2023 18:23:49 +0000 Subject: [python-win32] makepy.py "Some COM library" In-Reply-To: <475c5346-7af2-e32c-ea6f-b9c593bb4e75@skippinet.com.au> References: <28e49ca1495c4b02b70947b61861fb89@manross.net> <475c5346-7af2-e32c-ea6f-b9c593bb4e75@skippinet.com.au> Message-ID: <5fd703c882b34353a5b47a8a9bb07759@manross.net> C:\Python39\Lib\site-packages\win32com\client>python -c "from win32com.client.gencache import EnsureDispatch; EnsureDispatch('ADODB.Connection.6.0'); That code seems to generate a directory in the correct path in both 3.9 and 3.11 C:\Python39\Lib\site-packages\win32com\gen_py\B691E011-1797-432E-907A-4D8C69339129x0x6x1 * With the files: __init__.py _Connection.py Connection.py ConnectionEvents.py * Similar for 3.11 (base dir name is C:\Python311) Also? I?ve noticed (just now) that Python 3.9 makepy.py seems to put the constants file in the correct path? and 3.11 doesn?t. Test environment = Win2019 (Py3.11 ? multiple systems) and Win10 (Py3.9 ? one system)? I should have some 3.10 systems here too in case that helps identify any issue(s) HTH and let know if you want any more testing performed. I?m always happy to help. Steven From: Mark Hammond Sent: Tuesday, May 30, 2023 11:01 AM To: Steven Manross ; python-win32 at python.org Subject: Re: [python-win32] makepy.py "Some COM library" Does something like `python -c "from win32com.client.gencache import EnsureDispatch; EnsureDispatch('ADODB.Connection.6.0');` work? That should generate directly into the expected output directory. Mark On 2023-05-30 1:44 p.m., Steven Manross wrote: Command I ran: C:\Python311\Lib\site-packages\win32com\client>python makepy.py "ADODB.Connection.6.0" Output: Generating to C:\Users\someuser\AppData\Local\Temp\13\gen_py\3.11\B691E011-1797-432E-907A-4D8C69339129x0x6x1.py Building definitions from type library... Generating... Importing module --- I am running the command above, and if I do this, my Classic ASP does not see the resulting B691E011-1797-432E-907A-4D8C69339129x0x6x1.py file because it saved the file in the user temp directory as opposed to in the site-packages directory structure. 1. When I installed Python, I told it to install the application for ?All Users? (Default Directory = C:\Program Files\Python311 -- but I removed the Program Files portion for the installation) Is there some way to make it save the file in the correct place for the python installation from the command line so I don?t have to move the files it generates? Keep in mind that the files it generates seems to live in a 3.11 directory, but python seems to want it in: C:\Python311\Lib\site-packages\win32com\gen_py\B691E011-1797-432E-907A-4D8C69339129x0x6x1.py C:\Python311\Lib\site-packages\win32com\gen_py\dicts.dat C:\Python311\Lib\site-packages\win32com\gen_py\__init__.py I saw the -o parameter in the makepy.py script but if I use that, it doesn?t seem to build the dicts.dat or __init__.py files ? which already exist (is that a problem?). Please and thank you for any comments, Steven _______________________________________________ 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 steven at manross.net Tue May 30 17:28:57 2023 From: steven at manross.net (Steven Manross) Date: Tue, 30 May 2023 21:28:57 +0000 Subject: [python-win32] unknow solution In-Reply-To: References: Message-ID: <92c6f75b64474ab5b5ff4cf8f658688b@manross.net> While I?ve done word automation in the past, is it possible that there?s any issues with the word application installation itself? Or maybe you might have multiple scripts trying to open/write files simultaneously? As well, I might consider looking at task manager on your web server to see if there are a lot of processes for word that might create some sort of bottleneck, or concurrency issue. I know when I am doing some selenium work with Google Chrome, sometimes it leaves a rogue Chrome process running, and as a result, the server gets bogged down and can?t do what it?s supposed to very well because of all the chrome processes left over from failed python script instances. Typically the error you are seeing might point to a problem with some variable you believe should be an expected value, but in this case, it?s None, or another non-standard value? Typically, I will log that kind of data from my classic asp web pages to understand the problem more. In your case, I might start by writing the file name (self.ruta) to a log file in case it?s blank, or has special characters in it that could be causing issues. I hope this helps. The error messages you are seeing are quite generic, and reference a problem with rendering the webpage and not necessarily a python specific error. Steven From: python-win32 On Behalf Of Mart?n Trujillo Raddatz Sent: Monday, May 29, 2023 12:05 PM To: python-win32 at python.org Subject: [python-win32] unknow solution i ve using the library for some time now without any trouble...... but a few days ago the script for a conversion in word from doc to pdf respond with this error sometimes, other works fine, the error is random, i cant figure out why occurs. the error is: Traceback (most recent call last): File "C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\dynamic.py", line 81, in _GetGoodDispatch IDispatch = pythoncom.connect(IDispatch) pywintypes.com_error: (-2147221021, 'Operaci?n no disponible', None, None) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\inetpub\wwwroot\ruc2docs\r2d2documento.py", line 14, in __init__ self.save_as_('pdf') File "C:\inetpub\wwwroot\ruc2docs\r2d2documento.py", line 25, in save_as_ word = win32.gencache.EnsureDispatch('Word.Application') File "C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\gencache.py", line 524, in EnsureDispatch disp = win32com.client.Dispatch(prog_id) File "C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\dynamic.py", line 83, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2146959355, 'Error en la ejecuci?n de servidor', None, None) the code to execute the conversion is: def save_as_(self, tipo): import win32com.client as win32 from win32com.client import constants # self.registrar_conversion() word = win32.gencache.EnsureDispatch('Word.Application') doc = word.Documents.Open(self.ruta, ReadOnly=True, AddToRecentFiles=False, Revert=True, Visible=False) doc.Activate() if tipo == 'pdf': word.ActiveDocument.SaveAs(self.ruta[:-4] + '.pdf', FileFormat=constants.wdFormatPDF) elif tipo == 'docx': word.ActiveDocument.SaveAs(self.ruta[:-4] + '.doc', FileFormat=constants.wdFormatXMLDocument) doc.Close(SaveChanges=constants.wdDoNotSaveChanges) word.Quit() Thank you! ---------------------------------------- Mart?n Trujillo Raddatz Puerto Montt - Chile Tel?fono: +56 9 96427814 ---------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven at manross.net Tue May 30 17:41:21 2023 From: steven at manross.net (Steven Manross) Date: Tue, 30 May 2023 21:41:21 +0000 Subject: [python-win32] Setting Focus Assist Mode via COM In-Reply-To: <485248794.3882013.1685365314860@mail.yahoo.com> References: <485248794.3882013.1685365314860.ref@mail.yahoo.com> <485248794.3882013.1685365314860@mail.yahoo.com> Message-ID: <20c4023be3a043a590e7f3e4195abab8@manross.net> While I haven?t worked on exactly what you are working on: I?d first verify suggest that the application that installs this class needs to be installed on the PC you are trying to create the automation from, because ?Class not Registered? isn?t a python error, and it talks more directly to the fact that the appropriate class from the software you are trying to automate isn?t on the computer you are running python from: so either you have the wrong CLSID or are doing something else wrong (missing software???). Classes are listed in the registry here: HKEY_CLASSES_ROOT\clsid\{6bff4732-81ec-4ffb-ae67-b6c1bc29631f} ? and your CLSID would need to exist (as installed from whatever software you are trying to automate) prior to python being able to automate it. Here is an example that should work on your system? ms_dict = win32com.client.Dispatch('Scripting.Dictionary') ? because the scripting dictionary object class is installed in just about every Windows OS since pre-WindowsXP I hope this helps. Enjoy your day. Steven From: python-win32 On Behalf Of name zero via python-win32 Sent: Monday, May 29, 2023 6:02 AM To: python-win32 at python.org Subject: [python-win32] Setting Focus Assist Mode via COM Hi, could someone help me out with first steps for how to set Focus Assist via COM, which https://gist.github.com/riverar/085d98ffb1343e92225a10817109b2e3 demonstrates for a C++ code base? Something like win32com.client.Dispatch('{6bff4732-81ec-4ffb-ae67-b6c1bc29631f}', clsctx=pythoncom.CLSCTX_LOCAL_SERVER) fails with "pywintypes.com_error: (-2147221164, 'Class not registered', None, None)" Thank you and best regards! -------------- next part -------------- An HTML attachment was scrubbed... URL: From namezero911 at yahoo.com Wed May 31 01:31:46 2023 From: namezero911 at yahoo.com (name zero) Date: Wed, 31 May 2023 05:31:46 +0000 (UTC) Subject: [python-win32] Setting Focus Assist Mode via COM In-Reply-To: <20c4023be3a043a590e7f3e4195abab8@manross.net> References: <485248794.3882013.1685365314860.ref@mail.yahoo.com> <485248794.3882013.1685365314860@mail.yahoo.com> <20c4023be3a043a590e7f3e4195abab8@manross.net> Message-ID: <1712290564.2446579.1685511106225@mail.yahoo.com> Hi, thanks for explaining the issue with clsids. The "application" is basically part of MS Windows. Talking to it via COM is 100% possible, as the C++ code (that is part of the GitHub-Gist) demonstrates. It just doesn't work with pywin32. When I look for "6bff4732-81ec-4ffb-ae67-b6c1bc29631f" in the Windows registry, I only find an entry in "HKEY_CLASSES_ROOT\Interface" (there is no entry in HKEY_CLASSES_ROOT\clsid) with a default value of? "IQuietHoursSettings". But win32com.client.Dispatch('IQuietHoursSettings') fails with the error message "Invalid class string". Best regards! On Tuesday, May 30, 2023 at 11:41:25 PM GMT+2, Steven Manross wrote: While I haven?t worked on exactly what you are working on: ? I?d first verify suggest that the application that installs this class needs to be installed on the PC you are trying to create the automation from, because ?Class not Registered? isn?t a python error, and it talks more directly to the fact that the appropriate class from the software you are trying to automate isn?t on the computer you are running python from: so either you have the wrong CLSID or are doing something else wrong (missing software???). ? Classes are listed in the registry here: ? HKEY_CLASSES_ROOT\clsid\{6bff4732-81ec-4ffb-ae67-b6c1bc29631f} ? and your CLSID would need to exist (as installed from whatever software you are trying to automate) prior to python being able to automate it. ? Here is an example that should work on your system? ? ms_dict = win32com.client.Dispatch('Scripting.Dictionary') ? ? because the scripting dictionary object class is installed in just about every Windows OS since pre-WindowsXP ? I hope this helps.? Enjoy your day. ? Steven From: python-win32 On Behalf Of name zero via python-win32 Sent: Monday, May 29, 2023 6:02 AM To: python-win32 at python.org Subject: [python-win32] Setting Focus Assist Mode via COM ? Hi, ? could someone help me out with first steps for how to set Focus Assist via COM, whichhttps://gist.github.com/riverar/085d98ffb1343e92225a10817109b2e3 demonstrates for a C++ code base? Something like ? win32com.client.Dispatch('{6bff4732-81ec-4ffb-ae67-b6c1bc29631f}', clsctx=pythoncom.CLSCTX_LOCAL_SERVER) ? fails with "pywintypes.com_error: (-2147221164, 'Class not registered', None, None)" ? Thank you and best regards! -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven at manross.net Wed May 31 14:53:11 2023 From: steven at manross.net (Steven Manross) Date: Wed, 31 May 2023 18:53:11 +0000 Subject: [python-win32] Setting Focus Assist Mode via COM In-Reply-To: <1712290564.2446579.1685511106225@mail.yahoo.com> References: <485248794.3882013.1685365314860.ref@mail.yahoo.com> <485248794.3882013.1685365314860@mail.yahoo.com> <20c4023be3a043a590e7f3e4195abab8@manross.net> <1712290564.2446579.1685511106225@mail.yahoo.com> Message-ID: Interfaces are definitely different and cannot be used with IDispatch, etc. Someone with more experience might be able to direct you to something, but as far as I know, that?s reserved for C++ (or likely ctypes in python? but that?s on the fringe of what I?m capable of helping with ? and completely outside the scope of the pywin32 module). But to make it more clear.. ctypes is how python can call things like that C++ code, but my one endeavor into that space was a VERY long and frustrating road as making sure that all the prerequisite data structures were created (and defined correctly) was a daunting task, and someone ended up figuring it out for me ? as I was totally missing different structures that needed to be defined (it was for some data from Terminal Server that is not publicly supported ? but totally capable of being read from Windows). HTH Steven From: python-win32 On Behalf Of name zero via python-win32 Sent: Tuesday, May 30, 2023 10:32 PM To: python-win32 at python.org Subject: Re: [python-win32] Setting Focus Assist Mode via COM Hi, thanks for explaining the issue with clsids. The "application" is basically part of MS Windows. Talking to it via COM is 100% possible, as the C++ code (that is part of the GitHub-Gist) demonstrates. It just doesn't work with pywin32. When I look for "6bff4732-81ec-4ffb-ae67-b6c1bc29631f" in the Windows registry, I only find an entry in "HKEY_CLASSES_ROOT\Interface" (there is no entry in HKEY_CLASSES_ROOT\clsid) with a default value of "IQuietHoursSettings". But win32com.client.Dispatch('IQuietHoursSettings') fails with the error message "Invalid class string". Best regards! On Tuesday, May 30, 2023 at 11:41:25 PM GMT+2, Steven Manross > wrote: While I haven?t worked on exactly what you are working on: I?d first verify suggest that the application that installs this class needs to be installed on the PC you are trying to create the automation from, because ?Class not Registered? isn?t a python error, and it talks more directly to the fact that the appropriate class from the software you are trying to automate isn?t on the computer you are running python from: so either you have the wrong CLSID or are doing something else wrong (missing software???). Classes are listed in the registry here: HKEY_CLASSES_ROOT\clsid\{6bff4732-81ec-4ffb-ae67-b6c1bc29631f} ? and your CLSID would need to exist (as installed from whatever software you are trying to automate) prior to python being able to automate it. Here is an example that should work on your system? ms_dict = win32com.client.Dispatch('Scripting.Dictionary') ? because the scripting dictionary object class is installed in just about every Windows OS since pre-WindowsXP I hope this helps. Enjoy your day. Steven From: python-win32 > On Behalf Of name zero via python-win32 Sent: Monday, May 29, 2023 6:02 AM To: python-win32 at python.org Subject: [python-win32] Setting Focus Assist Mode via COM Hi, could someone help me out with first steps for how to set Focus Assist via COM, which https://gist.github.com/riverar/085d98ffb1343e92225a10817109b2e3 demonstrates for a C++ code base? Something like win32com.client.Dispatch('{6bff4732-81ec-4ffb-ae67-b6c1bc29631f}', clsctx=pythoncom.CLSCTX_LOCAL_SERVER) fails with "pywintypes.com_error: (-2147221164, 'Class not registered', None, None)" Thank you and best regards! -------------- next part -------------- An HTML attachment was scrubbed... URL: From martintrujillor at gmail.com Wed May 31 16:44:06 2023 From: martintrujillor at gmail.com (=?UTF-8?Q?Mart=C3=ADn_Trujillo_Raddatz?=) Date: Wed, 31 May 2023 16:44:06 -0400 Subject: [python-win32] unknow solution In-Reply-To: <92c6f75b64474ab5b5ff4cf8f658688b@manross.net> References: <92c6f75b64474ab5b5ff4cf8f658688b@manross.net> Message-ID: Thanks! Finally the problem is Word app, i try repair and reinstall, din not work. its seems that a virus may be affecting it, we are now moving the scripts to other machine ir orden to determine if the proble is Word or other thing. *----------------------------------------* *Mart?n Trujillo Raddatz Puerto Montt - Chile Tel?fono: +56 9 96427814 * *----------------------------------------* El mar, 30 may 2023 a las 17:29, Steven Manross () escribi?: > While I?ve done word automation in the past, is it possible that there?s > any issues with the word application installation itself? Or maybe you > might have multiple scripts trying to open/write files simultaneously? > > > > As well, I might consider looking at task manager on your web server to > see if there are a lot of processes for word that might create some sort of > bottleneck, or concurrency issue. > > > > I know when I am doing some selenium work with Google Chrome, sometimes it > leaves a rogue Chrome process running, and as a result, the server gets > bogged down and can?t do what it?s supposed to very well because of all the > chrome processes left over from failed python script instances. > > > > Typically the error you are seeing might point to a problem with some > variable you believe should be an expected value, but in this case, it?s > None, or another non-standard value? Typically, I will log that kind of > data from my classic asp web pages to understand the problem more. > > > > In your case, I might start by writing the file name (self.ruta) to a log > file in case it?s blank, or has special characters in it that could be > causing issues. > > > > I hope this helps. The error messages you are seeing are quite generic, > and reference a problem with rendering the webpage and not necessarily a > python specific error. > > > > Steven > > *From:* python-win32 *On > Behalf Of *Mart?n Trujillo Raddatz > *Sent:* Monday, May 29, 2023 12:05 PM > *To:* python-win32 at python.org > *Subject:* [python-win32] unknow solution > > > > i ve using the library for some time now without any trouble...... but a > few days ago the script for a conversion in word from doc to pdf > respond with this error sometimes, other works fine, the error is random, i > cant figure out why occurs. > > > > the error is: > > > > Traceback (most recent call last): > File > "C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\dynamic.py", > line 81, in _GetGoodDispatch > IDispatch = pythoncom.connect(IDispatch) > pywintypes.com_error: (-2147221021, 'Operaci?n no disponible', None, None) > > During handling of the above exception, another exception occurred: > > Traceback (most recent call last): > File "C:\inetpub\wwwroot\ruc2docs\r2d2documento.py", line 14, in __init__ > self.save_as_('pdf') > File "C:\inetpub\wwwroot\ruc2docs\r2d2documento.py", line 25, in save_as_ > word = win32.gencache.EnsureDispatch('Word.Application') > File > "C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\gencache.py", > line 524, in EnsureDispatch > disp = win32com.client.Dispatch(prog_id) > File > "C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\__init__.py", > line 95, in Dispatch > dispatch, userName = > dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) > File > "C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\dynamic.py", > line 98, in _GetGoodDispatchAndUserName > return (_GetGoodDispatch(IDispatch, clsctx), userName) > File > "C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\dynamic.py", > line 83, in _GetGoodDispatch > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, > pythoncom.IID_IDispatch) > pywintypes.com_error: (-2146959355, 'Error en la ejecuci?n de servidor', > None, None) > > > > the code to execute the conversion is: > > > > def save_as_(self, tipo): > import win32com.client as win32 > from win32com.client import constants > # self.registrar_conversion() > word = win32.gencache.EnsureDispatch('Word.Application') > doc = word.Documents.Open(self.ruta, ReadOnly=True, > AddToRecentFiles=False, Revert=True, Visible=False) > doc.Activate() > if tipo == 'pdf': > word.ActiveDocument.SaveAs(self.ruta[:-4] + '.pdf', > FileFormat=constants.wdFormatPDF) > elif tipo == 'docx': > word.ActiveDocument.SaveAs(self.ruta[:-4] + '.doc', > FileFormat=constants.wdFormatXMLDocument) > doc.Close(SaveChanges=constants.wdDoNotSaveChanges) > word.Quit() > > > > Thank you! > > > > *----------------------------------------* > > > > *Mart?n Trujillo Raddatz Puerto Montt - Chile > Tel?fono: +56 9 96427814 * > > *----------------------------------------* > -------------- next part -------------- An HTML attachment was scrubbed... URL: From christoph.dorner at gmx.de Wed May 31 17:55:04 2023 From: christoph.dorner at gmx.de (Christoph J. Dorner) Date: Wed, 31 May 2023 23:55:04 +0200 Subject: [python-win32] unknow solution In-Reply-To: References: <92c6f75b64474ab5b5ff4cf8f658688b@manross.net> Message-ID: <04827bad-4af0-96e2-d452-cfd5d2ba95f2@gmx.de> Hey guys, just one idea from a problem I had: Not succeeding to call ACCESS via pywin32 in the same way I succeeded to call EXCEL I learned that not all 32bit versions of Office applications provide a suitable 64bit proxy as part of their COM interface. I do not know which bitness your Office has but you may want to check if this is related to your problem? You may refer to the mailing list archive topic "Issue with PythonCOM - Application.Run does not work for Access.Application" from Sep-Nov 2021. Reference there is the following article: Re: [python-win32] Makepy for Access on Win7 ? python-win32 ? ActiveState List Archives Regards Christoph Am 31.05.2023 um 22:44 schrieb Mart?n Trujillo Raddatz: > Thanks! > Finally the problem is Word app, i try repair and reinstall, din not work. > its seems that a virus may be affecting it, we are now moving the > scripts to other machine ir orden to determine if the proble?is Word > or other thing. > > *----------------------------------------* > *Mart?n Trujillo Raddatz > Puerto Montt - Chile > Tel?fono: +56 9 96427814 * > *----------------------------------------* > > > El mar, 30 may 2023 a las 17:29, Steven Manross () > escribi?: > > While I?ve done word automation in the past, is it possible that > there?s any issues with the word application installation itself?? > Or maybe you might have multiple scripts trying to open/write > files simultaneously? > > As well, I might consider looking at task manager on your web > server to see if there are a lot of processes for word that might > create some sort of bottleneck, or concurrency issue. > > I know when I am doing some selenium work with Google Chrome, > sometimes it leaves a rogue Chrome process running, and as a > result, the server gets bogged down and can?t do what it?s > supposed to very well because of all the chrome processes left > over from failed python script instances. > > Typically the error you are seeing might point to a problem with > some variable you believe should be an expected value, but in this > case, it?s None, or another non-standard value?? Typically, I will > log that kind of data from my classic asp web pages to understand > the problem more. > > In your case, I might start by writing the file name (self.ruta) > to a log file in case it?s blank, or has special characters in it > that could be causing issues. > > I hope this helps.? The error messages you are seeing are quite > generic, and reference a problem with rendering the webpage and > not necessarily a python specific error. > > Steven > > *From:* python-win32 > *On Behalf Of > *Mart?n Trujillo Raddatz > *Sent:* Monday, May 29, 2023 12:05 PM > *To:* python-win32 at python.org > *Subject:* [python-win32] unknow solution > > i ve using the library for some time now without any trouble...... > but a few days ago the script for a conversion in word from doc to > pdf respond?with this error sometimes, other works fine, the error > is random, i cant?figure out why occurs. > > the error is: > > Traceback (most recent call last): > ? File > "C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\dynamic.py", > line 81, in _GetGoodDispatch > ? ? IDispatch = pythoncom.connect(IDispatch) > pywintypes.com_error: (-2147221021, 'Operaci?n no disponible', > None, None) > > During handling of the above exception, another exception occurred: > > Traceback (most recent call last): > ? File "C:\inetpub\wwwroot\ruc2docs\r2d2documento.py", line 14, in > __init__ > ? ? self.save_as_('pdf') > ? File "C:\inetpub\wwwroot\ruc2docs\r2d2documento.py", line 25, in > save_as_ > ? ? word = win32.gencache.EnsureDispatch('Word.Application') > ? File > "C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\gencache.py", > line 524, in EnsureDispatch > ? ? disp = win32com.client.Dispatch(prog_id) > ? File > "C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\__init__.py", > line 95, in Dispatch > ? ? dispatch, userName = > dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) > ? File > "C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\dynamic.py", > line 98, in _GetGoodDispatchAndUserName > ? ? return (_GetGoodDispatch(IDispatch, clsctx), userName) > ? File > "C:\inetpub\wwwroot\ruc2docs\venv\lib\site-packages\win32com\client\dynamic.py", > line 83, in _GetGoodDispatch > ? ? IDispatch = pythoncom.CoCreateInstance(IDispatch, None, > clsctx, pythoncom.IID_IDispatch) > pywintypes.com_error: (-2146959355, 'Error en la ejecuci?n de > servidor', None, None) > > the code to execute the conversion is: > > def save_as_(self, tipo): > ? ? ? ? import win32com.client as win32 > ? ? ? ? from win32com.client import constants > ? ? ? ? # self.registrar_conversion() > ? ? ? ? word = win32.gencache.EnsureDispatch('Word.Application') > ? ? ? ? doc = word.Documents.Open(self.ruta, ReadOnly=True, > AddToRecentFiles=False, Revert=True, Visible=False) > ? ? ? ? doc.Activate() > ? ? ? ? if tipo == 'pdf': > word.ActiveDocument.SaveAs(self.ruta[:-4] + '.pdf', > FileFormat=constants.wdFormatPDF) > ? ? ? ? elif tipo == 'docx': > word.ActiveDocument.SaveAs(self.ruta[:-4] + '.doc', > FileFormat=constants.wdFormatXMLDocument) > doc.Close(SaveChanges=constants.wdDoNotSaveChanges) > ? ? ? ? word.Quit() > > Thank you! > > *----------------------------------------* > > *Mart?n Trujillo Raddatz > Puerto Montt - Chile > Tel?fono: +56 9 96427814 * > > *----------------------------------------* > > > _______________________________________________ > 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: