From abhi.forall at gmail.com Fri Apr 1 07:11:03 2011 From: abhi.forall at gmail.com (abhijeet mahagaonkar) Date: Fri, 1 Apr 2011 10:41:03 +0530 Subject: [python-win32] Python code for windows users??? Message-ID: Dear Py-Winners, I just now finished project in python and would want to distribute to Windows users. What is the best way to do it? I know there is a module py2exe which i can use. I wanted to know what is the best way to achieve this? PS: If I had my way i would have all of the users install python on their comps and provide the source code :) Up the Open Source \m/ Rgds, Abhijeet -------------- next part -------------- An HTML attachment was scrubbed... URL: From jiawei.h.li at gmail.com Fri Apr 1 10:04:16 2011 From: jiawei.h.li at gmail.com (Jiawei Li) Date: Fri, 1 Apr 2011 03:04:16 -0500 Subject: [python-win32] Python code for windows users??? In-Reply-To: References: Message-ID: Here is a simple guide for py2exe: http://www.py2exe.org/index.cgi/Tutorial On Fri, Apr 1, 2011 at 12:11 AM, abhijeet mahagaonkar wrote: > Dear Py-Winners, > > I just now finished project in python and would want to distribute to > Windows users. > What is the best way to do it? > I know there is a module py2exe which i can use. > > I wanted to know what is the best way to achieve this? > > PS: If I had my way i would have all of the users install python on their > comps and provide the source code :) > Up the Open Source \m/ > > Rgds, > Abhijeet > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Sat Apr 2 08:39:49 2011 From: skippy.hammond at gmail.com (Mark Hammond) Date: Sat, 02 Apr 2011 17:39:49 +1100 Subject: [python-win32] Clear the interactive screen In-Reply-To: References: <4D8EDED0.5090502@gmail.com> <4D945D3A.6000301@gmail.com> Message-ID: <4D96C4B5.30705@gmail.com> On 1/04/2011 1:24 AM, Blockheads Oi Oi wrote: > This is what I set up. > c:\Python27\Lib\site-packages\pythonwin\pywin>type mine.cfg > [General] > BasedOn = Default If you check out idle.cfg, it has with: Based On = default Note the space. > This will clear the screen but there's no interactive prompt. Then type > any command you like and nothing happens,no errors, no output, zilch. > But you can select what you've typed with Ctrl-A and copy it with > Ctrl-C, which is exactly what I've done with the following three lines. Yeah - it sounds like the default config isn't being loaded. > Ctrl-R or Ctrl-Shift-R work fine for me but they're not in the default > config *FILE* as per:- > c:\Python27\Lib\site-packages\pythonwin\pywin>grep -i Ctrl default.cfg Right - I think they just predate the ability to have a config file and were never "ported". If this is inconvenient for you I'd be happy to accept a patch which moves them into that file. Cheers, Mark From matteo.boscolo at boscolini.eu Sat Apr 2 08:59:57 2011 From: matteo.boscolo at boscolini.eu (Matteo Boscolo) Date: Sat, 02 Apr 2011 08:59:57 +0200 Subject: [python-win32] Python code for windows users??? In-Reply-To: References: Message-ID: <4D96C96D.8020603@boscolini.eu> Hi .. >PS: If I had my way I would have all of the users install python on their comps and provide the source code :) me too .. :-) bur as you know windows user just wont a setup to make it easy to install a sw .. For my openSource project PythonCAD i use pyInstaller .. + inno setup Both are quite easy and you do not need to spend too much time to learn it .. LInk: http://www.pyinstaller.org/ http://www.jrsoftware.org/isinfo.php Regards, Matteo Il 01/04/2011 07:11, abhijeet mahagaonkar ha scritto: > Dear Py-Winners, > > I just now finished project in python and would want to distribute to > Windows users. > What is the best way to do it? > I know there is a module py2exe which i can use. > > I wanted to know what is the best way to achieve this? > > PS: If I had my way i would have all of the users install python on > their comps and provide the source code :) > Up the Open Source \m/ > > Rgds, > Abhijeet > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > Nessun virus nel messaggio. > Controllato da AVG - www.avg.com > Versione: 10.0.1209 / Database dei virus: 1500/3542 - Data di > rilascio: 31/03/2011 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From th.wiens at gmx.de Mon Apr 4 19:30:15 2011 From: th.wiens at gmx.de (Thomas Wiens) Date: Mon, 04 Apr 2011 19:30:15 +0200 Subject: [python-win32] Generate variant datatype VT_I2 Message-ID: <4D9A0027.8050501@gmx.de> Hi, is there a possibility generate a variable in python which equals to the VT_I2 variant datatype? I am using a COM-object where some methods use the VARIANT type as parameter. The COM objects checks the type of the VARIANT parameter and then decides what to to with the value. The problem I have is that all the python types are (minimum) VT_I4 values. In general the method works with VT_I4, but I also need VT_I2 (VT_I1 would be nice too). The makepy utility generates the following code: def WriteFlagValue(self, ByteIndex=defaultNamedNotOptArg, BitIndex=defaultNamedNotOptArg, pData=defaultNamedNotOptArg): """Writes single bit, byte, word, or double word to the Control Engine Flag memory.""" return self._oleobj_.InvokeTypes(27, LCID, 1, (24, 0), ((3, 1), (3, 1), (16396, 1)),ByteIndex , BitIndex, pData) The parameter where the variant type is checked is "pData". The type definition should be: (16396, 1) # 16396 = 0x400C -> 0x4000 = VT_BYREF, 0x000C=12 = VT_VARIANT I've tested calling the COM-object from C#, where I have to do the following to set the correct datatype: System.Object pData; System.object dataToWrite; dataToWrite = (bool)pData; // to write VT_BOOL dataToWrite = (byte)pData; // to write VT_I1 dataToWrite = BitConverter.ToInt16((byte[])pData, 0);// to write VT_I2 dataToWrite = BitConverter.ToInt32((byte[])pData, 0);// to write VT_I4 prosim.WriteFlagValue(bytepos, bitpos, ref dataToWrite); Maybe it's possible to do something equal in python, I hope so... Thanks! -- Regards Thomas From breamoreboy at yahoo.co.uk Tue Apr 5 17:58:34 2011 From: breamoreboy at yahoo.co.uk (Blockheads Oi Oi) Date: Tue, 05 Apr 2011 16:58:34 +0100 Subject: [python-win32] Clear the interactive screen In-Reply-To: <4D96C4B5.30705@gmail.com> References: <4D8EDED0.5090502@gmail.com> <4D945D3A.6000301@gmail.com> <4D96C4B5.30705@gmail.com> Message-ID: On 02/04/2011 07:39, Mark Hammond wrote: > On 1/04/2011 1:24 AM, Blockheads Oi Oi wrote: >> This is what I set up. >> c:\Python27\Lib\site-packages\pythonwin\pywin>type mine.cfg >> [General] >> BasedOn = Default > > If you check out idle.cfg, it has with: > > Based On = default > > Note the space. Should've gone to SpecSavers :( [1] Having thrown in the missing space I've tried this out fairly extensively over the last couple of days and all in all it works a treat. I've found using Alt-C to clear the interactive screen fits in extremely well with Alt-I to move to and from your code and Ctrl-Shift-R to run it. The only problem I've encountered is if you use Alt-C to clear the screen and then immediately use Ctrl-Up or Ctrl-Down to get a command from the history list you get this. Firing event '<>' failed. Traceback (most recent call last): File "C:\Python27\Lib\site-packages\pythonwin\pywin\scintilla\bindings.py", line 142, in fire rc = binding.handler(*args) File "C:\Python27\Lib\site-packages\pythonwin\pywin\idle\IdleHistory.py", line 15, in history_next self.history_do(0) File "C:\Python27\Lib\site-packages\pythonwin\pywin\idle\IdleHistory.py", line 62, in history_do self._put_source("iomark", item) File "C:\Python27\Lib\site-packages\pythonwin\pywin\idle\IdleHistory.py", line 30, in _put_source self.text.insert(where, output) File "C:\Python27\Lib\site-packages\pythonwin\pywin\scintilla\IDLEenvironment.py", line 363, in insert self.edit.SetSel((pos, pos)) File "C:\Python27\Lib\site-packages\pythonwin\pywin\scintilla\control.py", line 319, in SetSel assert start <= self.GetTextLength(), "The start postion is invalid (%d/%d)" % (start, self.GetTextLength()) AssertionError: The start postion is invalid (31/0) To me this isn't an issue, I simply don't do it, YMMV. Be aware it could also be associated with the patch to interact.py discussed in an earlier version of this thread. > >> This will clear the screen but there's no interactive prompt. Then type >> any command you like and nothing happens,no errors, no output, zilch. >> But you can select what you've typed with Ctrl-A and copy it with >> Ctrl-C, which is exactly what I've done with the following three lines. > > Yeah - it sounds like the default config isn't being loaded. > >> Ctrl-R or Ctrl-Shift-R work fine for me but they're not in the default >> config *FILE* as per:- >> c:\Python27\Lib\site-packages\pythonwin\pywin>grep -i Ctrl default.cfg > > Right - I think they just predate the ability to have a config file and > were never "ported". If this is inconvenient for you I'd be happy to > accept a patch which moves them into that file. I'd give this a go if other people were to express an interest and if someone could point me to the starting line as quite frankly I haven't a clue. > > Cheers, > > Mark Cheers. Mark L. [1] Slogan on a series of adverts running on UK TV for an opticians chain. Several of them on YouTube. From matteo.boscolo at boscolini.eu Thu Apr 7 16:22:04 2011 From: matteo.boscolo at boscolini.eu (Matteo Boscolo) Date: Thu, 07 Apr 2011 16:22:04 +0200 Subject: [python-win32] unable to register a python com server Message-ID: <4D9DC88C.10304@boscolini.eu> Hi All, I have successfully compiled a win32com server script written in python with PyInstaller. now I'm going to redistribute this script but I can't register the dll .. on any windows machine .. I get the following message: The module " my module path" was loaded but the entry point DLLRegisterServer was not found.. make sure " my module path" is a valid DLL or OCX file and try again .. I also try with py2exe the compilation is ok but we get en error when we try to register the dll .. missing python dll please give me any help .. we need to deploy this dll as soon is possible .. Regards, Matteo This is my pyinstaller log : I: skip Configure.py, use existing config D:\OmniaSolutions\Programming\EclipseWorkSpace\PyInstaller\config.dat I: Dependent assemblies of C:\Python26\python.exe: I: x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none checking Analysis building Analysis because outAnalysis0.toc non existent running Analysis outAnalysis0.toc Analyzing: D:\OmniaSolutions\Programming\EclipseWorkSpace\PyInstaller\support\_mountzlib.py Analyzing: D:\OmniaSolutions\Programming\EclipseWorkSpace\PyInstaller\support\useUnicode.py Analyzing: D:\OmniaSolutions\Programming\EclipseWorkSpace\tmp\bin\out\driveplmintegration.openclerk.py W: pythoncom is changing it's name to pythoncom26 W: pywintypes is changing it's name to PyWinTypes26 I: Analyzing C:\Python26\python.exe I: Dependent assemblies of C:\Python26\python.exe: I: x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none Adding Microsoft.VC90.CRT to dependent assemblies of final executable I: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none... I: Found manifest C:\Windows\WinSxS\Manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91.manifest I: Searching for file msvcr90.dll I: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\msvcr90.dll I: Searching for file msvcp90.dll I: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\msvcp90.dll I: Searching for file msvcm90.dll I: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\msvcm90.dll I: Adding Microsoft.VC90.CRT.manifest I: Adding msvcr90.dll I: Adding msvcp90.dll I: Adding msvcm90.dll I: Adding python26.dll dependency of python.exe I: Skipping KERNEL32.dll dependency of python.exe I: Analyzing C:\Windows\system32\python26.dll I: Dependent assemblies of C:\Windows\system32\python26.dll: I: x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none I: Skipping KERNEL32.dll dependency of python26.dll I: Skipping USER32.dll dependency of python26.dll I: Skipping ADVAPI32.dll dependency of python26.dll I: Skipping SHELL32.dll dependency of python26.dll I: Analyzing C:\Python26\lib\site-packages\win32\_win32sysloader.pyd I: Dependent assemblies of C:\Python26\lib\site-packages\win32\_win32sysloader.pyd: I: x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none I: Skipping KERNEL32.dll dependency of _win32sysloader.pyd I: Analyzing C:\Python26\lib\site-packages\win32\winxpgui.pyd I: Dependent assemblies of C:\Python26\lib\site-packages\win32\winxpgui.pyd: I: x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none I: Skipping GDI32.dll dependency of winxpgui.pyd I: Skipping USER32.dll dependency of winxpgui.pyd I: Skipping SHELL32.dll dependency of winxpgui.pyd I: Adding pywintypes26.dll dependency of winxpgui.pyd I: Skipping KERNEL32.dll dependency of winxpgui.pyd I: Analyzing C:\Python26\DLLs\select.pyd I: Skipping WSOCK32.dll dependency of select.pyd I: Skipping KERNEL32.dll dependency of select.pyd I: Analyzing C:\Python26\DLLs\unicodedata.pyd I: Skipping KERNEL32.dll dependency of unicodedata.pyd I: Analyzing C:\Python26\lib\site-packages\win32\win32event.pyd I: Dependent assemblies of C:\Python26\lib\site-packages\win32\win32event.pyd: I: x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none I: Skipping USER32.dll dependency of win32event.pyd I: Skipping KERNEL32.dll dependency of win32event.pyd I: Analyzing C:\Python26\lib\site-packages\sip.pyd I: Skipping KERNEL32.dll dependency of sip.pyd I: Skipping msvcrt.dll dependency of sip.pyd I: Adding libgcc_s_dw2-1.dll dependency of sip.pyd I: Analyzing C:\Python26\lib\site-packages\reportlab-2.5-py2.6-win32.egg\sgmlop.pyd I: Dependent assemblies of C:\Python26\lib\site-packages\reportlab-2.5-py2.6-win32.egg\sgmlop.pyd: I: x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none I: Skipping KERNEL32.dll dependency of sgmlop.pyd I: Analyzing C:\Python26\lib\site-packages\Pythonwin\win32ui.pyd I: Dependent assemblies of C:\Python26\lib\site-packages\Pythonwin\win32ui.pyd: I: x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none, x86_Microsoft.VC90.MFC_1fc8b3b9a1e18e3b_9.0.21022.8_none Adding Microsoft.VC90.MFC to dependent assemblies of final executable I: Searching for assembly x86_Microsoft.VC90.MFC_1fc8b3b9a1e18e3b_9.0.21022.8_none... I: Found manifest C:\Windows\WinSxS\Manifests\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_b81d038aaf540e86.manifest I: Searching for file mfc90.dll I: Found file C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_b81d038aaf540e86\mfc90.dll I: Searching for file mfc90u.dll I: Found file C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_b81d038aaf540e86\mfc90u.dll I: Searching for file mfcm90.dll I: Found file C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_b81d038aaf540e86\mfcm90.dll I: Searching for file mfcm90u.dll I: Found file C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_b81d038aaf540e86\mfcm90u.dll I: Adding Microsoft.VC90.MFC.manifest I: Adding mfc90.dll I: Adding mfc90u.dll I: Adding mfcm90.dll I: Adding mfcm90u.dll I: Skipping KERNEL32.dll dependency of win32ui.pyd I: Skipping USER32.dll dependency of win32ui.pyd I: Skipping GDI32.dll dependency of win32ui.pyd I: Skipping WINSPOOL.DRV dependency of win32ui.pyd I: Skipping SHELL32.dll dependency of win32ui.pyd I: Skipping OLEAUT32.dll dependency of win32ui.pyd I: Analyzing C:\Python26\DLLs\bz2.pyd I: Skipping KERNEL32.dll dependency of bz2.pyd I: Analyzing C:\Python26\DLLs\_ssl.pyd I: Skipping WS2_32.dll dependency of _ssl.pyd I: Skipping KERNEL32.dll dependency of _ssl.pyd I: Skipping USER32.dll dependency of _ssl.pyd I: Skipping ADVAPI32.dll dependency of _ssl.pyd I: Analyzing C:\Python26\lib\site-packages\PyQt4\QtCore.pyd I: Adding QtCore4.dll dependency of QtCore.pyd I: Skipping KERNEL32.dll dependency of QtCore.pyd I: Skipping msvcrt.dll dependency of QtCore.pyd I: Skipping msvcrt.dll dependency of QtCore.pyd I: Analyzing C:\Python26\lib\site-packages\win32\win32process.pyd I: Dependent assemblies of C:\Python26\lib\site-packages\win32\win32process.pyd: I: x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none I: Skipping ADVAPI32.dll dependency of win32process.pyd I: Skipping USER32.dll dependency of win32process.pyd I: Skipping KERNEL32.dll dependency of win32process.pyd I: Analyzing C:\Python26\DLLs\pyexpat.pyd I: Skipping KERNEL32.dll dependency of pyexpat.pyd I: Analyzing C:\Python26\lib\site-packages\win32\win32trace.pyd I: Dependent assemblies of C:\Python26\lib\site-packages\win32\win32trace.pyd: I: x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none I: Skipping ADVAPI32.dll dependency of win32trace.pyd I: Skipping KERNEL32.dll dependency of win32trace.pyd I: Analyzing C:\Python26\lib\site-packages\win32comext\shell\shell.pyd I: Dependent assemblies of C:\Python26\lib\site-packages\win32comext\shell\shell.pyd: I: x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none I: Skipping SHELL32.dll dependency of shell.pyd I: Skipping OLEAUT32.dll dependency of shell.pyd I: Skipping ole32.dll dependency of shell.pyd I: Adding pythoncom26.dll dependency of shell.pyd I: Skipping KERNEL32.dll dependency of shell.pyd I: Analyzing C:\Python26\lib\site-packages\win32\win32api.pyd I: Dependent assemblies of C:\Python26\lib\site-packages\win32\win32api.pyd: I: x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none I: Skipping USER32.dll dependency of win32api.pyd I: Skipping ADVAPI32.dll dependency of win32api.pyd I: Skipping SHELL32.dll dependency of win32api.pyd I: Skipping VERSION.dll dependency of win32api.pyd I: Skipping POWRPROF.dll dependency of win32api.pyd I: Skipping KERNEL32.dll dependency of win32api.pyd I: Analyzing C:\Python26\DLLs\_socket.pyd I: Skipping WS2_32.dll dependency of _socket.pyd I: Skipping KERNEL32.dll dependency of _socket.pyd I: Analyzing C:\Windows\system32\pywintypes26.dll I: Dependent assemblies of C:\Windows\system32\pywintypes26.dll: I: x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none I: Skipping ADVAPI32.dll dependency of pywintypes26.dll I: Skipping USER32.dll dependency of pywintypes26.dll I: Skipping ole32.dll dependency of pywintypes26.dll I: Skipping OLEAUT32.dll dependency of pywintypes26.dll I: Skipping KERNEL32.dll dependency of pywintypes26.dll I: Analyzing C:\Python26\lib\site-packages\gtk-2.0\runtime\bin\libgcc_s_dw2-1.dll I: Skipping KERNEL32.dll dependency of libgcc_s_dw2-1.dll I: Skipping msvcrt.dll dependency of libgcc_s_dw2-1.dll I: Analyzing C:\Python26\Lib\site-packages\PyQt4\bin\qtcore4.dll I: Skipping ADVAPI32.DLL dependency of qtcore4.dll I: Skipping KERNEL32.dll dependency of qtcore4.dll I: Adding mingwm10.dll dependency of qtcore4.dll I: Skipping msvcrt.dll dependency of qtcore4.dll I: Skipping msvcrt.dll dependency of qtcore4.dll I: Skipping OLE32.dll dependency of qtcore4.dll I: Skipping USER32.dll dependency of qtcore4.dll I: Skipping WS2_32.DLL dependency of qtcore4.dll I: Analyzing C:\Windows\system32\pythoncom26.dll I: Dependent assemblies of C:\Windows\system32\pythoncom26.dll: I: x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none I: Skipping OLEAUT32.dll dependency of pythoncom26.dll I: Skipping ole32.dll dependency of pythoncom26.dll I: Skipping USER32.dll dependency of pythoncom26.dll I: Skipping KERNEL32.dll dependency of pythoncom26.dll I: Analyzing C:\Python26\Lib\site-packages\PyQt4\bin\mingwm10.dll I: Skipping msvcrt.dll dependency of mingwm10.dll I: Skipping KERNEL32.dll dependency of mingwm10.dll Warnings written to D:\OmniaSolutions\Programming\EclipseWorkSpace\tmp\bin\out\build\pyi.win32\driveplmintegration.openclerk\warndriveplmintegration.openclerk.txt checking PYZ rebuilding outPYZ1.toc because outPYZ1.pyz is missing building PYZ outPYZ1.toc checking PKG rebuilding outPKG3.toc because outPKG3.pkg is missing building PKG outPKG3.pkg checking EXE rebuilding outEXE2.toc because driveplmintegration.openclerk.exe missing building EXE from outEXE2.toc Appending archive to EXE D:\OmniaSolutions\Programming\EclipseWorkSpace\tmp\bin\out\build\pyi.win32\driveplmintegration.openclerk\driveplmintegration.openclerk.exe checking PKG rebuilding outPKG5.toc because outPKG5.pkg is missing building PKG outPKG5.pkg checking DLL rebuilding outDLL4.toc because driveplmintegration.openclerk.dll missing building DLL outDLL4.toc checking COLLECT building because outCOLLECT6.toc missing or bad building COLLECT outCOLLECT6.toc -- You received this message because you are subscribed to the Google Groups "PyInstaller" group. To post to this group, send email to pyinstaller at googlegroups.com. To unsubscribe from this group, send email to pyinstaller+unsubscribe at googlegroups.com. For more options, visit this group at http://groups.google.com/group/pyinstaller?hl=en. ----- Nessun virus nel messaggio. Controllato da AVG - www.avg.com Versione: 10.0.1209 / Database dei virus: 1500/3556 - Data di rilascio: 06/04/2011 From matteo.boscolo at boscolini.eu Thu Apr 7 16:53:17 2011 From: matteo.boscolo at boscolini.eu (Matteo Boscolo) Date: Thu, 07 Apr 2011 16:53:17 +0200 Subject: [python-win32] unable to register a python com server In-Reply-To: <9A08FCF7549131B2CA0D23E772FC3136DAE3C7D9@IPDMCZ0250MIA> References: <9A08FCF7549131B2CA0D23E772FC3136DAE3C7D9@IPDMCZ0250MIA> Message-ID: <4D9DCFDD.6010402@boscolini.eu> thanks but unfortunately it does not solve the problem .. my machine is a 64 bit and my os is w7 my python version is 2.6 32bit .. could be this the reason of my troubles ? Regards, Matteo Il 07/04/2011 16:28, Chilkat Support ha scritto: > Thank you for your email. > > The answer to your question regarding the Chilkat component/library might be found at this URL: > //www.cknotes.com/?p=304 > > If this does not answer your question, please let us know. > > Best Regards, > Matt Fausey > Chilkat Software, Inc. > 630-784-9670 > > > > > > ----- > Nessun virus nel messaggio. > Controllato da AVG - www.avg.com > Versione: 10.0.1209 / Database dei virus: 1500/3556 - Data di rilascio: 06/04/2011 > > > From vernondcole at gmail.com Thu Apr 7 18:55:38 2011 From: vernondcole at gmail.com (Vernon Cole) Date: Thu, 7 Apr 2011 10:55:38 -0600 Subject: [python-win32] unable to register a python com server In-Reply-To: <4D9DCFDD.6010402@boscolini.eu> References: <9A08FCF7549131B2CA0D23E772FC3136DAE3C7D9@IPDMCZ0250MIA> <4D9DCFDD.6010402@boscolini.eu> Message-ID: Correct. 32 bit COM cannot talk to 64 bit COM. That's one of the few reasons for running 64 bit Python. On Thu, Apr 7, 2011 at 8:53 AM, Matteo Boscolo wrote: > thanks but unfortunately it does not solve the problem .. > > my machine is a 64 bit and my os is w7 > my python version is 2.6 32bit .. > > could be this the reason of my troubles ? > > Regards, > Matteo > From timr at probo.com Thu Apr 7 19:12:22 2011 From: timr at probo.com (Tim Roberts) Date: Thu, 7 Apr 2011 10:12:22 -0700 Subject: [python-win32] unable to register a python com server In-Reply-To: References: <9A08FCF7549131B2CA0D23E772FC3136DAE3C7D9@IPDMCZ0250MIA> <4D9DCFDD.6010402@boscolini.eu> Message-ID: <4D9DF076.80906@probo.com> Vernon Cole wrote: > Correct. 32 bit COM cannot talk to 64 bit COM. > That's one of the few reasons for running 64 bit Python. Well, we can't tell from his description whether this is actually the issue or not. He said he was unable to register the DLL. That would only be a problem if he were registering it using a 64-bit app. In the case of regsvr32, the system contains both versions (32-bit and 64-bit), and each will silently call the other if it finds a mismatch. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Thu Apr 7 21:28:21 2011 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 07 Apr 2011 12:28:21 -0700 Subject: [python-win32] Generate variant datatype VT_I2 In-Reply-To: <4D9A0027.8050501@gmx.de> References: <4D9A0027.8050501@gmx.de> Message-ID: <4D9E1055.6010107@skippinet.com.au> On 4/04/2011 10:30 AM, Thomas Wiens wrote: > is there a possibility generate a variable in python which equals to the > VT_I2 variant datatype? Not easily (although I have long been considering adding support for that, but haven't ever got close to an actual implementation) > The makepy utility generates the following code: > > def WriteFlagValue(self, ByteIndex=defaultNamedNotOptArg, > BitIndex=defaultNamedNotOptArg, pData=defaultNamedNotOptArg): > > """Writes single bit, byte, word, or double word to the Control Engine > Flag memory.""" > > return self._oleobj_.InvokeTypes(27, LCID, 1, (24, 0), ((3, 1), (3, 1), > (16396, 1)),ByteIndex > > , BitIndex, pData) > > The parameter where the variant type is checked is "pData". > The type definition should be: > (16396, 1) # 16396 = 0x400C -> 0x4000 = VT_BYREF, 0x000C=12 = VT_VARIANT I'm not sure what you mean by "should be" - it *is* that, right? You should be able to change that definition (or just clone it) to VT_BYREF|VT_I2 - the object will still be called with a variant and the type will be VT_BYREF|VT_I2 - which IIUC is what you want. (This is what I meant above by "not easily" - an easier way would be to introduce a new object called "Variant" and add special support in the type-handling code for this object - but that is what I referred to as nowhere near an implementation) HTH, Mark From leagen1 at gmail.com Sat Apr 9 13:26:45 2011 From: leagen1 at gmail.com (Misy) Date: Sat, 9 Apr 2011 11:26:45 +0000 (UTC) Subject: [python-win32] Problem using win32com.client.Dispatch on Win7 64bit References: <5E94BFD292E6664094E77128C4C459B504491D6923@eros2.Fekete.com> <4CB78DBE.40906@gmail.com> Message-ID: Mark Hammond gmail.com> writes: > > 64bit processes can't use 32bit COM objects (at least not in-proc - not > sure about external) and I guess your COM object is 32 bit. > > The easiest answer is probably just to install the 32bit Python and > 32bit pywin32 extensions - you can either leave or remove the 64bit > version - they can co-exist happily... > > Cheers, > > Mark > Hi, everyone, I met the same problem. However, for some reasons, I cannot change to use 32bit python and pywin32. If someone konw how to really get the 32bit COM in the 64bit pywin32? Or maybe another solution to get COM with 64bit python. Thanks. From rupole at hotmail.com Sun Apr 10 03:24:39 2011 From: rupole at hotmail.com (Roger Upole) Date: Sat, 9 Apr 2011 21:24:39 -0400 Subject: [python-win32] Problem using win32com.client.Dispatch on Win764bit References: <5E94BFD292E6664094E77128C4C459B504491D6923@eros2.Fekete.com><4CB78DBE.40906@gmail.com> Message-ID: Misy wrote: > Mark Hammond gmail.com> writes: > >> >> 64bit processes can't use 32bit COM objects (at least not in-proc - not >> sure about external) and I guess your COM object is 32 bit. >> >> The easiest answer is probably just to install the 32bit Python and >> 32bit pywin32 extensions - you can either leave or remove the 64bit >> version - they can co-exist happily... >> >> Cheers, >> >> Mark >> > > Hi, everyone, > > I met the same problem. However, for some reasons, I cannot change to use > 32bit python and pywin32. If someone konw how to really get the 32bit COM in the > 64bit pywin32? Or maybe another solution to get COM with 64bit python. > > Thanks. You may be able to create an out of process proxy for your 32-bit app. >From Administrative Tools->Component Services, navigate to COM+ Applications, and then click Action->New Application. Create an empty application, and then under its Components, add the 32-bit interfaces you need to access. Roger From leagen1 at gmail.com Mon Apr 11 05:04:17 2011 From: leagen1 at gmail.com (Misy) Date: Mon, 11 Apr 2011 03:04:17 +0000 (UTC) Subject: [python-win32] =?utf-8?q?Problem_using_win32com=2Eclient=2EDispat?= =?utf-8?q?ch_on=09Win764bit?= References: <5E94BFD292E6664094E77128C4C459B504491D6923@eros2.Fekete.com><4CB78DBE.40906@gmail.com> Message-ID: Roger Upole hotmail.com> writes: > > You may be able to create an out of process proxy for your 32-bit app. > >From Administrative Tools->Component Services, navigate to > COM+ Applications, and then click Action->New Application. > Create an empty application, and then under its Components, add > the 32-bit interfaces you need to access. > > Roger > Hi, Roger, Thanks for your suggestion. It sounds great! I'm trying this, but I'm not familiar with these techniques. Please help me~ Thank you. What I need is to execute this - com_nxn = win32com.client.Dispatch("NxNNamespace.NxNNamespaceHelper") I followed your steps to created an empty application in COM+ Applications, and then I selected Action->New in the Component folder. There was an install wizard and I chose "Import Component". There was a list of components. I checked the 32bit registry and found "NxNNamespace.NxNNamespaceHelper.1" to add. Ok, now I have this component and an "Interface" folder under it, but I don't konw how to add interfaces as you mentioned. Is it correct so far? Thnak you. Misy From rupole at hotmail.com Mon Apr 11 08:46:12 2011 From: rupole at hotmail.com (Roger Upole) Date: Mon, 11 Apr 2011 02:46:12 -0400 Subject: [python-win32] Problem using win32com.client.Dispatch on Win764bit References: <5E94BFD292E6664094E77128C4C459B504491D6923@eros2.Fekete.com><4CB78DBE.40906@gmail.com> Message-ID: "Misy" wrote in message news:loom.20110411T043551-525 at post.gmane.org... > Roger Upole hotmail.com> writes: >> >> You may be able to create an out of process proxy for your 32-bit app. >> >From Administrative Tools->Component Services, navigate to >> COM+ Applications, and then click Action->New Application. >> Create an empty application, and then under its Components, add >> the 32-bit interfaces you need to access. >> >> Roger >> > > Hi, Roger, > > Thanks for your suggestion. It sounds great! I'm trying this, > but I'm not familiar with these techniques. Please help me~ Thank you. > > What I need is to execute this - > > com_nxn = win32com.client.Dispatch("NxNNamespace.NxNNamespaceHelper") > > I followed your steps to created an empty application in COM+ Applications, > and then I selected Action->New in the Component folder. There was an install > wizard and I chose "Import Component". > There was a list of components. I checked the 32bit registry and found > "NxNNamespace.NxNNamespaceHelper.1" to add. > > Ok, now I have this component and an "Interface" folder under it, but I > don't konw how to add interfaces as you mentioned. > Is it correct so far? Thnak you. > > Misy If that's the only object you need to access, you should be done. Go ahead and try to Dispatch it. However, if there are other related classes (very likely), you'll need to import them into your proxy also. Roger From leagen1 at gmail.com Mon Apr 11 13:02:28 2011 From: leagen1 at gmail.com (Misy) Date: Mon, 11 Apr 2011 11:02:28 +0000 (UTC) Subject: [python-win32] =?utf-8?q?Problem_using_win32com=2Eclient=2EDispat?= =?utf-8?q?ch=09on=09Win764bit?= References: <5E94BFD292E6664094E77128C4C459B504491D6923@eros2.Fekete.com><4CB78DBE.40906@gmail.com> Message-ID: > If that's the only object you need to access, you should be done. > Go ahead and try to Dispatch it. However, if there are other > related classes (very likely), you'll need to import them into your > proxy also. > > Roger > Hi, Roger, Well...I still failed. I rebooted and tried, but it didn't work. And the message was the same. Maybe I should go back to the beginning. My error message was that: --------------------------------------------------- IDLE 2.6.6 >>> import win32com.client >>> com_nxn = win32com.client.Dispatch("NxNNamespace.NxNNamespaceHelper") Traceback (most recent call last): File "", line 1, in com_nxn = win32com.client.Dispatch("NxNNamespace.NxNNamespaceHelper") File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 108, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 85, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147221164, '\xc3\xfe\xa7O\xa5\xbc\xb5n\xbf\xfd', None, None) >>> ----------------------------------------------------- It was very strange that the com_error message is a .... binary code, so in fact, I am not sure it is the same problem as Eileen's. Any idea? Misy From timr at probo.com Mon Apr 11 18:47:42 2011 From: timr at probo.com (Tim Roberts) Date: Mon, 11 Apr 2011 09:47:42 -0700 Subject: [python-win32] Problem using win32com.client.Dispatch on Win764bit In-Reply-To: References: <5E94BFD292E6664094E77128C4C459B504491D6923@eros2.Fekete.com><4CB78DBE.40906@gmail.com> Message-ID: <4DA330AE.2060802@probo.com> Misy wrote: >> If that's the only object you need to access, you should be done. >> Go ahead and try to Dispatch it. However, if there are other >> related classes (very likely), you'll need to import them into your >> proxy also. >> >> Roger > Hi, Roger, > > Well...I still failed. I rebooted and tried, but it didn't work. And the > message was the same. Maybe I should go back to the beginning. My error message > was that: > > --------------------------------------------------- > IDLE 2.6.6 >>>> import win32com.client >>>> com_nxn = win32com.client.Dispatch("NxNNamespace.NxNNamespaceHelper") > ... > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) > com_error: (-2147221164, '\xc3\xfe\xa7O\xa5\xbc\xb5n\xbf\xfd', None, None) > ----------------------------------------------------- > > It was very strange that the com_error message is a .... binary code, so in > fact, I am not sure it is the same problem as Eileen's. -2147221164 is 0x80040154 which is REGDB_E_CLASSNOTREG. So, soething has gone wrong in registering your proxy class. Did you actually register it? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From leagen1 at gmail.com Tue Apr 12 05:01:20 2011 From: leagen1 at gmail.com (Misy) Date: Tue, 12 Apr 2011 03:01:20 +0000 (UTC) Subject: [python-win32] =?utf-8?q?Problem_using=09win32com=2Eclient=2EDisp?= =?utf-8?q?atch=09on=09Win764bit?= References: <5E94BFD292E6664094E77128C4C459B504491D6923@eros2.Fekete.com><4CB78DBE.40906@gmail.com> <4DA330AE.2060802@probo.com> Message-ID: Tim Roberts probo.com> writes: > > IDLE 2.6.6 > >>>> import win32com.client > >>>> com_nxn = win32com.client.Dispatch("NxNNamespace.NxNNamespaceHelper") > > ... > > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) > -2147221164 is 0x80040154 which is REGDB_E_CLASSNOTREG. So, soething > has gone wrong in registering your proxy class. Did you actually > register it? > Wow, I got lots of help. Thank you guys~ Thank you, Tim. I have no idea if I really registered it. Here's my screenshot - http://ppt.cc/oZrt (sorry.. my WINDOWS is Chinese version, but I add the English names beside them.) "AB" is the empty application I created. I imported two components from a list of registered components because I'd dispatch the two components in my pogram. Should I do any other action to register it? Thank you Misy From frantzcj at gmail.com Tue Apr 12 18:14:01 2011 From: frantzcj at gmail.com (Chris Frantz) Date: Tue, 12 Apr 2011 11:14:01 -0500 Subject: [python-win32] Issue with win32evtlog.ReportEvent Message-ID: Hello, I'm having a bit of trouble with ReportEvent: When I use a large value for eventID, I get an OverflowError. >>> import win32evtlogutil >>> win32evtlogutil.ReportEvent('FooBar', 0xc0004652) Traceback (most recent call last): File "", line 1, in File "c:\python26\lib\site-packages\win32\lib\win32evtlogutil.py", line 80, in ReportEvent data) OverflowError: long int too large to convert to int The prototype for ReportEvent (or rather it's wrapper) is: PyObject * MyReportEvent(HANDLE hEventLog, WORD wType, WORD wCategory, DWORD dwEventID, PyObject *obSID, PyObject *obStrings, PyObject *obData) I've noticed the SWIG generated interface for this wrapper uses PyArg_ParseTuple to parse the input parameters. Specifically, it uses the 'l' (lower case ell) specifier to extract dwEventID. After reading the documentation for PyArg_ParseTuple, I believe that the 'k' specifier is more appropriate. Unfortunately, I'm no SWIG wrangler, so I have no idea how to convince SWIG to use a different specifier for DWORD and other unsigned long types. Any ideas? Thanks, --Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Thu Apr 14 06:55:38 2011 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 14 Apr 2011 14:55:38 +1000 Subject: [python-win32] Issue with win32evtlog.ReportEvent In-Reply-To: References: Message-ID: <4DA67E4A.5000402@gmail.com> On 13/04/2011 2:14 AM, Chris Frantz wrote: > Hello, > > I'm having a bit of trouble with ReportEvent: When I use a large value > for eventID, I get an OverflowError. > > >>> import win32evtlogutil > >>> win32evtlogutil.ReportEvent('FooBar', 0xc0004652) > Traceback (most recent call last): > File "", line 1, in > File "c:\python26\lib\site-packages\win32\lib\win32evtlogutil.py", > line 80, in ReportEvent > data) > OverflowError: long int too large to convert to int Yeah - this is a bug in the general DWORD handling in SWIG generated files. I'm not sure how to tell SWIG to use a different format char, but I have managed to work around it in other ways which is good for the general case. However, in this case specifically, it doesn't seem to work as intended. After fixing it, the Event Viewer shows the event ID is actually 18002 - which is 0xc0004652 with the 2 most significant bits reset to zero. Digging deeper, the docs at http://msdn.microsoft.com/en-us/library/aa363651%28v=vs.85%29.aspx imply those 2 bits are used to record the severity of the message. It appears the function will mask out those bits according to the other params passed to ReportEvent, meaning you can't wind up with such an event ID in the event viewer anyway... But this consideration is specific to ReportEvent - so the next pywin32 build will allow DWORD params in SWIG wrappers to pass such integers without error - but it seems that wont actually help your problem. Cheers, Mark From amauryfa at gmail.com Thu Apr 14 08:55:12 2011 From: amauryfa at gmail.com (Amaury Forgeot d'Arc) Date: Thu, 14 Apr 2011 08:55:12 +0200 Subject: [python-win32] Issue with win32evtlog.ReportEvent In-Reply-To: <4DA67E4A.5000402@gmail.com> References: <4DA67E4A.5000402@gmail.com> Message-ID: Hi 2011/4/14 Mark Hammond : > Yeah - this is a bug in the general DWORD handling in SWIG generated files. > ?I'm not sure how to tell SWIG to use a different format char, but I have > managed to work around it in other ways which is good for the general case. With the old SWIG-1.1, the format char is hardcoded in the cpp source of SWIG (in Modules/Python.cxx):: case T_LONG : case T_ULONG: case T_SLONG : parse_args << "l"; break; which is wrong of course. Was it ever considered using a newer version of Swig? -- Amaury Forgeot d'Arc From skippy.hammond at gmail.com Thu Apr 14 09:13:56 2011 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 14 Apr 2011 17:13:56 +1000 Subject: [python-win32] Issue with win32evtlog.ReportEvent In-Reply-To: References: <4DA67E4A.5000402@gmail.com> Message-ID: <4DA69EB4.1010506@gmail.com> On 14/04/2011 4:55 PM, Amaury Forgeot d'Arc wrote: > Was it ever considered using a newer version of Swig? Sadly some hacks were made to SWIG to support some of the COM objects and the source to those changes were lost many years ago - this needs to be revisited before we can upgrade. I haven't put much thought into that yet but I'm sure something can be done... Mark From frantzcj at gmail.com Thu Apr 14 16:55:31 2011 From: frantzcj at gmail.com (Chris Frantz) Date: Thu, 14 Apr 2011 09:55:31 -0500 Subject: [python-win32] Issue with win32evtlog.ReportEvent In-Reply-To: <4DA67E4A.5000402@gmail.com> References: <4DA67E4A.5000402@gmail.com> Message-ID: On Wed, Apr 13, 2011 at 11:55 PM, Mark Hammond wrote: > Yeah - this is a bug in the general DWORD handling in SWIG generated files. > I'm not sure how to tell SWIG to use a different format char, but I have > managed to work around it in other ways which is good for the general case. > > However, in this case specifically, it doesn't seem to work as intended. > After fixing it, the Event Viewer shows the event ID is actually 18002 - > which is 0xc0004652 with the 2 most significant bits reset to zero. Digging > deeper, the docs at > http://msdn.microsoft.com/en-us/library/aa363651%28v=vs.85%29.aspx imply > those 2 bits are used to record the severity of the message. It appears the > function will mask out those bits according to the other params passed to > ReportEvent, meaning you can't wind up with such an event ID in the event > viewer anyway... > > But this consideration is specific to ReportEvent - so the next pywin32 > build will allow DWORD params in SWIG wrappers to pass such integers without > error - but it seems that wont actually help your problem. > > I'm logging events to the event log on behalf of another client. I've tried arguing this point with them, but they insist that I must use the full 32-bit event id. Something to do with how they generate their message catalogs. In any case, this snippet of python code seems to work around the problem: if id & 0x80000000: id = -0x80000000 | id ReportEvent(source, id, etc) Best Regards, --Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: From gremlin at armarize.com Thu Apr 14 21:52:41 2011 From: gremlin at armarize.com (Gremlin) Date: Thu, 14 Apr 2011 21:52:41 +0200 Subject: [python-win32] Strange error with win32security.AdjustTokenPrivileges Message-ID: <7C1FF6262D1C41509DEDE93ABBA01CFC@BELLO> Hello. I want to adapt the following technique into python: http://blogs.msdn.com/b/aaron_margosis/archive/2009/06/06/faq-how-do-i-start -a-program-as-the-desktop-user-from-an-elevated-app.aspx So I started with the following code: import win32security import win32process process = win32process.GetCurrentProcess() token = win32security.OpenProcessToken(process, win32security.TOKEN_ADJUST_PRIVILEGES) privilege_luid = win32security.LookupPrivilegeValue(None, win32security.SE_INCREASE_QUOTA_NAME) privilege = [(privilege_luid, win32security.SE_PRIVILEGE_ENABLED)] win32security.AdjustTokenPrivileges(token, 0, privilege) But it fails with the error number 5 (Access denied) once "AdjustTokenPrivileges" has been executed. That would be obvious if I had not started python as admin. (Properties -> Start as admin) Also the process token is another one (at least the integer of token.handle is another one) if started as non-elevated. I have no idea why this is happening. I do have the appropriate permissions and the code should be correct. Can anyone help me? (Btw: My OS is Windows7 Pro 64bit and I'm not a standard user.) Regards, Johannes -------------- next part -------------- An HTML attachment was scrubbed... URL: From rupole at hotmail.com Fri Apr 15 06:04:22 2011 From: rupole at hotmail.com (Roger Upole) Date: Fri, 15 Apr 2011 00:04:22 -0400 Subject: [python-win32] Strange error withwin32security.AdjustTokenPrivileges References: <7C1FF6262D1C41509DEDE93ABBA01CFC@BELLO> Message-ID: In the call to OpenProcessToken, you'll need to specify TOKEN_QUERY also. Roger "Gremlin" wrote in message news:7C1FF6262D1C41509DEDE93ABBA01CFC at BELLO... > Hello. > > > > I want to adapt the following technique into python: > http://blogs.msdn.com/b/aaron_margosis/archive/2009/06/06/faq-how-do-i-start > -a-program-as-the-desktop-user-from-an-elevated-app.aspx > > So I started with the following code: > > > > import win32security > > import win32process > > > > process = win32process.GetCurrentProcess() > > token = win32security.OpenProcessToken(process, > win32security.TOKEN_ADJUST_PRIVILEGES) > > privilege_luid = win32security.LookupPrivilegeValue(None, > win32security.SE_INCREASE_QUOTA_NAME) > > privilege = [(privilege_luid, win32security.SE_PRIVILEGE_ENABLED)] > > win32security.AdjustTokenPrivileges(token, 0, privilege) > > > > But it fails with the error number 5 (Access denied) once > "AdjustTokenPrivileges" has been executed. That would be obvious if I had > not started python as admin. (Properties -> Start as admin) Also the process > token is another one (at least the integer of token.handle is another one) > if started as non-elevated. I have no idea why this is happening. I do have > the appropriate permissions and the code should be correct. Can anyone help > me? (Btw: My OS is Windows7 Pro 64bit and I'm not a standard user.) > > > > Regards, > > Johannes > > > > -------------------------------------------------------------------------------- > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From matth at netsight.co.uk Fri Apr 15 10:23:14 2011 From: matth at netsight.co.uk (Matt Hamilton) Date: Fri, 15 Apr 2011 08:23:14 +0000 (UTC) Subject: [python-win32] SSPI memory problems with Kerberos? Message-ID: Hi all, I've been trying to use the win32 SSPI API to do some Kerberos auth stuff. After a lot of banging my head against the wall I've now pared the problem right down to the very basics and this is what I'm getting: # sspitest.py import sspi data = 'bogus' sa = sspi.ServerAuth('Kerberos') err, sec_buffer = sa.authorize(data) C:\krbtest>c:\Python26\python.exe sspitest.py Traceback (most recent call last): File "sspitest.py", line 5, in err, sec_buffer = sa.authorize(data) File "c:\Python26\lib\site-packages\win32\lib\sspi.py", line 196, in authorize self.datarep, self.ctxt, sec_buffer_out) pywintypes.error: (-2146893056, 'AcceptSecurityContext', 'Not enough memory is available to complete this request') Originally I was passing it a valid Kerberos ticket, but no matter what it would still give me that memory error. So I decided to pass in some bogus data to at least get a different error... but no dice. I always just get this memory error. Whereas if I use NTLM instead, I get the error I would expect: # sspitest.py import sspi data = 'bogus' sa = sspi.ServerAuth('NTLM') err, sec_buffer = sa.authorize(data) C:\krbtest>c:\Python26\python.exe sspitest.py Traceback (most recent call last): File "sspitest.py", line 5, in err, sec_buffer = sa.authorize(data) File "c:\Python26\lib\site-packages\win32\lib\sspi.py", line 196, in authorize self.datarep, self.ctxt, sec_buffer_out) pywintypes.error: (-2146893048, 'AcceptSecurityContext', 'The token supplied to the function is invalid') Any ideas? I've tried searching various windows forums about that error message in general as I'm guessing the python lib is just a thin wrapper around the win32 call, but can't find anything useful there either. I'm running this on a Windows 2003 SP2 server using Python 2.6.6 and pywin32-216. -Matt From amauryfa at gmail.com Fri Apr 15 18:56:25 2011 From: amauryfa at gmail.com (Amaury Forgeot d'Arc) Date: Fri, 15 Apr 2011 18:56:25 +0200 Subject: [python-win32] Issue with win32evtlog.ReportEvent In-Reply-To: <4DA69EB4.1010506@gmail.com> References: <4DA67E4A.5000402@gmail.com> <4DA69EB4.1010506@gmail.com> Message-ID: 2011/4/14 Mark Hammond : > Sadly some hacks were made to SWIG to support some of the COM objects and > the source to those changes were lost many years ago - this needs to be > revisited before we can upgrade. ?I haven't put much thought into that yet > but I'm sure something can be done... Here you are! Now you can comply with Swig's GPL license... I managed to hack an old version of SWIG and reproduce the same generated files: Start with the old swig 1.1p5: http://sourceforge.net/projects/swig/files/swig/1.1p5/ and apply the attached patch. The differences with the files generated generated by the old swig.exe are small, and are all similar to this one: where you previously had:: static PyObject *_wrap_python_const_FILE_GENERIC_READ; ... _wrap_python_const_FILE_GENERIC_READ = PyInt_FromLong(FILE_GENERIC_READ); PyDict_SetItemString(d,"FILE_GENERIC_READ", _wrap_python_const_FILE_GENERIC_READ); You now have: PyDict_SetItemString(d,"FILE_GENERIC_READ", PyInt_FromLong((long) FILE_GENERIC_READ)); Which is a small improvement IMO. -- Amaury Forgeot d'Arc -------------- next part -------------- A non-text attachment was scrubbed... Name: swig_pywin32.diff Type: application/octet-stream Size: 6285 bytes Desc: not available URL: From matth at netsight.co.uk Mon Apr 18 15:13:32 2011 From: matth at netsight.co.uk (Matt Hamilton) Date: Mon, 18 Apr 2011 13:13:32 +0000 (UTC) Subject: [python-win32] SSPI memory problems with Kerberos? References: Message-ID: Matt Hamilton netsight.co.uk> writes: > Originally I was passing it a valid Kerberos ticket, but no matter what it > would still give me that memory error. So I decided to pass in some bogus > data to at least get a different error... but no dice. I always just get this > memory error. After about 3 days of banging my head against the code, I finally worked out what the issue is. So for any future people looking and getting an error about 'Not enough memory is available to complete this request', SEC_E_INSUFFICIENT_MEMORY then is it likely that you are sending a Negotiate blob into a Kerberos context. The blob I was getting from IE is a Negotiate blob, not a native Kerberos one and so are decoded differently in ASN.1 and I guess the ASN.1 parser used by SSPI is not smart enough to work out when it is being fed something unexpected and runs out of memory trying to decode what it is given. So make sure you are doing: sa = sspi.ServerAuth('Negotiate') err, sec_buffer = sa.authorize(data) *not* sa = sspi.ServerAuth('Kerberos') err, sec_buffer = sa.authorize(data) -Matt From nikolay.mladenov at gmail.com Mon Apr 18 19:38:30 2011 From: nikolay.mladenov at gmail.com (Nikolay Mladenov) Date: Mon, 18 Apr 2011 17:38:30 +0000 (UTC) Subject: [python-win32] [ANN] pywin32 build 215 released. References: <4D61B494.6090202@skippinet.com.au> Message-ID: Mark Hammond skippinet.com.au> writes: > > Hi all, > I'm happy to announce the release of pywin32 build 215. > > This release has relatively few changes since build 214, although a > number of bugs have been addressed - the notable changes are: > > * The build process no longer includes a "manifest" in python 2.6 and > later versions - this should hopefully avoid failure to load the modules > in some environments (specifically, it should avoid "module not found" > type errors thrown by Windows.) Since win32ui.pyd ( and I guess others) no longer includes vc90.CRT manifest "import win32ui" fails from vc8 built executables. 214 and previous are working fine. Thanks for the excellent software! Nick From cman122887 at hotmail.com Wed Apr 20 03:16:07 2011 From: cman122887 at hotmail.com (Chris Bennett) Date: Tue, 19 Apr 2011 20:16:07 -0500 Subject: [python-win32] my python service needs to access network resources Message-ID: I have been trying to figure this out for weeks now. I have made a simply Python service on my local computer, but it needs to import a module from the network. I have tried appending the UNC of the folder to the path but it still says "there is no module named X" Then when I tried running the service logged on as NT AUTHORITY\NetworkService it cannot find my service object, even if I point to it with UNC in the registry. I am running out of ideas. Does anybody have any suggestions? Is it a firewall issue? Windows XP. Python 2.5. -Chris Bennett -------------- next part -------------- An HTML attachment was scrubbed... URL: From cman122887 at hotmail.com Wed Apr 20 02:48:22 2011 From: cman122887 at hotmail.com (Chris Bennett) Date: Tue, 19 Apr 2011 19:48:22 -0500 Subject: [python-win32] Python service needs to access network resources Message-ID: I have been trying to figure this out for weeks now. I have made a simply Python service on my local computer, but it needs to import a module from the network. I have tried appending the UNC of the folder to the path but it still says "there is no module named X" Then when I tried running the service logged on as NT AUTHORITY\NetworkService it cannot find my service object, even if I point to it with UNC in the registry. I am running out of ideas. Does anybody have any suggestions? Is it a firewall issue? Windows XP. Python 2.5. -------------- next part -------------- An HTML attachment was scrubbed... URL: From roberto.c.aguilar at gmail.com Wed Apr 20 05:02:34 2011 From: roberto.c.aguilar at gmail.com (Roberto Aguilar) Date: Tue, 19 Apr 2011 20:02:34 -0700 Subject: [python-win32] Python service needs to access network resources In-Reply-To: References: Message-ID: On Apr 19, 2011, at 5:48 PM, Chris Bennett wrote: > I have been trying to figure this out for weeks now. > I have made a simply Python service on my local computer, but it needs to import a module from the network. > I have tried appending the UNC of the folder to the path but it still says "there is no module named X" > Then when I tried running the service logged on as NT AUTHORITY\NetworkService it cannot find my service object, even if I point to it with UNC in the registry. > I am running out of ideas. Does anybody have any suggestions? Is it a firewall issue? > > Windows XP. Python 2.5. Have you tried running the script that imports the module as a stand alone program and _not_ as a service? Can it access the network module? Can os.listdir(unc_path) list the directory? I assume, when you say appending the UNC to the path you mean sys.path? Have you tried mapping the network drive to a drive letter and adding that to the path? If the module is on the local machine does it import properly? -Roberto. From timr at probo.com Wed Apr 20 19:09:25 2011 From: timr at probo.com (Tim Roberts) Date: Wed, 20 Apr 2011 10:09:25 -0700 Subject: [python-win32] Python service needs to access network resources In-Reply-To: References: Message-ID: <4DAF1345.6010407@probo.com> Chris Bennett wrote: > I have been trying to figure this out for weeks now. > I have made a simply Python service on my local computer, but it needs > to import a module from the network. > I have tried appending the UNC of the folder to the path but it still > says "there is no module named X" > Then when I tried running the service logged on as NT > AUTHORITY\NetworkService it cannot find my service object, even if I > point to it with UNC in the registry. > I am running out of ideas. Does anybody have any suggestions? Is it a > firewall issue? The NetworkService user does not have permissions to access your net shares, and it doesn't know about drive letters mapped by your username. It's not logged in to your network. You really have two choices. You can configure the service to log in with your user name (in the Services control panel), or you can copy these modules locally. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From cman122887 at hotmail.com Thu Apr 21 00:35:30 2011 From: cman122887 at hotmail.com (Chris Bennett) Date: Wed, 20 Apr 2011 17:35:30 -0500 Subject: [python-win32] Python service needs to access network resources In-Reply-To: References: , , Message-ID: From: cman122887 at hotmail.com To: roberto.c.aguilar at gmail.com Subject: RE: [python-win32] Python service needs to access network resources Date: Wed, 20 Apr 2011 11:10:56 -0500 > Subject: Re: [python-win32] Python service needs to access network resources > From: roberto.c.aguilar at gmail.com > Date: Tue, 19 Apr 2011 20:02:34 -0700 > CC: python-win32 at python.org > To: cman122887 at hotmail.com > > On Apr 19, 2011, at 5:48 PM, Chris Bennett wrote: > > I have been trying to figure this out for weeks now. > > I have made a simply Python service on my local computer, but it needs to import a module from the network. > > I have tried appending the UNC of the folder to the path but it still says "there is no module named X" > > Then when I tried running the service logged on as NT AUTHORITY\NetworkService it cannot find my service object, even if I point to it with UNC in the registry. > > I am running out of ideas. Does anybody have any suggestions? Is it a firewall issue? > > > > Windows XP. Python 2.5. > Thank you Roberto! Because of what you said I got it to work. I was appending to the path outside of the the service class when i should have been appending it inside. > Have you tried running the script that imports the module as a stand alone program and _not_ as a service? Can it access the network module? The script imports the module fine if it runs as a stand alone program. So yes it easily accesses the module, but I am logged in under a user that has that network device connected and mapped. > Can os.listdir(unc_path) list the directory? Yes it can when i run the service logged in under my user name. > I assume, when you say appending the UNC to the path you mean sys.path? Correct. > Have you tried mapping the network drive to a drive letter and adding that to the path? ^^^ THIS SUGGESTION LED ME TO THE ANSWER. When I tried to map the network drive outside the service class it threw an error saying it already existed. When I mapped the network drive and appended the path (appending the UNC worked too), I was able to use the module. much appreciated. This was making me quite aggravated. > If the module is on the local machine does it import properly? yes it does. > -Roberto. > -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Fri Apr 22 06:12:09 2011 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 22 Apr 2011 14:12:09 +1000 Subject: [python-win32] Issue with win32evtlog.ReportEvent In-Reply-To: References: <4DA67E4A.5000402@gmail.com> <4DA69EB4.1010506@gmail.com> Message-ID: <4DB10019.20908@skippinet.com.au> That is awesome - thanks very much. It works as advertised (although there was one trivial problem in the patch when generating COM objects that I fixed.) It works just fine with a py2k build, so all I need to do it integrate the changes Roger made for py3k into the mix and we are in a much better position :) Again, thanks, and I'll check this in over the next week or so... Cheers, Mark On 16/04/2011 2:56 AM, Amaury Forgeot d'Arc wrote: > 2011/4/14 Mark Hammond: >> Sadly some hacks were made to SWIG to support some of the COM objects and >> the source to those changes were lost many years ago - this needs to be >> revisited before we can upgrade. I haven't put much thought into that yet >> but I'm sure something can be done... > > Here you are! Now you can comply with Swig's GPL license... > > I managed to hack an old version of SWIG and reproduce the same generated files: > Start with the old swig 1.1p5: > http://sourceforge.net/projects/swig/files/swig/1.1p5/ > and apply the attached patch. > > The differences with the files generated generated by the old swig.exe > are small, > and are all similar to this one: where you previously had:: > static PyObject *_wrap_python_const_FILE_GENERIC_READ; > ... > _wrap_python_const_FILE_GENERIC_READ = > PyInt_FromLong(FILE_GENERIC_READ); > PyDict_SetItemString(d,"FILE_GENERIC_READ", > _wrap_python_const_FILE_GENERIC_READ); > You now have: > PyDict_SetItemString(d,"FILE_GENERIC_READ", > PyInt_FromLong((long) FILE_GENERIC_READ)); > Which is a small improvement IMO. > > From lueck at ipk-gatersleben.de Mon Apr 25 13:34:04 2011 From: lueck at ipk-gatersleben.de (lueck at ipk-gatersleben.de) Date: Mon, 25 Apr 2011 13:34:04 +0200 Subject: [python-win32] win32process.CreateProcess - strange behavior Message-ID: <20110425133404.ehpfjnuouso4skw4@webmail.ipk-gatersleben.de> Hello! I need to call an exe file (Windows XP) in my program. Up to now I used subprocess (Python 2.6): cmd = "bowtie-build mydb.fasta my_db_index" startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW startupinfo.wShowWindow = subprocess.SW_HIDE subprocess.call(cmd, startupinfo=startupinfo) Now I switched to Python 2.7 and also to win32process: StartupInfo = win32process.STARTUPINFO() StartupInfo.dwFlags = win32process.STARTF_USESHOWWINDOW StartupInfo.wShowWindow = win32con.SW_HIDE processHndl, primary_thread, pid, tid = win32process.CreateProcess( None, cmd, None, None, 0, win32process.REALTIME_PRIORITY_CLASS, None, None, StartupInfo) In generally it's works but with a very strange behavior. In my program I generate some data which are stored in text files and during the run proceeded. But If I use win32process, I see the results of the previous run in my output. If I start my program again and perform a new run with new data, the results are always calculated with the previous data. I do take care to delete data from the previous runs. I'm very confused how this can happen. If I use os.system(cmd) or subprocess as before, everything works as expected. Can anybody can help? Thanks in advance! Stefanie From odonnems at yahoo.com Tue Apr 26 03:45:49 2011 From: odonnems at yahoo.com (Michael ODonnell) Date: Mon, 25 Apr 2011 18:45:49 -0700 (PDT) Subject: [python-win32] Python and registry access with UAC enabled Message-ID: <636959.16804.qm@web161709.mail.bf1.yahoo.com> I have recently migrated to windows 7 from Windows XP. My organization enables UAC (level 3) at the group policy level and therefore I cannot disable it. I would like to know where there is a method to make registry changes using a python script without disabling UAC. For example, I can read registry hives and keys but I cannot write to them: import _winreg # Successful read RegConn = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE) keyStr = r'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\1033' key = _winreg.OpenKey(RegConn, keyStr, 0, _winreg.KEY_READ | _winreg.KEY_WOW64_32KEY) print _winreg.QueryValueEx(key, "Version")[0] # Unsuccessful write x = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE) y = _winreg.OpenKey(x, r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", 0, _winreg.KEY_ALL_ACCESS) _winreg.SetValueEx(y, "path", 0, _winreg.REG_EXPAND_SZ,path + ";C:\\test") _winreg.CloseKey(y) _winreg.CloseKey(x) I have compiled my code as an EXE and created a manifest and using the trustinfo xml node, but this will also not work for me. I am always logged in as an administrator. Can anyone provide me with some suggestions on how I can work through this. Also, on a personal Windows 7 64bit machine, if I disable UAC, I can successfully write to the registry. Thank you, Mike From planders at gmail.com Tue Apr 26 17:13:07 2011 From: planders at gmail.com (Preston Landers) Date: Tue, 26 Apr 2011 10:13:07 -0500 Subject: [python-win32] Python and registry access with UAC enabled In-Reply-To: <636959.16804.qm@web161709.mail.bf1.yahoo.com> References: <636959.16804.qm@web161709.mail.bf1.yahoo.com> Message-ID: Not sure if this solves the actual problem you're having, but I wrote a small script to relaunch a process as an admin using UAC. Hopefully this helps somehow. http://dl.dropbox.com/u/11450437/pyuac.py thanks, -Preston On Mon, Apr 25, 2011 at 8:45 PM, Michael ODonnell wrote: > I have recently migrated to windows 7 from Windows XP. My organization > enables UAC (level 3) at the group policy level and therefore I cannot > disable it. I would like to know where there is a method to make registry > changes using a python script without disabling UAC. For example, I can read > registry hives and keys but I cannot write to them: > > import _winreg > > # Successful read > RegConn = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE) > keyStr = r'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\1033' > key = _winreg.OpenKey(RegConn, keyStr, 0, _winreg.KEY_READ | > _winreg.KEY_WOW64_32KEY) > print _winreg.QueryValueEx(key, "Version")[0] > > # Unsuccessful write > > x = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE) > y = _winreg.OpenKey(x, r"SYSTEM\CurrentControlSet\Control\Session > Manager\Environment", 0, _winreg.KEY_ALL_ACCESS) > _winreg.SetValueEx(y, "path", 0, _winreg.REG_EXPAND_SZ,path + ";C:\\test") > _winreg.CloseKey(y) > _winreg.CloseKey(x) > > I have compiled my code as an EXE and created a manifest and using the > trustinfo xml node, but this will also not work for me. I am always logged > in as an administrator. Can anyone provide me with some suggestions on how I > can work through this. Also, on a personal Windows 7 64bit machine, if I > disable UAC, I can successfully write to the registry. > > > Thank you, > Mike > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Apr 26 19:52:34 2011 From: timr at probo.com (Tim Roberts) Date: Tue, 26 Apr 2011 10:52:34 -0700 Subject: [python-win32] Python and registry access with UAC enabled In-Reply-To: <636959.16804.qm@web161709.mail.bf1.yahoo.com> References: <636959.16804.qm@web161709.mail.bf1.yahoo.com> Message-ID: <4DB70662.90508@probo.com> Michael ODonnell wrote: > I have recently migrated to windows 7 from Windows XP. My organization enables UAC (level 3) at the group policy level and therefore I cannot disable it. I would like to know where there is a method to make registry changes using a python script without disabling UAC. For example, I can read registry hives and keys but I cannot write to them: To be more specific, you cannot write to HKEY_LOCAL_MACHINE. Most scripts should be using HKEY_CURRENT_USER, which is writable. > import _winreg > > # Successful read > RegConn = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE) > keyStr = r'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\1033' > key = _winreg.OpenKey(RegConn, keyStr, 0, _winreg.KEY_READ | _winreg.KEY_WOW64_32KEY) > print _winreg.QueryValueEx(key, "Version")[0] > > # Unsuccessful write > > x = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE) > y = _winreg.OpenKey(x, r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", 0, _winreg.KEY_ALL_ACCESS) > _winreg.SetValueEx(y, "path", 0, _winreg.REG_EXPAND_SZ,path + ";C:\\test") > _winreg.CloseKey(y) > _winreg.CloseKey(x) You can certainly write to HKEY_CURRENT_USER\Environment. Also, you don't really need KEY_ALL_ACCESS. All you need is KEY_SET_VALUE. I don't think that will be allowed either, but it's better to ask for only the permissions you need. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From vernondcole at gmail.com Thu Apr 28 21:02:18 2011 From: vernondcole at gmail.com (Vernon Cole) Date: Thu, 28 Apr 2011 13:02:18 -0600 Subject: [python-win32] Fw: [ pywin32-Bugs-3292681 ] adodbapi - Subtle crash Message-ID: I am cross-posting this message from the sourceforge bugtracker, so that everyone will know about it. Perhaps someone will have a clue what might be causing it. It's pretty weird... v v v v v v v v v v v From: SourceForge.net Subject: [ pywin32-Bugs-3292681 ] adodbapi - Subtle crash To: noreply at sourceforge.net Date: Tuesday, April 26, 2011, 3:11 PM Bugs item #3292681, was opened at 2011-04-25 15:51 [... snip ...] Category: adodbapi Group: None Status: [Accepted] Resolution: None Priority: 5 Private: No Submitted By: https://www.google.com/accounts () Assigned to: Vernon Cole (kf7xm) Summary: adodbapi - Subtle crash Initial Comment: There is a subtle crash that can occur related to time.sleep(>10) and adodbapi.connect() calls, the second time will crash, attached there is the simplest test case to crash it and various comments explaining the crash behavior test enviroement and stacktraces. i hope will be useful to find the right solution, i've only found a bad workarond, without calling adodbapi.close() the crash doesn't happens. thank you in advice ---------------------------------------------------------------------- >Comment By: https://www.google.com/accounts () Date: 2011-04-26 21:11 Message: The connection string needs sqlserver express installed on the machine, but the same happens also with oracle oledb provider, this are the two providers i've tested on, but could be the crash occurs with any provider ------------------------------- Comment By: Mark Hammond (mhammond) Date: 2011-04-26 03:19 Message: I haven't had a chance to repro this yet as the connection string doesn't work on my dev box. ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ I have downloaded the code and determined that it also crashes on my Vista 32 bit laptop, running either Python 2.7 or 3.2. It also crashes when using the JET data provider to open an ACCESS .mdb database, so the problem is not specific to any provider. It DOES NOT crash when using IronPython. It DOES NOT crash if you have made opened and closed a connection for less than 10 seconds before you try it with the 10 second pause. It also crashes if the time.sleep(10) call is replaced by sys.stdin.readline() and counting ten seconds, so it's not an interaction with the time() module. I'll continue looking, but frankly don't have a clue where to start. Brilliant helpers are invited to contribute. -- Vernon WebRep Overall rating -------------- next part -------------- An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Thu Apr 28 23:07:09 2011 From: vernondcole at gmail.com (Vernon Cole) Date: Thu, 28 Apr 2011 15:07:09 -0600 Subject: [python-win32] Fw: [ pywin32-Bugs-3292681 ] adodbapi - Subtle crash Message-ID: I found two fixes for the crash. Now I need one of you brilliant folks to tell me which is correct. First, here is a snippet from adodbapi. Look closely at the comments on the last three lines of code ... v v v v v v v v v [... Snip ...] [ (Note: lines below are paraphrased -- not quite the actual code) ] def connect(connection_string): pythoncom.CoInitialize() conn = win32com.client.Dispatch("ADODB.Connection") conn.ConnectionString = connection_string conn.Open() return Connection(conn) class Connection(object): __init__(self,conn): self.adoConn = conn self.messages = [] [... snip ...] def _closeAdoConnection(self): #all v2.1 Rose """close the underlying ADO Connection object, rolling it back first if it supports transactions.""" if self.supportsTransactions: self.adoConn.RollbackTrans() self.adoConn.Close() def close(self): self.messages=[] try: self._closeAdoConnection() #v2.1 Rose except (Exception), e: self._raiseConnectionError(InternalError,e) del self.adoConn #### adding this line cures the crash #### or pythoncom.CoUninitialize() #### removing this line cures the crash ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ So --- which is the correct correction? remove the CoUininitialize() or perform the explicit del of the Dispatch object? --- Vernon -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Fri Apr 29 02:50:40 2011 From: skippy.hammond at gmail.com (Mark Hammond) Date: Fri, 29 Apr 2011 10:50:40 +1000 Subject: [python-win32] Fw: [ pywin32-Bugs-3292681 ] adodbapi - Subtle crash In-Reply-To: References: Message-ID: <4DBA0B60.5090509@gmail.com> On 29/04/2011 7:07 AM, Vernon Cole wrote: > I found two fixes for the crash. Now I need one of you brilliant folks > to tell me which is correct. First, here is a snippet from adodbapi. > Look closely at the comments on the last three lines of code ... > v v v v v v v v v > def _closeAdoConnection(self): #all v2.1 Rose > """close the underlying ADO Connection object, > rolling it back first if it supports transactions.""" > if self.supportsTransactions: > self.adoConn.RollbackTrans() > self.adoConn.Close() > > def close(self): > self.messages=[] > try: > self._closeAdoConnection() #v2.1 Rose > except (Exception), e: > self._raiseConnectionError(InternalError,e) > > del self.adoConn #### > adding this line cures the crash > > #### or > pythoncom.CoUninitialize() #### removing > this line cures the crash > ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ > > So --- which is the correct correction? > remove the CoUininitialize() > or perform the explicit del of the Dispatch object? It sounds like the problem is that the object is still alive once CoUninitialize() is called - then, when the adoCon object is finally released (when the Connection object itself is released) "bad things" (tm) happen. I think that is likely to be considered expected behaviour - things should all be released before doing a CoUninitialize(). I'd suggest that something like self.adoConn = None in one of the close methods is perfectly reasonable. OTOH, I expect the benefits of uninitializing are probably fairly small, so never uninitializing will probably not cause any problems. Resetting the object to None (or del'ing it) is probably preferred though - if the object remains alive and is cleaned up while the Python interpreter is finalizing I'd expect things could still go wrong, and discarding the object completely at close time seems sensible anyway. If you can give me a connection string that is likely to fail for me, I can run the example in a debug version of Python and check there isn't some other bug in pywin32 or similar which could mitigate the entire issue... Thanks! Mark