From gbrunick at andrew.cmu.edu Sat Mar 1 08:24:01 2008 From: gbrunick at andrew.cmu.edu (Gerard Brunick) Date: Sat, 01 Mar 2008 02:24:01 -0500 Subject: [python-win32] If I used AddObject to add an object to a MS Script control where does it go? Message-ID: <47C90491.7010101@andrew.cmu.edu> I am using the active scripting stuff to run python code from within MS Office VBA code. Supposedly, the AddObject method of the scripting control makes an object visible to the script code; however, I don't see anything show up in the global python namespace when I do this? In the examples with win32com, there generally seems to be a useful object exposed to the script like "WScript" for the wsh, and I thought that the added object may show up as a member of such an object, but I don't see such anything like this in my global namespace either? A quick search of the list for "AddObject" found one question in 2004 with no replies. Hopefully, I do a little better this time :). Thanks in advance, Gerard From jn.ml.pyw32.88 at wingsandbeaks.org.uk Sat Mar 1 14:48:29 2008 From: jn.ml.pyw32.88 at wingsandbeaks.org.uk (Jeremy Nicoll - pyw32) Date: Sat, 1 Mar 2008 13:48:29 +0000 Subject: [python-win32] How to generate syslog records from a Python program eg using Kiwi's KLOG_COM.dll? Message-ID: Warning: I know nearly nothing about Windows, DLLs, COM etc. My programming has mainly been done on mainframes and RISC OS (ARM) machines. Kiwi Enterprises, at: http://www.kiwisyslog.com/ provide some free syslog utilities. Amongst them are a set of DLLs eg one called KLOG_COM.dll which I think can be used from various programming languages to generate syslog records. As I found out about this way of generating syslog records while reading about Kiwi's utilities I've assumed that this is the way (or at least a good way) to generate syslog records from a Python program, but I suppose there must be other ways too? A platform-independent method would clearly be better... There's lots of documentation provided with KLOG_COM.dll but none of it is Python-orientated and it is all well over my head. I've assumed that as KLOG_COM.dll is a COM thing, I'll need pywin32 installed to use it, so I have installed that too. But I have no idea what to do next. Can anyone provide sample code? -- Jeremy C B Nicoll - my opinions are my own. From mhammond at skippinet.com.au Sun Mar 2 23:46:28 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 3 Mar 2008 09:46:28 +1100 Subject: [python-win32] If I used AddObject to add an object to a MS Script control where does it go? In-Reply-To: <47C90491.7010101@andrew.cmu.edu> References: <47C90491.7010101@andrew.cmu.edu> Message-ID: <076b01c87cb7$50c8dea0$f25a9be0$@com.au> There is a magic 'axscript' global, which probably makes the item available. Cheers, Mark > -----Original Message----- > From: python-win32-bounces at python.org [mailto:python-win32- > bounces at python.org] On Behalf Of Gerard Brunick > Sent: Saturday, 1 March 2008 6:24 PM > To: python-win32 at python.org > Subject: [python-win32] If I used AddObject to add an object to a MS > Script control where does it go? > > I am using the active scripting stuff to run python code from within MS > Office VBA code. > Supposedly, the AddObject method of the scripting control makes an > object visible to the > script code; however, I don't see anything show up in the global python > namespace when I > do this? In the examples with win32com, there generally seems to be a > useful object exposed > to the script like "WScript" for the wsh, and I thought that the added > object may show up as a > member of such an object, but I don't see such anything like this in my > global namespace either? > A quick search of the list for "AddObject" found one question in 2004 > with no replies. Hopefully, > I do a little better this time :). > > Thanks in advance, > Gerard > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From mail at timgolden.me.uk Mon Mar 3 10:01:21 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 03 Mar 2008 09:01:21 +0000 Subject: [python-win32] How to generate syslog records from a Python program eg using Kiwi's KLOG_COM.dll? In-Reply-To: References: Message-ID: <47CBBE61.2060703@timgolden.me.uk> Jeremy Nicoll - pyw32 wrote: > Warning: I know nearly nothing about Windows, DLLs, COM etc. My programming > has mainly been done on mainframes and RISC OS (ARM) machines. > > Kiwi Enterprises, at: http://www.kiwisyslog.com/ provide some free syslog > utilities. > > Amongst them are a set of DLLs eg one called KLOG_COM.dll which I think can > be used from various programming languages to generate syslog records. > > As I found out about this way of generating syslog records while reading > about Kiwi's utilities I've assumed that this is the way (or at least a good > way) to generate syslog records from a Python program, but I suppose there > must be other ways too? A platform-independent method would clearly be > better... Just to save me downloading and trying to understand the Kiwi tools, the logging module has a SysLogHandler which (glancing quickly at the source) seems to be a handcrafted socket implementation which should therefore be cross-platform. Worth a look? TJG From jn.ml.pyw32.88 at wingsandbeaks.org.uk Mon Mar 3 11:50:52 2008 From: jn.ml.pyw32.88 at wingsandbeaks.org.uk (Jeremy Nicoll - pyw32) Date: Mon, 3 Mar 2008 10:50:52 +0000 Subject: [python-win32] How to generate syslog records from a Python program eg using Kiwi's KLOG_COM.dll? In-Reply-To: <47CBBE61.2060703@timgolden.me.uk> References: <47CBBE61.2060703@timgolden.me.uk> Message-ID: Tim Golden wrote: > Jeremy Nicoll - pyw32 wrote: > > Warning: I know nearly nothing about Windows, DLLs, COM etc. My > > programming has mainly been done on mainframes and RISC OS (ARM) > > machines. > > > > Kiwi Enterprises, at: http://www.kiwisyslog.com/ provide some free > > syslog utilities. > > > > Amongst them are a set of DLLs eg one called KLOG_COM.dll which I think > > can be used from various programming languages to generate syslog > > records. > > > > As I found out about this way of generating syslog records while reading > > about Kiwi's utilities I've assumed that this is the way (or at least a > > good way) to generate syslog records from a Python program, but I > > suppose there must be other ways too? A platform-independent method > > would clearly be better... > > Just to save me downloading and trying to understand the Kiwi > tools, the logging module has a SysLogHandler which (glancing > quickly at the source) seems to be a handcrafted socket implementation > which should therefore be cross-platform. Ah, yes... Thank-you! I wish I'd known that existed. Still, the logging module looks complicated to set up. I'll experiment and see where I get. [The simplest of Kiwi's tools is KLOG.exe which allows one to generate a syslog message from any command line and is therefore useful in .bat files etc as well. But I'd always assumed that using such a CLI command to pass many thousands of debugging/trace messages out of a Python program might be somewhat less efficient than using the same via an internal interface, which is why I'd asked about this. But clearly if Python can do it directly that'd be much better, at least from Python programs, and I can still use the simplest KLOG.exe from other places.] -- Jeremy C B Nicoll - my opinions are my own. From mail at timgolden.me.uk Mon Mar 3 12:35:15 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 03 Mar 2008 11:35:15 +0000 Subject: [python-win32] How to generate syslog records from a Python program eg using Kiwi's KLOG_COM.dll? In-Reply-To: References: <47CBBE61.2060703@timgolden.me.uk> Message-ID: <47CBE273.8000307@timgolden.me.uk> Jeremy Nicoll - pyw32 wrote: > Tim Golden wrote: >> Just to save me downloading and trying to understand the Kiwi >> tools, the logging module has a SysLogHandler which (glancing >> quickly at the source) seems to be a handcrafted socket implementation >> which should therefore be cross-platform. > > Ah, yes... Thank-you! I wish I'd known that existed. > > Still, the logging module looks complicated to set up. I'll experiment and > see where I get. It does (deservedly, I think) have that reputation. Have a look at its entry in Doug Hellman's module-of-the-week series; might be useful. http://blog.doughellmann.com/2007/05/pymotw-logging.html TJG From rdm at rcblue.com Tue Mar 4 22:57:05 2008 From: rdm at rcblue.com (Dick Moores) Date: Tue, 04 Mar 2008 13:57:05 -0800 Subject: [python-win32] Iron Python and Visual Basic 2005 (or 2008) Express Message-ID: <20080304220434.9DBFA1E4007@bag.python.org> Years ago I learned a bit of Visual Basic (VB6, IIRC) at a community college. About a year ago I downloaded the free Visual Basic 2005 Express (), but didn't do much with it. But I was wondering if it was possible to write Python code in Iron Python and use it somehow in Visual Basic 2005 (or 2008) Express. VB seemed a very easy way to create a GUI, but of course I prefer Python for the code. So, possible/impossible/impractical/foolish/Pythonically_traitorous? Thanks, Dick Moores From fuzzyman at voidspace.org.uk Tue Mar 4 23:14:36 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 04 Mar 2008 22:14:36 +0000 Subject: [python-win32] Iron Python and Visual Basic 2005 (or 2008) Express In-Reply-To: <20080304220434.9DBFA1E4007@bag.python.org> References: <20080304220434.9DBFA1E4007@bag.python.org> Message-ID: <47CDC9CC.1080304@voidspace.org.uk> Dick Moores wrote: > Years ago I learned a bit of Visual Basic (VB6, > IIRC) at a community college. About a year ago I > downloaded the free Visual Basic 2005 Express > (), > but didn't do much with it. > > But I was wondering if it was possible to write > Python code in Iron Python and use it somehow in > Visual Basic 2005 (or 2008) Express. VB seemed a very easy > way to create a GUI, but of course I prefer Python for the code. > > So, possible/impossible/impractical/foolish/Pythonically_traitorous? > Your question as phrased doesn't actually mean a great deal. :-) Do you want to code with Python or with VB? (They are different languages and you can't just mix them in the same source files - well you can actually but not in the way you mean I think...) This sort of question would be much better directed to the IronPython mailing list by the way: http://lists.ironpython.com/listinfo.cgi/users-ironpython.com Do you actually mean "can you use IronPython with Visual Studio Express"? If so, the answer is "not really". But you can use IronPython to create any sort of application that you can with VB. A good place to start is with the Early Access program for "IronPython in Action": http://www.manning.com/foord Michael > Thanks, > > Dick Moores > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From stef.mientki at gmail.com Tue Mar 4 23:37:07 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Tue, 04 Mar 2008 23:37:07 +0100 Subject: [python-win32] Iron Python and Visual Basic 2005 (or 2008) Express In-Reply-To: <20080304220434.9DBFA1E4007@bag.python.org> References: <20080304220434.9DBFA1E4007@bag.python.org> Message-ID: <47CDCF13.3060007@gmail.com> Dick Moores wrote: > Years ago I learned a bit of Visual Basic (VB6, > IIRC) at a community college. About a year ago I > downloaded the free Visual Basic 2005 Express > (), > but didn't do much with it. > > But I was wondering if it was possible to write > Python code in Iron Python and use it somehow in > Visual Basic 2005 (or 2008) Express. VB seemed a very easy > way to create a GUI, but of course I prefer Python for the code. > > So, possible/impossible/impractical/foolish/Pythonically_traitorous? > > I don't know what Iron Python is, but I'm using embedded Python in Delphi (which is quit comparable to VB) for about a year now, and it's indeed a fabulous great combination: - the GUI power of Delphi - the scripting and numerical power of Python / SciPy I would say much more powerful than MatLab, and even be more powerful than LabView. cheers, Stef > Thanks, > > Dick Moores > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From rdm at rcblue.com Wed Mar 5 00:08:59 2008 From: rdm at rcblue.com (Dick Moores) Date: Tue, 04 Mar 2008 15:08:59 -0800 Subject: [python-win32] Iron Python and Visual Basic 2005 (or 2008) Express In-Reply-To: <47CDC9CC.1080304@voidspace.org.uk> References: <20080304220434.9DBFA1E4007@bag.python.org> <47CDC9CC.1080304@voidspace.org.uk> Message-ID: <20080304230912.3A68D1E4007@bag.python.org> At 02:14 PM 3/4/2008, Michael Foord wrote: >Dick Moores wrote: >>Years ago I learned a bit of Visual Basic (VB6, >>IIRC) at a community college. About a year ago I >>downloaded the free Visual Basic 2005 Express >>(), >>but didn't do much with it. >> >>But I was wondering if it was possible to write >>Python code in Iron Python and use it somehow in >>Visual Basic 2005 (or 2008) Express. VB seemed a very easy >>way to create a GUI, but of course I prefer Python for the code. >> >>So, possible/impossible/impractical/foolish/Pythonically_traitorous? >> > >Your question as phrased doesn't actually mean a great deal. :-) > >Do you want to code with Python or with VB? (They are different >languages and you can't just mix them in the same source files - >well you can actually but not in the way you mean I think...) > >This sort of question would be much better directed to the >IronPython mailing list by the way: >http://lists.ironpython.com/listinfo.cgi/users-ironpython.com I did, a month ago (), but got no response, possibly because my "question as phrased doesn't actually mean a great deal". :-( >Do you actually mean "can you use IronPython with Visual Studio >Express"? If so, the answer is "not really". But you can use >IronPython to create any sort of application that you can with VB. OK, so I'm now a bit wiser. Rephrasing: "can IPython access the same GUI library as VB.NET?" And the answer is yes. >A good place to start is with the Early Access program for >"IronPython in Action": >http://www.manning.com/foord I've just read the free first chapter. Here's one paragraph (bottom of p. 12 of the PDF): "IronPython uses .NET classes natively and seamlessly, and there are a lot of them. Two of the gems in the collection are Windows Forms and the Windows Presentation Foundation, which are excellent libraries for building attractive and native looking user interfaces. As a Python programmer, you may be surprised by how straightforward the programmers interface to these libraries feels. Whatever programming task you are approaching, it is likely that there is some .NET assembly available to tackle it. This includes third party libraries for sophisticated GUI components, like data grids, where there is nothing comparable available for CPython. Table 1.1 shows a small selection of the libraries available to you in the .NET framework." I'm going to sign up for "MEAP + Ebook only" ($27.50) right now. Thanks very much. Dick Moores From rdm at rcblue.com Wed Mar 5 00:34:08 2008 From: rdm at rcblue.com (Dick Moores) Date: Tue, 04 Mar 2008 15:34:08 -0800 Subject: [python-win32] Iron Python and Visual Basic 2005 (or 2008) Express In-Reply-To: <47CDCF13.3060007@gmail.com> References: <20080304220434.9DBFA1E4007@bag.python.org> <47CDCF13.3060007@gmail.com> Message-ID: <20080304233508.F36811E401A@bag.python.org> At 02:37 PM 3/4/2008, Stef Mientki wrote: >Dick Moores wrote: > > Years ago I learned a bit of Visual Basic (VB6, > > IIRC) at a community college. About a year ago I > > downloaded the free Visual Basic 2005 Express > > (), > > but didn't do much with it. > > > > But I was wondering if it was possible to write > > Python code in Iron Python and use it somehow in > > Visual Basic 2005 (or 2008) Express. VB seemed a very easy > > way to create a GUI, but of course I prefer Python for the code. > > > > So, possible/impossible/impractical/foolish/Pythonically_traitorous? > > > > >I don't know what Iron Python is, >but I'm using embedded Python in Delphi (which is quit comparable to >VB) for about a year now, >and it's indeed a fabulous great combination: >- the GUI power of Delphi >- the scripting and numerical power of Python / SciPy >I would say much more powerful than MatLab, >and even be more powerful than LabView. I just Googled "Delphi". Is your Delphi listed on this page?: And does it come with Python embedded or do you have to do the embedding? I have a feeling that's a stupid question, but I'm fearless. :-) Thanks, Dick Moores From timr at probo.com Wed Mar 5 00:57:30 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 04 Mar 2008 15:57:30 -0800 Subject: [python-win32] Iron Python and Visual Basic 2005 (or 2008) Express In-Reply-To: <20080304233508.F36811E401A@bag.python.org> References: <20080304220434.9DBFA1E4007@bag.python.org> <47CDCF13.3060007@gmail.com> <20080304233508.F36811E401A@bag.python.org> Message-ID: <47CDE1EA.1090706@probo.com> Dick Moores wrote: > I just Googled "Delphi". Is your Delphi listed on this page?: > And does it come with > Python embedded or do you have to do the embedding? I have a feeling > that's a stupid question, but I'm fearless. :-) > Delphi is the grown-up version of Borland's Object Pascal. Think of it as Visual Studio for Pascal. It was a very cool product, with a great IDE and a wonderful class library for writing GUI apps. I was a steadfast Delphi zealot from versions 1 through 5, but when I got hooked on Python I drifted away, and I haven't looked back. Delphi doesn't come with Python in the box, but it's very easy to add packages, and there are lots of places to download them. Essentially one DLL gives you a Python engine within your Delphi application. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From nytrokiss at gmail.com Wed Mar 5 01:50:17 2008 From: nytrokiss at gmail.com (James Matthews) Date: Wed, 5 Mar 2008 01:50:17 +0100 Subject: [python-win32] Iron Python and Visual Basic 2005 (or 2008) Express In-Reply-To: <20080304220434.9DBFA1E4007@bag.python.org> References: <20080304220434.9DBFA1E4007@bag.python.org> Message-ID: <8a6b8e350803041650u7f0e7b1cmf2bff6e2e827856e@mail.gmail.com> Yes because it uses the CLR! On Tue, Mar 4, 2008 at 10:57 PM, Dick Moores wrote: > Years ago I learned a bit of Visual Basic (VB6, > IIRC) at a community college. About a year ago I > downloaded the free Visual Basic 2005 Express > (), > but didn't do much with it. > > But I was wondering if it was possible to write > Python code in Iron Python and use it somehow in > Visual Basic 2005 (or 2008) Express. VB seemed a very easy > way to create a GUI, but of course I prefer Python for the code. > > So, possible/impossible/impractical/foolish/Pythonically_traitorous? > > Thanks, > > Dick Moores > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- http://search.goldwatches.com/?Search=Movado+Watches http://www.jewelerslounge.com http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080305/90810930/attachment.htm From rdm at rcblue.com Wed Mar 5 02:21:40 2008 From: rdm at rcblue.com (Dick Moores) Date: Tue, 04 Mar 2008 17:21:40 -0800 Subject: [python-win32] Iron Python and Visual Basic 2005 (or 2008) Express In-Reply-To: <47CDE1EA.1090706@probo.com> References: <20080304220434.9DBFA1E4007@bag.python.org> <47CDCF13.3060007@gmail.com> <20080304233508.F36811E401A@bag.python.org> <47CDE1EA.1090706@probo.com> Message-ID: <20080305012223.BFBB01E4007@bag.python.org> At 03:57 PM 3/4/2008, Tim Roberts wrote: >Dick Moores wrote: > > I just Googled "Delphi". Is your Delphi listed on this page?: > > And does it come with > > Python embedded or do you have to do the embedding? I have a feeling > > that's a stupid question, but I'm fearless. :-) > > > >Delphi is the grown-up version of Borland's Object Pascal. Think of it >as Visual Studio for Pascal. It was a very cool product, with a great >IDE and a wonderful class library for writing GUI apps. I was a >steadfast Delphi zealot from versions 1 through 5, but when I got hooked >on Python I drifted away, and I haven't looked back. > >Delphi doesn't come with Python in the box, but it's very easy to add >packages, and there are lots of places to download them. Essentially >one DLL gives you a Python engine within your Delphi application. So is this the Delphi you are talking about?: Dick Moores From gbrunick at andrew.cmu.edu Wed Mar 5 16:44:18 2008 From: gbrunick at andrew.cmu.edu (Gerard Brunick) Date: Wed, 05 Mar 2008 10:44:18 -0500 Subject: [python-win32] If I used AddObject to add an object to a MS Script control where does it go? In-Reply-To: <076b01c87cb7$50c8dea0$f25a9be0$@com.au> References: <47C90491.7010101@andrew.cmu.edu> <076b01c87cb7$50c8dea0$f25a9be0$@com.au> Message-ID: <47CEBFD2.9010809@andrew.cmu.edu> Thanks Mark. I can't seem to get my hands on the axscript global; however, I now see the objects that I add as globals themselves. It also appears that everything vanishes if there is an unhandled exception in the code being run in the script control. I think this behavior was what was initially confusing to me. Thanks again for the response, Gerard Mark Hammond wrote: > There is a magic 'axscript' global, which probably makes the item available. > > Cheers, > > Mark > > >> -----Original Message----- >> From: python-win32-bounces at python.org [mailto:python-win32- >> bounces at python.org] On Behalf Of Gerard Brunick >> Sent: Saturday, 1 March 2008 6:24 PM >> To: python-win32 at python.org >> Subject: [python-win32] If I used AddObject to add an object to a MS >> Script control where does it go? >> >> I am using the active scripting stuff to run python code from within MS >> Office VBA code. >> Supposedly, the AddObject method of the scripting control makes an >> object visible to the >> script code; however, I don't see anything show up in the global python >> namespace when I >> do this? In the examples with win32com, there generally seems to be a >> useful object exposed >> to the script like "WScript" for the wsh, and I thought that the added >> object may show up as a >> member of such an object, but I don't see such anything like this in my >> global namespace either? >> A quick search of the list for "AddObject" found one question in 2004 >> with no replies. Hopefully, >> I do a little better this time :). >> >> Thanks in advance, >> Gerard >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 >> > > > From timr at probo.com Wed Mar 5 18:16:49 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 05 Mar 2008 09:16:49 -0800 Subject: [python-win32] Iron Python and Visual Basic 2005 (or 2008) Express In-Reply-To: <200803050121.m251LW226976@probo.probo.com> References: <20080304220434.9DBFA1E4007@bag.python.org> <47CDCF13.3060007@gmail.com> <20080304233508.F36811E401A@bag.python.org> <47CDE1EA.1090706@probo.com> <200803050121.m251LW226976@probo.probo.com> Message-ID: <47CED581.7040501@probo.com> Dick Moores wrote: > At 03:57 PM 3/4/2008, Tim Roberts wrote: >> >> Delphi is the grown-up version of Borland's Object Pascal. Think of it >> as Visual Studio for Pascal. It was a very cool product, with a great >> IDE and a wonderful class library for writing GUI apps. I was a >> steadfast Delphi zealot from versions 1 through 5, but when I got hooked >> on Python I drifted away, and I haven't looked back. >> >> Delphi doesn't come with Python in the box, but it's very easy to add >> packages, and there are lots of places to download them. Essentially >> one DLL gives you a Python engine within your Delphi application. > > So is this the Delphi you are talking about?: > Delphi was originally developed by Borland, which later changed its name to Inprise or something equally banal, then back to Borland when they realized their mistake. They have now spun off all of their great development tools to this separate business, CodeGear. Delphi has morphed quite a bit since I last played with it, but the Delphi for Win32, Delphi for PHP, and RAD Studio products certainly appear to be children and grandchildren of the product I knew. There was also a Delphi for Linux, but I don't see that any more. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From glenn.graessle at honeywell.com Wed Mar 5 20:36:28 2008 From: glenn.graessle at honeywell.com (Graessle, Glenn (FC COE)) Date: Wed, 5 Mar 2008 12:36:28 -0700 Subject: [python-win32] Python Interface to PVCS. Message-ID: <782F51FEE95A4848BD87BD3E75DAD0F91E132D@AZ18EV801.global.ds.honeywell.com> Anyone know where I can find a Python interface to Merant's CM tool called PVCS? Glenn Graessle Flight Controls CoE Honeywell International, Inc. 23500 West 105th Street (M/D 42) Olathe, KS 66061 913-712-2645(phone/fax) 913-832-2345 (mobile) glenn.graessle at honeywell.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080305/18eef92d/attachment.htm From timr at probo.com Wed Mar 5 20:51:51 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 05 Mar 2008 11:51:51 -0800 Subject: [python-win32] Python Interface to PVCS. In-Reply-To: <782F51FEE95A4848BD87BD3E75DAD0F91E132D@AZ18EV801.global.ds.honeywell.com> References: <782F51FEE95A4848BD87BD3E75DAD0F91E132D@AZ18EV801.global.ds.honeywell.com> Message-ID: <47CEF9D7.8090602@probo.com> Graessle, Glenn (FC COE) wrote: > Anyone know where I can find a Python interface to Merant's CM tool > called PVCS? I found it was easier just to call their command line tools with the subprocess module. There's supposed to be an API, but their product is baroquely complicated. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Mar 5 21:34:00 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 05 Mar 2008 12:34:00 -0800 Subject: [python-win32] Python Interface to PVCS. In-Reply-To: <782F51FEE95A4848BD87BD3E75DAD0F91E1339@AZ18EV801.global.ds.honeywell.com> References: <782F51FEE95A4848BD87BD3E75DAD0F91E132D@AZ18EV801.global.ds.honeywell.com> <47CEF9D7.8090602@probo.com> <782F51FEE95A4848BD87BD3E75DAD0F91E1339@AZ18EV801.global.ds.honeywell.com> Message-ID: <47CF03B8.4060705@probo.com> Graessle, Glenn (FC COE) wrote: > Thanks. Have you seen a basic, command-line-wrapper class anywhere? > Do you mean, specifically for PVCS? No. I just rolled my own. This was a number of years ago, and I don't think I even have the wrappers I wrote any more. They weren't all that complicated, and they just kind of grew out of my own needs. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mbelzile at softimage.com Thu Mar 6 00:42:04 2008 From: mbelzile at softimage.com (=?iso-8859-1?Q?Marc-Andr=E9_Belzile?=) Date: Wed, 5 Mar 2008 18:42:04 -0500 Subject: [python-win32] Building pywin32 on Vista 64 Message-ID: <0BCB4AE868D8934A8B3DCE3A58126A8901B976E7@tewk-mbpf3> Hello, I'm trying to build pywin32 (2.5.210.0) on Vista 64 (AMD64) with VS 2005. I'm stucked right at the beginning of the process with this error : File "C:\Python25\lib\distutils\msvccompiler.py", line 616, in get_msvc_paths % (self.__root, self.__version)) AttributeError: my_compiler instance has no attribute '_MSVCCompiler__root' I did install the windows server 2003 platform SDK (AMD64) and set both DISTUTILS_USE_SDK + MSSdk as advertised. Still no succcess. Any ideas what could go wrong ? Thank you -mab -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080305/73770f97/attachment.htm From teekaysoh at gmail.com Thu Mar 6 06:04:18 2008 From: teekaysoh at gmail.com (TK Soh) Date: Thu, 6 Mar 2008 05:04:18 +0000 Subject: [python-win32] shelve data corruption Message-ID: <58b84f8e0803052104w7f230a4cg6392a7aec13bf8ce@mail.gmail.com> I ran into strange problem with my program that uses the shelve module to maintain program settings, which later turned out to be caused by the corrupted shelve data. It looks like the shelve module itself is not capable of detecting the data corruption. I wonder if there's anything we can do to address this issue. Thanks. From cappy2112 at gmail.com Thu Mar 6 08:21:47 2008 From: cappy2112 at gmail.com (Tony Cappellini) Date: Wed, 5 Mar 2008 23:21:47 -0800 Subject: [python-win32] Iron Python and Visual Basic 2005 (or 2008) Express Message-ID: <8249c4ac0803052321v305dab1eu4d2343bd8fee2e4d@mail.gmail.com> Here's what's left of the marriage of Python & Delphi http://www.atug.com/andypatterns/pythonDelphiTalk.htm http://mmm-experts.com/Products.aspx?ProductId=3 Note- this was around for many years- so may not be compatible with current versions of Delphi. I think I first read about this around Delphi 4&5 days, but i'm not sure. There was some attempt to get C++ Builder working with Python, but it wasn't as successful ;( (we really need Borland-like RAD (wysiwig) IDE for Python.I'd gladly pay what Delphi costs for one.) From mail at timgolden.me.uk Thu Mar 6 10:00:48 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 06 Mar 2008 09:00:48 +0000 Subject: [python-win32] Iron Python and Visual Basic 2005 (or 2008) Express In-Reply-To: <8249c4ac0803052321v305dab1eu4d2343bd8fee2e4d@mail.gmail.com> References: <8249c4ac0803052321v305dab1eu4d2343bd8fee2e4d@mail.gmail.com> Message-ID: <47CFB2C0.4060204@timgolden.me.uk> Tony Cappellini wrote: > Here's what's left of the marriage of Python & Delphi > http://www.atug.com/andypatterns/pythonDelphiTalk.htm > http://mmm-experts.com/Products.aspx?ProductId=3 > > Note- this was around for many years- so may not be compatible with > current versions of Delphi. > I think I first read about this around Delphi 4&5 days, but i'm not sure. > > There was some attempt to get C++ Builder working with Python, but it > wasn't as successful ;( > (we really need Borland-like RAD (wysiwig) IDE for Python.I'd gladly > pay what Delphi costs for one.) As far as I know, PyScripter [1] is written in Delphi so the guys there presumably have some sort of marriage arrangement! TJG http://mmm-experts.com/Products.aspx?ProductId=4 From Mark.English at rbccm.com Thu Mar 6 10:16:34 2008 From: Mark.English at rbccm.com (English, Mark) Date: Thu, 6 Mar 2008 09:16:34 -0000 Subject: [python-win32] Iron Python and Visual Basic 2005 (or2008) Express In-Reply-To: <47CFB2C0.4060204@timgolden.me.uk> References: <8249c4ac0803052321v305dab1eu4d2343bd8fee2e4d@mail.gmail.com> <47CFB2C0.4060204@timgolden.me.uk> Message-ID: > Tim Golden wrote: > As far as I know, PyScripter [1] is written in Delphi so the > guys there presumably have some sort of marriage arrangement! > > http://mmm-experts.com/Products.aspx?ProductId=4 Date since last version may suggest they're drifting apart. Version 1.7.2: Oct 26, 2006 http://mmm-experts.com/VersionHistory.aspx?ProductId=4 ________________________________________ This E-Mail (including any attachments) may contain privileged or confidential information. It is intended only for the addressee(s) indicated above. The sender does not waive any of its rights, privileges or other protections respecting this information. Any distribution, copying or other use of this E-Mail or the information it contains, by other than an intended recipient, is not sanctioned and is prohibited. If you received this E-Mail in error, please delete it and advise the sender (by return E-Mail or otherwise) immediately. This E-Mail (including any attachments) has been scanned for viruses. It is believed to be free of any virus or other defect that might affect any computer system into which it is received and opened. However, it is the responsibility of the recipient to ensure that it is virus free. The sender accepts no responsibility for any loss or damage arising in any way from its use. E-Mail received by or sent from RBC Capital Markets is subject to review by Supervisory personnel. Such communications are retained and may be produced to regulatory authorities or others with legal rights to the information. IRS CIRCULAR 230 NOTICE: TO COMPLY WITH U.S. TREASURY REGULATIONS, WE ADVISE YOU THAT ANY U.S. FEDERAL TAX ADVISE INCLUDED IN THIS COMMUNICATION IS NOT INTENDED OR WRITTEN TO BE USED, AND CANNOT BE USED, TO AVOID ANY U.S. FEDERAL TAX PENALTIES OR TO PROMOTE, MARKET, OR RECOMMEND TO ANOTHER PARTY ANY TRANSACTION OR MATTER. From mail at timgolden.me.uk Thu Mar 6 10:35:33 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 06 Mar 2008 09:35:33 +0000 Subject: [python-win32] Iron Python and Visual Basic 2005 (or2008) Express In-Reply-To: References: <8249c4ac0803052321v305dab1eu4d2343bd8fee2e4d@mail.gmail.com> <47CFB2C0.4060204@timgolden.me.uk> Message-ID: <47CFBAE5.3040208@timgolden.me.uk> English, Mark wrote: >> Tim Golden wrote: >> As far as I know, PyScripter [1] is written in Delphi so the >> guys there presumably have some sort of marriage arrangement! >> >> http://mmm-experts.com/Products.aspx?ProductId=4 > > Date since last version may suggest they're drifting apart. > > Version 1.7.2: Oct 26, 2006 > http://mmm-experts.com/VersionHistory.aspx?ProductId=4 Well, at the least they seem to have a slightly split personality! http://pyscripter.googlepages.com/ TJG From caxelrud at pav.com Thu Mar 6 14:06:33 2008 From: caxelrud at pav.com (caxelrud) Date: Thu, 6 Mar 2008 05:06:33 -0800 (PST) Subject: [python-win32] Windows Vista slow down Python xmlrpc Message-ID: <15872996.post@talk.nabble.com> I tried the following simple code for client-server comunication with xmlrpc in Wiindows XP and Windows Vista (Python 2.5(r25:51908)). The Vista hardware was classified as 2x faster then the other. I got the following results: Vista: 10.1 sec XP: 0.12 sec The XP was about 100 times faster ! Does anybody now how to seepup the Vista execution? Server.py file: ----------------------------------------------------------------- import SimpleXMLRPCServer import math def add(x,y): "Add two numbers" return x+y s=SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost",8080)) s.register_function(add) s.register_instance(math) s.register_introspection_functions() s.serve_forever() ----------------------------------------------------------------- Client.py file: ----------------------------------------------------------------- import xmlrpclib import time s=xmlrpclib.ServerProxy("http://localhost:8080") tinit=time.time() for i,j in zip(xrange(10),xrange(10,20)): print s.add(i,j) tend=time.time() dtime=tend-tinit print "dtime:",dtime raw_input("Enter") ----------------------------------------------------------------- -- View this message in context: http://www.nabble.com/Windows-Vista-slow-down-Python-xmlrpc-tp15872996p15872996.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From mc at mclaveau.com Thu Mar 6 14:31:07 2008 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 6 Mar 2008 14:31:07 +0100 Subject: [python-win32] Windows Vista slow down Python xmlrpc In-Reply-To: <15872996.post@talk.nabble.com> References: <15872996.post@talk.nabble.com> Message-ID: <844A87ED48634E5FAAD19460F40F8CC8@MCI1330> Hi! +1 ; for me: - Vista: 10.55 sec - XP: 0.16 sec @-salutations -- Michel Claveau From mbelzile at softimage.com Thu Mar 6 16:36:55 2008 From: mbelzile at softimage.com (=?iso-8859-1?Q?Marc-Andr=E9_Belzile?=) Date: Thu, 6 Mar 2008 10:36:55 -0500 Subject: [python-win32] Building pywin32 on Vista 64 In-Reply-To: <0BCB4AE868D8934A8B3DCE3A58126A8901B976E7@tewk-mbpf3> Message-ID: <0BCB4AE868D8934A8B3DCE3A58126A89D3AAFC@tewk-mbpf3> Looks like MSVCCompiler hasn't been fixed yet to support AMD64 architectures. __root is referenced by get_msvc_paths but wasn't set in __init__. Known bug ? My current settings: self.__product -> Microsoft SDK compiler 14.0 self.__version -> 8.0 self.__arch -> AMD64 class MSVCCompiler (CCompiler) : ... def __init__ (self, verbose=0, dry_run=0, force=0): CCompiler.__init__ (self, verbose, dry_run, force) self.__version = get_build_version() self.__arch = get_build_architecture() if self.__arch == "Intel": # x86 if self.__version >= 7: self.__root = r"Software\Microsoft\VisualStudio" self.__macros = MacroExpander(self.__version) else: self.__root = r"Software\Microsoft\Devstudio" self.__product = "Visual Studio version %s" % self.__version else: # Win64. Assume this was built with the platform SDK self.__product = "Microsoft SDK compiler %s" % (self.__version + 6) def get_msvc_paths(self, path, platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings. The list will be empty if unable to access the registry or appropriate registry keys not found. """ if not _can_read_reg: return [] path = path + " dirs" if self.__version >= 7: key = (r"%s\%0.1f\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories" % (self.__root, self.__version)) << line 616 ________________________________ From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Marc-Andr? Belzile Sent: March 5, 2008 6:42 PM To: python-win32 at python.org Subject: [python-win32] Building pywin32 on Vista 64 Hello, I'm trying to build pywin32 (2.5.210.0) on Vista 64 (AMD64) with VS 2005. I'm stucked right at the beginning of the process with this error : File "C:\Python25\lib\distutils\msvccompiler.py", line 616, in get_msvc_paths % (self.__root, self.__version)) AttributeError: my_compiler instance has no attribute '_MSVCCompiler__root' I did install the windows server 2003 platform SDK (AMD64) and set both DISTUTILS_USE_SDK + MSSdk as advertised. Still no succcess. Any ideas what could go wrong ? Thank you -mab -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080306/d577f220/attachment.htm From cappy2112 at gmail.com Thu Mar 6 17:20:45 2008 From: cappy2112 at gmail.com (Tony Cappellini) Date: Thu, 6 Mar 2008 08:20:45 -0800 Subject: [python-win32] Iron Python and Visual Basic 2005 (or 2008) Express Message-ID: <8249c4ac0803060820r59ea2510xab7a073ce7b6f805@mail.gmail.com> Message: 9 Date: Thu, 06 Mar 2008 09:00:48 +0000 From: Tim Golden Subject: Re: [python-win32] Iron Python and Visual Basic 2005 (or 2008) Express Cc: python-win32 at python.org Message-ID: <47CFB2C0.4060204 at timgolden.me.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed >>As far as I know, PyScripter [1] is written in Delphi so the >>guys there presumably have some sort of marriage arrangement! This looks like "just another IDE". The fact that it was written in Delphi doesn't make it better. It is lacking what most Python IDE's are lacking ; "A Delphi-quaility" RAD environment for building a UI. QT Designer is the probably the one which is the closest, but is still far from being Delphi-like, and the installation/compilation for the QT framework is complicated. As far as non-RAD IDE's for Python, Wing IDE is the front runner, and not that expensive. The Eric4 IDE is free, but again requires installing/compiling QT4, and QT designer is it's GUI design tool. From mail at timgolden.me.uk Thu Mar 6 17:24:54 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 06 Mar 2008 16:24:54 +0000 Subject: [python-win32] Iron Python and Visual Basic 2005 (or 2008) Express In-Reply-To: <8249c4ac0803060820r59ea2510xab7a073ce7b6f805@mail.gmail.com> References: <8249c4ac0803060820r59ea2510xab7a073ce7b6f805@mail.gmail.com> Message-ID: <47D01AD6.3010707@timgolden.me.uk> Tony Cappellini wrote: > Message: 9 > Date: Thu, 06 Mar 2008 09:00:48 +0000 > From: Tim Golden > Subject: Re: [python-win32] Iron Python and Visual Basic 2005 (or > 2008) Express > Cc: python-win32 at python.org > Message-ID: <47CFB2C0.4060204 at timgolden.me.uk> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > >>> As far as I know, PyScripter [1] is written in Delphi so the >>> guys there presumably have some sort of marriage arrangement! > > This looks like "just another IDE". The fact that it was written in > Delphi doesn't make it better. > It is lacking what most Python IDE's are lacking ; "A Delphi-quaility" > RAD environment for building a UI. > QT Designer is the probably the one which is the closest, but is still > far from being Delphi-like, and the installation/compilation for the > QT framework is complicated. > > As far as non-RAD IDE's for Python, Wing IDE is the front runner, and > not that expensive. > The Eric4 IDE is free, but again requires installing/compiling QT4, > and QT designer is it's GUI design tool. Sorry; I wasn't really paying attention to the thread at all :( I simply reacted to someone's suggestion that any Python-Delphi relationship was moribund. No particular comment on PyScripter qua IDE: I've used it but never found it The Right Thing for me. TJG From timr at probo.com Thu Mar 6 19:19:50 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 06 Mar 2008 10:19:50 -0800 Subject: [python-win32] Windows Vista slow down Python xmlrpc In-Reply-To: <15872996.post@talk.nabble.com> References: <15872996.post@talk.nabble.com> Message-ID: <47D035C6.6070906@probo.com> caxelrud wrote: > I tried the following simple code for client-server comunication with xmlrpc > in Wiindows XP and Windows Vista (Python 2.5(r25:51908)). The Vista hardware > was classified as 2x faster then the other. > I got the following results: > Vista: 10.1 sec > XP: 0.12 sec > > The XP was about 100 times faster ! > > Does anybody now how to seepup the Vista execution? > Yes: upgrade to Windows XP. ;) Vista Service Pack 1, which is now available on MSDN and should be available for retail purchase soon, is supposed to clean up many of the very ugly performance issues in Vista. I'll believe it when I see it. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Thu Mar 6 19:23:58 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 06 Mar 2008 10:23:58 -0800 Subject: [python-win32] shelve data corruption In-Reply-To: <58b84f8e0803052104w7f230a4cg6392a7aec13bf8ce@mail.gmail.com> References: <58b84f8e0803052104w7f230a4cg6392a7aec13bf8ce@mail.gmail.com> Message-ID: <47D036BE.2000003@probo.com> TK Soh wrote: > I ran into strange problem with my program that uses the shelve module > to maintain program settings, which later turned out to be caused by > the corrupted shelve data. It looks like the shelve module itself is > not capable of detecting the data corruption. I wonder if there's > anything we can do to address this issue. What would you have it do? If data integrity is critical for you, you could run a checksum or an MD5 digest of the shelve data and store that with the data. That way, you can at least tell whether the shelve was compromised. How was the shelve damaged? Are humans trying to edit the data by hand? If so, perhaps you should write it in a more human-readable format. For example, you can "pprint" a dictionary, and then restore it with "eval" (assuming you are prepared for security issues). Or, you could use XML to save your settings. Or, you could create your own format. I often use the Windows .INI style, because it is simple to create and simple to parse: [GlobalSettings] DebugLevel = 6 DebugPrefix = "MyApplication" [UserSettings] Color = 0xffddee etc. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From p.f.moore at gmail.com Thu Mar 6 20:31:59 2008 From: p.f.moore at gmail.com (Paul Moore) Date: Thu, 6 Mar 2008 19:31:59 +0000 Subject: [python-win32] Windows Vista slow down Python xmlrpc In-Reply-To: <47D035C6.6070906@probo.com> References: <15872996.post@talk.nabble.com> <47D035C6.6070906@probo.com> Message-ID: <79990c6b0803061131x49831c65ra5d97abef4a83191@mail.gmail.com> On 06/03/2008, Tim Roberts wrote: > caxelrud wrote: > > The XP was about 100 times faster ! > > > > Does anybody now how to seepup the Vista execution? > > Yes: upgrade to Windows XP. ;) Is it also possible that Vista has some form of firewall enabled by default, that is not on XP? If so, disabling that may help. (Disclaimer: I've not used Vista, I'm just going off the various postings around, which seem to imply that Vista takes a much harder line on the "secure by default" approach - so having a firewall on by default seems plausible). Paul. From mc at mclaveau.com Thu Mar 6 21:12:59 2008 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 6 Mar 2008 21:12:59 +0100 Subject: [python-win32] Windows Vista slow down Python xmlrpc In-Reply-To: <15872996.post@talk.nabble.com> References: <15872996.post@talk.nabble.com> Message-ID: Hi! If you replace localhost by 127.0.0.1, Vista become fast... e.g. : s=xmlrpclib.ServerProxy("http://127.0.0.1:8080") I think that it's a name resolution problem... @-salutations -- Michel Claveau From mdriscoll at co.marshall.ia.us Thu Mar 6 21:21:42 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Thu, 6 Mar 2008 14:21:42 -0600 (CST) Subject: [python-win32] Windows Vista slow down Python xmlrpc In-Reply-To: References: Message-ID: <002401c87fc7$9d3cb500$96c051d8@mcis0492> Paul, > Message: 8 > Date: Thu, 6 Mar 2008 19:31:59 +0000 > From: "Paul Moore" > Subject: Re: [python-win32] Windows Vista slow down Python xmlrpc > To: "Tim Roberts" > Cc: Python-Win32 List > Message-ID: > <79990c6b0803061131x49831c65ra5d97abef4a83191 at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > On 06/03/2008, Tim Roberts wrote: > > caxelrud wrote: > > > The XP was about 100 times faster ! > > > > > > Does anybody now how to seepup the Vista execution? > > > > Yes: upgrade to Windows XP. ;) > > Is it also possible that Vista has some form of firewall enabled by > default, that is not on XP? If so, disabling that may help. > > (Disclaimer: I've not used Vista, I'm just going off the various > postings around, which seem to imply that Vista takes a much harder > line on the "secure by default" approach - so having a firewall on by > default seems plausible). > > Paul. > > I've been watching the whole Vista debate and this guy at zdnet did some testing with Vista's SP1 vs. XP SP2. The results are that XP is just plain faster in most cases. You can check it out here: http://blogs.zdnet.com/hardware/?p=1332 http://blogs.zdnet.com/hardware/?p=1338 I have only used Vista when working on a client's PC or to uninstall it to be replaced with its predecessor. From what I've seen personally, I also think it's slower in general. Mike From mc at mclaveau.com Thu Mar 6 21:50:58 2008 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 6 Mar 2008 21:50:58 +0100 Subject: [python-win32] Windows Vista slow down Python xmlrpc In-Reply-To: References: <15872996.post@talk.nabble.com> Message-ID: Re! In the same direction, I had: - reduce the size of HOSTS (delete all SpyBot Search & Destroy entries) - set all rights on HOSTS - in my antivirus (Avast-Pro), set HOSTS like an exception (no resident scan on him) - use http://127.0.0.1:8080 (for the client, needless for server) - use my "miracle" batch, for optimize network : netsh interface tcp set global autotuninglevel=disabled netsh interface tcp set global rss=disabled netsh interface tcp set global congestionprovider=none netsh interface tcp set global ecncapability=disabled Results: my Vista become twice faster than my XP... @-salutations Michel Claveau From mhammond at skippinet.com.au Thu Mar 6 23:21:13 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 7 Mar 2008 09:21:13 +1100 Subject: [python-win32] Building pywin32 on Vista 64 In-Reply-To: <0BCB4AE868D8934A8B3DCE3A58126A89D3AAFC@tewk-mbpf3> References: <0BCB4AE868D8934A8B3DCE3A58126A8901B976E7@tewk-mbpf3> <0BCB4AE868D8934A8B3DCE3A58126A89D3AAFC@tewk-mbpf3> Message-ID: <0b1101c87fd8$660d72c0$32285840$@com.au> It looks like a bug to me ? but for some reason I don?t hit it. Last I checked, the x64 version of pywin32 builds fine following the instructions at the top of setup.py (but last I tried, it was cross-compiling from a 32bit environment) Mark From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Marc-Andr? Belzile Sent: Friday, 7 March 2008 2:37 AM To: python-win32 at python.org Subject: Re: [python-win32] Building pywin32 on Vista 64 Looks like MSVCCompiler hasn't been fixed yet to support AMD64 architectures. __root is referenced by get_msvc_paths but wasn't set in __init__. Known bug ? My current settings: self.__product -> Microsoft SDK compiler 14.0 self.__version -> 8.0 self.__arch -> AMD64 class MSVCCompiler (CCompiler) : ... def __init__ (self, verbose=0, dry_run=0, force=0): CCompiler.__init__ (self, verbose, dry_run, force) self.__version = get_build_version() self.__arch = get_build_architecture() if self.__arch == "Intel": # x86 if self.__version >= 7: self.__root = r"Software\Microsoft\VisualStudio" self.__macros = MacroExpander(self.__version) else: self.__root = r"Software\Microsoft\Devstudio" self.__product = "Visual Studio version %s" % self.__version else: # Win64. Assume this was built with the platform SDK self.__product = "Microsoft SDK compiler %s" % (self.__version + 6) def get_msvc_paths(self, path, platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings. The list will be empty if unable to access the registry or appropriate registry keys not found. """ if not _can_read_reg: return [] path = path + " dirs" if self.__version >= 7: key = (r"%s\%0.1f\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories" % (self.__root, self.__version)) << line 616 _____ From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Marc-Andr? Belzile Sent: March 5, 2008 6:42 PM To: python-win32 at python.org Subject: [python-win32] Building pywin32 on Vista 64 Hello, I'm trying to build pywin32 (2.5.210.0) on Vista 64 (AMD64) with VS 2005. I'm stucked right at the beginning of the process with this error : File "C:\Python25\lib\distutils\msvccompiler.py", line 616, in get_msvc_paths % (self.__root, self.__version)) AttributeError: my_compiler instance has no attribute '_MSVCCompiler__root' I did install the windows server 2003 platform SDK (AMD64) and set both DISTUTILS_USE_SDK + MSSdk as advertised. Still no succcess. Any ideas what could go wrong ? Thank you -mab -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080307/5d956724/attachment.htm From mc at mclaveau.com Thu Mar 6 23:49:39 2008 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 6 Mar 2008 23:49:39 +0100 Subject: [python-win32] Building pywin32 on Vista 64 In-Reply-To: <0b1101c87fd8$660d72c0$32285840$@com.au> References: <0BCB4AE868D8934A8B3DCE3A58126A8901B976E7@tewk-mbpf3><0BCB4AE868D8934A8B3DCE3A58126A89D3AAFC@tewk-mbpf3> <0b1101c87fd8$660d72c0$32285840$@com.au> Message-ID: <83165A7953DE47499DE98DF8A3F51A06@MCI1330> Hi! Not the good subject, but... I had try Pywin32 "standard" in Windows-2008-server-64bits. Results : no problem! - install: OK - tests: OK (my softs: COM-server ; manage IE7(via COM) ; PLUIE (Python+JScript in IE like GUI) ; etc. Some entries of the register are differents. But non really important. @-salutations Michel Claveau From leegold at fastmail.fm Fri Mar 7 06:59:54 2008 From: leegold at fastmail.fm (leegold) Date: Fri, 07 Mar 2008 00:59:54 -0500 Subject: [python-win32] Blob fields Message-ID: <1204869594.24373.1241059775@webmail.messagingengine.com> Hi, I want to play with blobs in ms-access. Is there any documentation or python examples using ADO for AppendChunk and GetChunk? Would that be the best way to do it - w/ADO? Googling it but so far not much I can find. Thanks, Lee G. From le.dahut at laposte.net Fri Mar 7 14:37:10 2008 From: le.dahut at laposte.net (le dahut) Date: Fri, 07 Mar 2008 14:37:10 +0100 Subject: [python-win32] get python install dir Message-ID: <47D14506.5030600@laposte.net> Hello, How can I get python's installation directory ? From mail at timgolden.me.uk Fri Mar 7 15:05:05 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 07 Mar 2008 14:05:05 +0000 Subject: [python-win32] get python install dir In-Reply-To: <47D14506.5030600@laposte.net> References: <47D14506.5030600@laposte.net> Message-ID: <47D14B91.1000302@timgolden.me.uk> le dahut wrote: > Hello, > How can I get python's installation directory ? import sys print sys.prefix TJG From mbelzile at softimage.com Fri Mar 7 15:43:10 2008 From: mbelzile at softimage.com (=?iso-8859-1?Q?Marc-Andr=E9_Belzile?=) Date: Fri, 7 Mar 2008 09:43:10 -0500 Subject: [python-win32] Building pywin32 on Vista 64 In-Reply-To: <0b1101c87fd8$660d72c0$32285840$@com.au> Message-ID: <0BCB4AE868D8934A8B3DCE3A58126A89D3AB06@tewk-mbpf3> Are there any directives regarding x64 version in setup.py ? I can't find them. I downloaded pywin32-210.zip and the setup.py file is dated from 23/09/2006. Is there a newer version ? thanks -mab ________________________________ From: Mark Hammond [mailto:mhammond at skippinet.com.au] Sent: March 6, 2008 5:21 PM To: Marc-Andr? Belzile; python-win32 at python.org Subject: RE: [python-win32] Building pywin32 on Vista 64 It looks like a bug to me - but for some reason I don't hit it. Last I checked, the x64 version of pywin32 builds fine following the instructions at the top of setup.py (but last I tried, it was cross-compiling from a 32bit environment) Mark From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Marc-Andr? Belzile Sent: Friday, 7 March 2008 2:37 AM To: python-win32 at python.org Subject: Re: [python-win32] Building pywin32 on Vista 64 Looks like MSVCCompiler hasn't been fixed yet to support AMD64 architectures. __root is referenced by get_msvc_paths but wasn't set in __init__. Known bug ? My current settings: self.__product -> Microsoft SDK compiler 14.0 self.__version -> 8.0 self.__arch -> AMD64 class MSVCCompiler (CCompiler) : ... def __init__ (self, verbose=0, dry_run=0, force=0): CCompiler.__init__ (self, verbose, dry_run, force) self.__version = get_build_version() self.__arch = get_build_architecture() if self.__arch == "Intel": # x86 if self.__version >= 7: self.__root = r"Software\Microsoft\VisualStudio" self.__macros = MacroExpander(self.__version) else: self.__root = r"Software\Microsoft\Devstudio" self.__product = "Visual Studio version %s" % self.__version else: # Win64. Assume this was built with the platform SDK self.__product = "Microsoft SDK compiler %s" % (self.__version + 6) def get_msvc_paths(self, path, platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings. The list will be empty if unable to access the registry or appropriate registry keys not found. """ if not _can_read_reg: return [] path = path + " dirs" if self.__version >= 7: key = (r"%s\%0.1f\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories" % (self.__root, self.__version)) << line 616 ________________________________ From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Marc-Andr? Belzile Sent: March 5, 2008 6:42 PM To: python-win32 at python.org Subject: [python-win32] Building pywin32 on Vista 64 Hello, I'm trying to build pywin32 (2.5.210.0) on Vista 64 (AMD64) with VS 2005. I'm stucked right at the beginning of the process with this error : File "C:\Python25\lib\distutils\msvccompiler.py", line 616, in get_msvc_paths % (self.__root, self.__version)) AttributeError: my_compiler instance has no attribute '_MSVCCompiler__root' I did install the windows server 2003 platform SDK (AMD64) and set both DISTUTILS_USE_SDK + MSSdk as advertised. Still no succcess. Any ideas what could go wrong ? Thank you -mab -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080307/67c9aa4e/attachment.htm From caxelrud at pav.com Fri Mar 7 16:11:30 2008 From: caxelrud at pav.com (caxelrud) Date: Fri, 7 Mar 2008 07:11:30 -0800 (PST) Subject: [python-win32] Windows Vista slow down Python xmlrpc In-Reply-To: References: <15872996.post@talk.nabble.com> Message-ID: <15894528.post@talk.nabble.com> Hi, I changed "localhost" to "127.0.0.1" and worked as fast as the XP. Thanks, Michel Claveau wrote: > > Hi! > > > If you replace localhost by 127.0.0.1, Vista become fast... > > e.g. : s=xmlrpclib.ServerProxy("http://127.0.0.1:8080") > > I think that it's a name resolution problem... > > > @-salutations > -- > Michel Claveau > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -- View this message in context: http://www.nabble.com/Windows-Vista-slow-down-Python-xmlrpc-tp15872996p15894528.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From mc at mclaveau.com Fri Mar 7 17:13:56 2008 From: mc at mclaveau.com (Michel Claveau) Date: Fri, 7 Mar 2008 17:13:56 +0100 Subject: [python-win32] Windows Vista slow down Python xmlrpc In-Reply-To: <15894528.post@talk.nabble.com> References: <15872996.post@talk.nabble.com> <15894528.post@talk.nabble.com> Message-ID: <024FB529EB7549DBBB7DF11C667B1F51@MCI1330> Thanks for the return. Another thing: do you have sun in NL? ;-) Michel Claveau ; Ard?che ; France. From mbelzile at softimage.com Fri Mar 7 17:34:15 2008 From: mbelzile at softimage.com (=?iso-8859-1?Q?Marc-Andr=E9_Belzile?=) Date: Fri, 7 Mar 2008 11:34:15 -0500 Subject: [python-win32] Building pywin32 on Vista 64 In-Reply-To: <83165A7953DE47499DE98DF8A3F51A06@MCI1330> Message-ID: <0BCB4AE868D8934A8B3DCE3A58126A89D3AB0B@tewk-mbpf3> Hello, I tried installing pywin3-210 on vista-64 but got this installation error: 'Can't load Python for pre-install script'. -mab -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Michel Claveau Sent: March 6, 2008 5:50 PM To: python-win32 at python.org Subject: Re: [python-win32] Building pywin32 on Vista 64 Hi! Not the good subject, but... I had try Pywin32 "standard" in Windows-2008-server-64bits. Results : no problem! - install: OK - tests: OK (my softs: COM-server ; manage IE7(via COM) ; PLUIE (Python+JScript in IE like GUI) ; etc. Some entries of the register are differents. But non really important. @-salutations Michel Claveau _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From commercials at gmx.net Fri Mar 7 21:44:36 2008 From: commercials at gmx.net (Julius) Date: Fri, 07 Mar 2008 21:44:36 +0100 Subject: [python-win32] Monitor directories/files Message-ID: <1204922676.31247.22.camel@bohlsen> Hi, how do you monitor files/directories on windows systems with python? gamin in linux is really nice, but i wasnt able to find something that works on windows systems. greets From adam at volition-inc.com Fri Mar 7 21:45:00 2008 From: adam at volition-inc.com (Adam Pletcher) Date: Fri, 7 Mar 2008 14:45:00 -0600 Subject: [python-win32] Monitor directories/files In-Reply-To: <1204922676.31247.22.camel@bohlsen> References: <1204922676.31247.22.camel@bohlsen> Message-ID: <893A44FF792E904A97B7515CE3419146026E32F6@volimxs01.thqinc.com> I recently found this helpful: http://tgolden.sc.sabren.com/python/win32_how_do_i/watch_directory_for_c hanges.html - Adam > -----Original Message----- > From: python-win32-bounces+adam=volition-inc.com at python.org > [mailto:python-win32-bounces+adam=volition-inc.com at python.org] On > Behalf Of Julius > Sent: Friday, March 07, 2008 2:45 PM > To: python-win32 at python.org > Subject: [python-win32] Monitor directories/files > > Hi, > > how do you monitor files/directories on windows systems with python? > gamin in linux is really nice, but i wasnt able to find something that > works on windows systems. > > greets > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From mail at timgolden.me.uk Fri Mar 7 21:59:15 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 07 Mar 2008 20:59:15 +0000 Subject: [python-win32] Monitor directories/files In-Reply-To: <1204922676.31247.22.camel@bohlsen> References: <1204922676.31247.22.camel@bohlsen> Message-ID: <47D1ACA3.8020009@timgolden.me.uk> Julius wrote: > how do you monitor files/directories on windows systems with python? > gamin in linux is really nice, but i wasnt able to find something that > works on windows systems. http://timgolden.me.uk/python/win32_how_do_i/watch_directory_for_changes.html TJG From mc at mclaveau.com Fri Mar 7 21:59:12 2008 From: mc at mclaveau.com (Michel Claveau) Date: Fri, 7 Mar 2008 21:59:12 +0100 Subject: [python-win32] Building pywin32 on Vista 64 In-Reply-To: <0BCB4AE868D8934A8B3DCE3A58126A89D3AB0B@tewk-mbpf3> References: <0BCB4AE868D8934A8B3DCE3A58126A89D3AB0B@tewk-mbpf3> Message-ID: Hi! Bonsoir ! > I tried installing pywin3-210 on vista-64 but got this installation error: > 'Can't load Python for pre-install script'. - is python 2.5 already installed? - avant pywin32, avez-vous bien install? Python 2.5 (pr?alablement) ? Perso, je n'ai pas test? sur Vista-64, mais sous Windows-Serveur-2008-64bits (mais, auparavant, sous Vista, XP, 2000, 2003, etc.) Je n'ai eu aucun probl?me. Mais, j'ai fait ?a en Administrateur, avec l'UAC (contr?le des comptes utilisateurs) d?sactiv?, et le parefeu d?sactiv?. @-salutations -- Michel Claveau From whatyoulookin at yahoo.com Fri Mar 7 21:53:47 2008 From: whatyoulookin at yahoo.com (Alec Bennett) Date: Fri, 7 Mar 2008 12:53:47 -0800 (PST) Subject: [python-win32] possible to save the output of TTS to a WAV file? Message-ID: <510884.87918.qm@web54604.mail.re2.yahoo.com> I'm trying to save the output of some TTS to a sound file, is this possible? Here's how I'm doing the TTS, though am certainly open to other methods: import pythoncom, win32com import win32api, win32com.client pythoncom.CoInitialize () s = win32com.client.Dispatch("SAPI.SpVoice") s.Speak("hi there") Thanks for any help. ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs From timr at probo.com Fri Mar 7 22:02:19 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 07 Mar 2008 13:02:19 -0800 Subject: [python-win32] Monitor directories/files In-Reply-To: <1204922676.31247.22.camel@bohlsen> References: <1204922676.31247.22.camel@bohlsen> Message-ID: <47D1AD5B.4000504@probo.com> Julius wrote: > Hi, > > how do you monitor files/directories on windows systems with python? > gamin in linux is really nice, but i wasnt able to find something that > works on windows systems. > As with many such questions, the all-knowing Tim Golden has an answer for you: http://tgolden.sc.sabren.com/python/win32_how_do_i/watch_directory_for_changes.html -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From theller at ctypes.org Fri Mar 7 22:11:26 2008 From: theller at ctypes.org (Thomas Heller) Date: Fri, 07 Mar 2008 22:11:26 +0100 Subject: [python-win32] possible to save the output of TTS to a WAV file? In-Reply-To: <510884.87918.qm@web54604.mail.re2.yahoo.com> References: <510884.87918.qm@web54604.mail.re2.yahoo.com> Message-ID: Alec Bennett schrieb: > I'm trying to save the output of some TTS to a sound file, is this possible? > > Here's how I'm doing the TTS, though am certainly open to other methods: > > import pythoncom, win32com > import win32api, win32com.client > pythoncom.CoInitialize () > > s = win32com.client.Dispatch("SAPI.SpVoice") > s.Speak("hi there") > > Thanks for any help. In comtypes, this code does 'speak to a file': engine = CreateObject("SAPI.SpVoice") stream = CreateObject("SAPI.SpFileStream") from comtypes.gen import SpeechLib stream.Open(fname, SpeechLib.SSFMCreateForWrite) engine.AudioOutputStream = stream engine.speak("Hello, World", 0) stream.Close() Should be trivial to convert it to pywin32. Thomas From mc at mclaveau.com Fri Mar 7 22:19:53 2008 From: mc at mclaveau.com (Michel Claveau) Date: Fri, 7 Mar 2008 22:19:53 +0100 Subject: [python-win32] possible to save the output of TTS to a WAV file? In-Reply-To: <510884.87918.qm@web54604.mail.re2.yahoo.com> References: <510884.87918.qm@web54604.mail.re2.yahoo.com> Message-ID: <9CF1690E0DF04250B00D70C4C55A8741@MCI1330> Hi ! > I'm trying to save the output of some TTS to a sound file, is this > possible? Yes, it's possible. I had done that (save MS-agent's blah-blah), under XP, with Python. But, sorry, I completely forgot how I had proceeded... I remember only that I had used MCI. @-salutations -- Michel Claveau From mail at timgolden.me.uk Fri Mar 7 22:21:45 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 07 Mar 2008 21:21:45 +0000 Subject: [python-win32] possible to save the output of TTS to a WAV file? In-Reply-To: <510884.87918.qm@web54604.mail.re2.yahoo.com> References: <510884.87918.qm@web54604.mail.re2.yahoo.com> Message-ID: <47D1B1E9.8020809@timgolden.me.uk> Alec Bennett wrote: > I'm trying to save the output of some TTS to a sound file, is this possible? > > Here's how I'm doing the TTS, though am certainly open to other methods: > > import pythoncom, win32com > import win32api, win32com.client > pythoncom.CoInitialize () > > s = win32com.client.Dispatch("SAPI.SpVoice") > s.Speak("hi there") You definitely want the pyTTS module [1][2] for this -- which wraps the SAPI stuff at C level. import pyTTS speaker = pyTTS.Create () speaker.SpeakToWave ("c:/temp/hello.wav", "hello") TJG [1] http://www.cs.unc.edu/Research/assist/doc/pytts/ [2] http://sourceforge.net/project/showfiles.php?group_id=65529&package_id=74248 From mbelzile at softimage.com Fri Mar 7 22:46:41 2008 From: mbelzile at softimage.com (=?iso-8859-1?Q?Marc-Andr=E9_Belzile?=) Date: Fri, 7 Mar 2008 16:46:41 -0500 Subject: [python-win32] Building pywin32 on Vista 64 In-Reply-To: Message-ID: <0BCB4AE868D8934A8B3DCE3A58126A89D3AB12@tewk-mbpf3> Salut, Oui, python 2.5 (AMD64) est install? et fonctionne tr?s bien. I've installed Python 2.5 (x86) and pywin32 (build 2.5.210.0) and everything works. However, I want to use the python 2.5 and pywin32 64 bit version. -mab -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Michel Claveau Sent: March 7, 2008 3:59 PM To: python-win32 at python.org Subject: Re: [python-win32] Building pywin32 on Vista 64 Hi! Bonsoir ! > I tried installing pywin3-210 on vista-64 but got this installation error: > 'Can't load Python for pre-install script'. - is python 2.5 already installed? - avant pywin32, avez-vous bien install? Python 2.5 (pr?alablement) ? Perso, je n'ai pas test? sur Vista-64, mais sous Windows-Serveur-2008-64bits (mais, auparavant, sous Vista, XP, 2000, 2003, etc.) Je n'ai eu aucun probl?me. Mais, j'ai fait ?a en Administrateur, avec l'UAC (contr?le des comptes utilisateurs) d?sactiv?, et le parefeu d?sactiv?. @-salutations -- Michel Claveau _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From mdriscoll at co.marshall.ia.us Fri Mar 7 23:07:23 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Fri, 7 Mar 2008 16:07:23 -0600 (CST) Subject: [python-win32] Monitor directories/files In-Reply-To: References: Message-ID: <001001c8809f$7b13f500$96c051d8@mcis0492> Hi Julius, > > Message: 7 > Date: Fri, 07 Mar 2008 21:44:36 +0100 > From: Julius > Subject: [python-win32] Monitor directories/files > To: python-win32 at python.org > Message-ID: <1204922676.31247.22.camel at bohlsen> > Content-Type: text/plain > > Hi, > > how do you monitor files/directories on windows systems with python? > gamin in linux is really nice, but i wasnt able to find something that > works on windows systems. > > greets > I'm sure Tim will jump on this too, but I recommend his site for the answer to this question (and many other win32 questions): http://tgolden.sc.sabren.com/python/win32_how_do_i/watch_directory_for_cha nges.html He lists 3 ways to do it there. Have fun! Mike From python-win32 at raisethehammer.org Sat Mar 8 04:40:35 2008 From: python-win32 at raisethehammer.org (python-win32 at raisethehammer.org) Date: Fri, 07 Mar 2008 19:40:35 -0800 Subject: [python-win32] Response.Flush not working Message-ID: <20080307194035.4qhsln2yhcows8g0@208.179.130.21> Hi All, I searched for this but couldn't find it anywhere: I've just started running Python in Classic ASP, and would like to Response.Flush periodically on a page with a lot of processing behind it. However, it seems to have no effect. I confirmed that Response.Buffer = True. Any suggestions? Regards, Ryan McGreal From Ron at FascinatingElectronics.com Sat Mar 8 06:26:15 2008 From: Ron at FascinatingElectronics.com (Ron Jackson) Date: Fri, 07 Mar 2008 21:26:15 -0800 Subject: [python-win32] win32file.SetupComm Error Using PySerial in new Python 2.5.2 installation on 32 bit XP Message-ID: <47D22377.9050505@FascinatingElectronics.com> I am setting up Python on a newly upgraded computer (AMD 64 X2 dual core) running 32 bit XP home. I installed the following packages: Python 2.5.2 from python-2.5.2.msi PySerial from pyserial-2.2win32.exe Python extensions for windows from pywin32-210.win32-py2.5.exe Running a test of my program (feserial.py) I get the following error: Traceback (most recent call last): File "C:\Python25\Lib\site-packages\feserial.py", line 166, in port_numbers = portList() File "C:\Python25\Lib\site-packages\feserial.py", line 22, in portList s = FEserial(i) File "C:\Python25\Lib\site-packages\serial\serialutil.py", line 156, in __init__ self.open() File "C:\Python25\Lib\site-packages\serial\serialwin32.py", line 57, in open win32file.SetupComm(self.hComPort, 4096, 4096) error: (1, 'SetupComm', 'Incorrect function.') Lines 56-57 in serialwin32.py are: # Setup a 4k buffer win32file.SetupComm(self.hComPort, 4096, 4096) This works just fine on my laptop computer, which was set up some time ago and has a slightly older version of Python. So, why am I getting this error? I don't think PySerial has changed in a long time, but was there some recent change in pywin32? Some change in Python 2.5.2 that would account for this error? Something in the installation that I haven't properly done? Thanks for the help! -- Ron From clintonlee.taylor at gmail.com Sun Mar 9 18:25:56 2008 From: clintonlee.taylor at gmail.com (Clinton Lee Taylor) Date: Sun, 9 Mar 2008 19:25:56 +0200 Subject: [python-win32] OE/WAB help with VB ... Message-ID: Greetings ... I hope I might be able to get some help with a little problem ... I have used the many examples on the net with Outlook, but I'm have problems using python and Outlook Express ... I hear all of the python-win32 mail list groan ... Please hear me out before deleting ... I have found a nice little LGPL library that I hope will make my life and many others easier ... http://www.nektra.com/products/wab/ If I understand the docs, it's an activeX component, with a nice little VB app, but I'm a total noob at both languages and total lost in all com stuff and dll this and some other stuff ... If anybody could look at the VB app and give me a hand at starting a basic python script that just can dump the names from the WAB, it would rally help to have a working example to work from ... Thanks Mailed LeeT From rwupole at msn.com Sun Mar 9 20:01:27 2008 From: rwupole at msn.com (Roger Upole) Date: Sun, 9 Mar 2008 15:01:27 -0400 Subject: [python-win32] Re: OE/WAB help with VB ... Message-ID: Clinton Lee Taylor wrote: > Greetings ... > > I hope I might be able to get some help with a little problem ... > > I have used the many examples on the net with Outlook, but I'm have > problems using python and Outlook Express ... I hear all of the > python-win32 mail list groan ... Please hear me out before deleting > ... > > I have found a nice little LGPL library that I hope will make my life > and many others easier ... http://www.nektra.com/products/wab/ > > If I understand the docs, it's an activeX component, with a nice > little VB app, but I'm a total noob at both languages and total lost > in all com stuff and dll this and some other stuff ... > > If anybody could look at the VB app and give me a hand at starting a > basic python script that just can dump the names from the WAB, it > would rally help to have a working example to work from ... > > Thanks > Mailed > LeeT import win32com.client n=win32com.client.Dispatch('NKTWABLib.NKTWAB') r=n.RootFolder print r.Name print r.Folders.Count for folder_num in range(1, r.Folders.Count+1): f=r.Folders[folder_num] print f.Name, 'Groups:', f.Groups.Count, 'Contacts:', f.Contacts.Count for contact_num in range(1, f.Contacts.Count+1): c=f.Contacts[contact_num] print '\t',c.Email1Address Roger From rwupole at msn.com Sun Mar 9 21:56:46 2008 From: rwupole at msn.com (Roger Upole) Date: Sun, 9 Mar 2008 16:56:46 -0400 Subject: [python-win32] Re: Blob fields Message-ID: > Hi, > > I want to play with blobs in ms-access. Is there any documentation or > python examples using ADO for AppendChunk and GetChunk? Would that be > the best way to do it - w/ADO? Googling it but so far not much I can > find. > > Thanks, > Lee G. This is fairly simple using ADO. import win32com.client dbname='tmp.mdb' c=win32com.client.gencache.EnsureDispatch('adodb.connection',0) c.Open("Driver={Microsoft Access Driver (*.mdb)};Dbq=%s;" %dbname) rs, rc=c.Execute('select tmp1 from tmp') print rs.Fields[0].GetChunk(100) Using AppendChunk on an updateable recordset should be just as simple. Roger From clintonlee.taylor at gmail.com Mon Mar 10 16:45:23 2008 From: clintonlee.taylor at gmail.com (Clinton Lee Taylor) Date: Mon, 10 Mar 2008 17:45:23 +0200 Subject: [python-win32] OE/WAB help with VB ... Message-ID: Greetings ... > > I have found a nice little LGPL library that I hope will make my life > > and many others easier ... http://www.nektra.com/products/wab/ > > > > If I understand the docs, it's an activeX component, with a nice > > little VB app, but I'm a total noob at both languages and total lost > > in all com stuff and dll this and some other stuff ... > > > > If anybody could look at the VB app and give me a hand at starting a > > basic python script that just can dump the names from the WAB, it > > would rally help to have a working example to work from ... Thanks Roger for your quick response ... I hope that I might get a little further help ... A quick cut and paste and run to see if this works ... > import win32com.client > n=win32com.client.Dispatch('NKTWABLib.NKTWAB') > r=n.RootFolder > print r.Name > print r.Folders.Count > for folder_num in range(1, r.Folders.Count+1): > f=r.Folders[folder_num] > print f.Name, 'Groups:', f.Groups.Count, 'Contacts:', f.Contacts.Count > for contact_num in range(1, f.Contacts.Count+1): > c=f.Contacts[contact_num] > print '\t',c.Email1Address I get ... Traceback (most recent call last): File "D:\Hyplex\outlook\Hylapex\WAB-Contacts-02.py", line 5, in -toplevel- r=n.RootFolder File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 455, in __getattr__ return self._ApplyTypes_(*args) File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 446, in _ApplyTypes_ return self._get_good_object_( com_error: (-2147352559, 'Does not support a collection.', None, None) I think I get this because com objects have to be "imported" ... But this ActiveX object does not seem to have a "type lib"? ... So I tried the following ... import win32com.client n=win32com.client.gencache.EnsureDispatch("NKTWABLib.NKTWAB") print n and I get ... >>> >>> Again, I tried ... import win32com.client n=win32com.client.gencache.EnsureDispatch("NKTWABLib.NKTWAB") print n r=n.RootFolder print r.Folders.Count and I get ... >>> ================================ RESTART ================================ >>> Traceback (most recent call last): File "D:/Hyplex/outlook/Hylapex/WAB-Contacts-03.py", line 6, in -toplevel- r=n.RootFolder File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 455, in __getattr__ return self._ApplyTypes_(*args) File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 446, in _ApplyTypes_ return self._get_good_object_( com_error: (-2147352559, 'Does not support a collection.', None, None) >>> ... So, how lost am I? Thanks for all the help. Mailed LeeT From commercials at gmx.net Mon Mar 10 17:27:50 2008 From: commercials at gmx.net (Julius) Date: Mon, 10 Mar 2008 17:27:50 +0100 Subject: [python-win32] windows webdav mount Message-ID: <1205166470.3679.25.camel@bohlsen> Hi, is there python code to "monut" a webdave share to a windows drive letter? i know there are free/commercial applications that can do that, but i need at least a a program that can be controlled through some programming language. Julius From mail at timgolden.me.uk Mon Mar 10 17:32:12 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 10 Mar 2008 16:32:12 +0000 Subject: [python-win32] windows webdav mount In-Reply-To: <1205166470.3679.25.camel@bohlsen> References: <1205166470.3679.25.camel@bohlsen> Message-ID: <47D5628C.5020609@timgolden.me.uk> Julius wrote: > is there python code to "monut" a webdave share to a windows drive > letter? > i know there are free/commercial applications that can do that, but i > need at least a a program that can be controlled through some > programming language. I remember this coming up not long ago (altho' I seem to remember that the answer wasn't helpful). Have a look at this thread to see if it starts any hares: http://mail.python.org/pipermail/python-win32/2007-October/006332.html TJG From mail at timgolden.me.uk Mon Mar 10 17:33:57 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 10 Mar 2008 16:33:57 +0000 Subject: [python-win32] windows webdav mount In-Reply-To: <1205166470.3679.25.camel@bohlsen> References: <1205166470.3679.25.camel@bohlsen> Message-ID: <47D562F5.1040906@timgolden.me.uk> Julius wrote: > Hi, > > is there python code to "monut" a webdave share to a windows drive > letter? > i know there are free/commercial applications that can do that, but i > need at least a a program that can be controlled through some > programming language. ... or this one where Tim Roberts (a man you want on your side when it comes to delving deep into Windows) pours cold water: http://mail.python.org/pipermail/python-list/2002-April/140651.html TJG BTW, I just put site:mail.python.org webdav win32 into Google to fetch those results, altho' I had the advantage of remembering that there was something to search for :) From rwupole at msn.com Mon Mar 10 18:14:29 2008 From: rwupole at msn.com (Roger Upole) Date: Mon, 10 Mar 2008 13:14:29 -0400 Subject: [python-win32] Re: windows webdav mount Message-ID: Julius wrote: > Hi, > > is there python code to "monut" a webdave share to a windows drive > letter? > i know there are free/commercial applications that can do that, but i > need at least a a program that can be controlled through some > programming language. > > You should be able to use win32wnet.WNetAddConnection2 to do this. Roger From commercials at gmx.net Mon Mar 10 18:20:30 2008 From: commercials at gmx.net (Julius) Date: Mon, 10 Mar 2008 18:20:30 +0100 Subject: [python-win32] windows webdav mount In-Reply-To: <47D562F5.1040906@timgolden.me.uk> References: <1205166470.3679.25.camel@bohlsen> <47D562F5.1040906@timgolden.me.uk> Message-ID: <1205169631.3679.33.camel@bohlsen> On Mon, 2008-03-10 at 16:33 +0000, Tim Golden wrote: > Julius wrote: > > Hi, > > > > is there python code to "monut" a webdave share to a windows drive > > letter? > > i know there are free/commercial applications that can do that, but i > > need at least a a program that can be controlled through some > > programming language. > > ... or this one where Tim Roberts (a man you want on your > side when it comes to delving deep into Windows) pours > cold water: > > http://mail.python.org/pipermail/python-list/2002-April/140651.html > > TJG > > > BTW, I just put > > site:mail.python.org webdav win32 > > into Google to fetch those results, altho' I had the advantage > of remembering that there was something to search for :) If i could automate the second solution with python/perl/java that would be great, but i dont see how. The first c# just scares the hell out of me. Ive also found this solution "net use * http://ip/folder" - the xp client is able to list the content but thats it, no copy/read possible. will post that on the apache user mailing list (apache mod_dav is the server side). From rwupole at msn.com Mon Mar 10 20:07:41 2008 From: rwupole at msn.com (Roger Upole) Date: Mon, 10 Mar 2008 15:07:41 -0400 Subject: [python-win32] Re: OE/WAB help with VB ... Message-ID: Clinton Lee Taylor wrote: > I think I get this because com objects have to be "imported" ... But > this ActiveX object does not seem to have a "type lib"? ... It appears the type info is embedded in the dll itself, rather than shipped as a separate .tlb. > So I tried the following ... > > import win32com.client > n=win32com.client.gencache.EnsureDispatch("NKTWABLib.NKTWAB") > print n > > and I get ... >>>> > >>>> > > > Again, I tried ... > import win32com.client > > n=win32com.client.gencache.EnsureDispatch("NKTWABLib.NKTWAB") > print n > > r=n.RootFolder > print r.Folders.Count > > and I get ... > >>>> ================================ RESTART >>>> ================================ >>>> > > > Traceback (most recent call last): > File "D:/Hyplex/outlook/Hylapex/WAB-Contacts-03.py", line 6, > in -toplevel- > r=n.RootFolder > File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", > line 455, in __getattr__ > return self._ApplyTypes_(*args) > File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", > line 446, in _ApplyTypes_ > return self._get_good_object_( > com_error: (-2147352559, 'Does not support a collection.', None, None) >>>> > I get the same error after generating the wrapper from the type info. Try clearing your \win32com\genpy folder, and run it without the EnsureDispatch. There may be something wrong with the type info, but it would take a lot of digging to find out exactly what. Roger From timr at probo.com Mon Mar 10 19:14:08 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 10 Mar 2008 11:14:08 -0700 Subject: [python-win32] win32file.SetupComm Error Using PySerial in new Python 2.5.2 installation on 32 bit XP In-Reply-To: <47D22377.9050505@FascinatingElectronics.com> References: <47D22377.9050505@FascinatingElectronics.com> Message-ID: <47D57A70.7090903@probo.com> Ron Jackson wrote: > I am setting up Python on a newly upgraded computer (AMD 64 X2 dual > core) running 32 bit XP home. I installed the following packages: > ... > Traceback (most recent call last): > ... > File "C:\Python25\Lib\site-packages\serial\serialwin32.py", line 57, > in open > win32file.SetupComm(self.hComPort, 4096, 4096) > error: (1, 'SetupComm', 'Incorrect function.') > > Lines 56-57 in serialwin32.py are: > # Setup a 4k buffer > win32file.SetupComm(self.hComPort, 4096, 4096) > > This works just fine on my laptop computer, which was set up some time > ago and has a slightly older version of Python. > > So, why am I getting this error? I don't think PySerial has changed in a > long time, but was there some recent change in pywin32? Some change in > Python 2.5.2 that would account for this error? Something in the > installation that I haven't properly done? > Are the serial ports on your AMD 64X2 actually enabled in the BIOS? "Incorrect function" usually means that the system sent a request into the serial driver, and the particular request it sent is not one that the driver supports. If the serial ports were disabled in the BIOS (and many machines are so configured these days), or if you had a serial mouse in that port (which almost no one has any more), or if you were talking to a USB-to-serial converter, this kind of thing can happen. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mani.sabri at gmail.com Mon Mar 10 22:03:54 2008 From: mani.sabri at gmail.com (mani sabri) Date: Tue, 11 Mar 2008 00:33:54 +0330 Subject: [python-win32] embedding IPython in a windows dll Message-ID: <47d5a286.0ac0100a.38a4.2bb4@mx.google.com> Hi It's my first email in this list. After googleing for a day about redirecting python stdout/stdin/stderr.I found out that for a win32 application or a dllmain that does not naturally has a console I can AllocConsole() for them and blah blah blah! well anybody knows how that story ended? Or is it still a problem? I didn't saw anybody satisfied at the end of that threads with python shells from their dlls!. Best regards, Mani From timr at probo.com Mon Mar 10 22:43:53 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 10 Mar 2008 14:43:53 -0700 Subject: [python-win32] embedding IPython in a windows dll In-Reply-To: <47d5a286.0ac0100a.38a4.2bb4@mx.google.com> References: <47d5a286.0ac0100a.38a4.2bb4@mx.google.com> Message-ID: <47D5AB99.3050301@probo.com> mani sabri wrote: > Hi > It's my first email in this list. > After googleing for a day about redirecting python stdout/stdin/stderr.I > found out that for a win32 application or a dllmain that does not naturally > has a console I can AllocConsole() for them and blah blah blah! well anybody > knows how that story ended? Or is it still a problem? I didn't saw anybody > satisfied at the end of that threads with python shells from their dlls!. > I have no idea what you are asking. Are you trying to give access to a Python shell inside of another application? If so, then AllocConsole is not what you want. The wxPython GUI framework includes several tools to do exactly that. They put up an editable window, which is often more useful than a barebones console. If I misunderstand you, try asking your question again, and be specific. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mani.sabri at gmail.com Mon Mar 10 23:54:51 2008 From: mani.sabri at gmail.com (mani sabri) Date: Tue, 11 Mar 2008 02:24:51 +0330 Subject: [python-win32] embedding IPython in a windows dll In-Reply-To: <47D5AB99.3050301@probo.com> Message-ID: <47d5bc86.09a8100a.24e9.36cb@mx.google.com> >-----Original Message----- >From: python-win32-bounces at python.org [mailto:python-win32- >I have no idea what you are asking. I want to run a Python shell from a DllMain() function. This is what I came up with so far: BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) { //---- switch(ul_reason_for_call) { case DLL_PROCESS_ATTACH: { if (!Py_IsInitialized()) { BOOL res = AllocConsole(); //I was going to use the handles but I heard its not the way to do that //HANDLE OutHand = GetStdHandle(STD_OUTPUT_HANDLE); //HANDLE InHand = GetStdHandle(STD_INPUT_HANDLE); //HANDLE ErrHand = GetStdHandle(STD_ERROR_HANDLE); //Redirecting console freopen("CONOUT$","w",stdout); freopen("CONIN$","w",stdin); freopen("CONERR$","w",stderr); //Another way to redirect console //std::ofstream console_out("CONOUT$"); //std::ifstream console_in("CONIN$"); //std::ofstream console_err("CONOUT$"); //the printf prints on the new console after redirection printf("test"); //opening stdout and stdin files to pass to python for redirection FILE* afile = fopen("CONOUT$", "w+"); FILE* bfile = fopen("CONIN$", "w+"); Py_Initialize(); if (!Py_IsInitialized()) return(FALSE); //the bellow lines , instead of redirecting python crashes the dll PySys_SetObject("stdout", PyFile_FromFile(afile, "test","wb", fclose)); PySys_SetObject("stdin", PyFile_FromFile(bfile, "CONIN$","wb", fclose)); //these lines produces no output PyRun_SimpleString("print 'hello'\n"); PyRun_SimpleString("from IPython.Shell import IPShellEmbed\n"); PyRun_SimpleString("ipshell = IPShellEmbed()\n"); PyRun_SimpleString("ipshell()\n"); } break; } case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: { FreeConsole(); Py_Finalize(); break; } } //---- return(TRUE); } >Are you trying to give access to a Python shell inside of another >application? If so, then AllocConsole is not what you want. The >wxPython GUI framework includes several tools to do exactly that. They >put up an editable window, which is often more useful than a barebones >console. As you said all I was able to accomplish with AllocConsole was to redirect the printf not the python >If I misunderstand you, try asking your question again, and be specific. If it's not clear please don't hesitate to ask. Best regards, Mani From mani.sabri at gmail.com Tue Mar 11 00:03:34 2008 From: mani.sabri at gmail.com (mani sabri) Date: Tue, 11 Mar 2008 02:33:34 +0330 Subject: [python-win32] embedding IPython in a windows dll In-Reply-To: <47D5AB99.3050301@probo.com> Message-ID: <47d5be91.05a4100a.5a0f.5844@mx.google.com> >-----Original Message----- >From: python-win32-bounces at python.org [mailto:python-win32- >bounces at python.org] On Behalf Of Tim Roberts > >Are you trying to give access to a Python shell inside of another application? wxPython GUI framework includes several tools to do exactly that. They >put up an editable window, which is often more useful than a barebones >console. Good point, I have to try it in maindll() Best regards, Mani From timr at probo.com Tue Mar 11 00:43:21 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 10 Mar 2008 16:43:21 -0700 Subject: [python-win32] embedding IPython in a windows dll In-Reply-To: <47d5bc86.09a8100a.24e9.36cb@mx.google.com> References: <47d5bc86.09a8100a.24e9.36cb@mx.google.com> Message-ID: <47D5C799.5080101@probo.com> mani sabri wrote: > I want to run a Python shell from a DllMain() function. > It isn't safe to do this much processing in a DllMain. There is a thing called the "loader lock" that is held while DllMain is called, and it can prevent you from loading other DLLs. You might try spinning off a thread to do your real work. > This is what I came up with so far: > > BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID > lpReserved) > { > //---- > switch(ul_reason_for_call) > { > case DLL_PROCESS_ATTACH: > { > if (!Py_IsInitialized()) > { > BOOL res = AllocConsole(); > > //I was going to use the handles but I heard its not the way to do > that > //HANDLE OutHand = GetStdHandle(STD_OUTPUT_HANDLE); > //HANDLE InHand = GetStdHandle(STD_INPUT_HANDLE); > //HANDLE ErrHand = GetStdHandle(STD_ERROR_HANDLE); > > //Redirecting console > freopen("CONOUT$","w",stdout); > freopen("CONIN$","w",stdin); > freopen("CONERR$","w",stderr); > Do you really think "w" is correct for all three of those? > //the printf prints on the new console after redirection > printf("test"); > > //opening stdout and stdin files to pass to python for redirection > FILE* afile = fopen("CONOUT$", "w+"); > FILE* bfile = fopen("CONIN$", "w+"); > Again, do you really think you want "w+ for both of these? How much writing will you do to stdin? > Py_Initialize(); > if (!Py_IsInitialized()) return(FALSE); > > //the bellow lines , instead of redirecting python crashes the dll > PySys_SetObject("stdout", PyFile_FromFile(afile, "test","wb", > fclose)); > PySys_SetObject("stdin", PyFile_FromFile(bfile, "CONIN$","wb", > fclose)); > Again, you're probably going to want to read from stdin, not write to it. And you don't really need to do the fopen yourself: PyFileObject* xout = PyFile_FromString( "CONOUT$", "wb" ); PyFileObject* xin = PyFile_FromString( "CONIN$", "rb" ); PySys_SetObject( "stdout", xout ); PySys_SetObject( "__stdout__", xout ); PySys_SetObject( "stdin", xin ); PySys_SetObject( "__stdin__", xin ); -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mark.a.brand at gmail.com Tue Mar 11 03:16:37 2008 From: mark.a.brand at gmail.com (mark.a.brand) Date: Tue, 11 Mar 2008 13:16:37 +1100 Subject: [python-win32] advice on architecting or program design in python: Message-ID: <1f40e84a0803101916k4274698bvd5fc965e8069b852@mail.gmail.com> hi: i am new to python and wish but am writing a program as both a learning experience and which may even get used if it is any good. purpose of this program: is to retrieve and store (for historical purposes) system-info for multiple clients about multiple windows servers using tim golden's wmiwrapper. broadly the algorithm is something like this. for each client for each server get-info(Win32_Process())) get-info(get-Win32_Service()) ... ... write-system-info (to-a-db) endfor endfor a call to any of these Win32_* classes returns a list of 1..n instances which have a varying number of attributes. eg Win32_Process will have attributes about processes, and Win32_Service() will have attributes about services. i'am pretty sure i will need to have a seperate table for each server component (eg a services table which contains historical info about services, and a process table which contains historical info about processes). but is appears to me there is there is a lot of duplication as each class always returns a list of instances - the only thing different is the name of the class (eg. Win32_Service() as opposed to Win32_Process()) and the attributes returned by those classes. so the things i am confused about: * what would be an appropriate class structure * is it possible to wrap somehow all the calls to the different Win32 classes and then do something with each different set of attributes that are returned. apologies - if this request seems vague, i can illuminate if asked specific questions. thanks mark -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080311/6777b21c/attachment.htm From clintonlee.taylor at gmail.com Tue Mar 11 09:01:47 2008 From: clintonlee.taylor at gmail.com (Clinton Lee Taylor) Date: Tue, 11 Mar 2008 10:01:47 +0200 Subject: [python-win32] OE/WAB help with VB ... Message-ID: Greetings ... Thanks again for the quick response ... > Clinton Lee Taylor wrote: > > I think I get this because com objects have to be "imported" ... But > > this ActiveX object does not seem to have a "type lib"? ... > It appears the type info is embedded in the dll itself, rather than > shipped as a separate .tlb. > I get the same error after generating the wrapper from the type info. > Try clearing your \win32com\genpy folder, and run it without the > EnsureDispatch. There may be something wrong with the type > info, but it would take a lot of digging to find out exactly what. Okay, the little library is LGPL and the source is about, would we be able to get the details from the header files or something else? Thanks Mailed LeeT From mail at timgolden.me.uk Tue Mar 11 11:14:29 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 11 Mar 2008 10:14:29 +0000 Subject: [python-win32] advice on architecting or program design in python: In-Reply-To: <1f40e84a0803101916k4274698bvd5fc965e8069b852@mail.gmail.com> References: <1f40e84a0803101916k4274698bvd5fc965e8069b852@mail.gmail.com> Message-ID: <47D65B85.1080304@timgolden.me.uk> mark.a.brand wrote: > hi: > > i am new to python and wish but am writing a program as both a learning > experience and which may even get used if it is any good. Welcome to the wonderful world of Python :) > purpose of this program: > is to retrieve and store (for historical purposes) system-info for multiple > clients about multiple windows servers using tim golden's > wmiwrapper. broadly the > algorithm is something like this. > > for each client > for each server > get-info(Win32_Process())) > get-info(get-Win32_Service()) > ... > ... > write-system-info (to-a-db) > endfor > endfor Not that it's necessarily wrong, but it's not clear why you're bothering to pull server information from each client separately. It's not as though the services running on Server S1 will appear different when queried from client C1 and C2. But maybe there's something I'm missing. [... snip slightly confused post which seems to be mixing RDBMS terminology and class queries ...] I'd love to help you out here, Mark, but it's not entirely clear whether you're asking for advice on RDBMS structures (what tables to use for the data) or class structures (how to fit the data returned into classes). Wearing my database hat for a moment, it seems as though the most obvious table structure from your description above is (Noddy structure - I don't usually create a bunch of V(100 fields): CREATE TABLE services ( client VARCHAR (100), server VARCHAR (100), name VARCHAR (100), status VARCHAR (100) . . etc ) CREATE TABLE processes ( client VARCHAR (100), server VARCHAR (100), name VARCHAR (100), status VARCHAR (100) . . etc ) Now, if what you're saying is: hey, they all seem to have .Caption, .Status, .Name attributes; surely some sort of denormalisation applies here, then I would say: Beware. It's terribly tempting to create a database-within-a-database without any real gain. Unless it's really offering you something to create a wmi_objects table with 1:1 subordinates, don't do it. As to the class structure within Python, the same sort of caveats apply. Use Python core data structures -- lists, dicts, sets, tuples -- as much as you possibly can. They're simple and well-defined and they're optimized to hell and back (not least since they're used by Python itself as part of its internals). Don't feel you have to go around creating hierarchies of classes just because you can! Anyway, if that wasn't what you were after, or if you want to explain your plans further feel free to post back. TJG From mark.a.brand at gmail.com Tue Mar 11 11:48:11 2008 From: mark.a.brand at gmail.com (mark.a.brand) Date: Tue, 11 Mar 2008 21:48:11 +1100 Subject: [python-win32] advice on architecting or program design in python: In-Reply-To: <1f40e84a0803110347k1f9a83e9g2c6c9f7bb99cdd50@mail.gmail.com> References: <1f40e84a0803101916k4274698bvd5fc965e8069b852@mail.gmail.com> <47D65B85.1080304@timgolden.me.uk> <1f40e84a0803110347k1f9a83e9g2c6c9f7bb99cdd50@mail.gmail.com> Message-ID: <1f40e84a0803110348h25be9c1bv2a2974e5dde8e1e0@mail.gmail.com> > > hi: > > > Not that it's necessarily wrong, but it's not clear why you're bothering > to pull server information from each client separately. It's not as > though the services running on Server S1 will appear different when > queried from client C1 and C2. But maybe there's something I'm missing. > > > sorry - client as in customer > > > CREATE TABLE > processes > ( > client VARCHAR (100), > server VARCHAR (100), > name VARCHAR (100), > status VARCHAR (100) > . > . > etc > ) > > > thats what i have > > > Now, if what you're saying is: hey, they all seem to have .Caption, > .Status, .Name attributes; surely some sort of denormalisation applies > here, then I would say: Beware. It's terribly tempting to create a > database-within-a-database without any real gain. Unless it's really > offering you something to create a wmi_objects table with 1:1 > subordinates, don't do it. > > > no - the db structure you outlined above is fine. > > i will try and explain better, but its not quite clear in my mind what is > achievable ... > > so to build up these database tables, i have to have some queries > happening of the form : > > for list in Win32_Process() > add instance to table-process > > for list in Win32_Service() > add instance to table-service > > ... > etc etc for each Win32_* query i wanted to implement. > > what I am looking for is an object based / pythonic way to replace all > those "for loops". it just seemed to me that the "for loops" only differ in > the Win32_* class they call. so for example would i: > > * define a class Service() and a class Process () and put a method in each > class that contained the above for loop. > or > > * define a class Service() and a class Process() and a class Manager() and > put the for loops in the Manager class > > now both of these ways strike me as being clumsy, so I was looking for a > better way to represent this behaviour. > > thanks for you assistance tim. > > cheers > mark > > > > On 11/03/2008, Tim Golden wrote: > > > > mark.a.brand wrote: > > > hi: > > > > > > i am new to python and wish but am writing a program as both a > > learning > > > experience and which may even get used if it is any good. > > > > > > Welcome to the wonderful world of Python :) > > > > > > > purpose of this program: > > > is to retrieve and store (for historical purposes) system-info for > > multiple > > > clients about multiple windows servers using tim golden's > > > > > wmiwrapper. broadly the > > > > > algorithm is something like this. > > > > > > for each client > > > for each server > > > get-info(Win32_Process())) > > > get-info(get-Win32_Service()) > > > ... > > > ... > > > write-system-info (to-a-db) > > > endfor > > > endfor > > > > > > Not that it's necessarily wrong, but it's not clear why you're bothering > > to pull server information from each client separately. It's not as > > though the services running on Server S1 will appear different when > > queried from client C1 and C2. But maybe there's something I'm missing. > > > > [... snip slightly confused post which seems to be mixing > > RDBMS terminology and class queries ...] > > > > I'd love to help you out here, Mark, but it's not entirely clear > > whether you're asking for advice on RDBMS structures (what tables > > to use for the data) or class structures (how to fit the data > > returned into classes). > > > > Wearing my database hat for a moment, it seems as though the > > most obvious table structure from your description above is > > (Noddy structure - I don't usually create a bunch of V(100 fields): > > > > CREATE TABLE > > services > > ( > > client VARCHAR (100), > > server VARCHAR (100), > > name VARCHAR (100), > > status VARCHAR (100) > > . > > . > > etc > > ) > > > > CREATE TABLE > > processes > > ( > > client VARCHAR (100), > > server VARCHAR (100), > > name VARCHAR (100), > > status VARCHAR (100) > > . > > . > > etc > > ) > > > > Now, if what you're saying is: hey, they all seem to have .Caption, > > .Status, .Name attributes; surely some sort of denormalisation applies > > here, then I would say: Beware. It's terribly tempting to create a > > database-within-a-database without any real gain. Unless it's really > > offering you something to create a wmi_objects table with 1:1 > > subordinates, don't do it. > > > > As to the class structure within Python, the same sort of caveats apply. > > Use Python core data structures -- lists, dicts, sets, tuples -- as much > > as you possibly can. They're simple and well-defined and they're > > optimized to hell and back (not least since they're used by Python > > itself as part of its internals). Don't feel you have to go around > > creating hierarchies of classes just because you can! > > > > Anyway, if that wasn't what you were after, or if you want to explain > > your plans further feel free to post back. > > > > TJG > > > > _______________________________________________ > > 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: http://mail.python.org/pipermail/python-win32/attachments/20080311/f6c13069/attachment-0001.htm From mail at timgolden.me.uk Tue Mar 11 12:11:45 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 11 Mar 2008 11:11:45 +0000 Subject: [python-win32] advice on architecting or program design in python: In-Reply-To: <1f40e84a0803110347k1f9a83e9g2c6c9f7bb99cdd50@mail.gmail.com> References: <1f40e84a0803101916k4274698bvd5fc965e8069b852@mail.gmail.com> <47D65B85.1080304@timgolden.me.uk> <1f40e84a0803110347k1f9a83e9g2c6c9f7bb99cdd50@mail.gmail.com> Message-ID: <47D668F1.4030005@timgolden.me.uk> mark.a.brand wrote: > sorry - client as in customer Ah. I see. (Didn't think of that :) > i will try and explain better, but its not quite clear in my mind what is > achievable ... > > so to build up these database tables, i have to have some queries happening > of the form : > > for list in Win32_Process() > add instance to table-process > > for list in Win32_Service() > add instance to table-service > > ... > etc etc for each Win32_* query i wanted to implement. > > what I am looking for is an object based / pythonic way to replace all those > "for loops". Certainly possible at several levels. There are a number of ORM packages around, but the general favourite is probably sqlalchemy [1] and its spin-off Elixir [2]. That said, there's nothing to stop you working straight at the DBAPI [3] level and calling .executemany against the tables you want. Certainly you could have your table structure exactly mimic the "column" structure of the corresponding WMI class and push things along a bit that way. It's fairly trivial to turn the WMI attribute values into a dictionary which could then be passed on to something like Elixir's row-creation. import os, sys from elixir import * import wmi DB_FILENAME = os.path.abspath ("wmi.db") metadata.bind = "sqlite:///%s" % DB_FILENAME class Process (Entity): ProcessId = Field (Integer, primary_key=True) Caption = Field (Unicode (100)) if __name__ == '__main__': setup_all (True) c = wmi.WMI () for process in c.Win32_Process (['ProcessId', 'Caption']): d = dict ((p, getattr (process, p)) for p in process.properties) Process (**d) session.flush () session.close () Obviously, this is a mere stub but it does at least work and might be a useful basis. There is definite scope for factoring things out but you might do better just to have a function which took -- or inferred -- the relevant class and table names. YMMV. > thanks for you assistance tim. Glad to be of service :) TJG [1] http://sqlalchemy.org [2] http://elixir.ematia.de/trac/wiki [3] http://www.python.org/dev/peps/pep-0249/ From mail at timgolden.me.uk Tue Mar 11 13:06:23 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 11 Mar 2008 12:06:23 +0000 Subject: [python-win32] advice on architecting or program design in python: In-Reply-To: <47D668F1.4030005@timgolden.me.uk> References: <1f40e84a0803101916k4274698bvd5fc965e8069b852@mail.gmail.com> <47D65B85.1080304@timgolden.me.uk> <1f40e84a0803110347k1f9a83e9g2c6c9f7bb99cdd50@mail.gmail.com> <47D668F1.4030005@timgolden.me.uk> Message-ID: <47D675BF.20909@timgolden.me.uk> Tim Golden wrote: [... snip Elixir-based solution ...] I realise, rereading my post that it doesn't really solve your concern about multiple loops etc. I doubt it's really a problem, but in the spirit of the question, here's a raw sqlite solution, again Noddy and untested. You've said you're newish to Python and while there's no black magic here, I am being fairly free with generator expressions and getattr-fu. If you think the approach might be useful and need further explanation feel free to ask. import os, sys import sqlite3 import wmi os.remove ("c:/temp/wmi.db") db = sqlite3.connect ("c:/temp/wmi.db") classes_wanted = ["Win32_Process", "Win32_Service"] # # Generate a dictionary of class name -> WMI class # c = wmi.WMI () wmi_classes = dict ( (class_wanted, getattr (c, class_wanted)) \ for class_wanted in classes_wanted ) # # Create a simplistic Sqlite table for each WMI # class with one (untyped) column per attribute. # for class_name, wmi_class in wmi_classes.items (): db.execute ("CREATE TABLE %s (%s)" % ( class_name, ", ".join (p for p in wmi_class.properties) )) db.commit () # # For each WMI class, add all its instances as # rows to the corresponding sqlite table. # for class_name, wmi_class in wmi_classes.items (): db.executemany ( "INSERT INTO %s (%s) VALUES (%s)" % ( class_name, ", ".join (p for p in wmi_class.properties), ", ".join ("?" for p in wmi_class.properties) ), [[getattr (c, p) for p in c.properties] for c in wmi_class ()] ) db.commit () From mark.a.brand at gmail.com Tue Mar 11 13:08:54 2008 From: mark.a.brand at gmail.com (mark.a.brand) Date: Tue, 11 Mar 2008 23:08:54 +1100 Subject: [python-win32] advice on architecting or program design in python: In-Reply-To: <47D668F1.4030005@timgolden.me.uk> References: <1f40e84a0803101916k4274698bvd5fc965e8069b852@mail.gmail.com> <47D65B85.1080304@timgolden.me.uk> <1f40e84a0803110347k1f9a83e9g2c6c9f7bb99cdd50@mail.gmail.com> <47D668F1.4030005@timgolden.me.uk> Message-ID: <1f40e84a0803110508v753fb4a6sfddcffa769cae66f@mail.gmail.com> Hi Tim: So what you are saying is that it would be perfectly acceptable to have a "for loop" for each Win32_* query and that there is no good way to generalise that behaviour. eg. class Process() ... class Product() ... class Event() ... class Service() .... if __name__ == '__main__': setup_all (True) c = wmi.WMI () for process in c.Win32_Process (['ProcessId', 'Caption']): d = dict ((p, getattr (process, p)) for p in process.properties) Process (**d) for product in c.Win32_Products (['ProductId', 'Caption']): d = dict ((p, getattr (process, p)) for p in product.properties) Product (**d) for event in c.Win32_NTEvent (['EventId', 'Caption']): d = dict ((p, getattr (event, p)) for p in event.properties) Event (**d) for service in c.Win32_Service (['ServiceId', 'Caption']): d = dict ((p, getattr (service, p)) for p in service.properties) Service (**d) .... etc etc. session.flush () session.close () Thanks for your patience. Cheers Mark On 11/03/2008, Tim Golden wrote: > > mark.a.brand wrote: > > sorry - client as in customer > > > Ah. I see. (Didn't think of that :) > > > > i will try and explain better, but its not quite clear in my mind what > is > > achievable ... > > > > so to build up these database tables, i have to have some queries > happening > > of the form : > > > > for list in Win32_Process() > > add instance to table-process > > > > for list in Win32_Service() > > add instance to table-service > > > > ... > > etc etc for each Win32_* query i wanted to implement. > > > > what I am looking for is an object based / pythonic way to replace all > those > > "for loops". > > > Certainly possible at several levels. There are a number > of ORM packages around, but the general favourite is probably > sqlalchemy [1] and its spin-off Elixir [2]. That said, there's > nothing to stop you working straight at the DBAPI [3] level > and calling .executemany against the tables you want. > > Certainly you could have your table structure exactly mimic > the "column" structure of the corresponding WMI class and > push things along a bit that way. It's fairly trivial to > turn the WMI attribute values into a dictionary which could > then be passed on to something like Elixir's row-creation. > > > import os, sys > from elixir import * > import wmi > > DB_FILENAME = os.path.abspath ("wmi.db") > metadata.bind = "sqlite:///%s" % DB_FILENAME > > class Process (Entity): > > ProcessId = Field (Integer, primary_key=True) > Caption = Field (Unicode (100)) > > if __name__ == '__main__': > setup_all (True) > c = wmi.WMI () > for process in c.Win32_Process (['ProcessId', 'Caption']): > d = dict ((p, getattr (process, p)) for p in process.properties) > Process (**d) > > session.flush () > session.close () > > > > Obviously, this is a mere stub but it does at least work > and might be a useful basis. There is definite scope for > factoring things out but you might do better just to have > a function which took -- or inferred -- the relevant class > and table names. YMMV. > > > > thanks for you assistance tim. > > > Glad to be of service > > :) > > TJG > > [1] http://sqlalchemy.org > [2] http://elixir.ematia.de/trac/wiki > [3] http://www.python.org/dev/peps/pep-0249/ > > > _______________________________________________ > 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: http://mail.python.org/pipermail/python-win32/attachments/20080311/1aa65e56/attachment.htm From mark.a.brand at gmail.com Tue Mar 11 13:15:51 2008 From: mark.a.brand at gmail.com (mark.a.brand) Date: Tue, 11 Mar 2008 23:15:51 +1100 Subject: [python-win32] advice on architecting or program design in python: In-Reply-To: <47D675BF.20909@timgolden.me.uk> References: <1f40e84a0803101916k4274698bvd5fc965e8069b852@mail.gmail.com> <47D65B85.1080304@timgolden.me.uk> <1f40e84a0803110347k1f9a83e9g2c6c9f7bb99cdd50@mail.gmail.com> <47D668F1.4030005@timgolden.me.uk> <47D675BF.20909@timgolden.me.uk> Message-ID: <1f40e84a0803110515s301bfdd8v191545557533745a@mail.gmail.com> Hi Tim: Thanks, that was what I was after, but maybe you are right a couple of extra for loops is not looking too bad after all. Cheers Mark On 11/03/2008, Tim Golden wrote: > > Tim Golden wrote: > [... snip Elixir-based solution ...] > > I realise, rereading my post that it doesn't really solve > your concern about multiple loops etc. I doubt it's really > a problem, but in the spirit of the question, here's a raw > sqlite solution, again Noddy and untested. > > You've said you're newish to Python and while > there's no black magic here, I am being fairly free with > generator expressions and getattr-fu. If you think the > approach might be useful and need further explanation > feel free to ask. > > > import os, sys > import sqlite3 > import wmi > > os.remove ("c:/temp/wmi.db") > db = sqlite3.connect ("c:/temp/wmi.db") > classes_wanted = ["Win32_Process", "Win32_Service"] > > # > # Generate a dictionary of class name -> WMI class > # > c = wmi.WMI () > wmi_classes = dict ( > (class_wanted, getattr (c, class_wanted)) \ > for class_wanted in classes_wanted > ) > > # > # Create a simplistic Sqlite table for each WMI > # class with one (untyped) column per attribute. > # > for class_name, wmi_class in wmi_classes.items (): > db.execute ("CREATE TABLE %s (%s)" % ( > class_name, > ", ".join (p for p in wmi_class.properties) > )) > > db.commit () > > # > # For each WMI class, add all its instances as > # rows to the corresponding sqlite table. > # > for class_name, wmi_class in wmi_classes.items (): > db.executemany ( > "INSERT INTO %s (%s) VALUES (%s)" % ( > class_name, > ", ".join (p for p in wmi_class.properties), > ", ".join ("?" for p in wmi_class.properties) > ), > [[getattr (c, p) for p in c.properties] for c in wmi_class ()] > ) > > db.commit () > > > > _______________________________________________ > 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: http://mail.python.org/pipermail/python-win32/attachments/20080311/d6b9eaef/attachment.htm From mail at timgolden.me.uk Tue Mar 11 14:03:42 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 11 Mar 2008 13:03:42 +0000 Subject: [python-win32] advice on architecting or program design in python: In-Reply-To: <1f40e84a0803110515s301bfdd8v191545557533745a@mail.gmail.com> References: <1f40e84a0803101916k4274698bvd5fc965e8069b852@mail.gmail.com> <47D65B85.1080304@timgolden.me.uk> <1f40e84a0803110347k1f9a83e9g2c6c9f7bb99cdd50@mail.gmail.com> <47D668F1.4030005@timgolden.me.uk> <47D675BF.20909@timgolden.me.uk> <1f40e84a0803110515s301bfdd8v191545557533745a@mail.gmail.com> Message-ID: <47D6832E.7000104@timgolden.me.uk> mark.a.brand wrote: > Hi Tim: > > Thanks, that was what I was after, but maybe you are right a couple of extra > for loops is not looking too bad after all. The code looks a little scary at first sight but it's not that bad ;) It's one of those things everyone learns to weigh up when they're putting together code / data. How "clever" do I try to be. Sometimes there's clear benefit (or at least no clear disadvantage). Other times it's the result of overengineering -- and often up front. You may find, for example, that the .executemany in the sqlite example gives a performance benefit over Elixir's more explicit looping, but you might not (or it might not be significant). Go with what's clearest first, then look for optimisations where you really need them. [One of] The great thing[s] about Python is that refactoring is usually really easy. The two solutions I outlined did (broadly) the same thing. You could make them even more similar with a little work. Each one is only a couple of dozens of lines of code. If you started with one and decided later that the other was preferable, it would be really simple to swap one out and the other in. Obviously, it's not always that easy but it's certainly easi*er*. Good luck with the project. Do come back for more help (or hindrance). TJG From mark.a.brand at gmail.com Tue Mar 11 14:30:34 2008 From: mark.a.brand at gmail.com (mark.a.brand) Date: Wed, 12 Mar 2008 00:30:34 +1100 Subject: [python-win32] advice on architecting or program design in python: In-Reply-To: <47D6832E.7000104@timgolden.me.uk> References: <1f40e84a0803101916k4274698bvd5fc965e8069b852@mail.gmail.com> <47D65B85.1080304@timgolden.me.uk> <1f40e84a0803110347k1f9a83e9g2c6c9f7bb99cdd50@mail.gmail.com> <47D668F1.4030005@timgolden.me.uk> <47D675BF.20909@timgolden.me.uk> <1f40e84a0803110515s301bfdd8v191545557533745a@mail.gmail.com> <47D6832E.7000104@timgolden.me.uk> Message-ID: <1f40e84a0803110630i4802ba7bp5b96096d8500bae1@mail.gmail.com> Python is that refactoring is usually really easy. thats a good thing to know. i was originally going to just start out the naive way and refactor as python became more familiar. i think that approach may work best for me - take baby steps and refactor as i my knowledge and experience grows. thanks again mark On 12/03/2008, Tim Golden wrote: > > mark.a.brand wrote: > > Hi Tim: > > > > Thanks, that was what I was after, but maybe you are right a couple of > extra > > for loops is not looking too bad after all. > > > The code looks a little scary at first sight but it's > not that bad ;) > > It's one of those things everyone learns to weigh up when > they're putting together code / data. How "clever" do I > try to be. Sometimes there's clear benefit (or at least > no clear disadvantage). Other times it's the result of > overengineering -- and often up front. You may find, for > example, that the .executemany in the sqlite example gives > a performance benefit over Elixir's more explicit looping, > but you might not (or it might not be significant). Go > with what's clearest first, then look for optimisations where > you really need them. > > [One of] The great thing[s] about Python is that refactoring > is usually really easy. The two solutions I outlined did > (broadly) the same thing. You could make them even more > similar with a little work. Each one is only a couple of > dozens of lines of code. If you started with one and decided > later that the other was preferable, it would be really simple > to swap one out and the other in. Obviously, it's not always > that easy but it's certainly easi*er*. > > Good luck with the project. Do come back for more help > (or hindrance). > > TJG > > _______________________________________________ > 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: http://mail.python.org/pipermail/python-win32/attachments/20080312/7e85a86a/attachment-0001.htm From mani.sabri at gmail.com Tue Mar 11 17:25:28 2008 From: mani.sabri at gmail.com (mani sabri) Date: Tue, 11 Mar 2008 19:55:28 +0330 Subject: [python-win32] embedding IPython in a windows dll In-Reply-To: <47D5C799.5080101@probo.com> Message-ID: <47d6b2d4.21d2260a.12c6.ffffed72@mx.google.com> >-----Original Message----- >From: python-win32-bounces at python.org [mailto:python-win32- >bounces at python.org] On Behalf Of Tim Roberts mani sabri wrote: >> I want to run a Python shell from a DllMain() function. > >It isn't safe to do this much processing in a DllMain. There is a >thing called the "loader lock" that is held while DllMain is called, >and it can prevent you from loading other DLLs. You might try spinning >off a thread to do your real work. > > Wow thanks,I'll difinitly use a thread. Do have any link to a sample code or some keywords for google? >> freopen("CONOUT$","w",stdout); >> freopen("CONIN$","w",stdin); >> freopen("CONERR$","w",stderr); >> > >Do you really think "w" is correct for all three of those? > >> FILE* afile = fopen("CONOUT$", "w+"); >> FILE* bfile = fopen("CONIN$", "w+"); > >Again, do you really think you want "w+ for both of these? How much >writing will you do to stdin? > >> PySys_SetObject("stdin", PyFile_FromFile(bfile, "CONIN$","wb", >> fclose)); > >Again, you're probably going to want to read from stdin, not write to >it. Thanks a lot. I'm sure I'll never forget that. > And you don't really need to do the fopen yourself: > > PyFileObject* xout = PyFile_FromString( "CONOUT$", "wb" ); > PyFileObject* xin = PyFile_FromString( "CONIN$", "rb" ); > PySys_SetObject( "stdout", xout ); > PySys_SetObject( "__stdout__", xout ); > PySys_SetObject( "stdin", xin ); > PySys_SetObject( "__stdin__", xin ); And this, I was not able to compile it[1] until I changed it a little bit[2]. [1] It was 6 errors, first and seconed line of the kind: expertsample.cpp(85) : error C2440: 'initializing' : cannot convert from 'PyObject *' to 'PyFileObject *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast And the remaining four of the kind: expertsample.cpp(87) : error C2664: 'PySys_SetObject' : cannot convert parameter 2 from 'PyFileObject *' to 'PyObject *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast [2] So I changed the code to: PyFileObject* xout = (PyFileObject*)PyFile_FromString("CONOUT$","wb"); PyFileObject* xin = (PyFileObject*)PyFile_FromString( "CONIN$", "rb" ); PySys_SetObject( "stdout", (PyObject*)xout ); PySys_SetObject( "__stdout__", (PyObject*)xout ); PySys_SetObject( "stdin", (PyObject*)xin ); PySys_SetObject( "__stdin__", (PyObject*)xin ); But still no output after a PyRun_SimpleString("print 'Hello from python'\n"); >-- >Tim Roberts, timr at probo.com >Providenza & Boekelheide, Inc. Best regards, Mani From patter001 at gmail.com Tue Mar 11 17:58:35 2008 From: patter001 at gmail.com (Kevin Patterson) Date: Tue, 11 Mar 2008 12:58:35 -0400 Subject: [python-win32] How to create a com_record? In-Reply-To: <009001c8677f$8931d0f0$9b9572d0$@com.au> References: <091c01c86494$28e28390$7aa78ab0$@com.au> <0a0a01c86619$2feff650$8fcfe2f0$@com.au> <0a5201c866b5$88447280$98cd5780$@com.au> <0a8d01c866de$b3b97db0$1b2c7910$@com.au> <009001c8677f$8931d0f0$9b9572d0$@com.au> Message-ID: Old thread, but I got a little more data on the function. The function actually has a REFIID as the first parameter. This apparently is a standard structure for C COM code. I'm not entirely sure why the win32com changes the REFIID to be a VT_RECORD. Does the following definition of the functions help at all (they are from the IDL file) HRESULT GetInterface( [in] REFIID riid, [out, retval, iid_is(riid)] IUnknown** ppUnknown); should be same as: HRESULT GetInterface( [in] GUID* pGuid, [out, retval, iid_is(pGuid)] IUnknown** ppUnknown); On Mon, Feb 4, 2008 at 6:44 PM, Mark Hammond wrote: > > guid = win32com.client.Record("GUID", some_ob) > > > I don't have the some_obj that allows me to build "GUID". > > It should be any object from the same typelib - almost certainly whatever > object you intend passing this record to. > > > VB.NET (GetType) and C++ (__uuid) both already know that a GUID is a > record. > > C++ doesn't know it is a COM record. A COM record is something quite > different to a C/C++ struct or from .NET types. A COM record is > specifically designed to be cross-language. > > > It seems the python CLSID is the same thing, but i don't know what to > call > > > to get a CLSID that is a com_record type. > > As I've explained, we are looking for the COM record definition you are > trying to use. A C++ struct definition for a GUID is *not* what you are > looking for - you are looking for the COM record definition of a GUID. I > see now that you simply copied me a C++ struct you found, which is not at > all useful in this context. > > To clarify: in a *typelib* you will find a struct definition that you are > trying to use. Finding a struct definition of the same name somewhere > else > is not suitable. > > > Am I understanding the win32com.client.Record call correctly? It needs > GUID to be defined by the > > COM right? > > Not "defined by COM", but "defined using COM" - the author of a typelib > must > have defined it somewhere. > > > Its odd b/c the GIUD (python's CLSID) is all over the COM definitions > its > just type > > VT_RECORD type that I'm not understanding how to convert to. > > Yes, I'm afraid you are confused. All existing GUID or CLSID definitions > you can find are useless - there is only 1 that is relevant, and that will > be defined in a typelib. > > I think the confusion is such that you need to find basic docs for the > object, so we can get back to square 1. > > Mark > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080311/dbd70503/attachment.htm From commercials at gmx.net Tue Mar 11 22:59:42 2008 From: commercials at gmx.net (Julius) Date: Tue, 11 Mar 2008 22:59:42 +0100 Subject: [python-win32] win32gui.EnumWindows, documentation? Message-ID: <1205272782.3679.76.camel@bohlsen> Hi, im new to python in generell and was wondering where i would find the api to win32gui.EnumWindows? I know one of its arguments is a callback function, but i cant find any information how it should look like? Is this another win32 python implementation or is the site just called activestate? Ive installed Mark Hammond's win32 extensions http://aspn.activestate.com/ASPN/docs/ActivePython/2.2/PyWin32/win32gui__EnumWindows_meth.html Julius From Kyle.Rickey at bakerhughes.com Tue Mar 11 23:04:37 2008 From: Kyle.Rickey at bakerhughes.com (Rickey, Kyle W) Date: Tue, 11 Mar 2008 17:04:37 -0500 Subject: [python-win32] win32gui.EnumWindows, documentation? In-Reply-To: <1205272782.3679.76.camel@bohlsen> References: <1205272782.3679.76.camel@bohlsen> Message-ID: I like using lambda for this, but you could also put it into a function. windows = [] win32gui.EnumWindows(lambda hwnd, resultList: resultList.append(hwnd), windows) This will populate windows with all the hwnds. -Kyle Rickey -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Julius Sent: Tuesday, March 11, 2008 5:00 PM To: python-win32 at python.org Subject: [python-win32] win32gui.EnumWindows, documentation? Hi, im new to python in generell and was wondering where i would find the api to win32gui.EnumWindows? I know one of its arguments is a callback function, but i cant find any information how it should look like? Is this another win32 python implementation or is the site just called activestate? Ive installed Mark Hammond's win32 extensions http://aspn.activestate.com/ASPN/docs/ActivePython/2.2/PyWin32/win32gui_ _EnumWindows_meth.html Julius _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From commercials at gmx.net Tue Mar 11 23:52:08 2008 From: commercials at gmx.net (Julius) Date: Tue, 11 Mar 2008 23:52:08 +0100 Subject: [python-win32] win32gui.EnumWindows, documentation? In-Reply-To: References: <1205272782.3679.76.camel@bohlsen> Message-ID: <1205275928.3679.90.camel@bohlsen> My fault(already got that one running), i meant the win32gui.EnumChildWindows(currentHwnd, windowEnumerationHandler, childWindows) function. from what i understand the purpose of this function is to return the childwindows from a top window - if this is right why not just pass a topwindow as argument and return a list of childwindows? On Tue, 2008-03-11 at 17:04 -0500, Rickey, Kyle W wrote: > I like using lambda for this, but you could also put it into a function. > > windows = [] > win32gui.EnumWindows(lambda hwnd, resultList: resultList.append(hwnd), > windows) > > This will populate windows with all the hwnds. > > -Kyle Rickey > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org] On Behalf Of Julius > Sent: Tuesday, March 11, 2008 5:00 PM > To: python-win32 at python.org > Subject: [python-win32] win32gui.EnumWindows, documentation? > > Hi, > > im new to python in generell and was wondering where i would find the > api to win32gui.EnumWindows? > I know one of its arguments is a callback function, but i cant find any > information how it should look like? > > Is this another win32 python implementation or is the site just called > activestate? Ive installed Mark Hammond's win32 extensions > http://aspn.activestate.com/ASPN/docs/ActivePython/2.2/PyWin32/win32gui_ > _EnumWindows_meth.html > > > > > Julius From timr at probo.com Wed Mar 12 00:13:45 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 11 Mar 2008 16:13:45 -0700 Subject: [python-win32] win32gui.EnumWindows, documentation? In-Reply-To: <1205275928.3679.90.camel@bohlsen> References: <1205272782.3679.76.camel@bohlsen> <1205275928.3679.90.camel@bohlsen> Message-ID: <47D71229.3020106@probo.com> Julius wrote: > My fault(already got that one running), i meant the > win32gui.EnumChildWindows(currentHwnd, windowEnumerationHandler, > childWindows) > function. > > from what i understand the purpose of this function is to return the > childwindows from a top window - if this is right why not just pass a > topwindow as argument and return a list of childwindows? > Windows APIs don't ever return lists of things, because it present a memory management difficulty. Who allocates, who owns, who releases, etc. Instead, they all use the "enumeration callback" concept. That way, if you want a list, you can construct and maintain it yourself. If you just want the list of handles, you can do something like this: childlist = [] win32ui.EnumChildWindows( hwnd, lamba hwnd,oldlist: oldlist.append( hwnd ), childlist ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mail at timgolden.me.uk Wed Mar 12 01:12:22 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 12 Mar 2008 00:12:22 +0000 Subject: [python-win32] win32gui.EnumWindows, documentation? In-Reply-To: <1205272782.3679.76.camel@bohlsen> References: <1205272782.3679.76.camel@bohlsen> Message-ID: <47D71FE6.2030707@timgolden.me.uk> Julius wrote: > Hi, > > im new to python in generell and was wondering where i would find the > api to win32gui.EnumWindows? > I know one of its arguments is a callback function, but i cant find any > information how it should look like? > > Is this another win32 python implementation or is the site just called > activestate? Ive installed Mark Hammond's win32 extensions > http://aspn.activestate.com/ASPN/docs/ActivePython/2.2/PyWin32/win32gui__EnumWindows_meth.html There's a worked example here: http://timgolden.me.uk/python/win32_how_do_i/find-the-window-for-my-subprocess.html (which may or may not ease your problems!) TJG From patter001 at gmail.com Wed Mar 12 03:04:23 2008 From: patter001 at gmail.com (Kevin Patterson) Date: Tue, 11 Mar 2008 22:04:23 -0400 Subject: [python-win32] How to create a com_record? In-Reply-To: References: <0a0a01c86619$2feff650$8fcfe2f0$@com.au> <0a5201c866b5$88447280$98cd5780$@com.au> <0a8d01c866de$b3b97db0$1b2c7910$@com.au> <009001c8677f$8931d0f0$9b9572d0$@com.au> Message-ID: I found the comtypes equivalent if that helps any. The generated comtypes file looks like this: COMMETHOD([dispid(1610743812), helpstring(u'GetInterface() method')], HRESULT, 'GetInterface', ( ['in'], POINTER(GUID), 'riid' ), ( ['retval', 'out'], POINTER(POINTER(IUnknown)), 'ppUnknown' )), With the above, I'm able to use the comtypes.GUID.GUID structure to pass the information over through the COM. Unfortunately I still can't find the win32com equivalent of passing my structure through the COM. The win32com generated py file is saying that it expects a VT_RECORD, but from above, maybe it should really be expecting a POINTER ? or VT_POINTER ? I tried to modify the win32com generated file to take a VT_PTR but that didn't seem to help. I really don't want to redo my infastructure in comtypes, so if anyone knows the win32com equivalent, that would be awesome. In the meantime, I'll keep digging, and will post if I find more. On Tue, Mar 11, 2008 at 12:58 PM, Kevin Patterson wrote: > Old thread, but I got a little more data on the function. The function > actually has a REFIID as the first parameter. This apparently is a standard > structure for C COM code. I'm not entirely sure why the win32com changes > the REFIID to be a VT_RECORD. Does the following definition of the functions > help at all (they are from the IDL file) > > HRESULT GetInterface( [in] REFIID riid, [out, retval, iid_is(riid)] > IUnknown** ppUnknown); > should be same as: > HRESULT GetInterface( [in] GUID* pGuid, [out, retval, iid_is(pGuid)] > IUnknown** ppUnknown); > > > > On Mon, Feb 4, 2008 at 6:44 PM, Mark Hammond > wrote: > > > > guid = win32com.client.Record("GUID", some_ob) > > > > > I don't have the some_obj that allows me to build "GUID". > > > > It should be any object from the same typelib - almost certainly > > whatever > > object you intend passing this record to. > > > > > VB.NET (GetType) and C++ (__uuid) both already know that a GUID is a > > record. > > > > C++ doesn't know it is a COM record. A COM record is something quite > > different to a C/C++ struct or from .NET types. A COM record is > > specifically designed to be cross-language. > > > > > It seems the python CLSID is the same thing, but i don't know what to > > call > > > > > to get a CLSID that is a com_record type. > > > > As I've explained, we are looking for the COM record definition you are > > trying to use. A C++ struct definition for a GUID is *not* what you are > > looking for - you are looking for the COM record definition of a GUID. > > I > > see now that you simply copied me a C++ struct you found, which is not > > at > > all useful in this context. > > > > To clarify: in a *typelib* you will find a struct definition that you > > are > > trying to use. Finding a struct definition of the same name somewhere > > else > > is not suitable. > > > > > Am I understanding the win32com.client.Record call correctly? It needs > > GUID to be defined by the > > > COM right? > > > > Not "defined by COM", but "defined using COM" - the author of a typelib > > must > > have defined it somewhere. > > > > > Its odd b/c the GIUD (python's CLSID) is all over the COM definitions > > its > > just type > > > VT_RECORD type that I'm not understanding how to convert to. > > > > Yes, I'm afraid you are confused. All existing GUID or CLSID > > definitions > > you can find are useless - there is only 1 that is relevant, and that > > will > > be defined in a typelib. > > > > I think the confusion is such that you need to find basic docs for the > > object, so we can get back to square 1. > > > > Mark > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080311/8d16a1d1/attachment-0001.htm From commercials at gmx.net Wed Mar 12 16:03:38 2008 From: commercials at gmx.net (Julius) Date: Wed, 12 Mar 2008 16:03:38 +0100 Subject: [python-win32] win32gui.EnumWindows, documentation? In-Reply-To: <47D71229.3020106@probo.com> References: <1205272782.3679.76.camel@bohlsen> <1205275928.3679.90.camel@bohlsen> <47D71229.3020106@probo.com> Message-ID: <1205334218.3679.99.camel@bohlsen> On Tue, 2008-03-11 at 16:13 -0700, Tim Roberts wrote: > Julius wrote: > > My fault(already got that one running), i meant the > > win32gui.EnumChildWindows(currentHwnd, windowEnumerationHandler, > > childWindows) > > function. > > > > from what i understand the purpose of this function is to return the > > childwindows from a top window - if this is right why not just pass a > > topwindow as argument and return a list of childwindows? > > > > Windows APIs don't ever return lists of things, because it present a > memory management difficulty. Who allocates, who owns, who releases, > etc. Instead, they all use the "enumeration callback" concept. That > way, if you want a list, you can construct and maintain it yourself. > > If you just want the list of handles, you can do something like this: > childlist = [] > win32ui.EnumChildWindows( hwnd, lamba hwnd,oldlist: oldlist.append( > hwnd ), childlist ) > Ok, havent tried it yet but im sure it will work. But why isnt there any documentation what the arguments are good for? Julius From timr at probo.com Wed Mar 12 17:59:05 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 12 Mar 2008 09:59:05 -0700 Subject: [python-win32] win32gui.EnumWindows, documentation? In-Reply-To: <1205334218.3679.99.camel@bohlsen> References: <1205272782.3679.76.camel@bohlsen> <1205275928.3679.90.camel@bohlsen> <47D71229.3020106@probo.com> <1205334218.3679.99.camel@bohlsen> Message-ID: <47D80BD9.4030106@probo.com> Julius wrote: > On Tue, 2008-03-11 at 16:13 -0700, Tim Roberts wrote: > >> Julius wrote: >> >>> My fault(already got that one running), i meant the >>> win32gui.EnumChildWindows(currentHwnd, windowEnumerationHandler, >>> childWindows) >>> function. >>> >>> from what i understand the purpose of this function is to return the >>> childwindows from a top window - if this is right why not just pass a >>> topwindow as argument and return a list of childwindows? >>> >>> >> Windows APIs don't ever return lists of things, because it present a >> memory management difficulty. Who allocates, who owns, who releases, >> etc. Instead, they all use the "enumeration callback" concept. That >> way, if you want a list, you can construct and maintain it yourself. >> >> If you just want the list of handles, you can do something like this: >> childlist = [] >> win32ui.EnumChildWindows( hwnd, lamba hwnd,oldlist: oldlist.append( >> hwnd ), childlist ) >> > > Ok, havent tried it yet but im sure it will work. > Actually, if that's really what I typed, I made a mistake. It's win32gui, not win32ui. > But why isnt there any documentation what the arguments are good for? > In part, because these are simple mappings of Windows APIs. You can go to MSDN to get information on the actual parameters to EnumChildWindows in excruciating detail. In most cases, the mapping from the C API to the Python API is quite clear, and this is one such case. The C API gets a top-level window handle, a callback function, and a context parameter. That's exactly what the win32ui version wants. It would be a very large effort with a very small payback to retype all of the Windows API documentation in Python terms. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From clintonlee.taylor at gmail.com Wed Mar 12 22:09:29 2008 From: clintonlee.taylor at gmail.com (Clinton Lee Taylor) Date: Wed, 12 Mar 2008 23:09:29 +0200 Subject: [python-win32] WABAccess help ... Message-ID: Greetings ... Take two ... This time I think I found something a little better ... http://sourceforge.net/projects/wabaccess/ Another LGPL com lib to access Windows Address Book ... But this one seems to work with Python ... Okay, so I'm asking again, if anybody (maybe Roger again ... ) Could help with a basic working example of how to get just something listing out of the WAB ... Spend a whole night, with the following code, but can only put stuff into the WAB, not get a list of e-mail address ... import win32com.client objSession = win32com.client.gencache.EnsureDispatch("WABAccess.Session") print objSession objSession.Open(False) if objSession.Identities.LastIdentity == "{00000000-0000-0000-0000-000000000000}": print "No Identity Selected" else: print "The Identity " + objSession.Identities(objSession.Identities.LastIdentity).Name + " is selected" print objSession.Identities.DefaultIdentity print objSession.Identities.Count print objSession.Containers.Count objContainer = objSession.Containers(1) objMyContact=objContainer.Elements.NewContact( False, "Clinton Taylor" ) # FixMe, throught all the constant things would be import somehow ... PR_EMAIL_ADDRESS = 0x3003001F PR_BUSINESS_HOME_PAGE = 0x3A51001F PR_COMPANY_NAME = 0x3A16001F PR_BUSINESS_ADDRESS_CITY = 0x3A27001F City = "Paris" # objCityProperty = objMyContact.Properties.Add( wabPR_BUSINESS_ADDRESS_CITY, City ) objCityProperty = objMyContact.Properties.Add( PR_BUSINESS_ADDRESS_CITY, City ) # Adding an email address objMyContact.Properties.Add (PR_EMAIL_ADDRESS, "john.smith at mysociety.com") # Adding the Web page property objMyContact.Properties.Add (PR_BUSINESS_HOME_PAGE, "http://www.mysociety.com") # Adding the company name property objProperty = objMyContact.Properties.Add(PR_COMPANY_NAME, "") # Changing the company name property objProperty.Value = "My Society Name" objMyContact.ShowDetails objMyRecipients = objSession.ShowAddress() objSession.Refresh objSession.Close print "Done." From rwupole at msn.com Wed Mar 12 22:14:10 2008 From: rwupole at msn.com (Roger Upole) Date: Wed, 12 Mar 2008 17:14:10 -0400 Subject: [python-win32] Re: OE/WAB help with VB ... Message-ID: Clinton Lee Taylor wrote: > Greetings ... > > Thanks again for the quick response ... >> Clinton Lee Taylor wrote: >> > I think I get this because com objects have to be "imported" ... But >> > this ActiveX object does not seem to have a "type lib"? ... >> It appears the type info is embedded in the dll itself, rather than >> shipped as a separate .tlb. > >> I get the same error after generating the wrapper from the type info. >> Try clearing your \win32com\genpy folder, and run it without the >> EnsureDispatch. There may be something wrong with the type >> info, but it would take a lot of digging to find out exactly what. > Okay, the little library is LGPL and the source is about, would we be > able to get the details from the header files or something else? > The .idl file is where the type info comes from. Roger From timr at probo.com Wed Mar 12 22:23:02 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 12 Mar 2008 14:23:02 -0700 Subject: [python-win32] WABAccess help ... In-Reply-To: References: Message-ID: <47D849B6.7040904@probo.com> Clinton Lee Taylor wrote: > Take two ... This time I think I found something a little better ... > http://sourceforge.net/projects/wabaccess/ > > Another LGPL com lib to access Windows Address Book ... But this one > seems to work with Python ... > > Okay, so I'm asking again, if anybody (maybe Roger again ... ) Could > help with a basic working example of how to get just something listing > out of the WAB ... > > Spend a whole night, with the following code, but can only put stuff > into the WAB, not get a list of e-mail address ... > Have you gone through the sample code at wabaccess.sourceeforge.net? Based on samples, something like this should work: for c in objSession.Containers.Count: ctr = objSession.Containers(c) for cid in ctr.Elements.Count print ctr.Elements(cid).Name print ctr.Elements(cid).Properties( PR_EMAIL_ADDRESS ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rwupole at msn.com Wed Mar 12 22:28:04 2008 From: rwupole at msn.com (Roger Upole) Date: Wed, 12 Mar 2008 17:28:04 -0400 Subject: [python-win32] Re: WABAccess help ... Message-ID: Clinton Lee Taylor wrote: > Greetings ... > > Take two ... This time I think I found something a little better ... > http://sourceforge.net/projects/wabaccess/ > > Another LGPL com lib to access Windows Address Book ... But this one > seems to work with Python ... > > Okay, so I'm asking again, if anybody (maybe Roger again ... ) Could > help with a basic working example of how to get just something listing > out of the WAB ... > > Spend a whole night, with the following code, but can only put stuff > into the WAB, not get a list of e-mail address ... > > > import win32com.client > > objSession = win32com.client.gencache.EnsureDispatch("WABAccess.Session") > > print objSession > > objSession.Open(False) > > if objSession.Identities.LastIdentity == > "{00000000-0000-0000-0000-000000000000}": > print "No Identity Selected" > else: > print "The Identity " + > objSession.Identities(objSession.Identities.LastIdentity).Name + " is > selected" > > print objSession.Identities.DefaultIdentity > print objSession.Identities.Count > > print objSession.Containers.Count > > objContainer = objSession.Containers(1) > > objMyContact=objContainer.Elements.NewContact( False, "Clinton Taylor" ) > > # FixMe, throught all the constant things would be import somehow ... > PR_EMAIL_ADDRESS = 0x3003001F > PR_BUSINESS_HOME_PAGE = 0x3A51001F > PR_COMPANY_NAME = 0x3A16001F > PR_BUSINESS_ADDRESS_CITY = 0x3A27001F These show up in win32com.client.constants, eg >>> win32com.client.constants.wabPR_EMAIL_ADDRESS 805503007 > City = "Paris" > # objCityProperty = objMyContact.Properties.Add( > wabPR_BUSINESS_ADDRESS_CITY, City ) > objCityProperty = objMyContact.Properties.Add( PR_BUSINESS_ADDRESS_CITY, > City ) > > # Adding an email address > objMyContact.Properties.Add (PR_EMAIL_ADDRESS, "john.smith at mysociety.com") > # Adding the Web page property > objMyContact.Properties.Add (PR_BUSINESS_HOME_PAGE, > "http://www.mysociety.com") > # Adding the company name property > objProperty = objMyContact.Properties.Add(PR_COMPANY_NAME, "") > # Changing the company name property > objProperty.Value = "My Society Name" > > objMyContact.ShowDetails > > objMyRecipients = objSession.ShowAddress() > > objSession.Refresh > > objSession.Close > print "Done." You're missing some parens from the ShowDetails and Refresh lines. With those in place, this code works for me (at least on XP, haven't tried it on Vista yet) Roger From clintonlee.taylor at gmail.com Wed Mar 12 22:28:26 2008 From: clintonlee.taylor at gmail.com (Clinton Lee Taylor) Date: Wed, 12 Mar 2008 23:28:26 +0200 Subject: [python-win32] WABAccess help ... In-Reply-To: References: Message-ID: Sorry ... JFYI ... How to dump all contacts in the Windows Address Book ... ;-) > Spend a whole night, with the following code, but can only put stuff > into the WAB, not get a list of e-mail address ... Really simple to dump all the contacts ... import win32com.client objSession = win32com.client.gencache.EnsureDispatch("WABAccess.Session") print objSession objSession.Open(False) if objSession.Identities.LastIdentity == "{00000000-0000-0000-0000-000000000000}": print "No Identity Selected" else: print "The Identity " + objSession.Identities(objSession.Identities.LastIdentity).Name + " is selected" print objSession.Identities.DefaultIdentity print objSession.Identities.Count print objSession.Containers.Count for oCont in objSession.Containers: for oItem in oCont.Elements: print oItem.Name objSession.Refresh objSession.Close print "Done." Now to figure how to get only contacts with fax numbers and print the name and fax number ... Thanks Mailed LeeT From kevin.horn at gmail.com Wed Mar 12 23:36:06 2008 From: kevin.horn at gmail.com (Kevin Horn) Date: Wed, 12 Mar 2008 17:36:06 -0500 Subject: [python-win32] WABAccess help ... In-Reply-To: References: Message-ID: <562bcc10803121536q192d7a9fg2e5fc57a090e01ca@mail.gmail.com> On Wed, Mar 12, 2008 at 4:28 PM, Clinton Lee Taylor < clintonlee.taylor at gmail.com> wrote: > > Now to figure how to get only contacts with fax numbers and print the > name and fax number ... > > Thanks > Mailed > LeeT > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > Unless you're dealing with a really large number of contacts, I would probably just do the "Simplest Possible Thing"(tm) and read the all into a list, filter the list using a list comprehension, then print the results. But that's just me...I like to get out of COM as soon as possible :) Kevin Horn -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080312/3d8e4837/attachment.htm From kevin at koconnor.net Fri Mar 14 02:09:10 2008 From: kevin at koconnor.net (Kevin O'Connor) Date: Thu, 13 Mar 2008 21:09:10 -0400 Subject: [python-win32] excelRTDServer demo not working Message-ID: <20080314010910.GA16449@double.lan> Hi, I've downloaded pywin32-210.zip and installed it on my "Windows XP Professional" machine. I've been trying to get the demo com/win32com/demos/excelRTDServer.py to work, but have not had success. I'm using MS Excel 2003. When I add a cell in Excel (with =RTD("Python.RTD.TimeServer","","seconds","5")) I get a cryptic "#N/A". When I run the excelRTDServer program it states that it has successfully registered. I can instantiate an object of "Python.RTD.TimeServer" from the win32com ide. I can register with "--debug" and see trace messages when I instantiate it from win32com ide. However, when I launch Excel with the above cell formula, I don't see any trace messages at all. I have disabled security on macros in Excel. Any ideas? Can anyone confirm if the demo works elsewhere? Thanks in advance, -Kevin From chris at slort.org Fri Mar 14 03:46:16 2008 From: chris at slort.org (Christopher Nilsson) Date: Fri, 14 Mar 2008 13:46:16 +1100 Subject: [python-win32] excelRTDServer demo not working In-Reply-To: <20080314010910.GA16449@double.lan> References: <20080314010910.GA16449@double.lan> Message-ID: <29a42920803131946v7e335b7dt8d2b26bc0e1f96d4@mail.gmail.com> It's been ages since I looked at this, but you need to make sure the constants at the top of the module match your version of excel. The ones that are currently there are for Excel XP (which is the one before the version you're using, I believe): EXCEL_TLB_GUID = '{00020813-0000-0000-C000-000000000046}' EXCEL_TLB_LCID = 0 EXCEL_TLB_MAJOR = 1 EXCEL_TLB_MINOR = 4 There are very likely much nicer, and dynamic, ways to obtain these values now. I did have the docs at one stage, but someone else on the list can probably answer faster than I can find them. Unfortunately I no longer have a copy of excel to play with. I promise it was working with Office XP. :) Cheers, Chris. On 14/03/2008, Kevin O'Connor wrote: > Hi, > > I've downloaded pywin32-210.zip and installed it on my "Windows XP > Professional" machine. I've been trying to get the demo > com/win32com/demos/excelRTDServer.py to work, but have not had > success. I'm using MS Excel 2003. > > When I add a cell in Excel (with > =RTD("Python.RTD.TimeServer","","seconds","5")) I get a cryptic "#N/A". > > When I run the excelRTDServer program it states that it has > successfully registered. I can instantiate an object of > "Python.RTD.TimeServer" from the win32com ide. I can register with > "--debug" and see trace messages when I instantiate it from win32com > ide. However, when I launch Excel with the above cell formula, I > don't see any trace messages at all. > > I have disabled security on macros in Excel. > > Any ideas? Can anyone confirm if the demo works elsewhere? > > Thanks in advance, > -Kevin > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From patter001 at gmail.com Fri Mar 14 04:02:25 2008 From: patter001 at gmail.com (Kevin Patterson) Date: Thu, 13 Mar 2008 23:02:25 -0400 Subject: [python-win32] How to create a com_record? In-Reply-To: References: <0a0a01c86619$2feff650$8fcfe2f0$@com.au> <0a5201c866b5$88447280$98cd5780$@com.au> <0a8d01c866de$b3b97db0$1b2c7910$@com.au> <009001c8677f$8931d0f0$9b9572d0$@com.au> Message-ID: Ok, more digging, it looks like the OLE Automation TypeLib should have a GUID Record defined. I see this when using the Python Object Browser However, when I generate the py file for the OLE Automation type library, I don't see GUID in the RecordMap (or any reference to the GUID Record)...Is there suppose to be something in the generated file, but maybe its not working ? How do I actually create one of these Records ? On Tue, Mar 11, 2008 at 10:04 PM, Kevin Patterson wrote: > I found the comtypes equivalent if that helps any. The generated comtypes > file looks like this: > > COMMETHOD([dispid(1610743812), helpstring(u'GetInterface() method')], > HRESULT, 'GetInterface', > ( ['in'], POINTER(GUID), 'riid' ), > ( ['retval', 'out'], POINTER(POINTER(IUnknown)), 'ppUnknown' > )), > > With the above, I'm able to use the comtypes.GUID.GUID structure to pass > the information over through the COM. Unfortunately I still can't find the > win32com equivalent of passing my structure through the COM. > > The win32com generated py file is saying that it expects a VT_RECORD, but > from above, maybe it should really be expecting a POINTER ? or VT_POINTER ? > I tried to modify the win32com generated file to take a VT_PTR but that > didn't seem to help. I really don't want to redo my infastructure in > comtypes, so if anyone knows the win32com equivalent, that would be awesome. > > In the meantime, I'll keep digging, and will post if I find more. > > > > On Tue, Mar 11, 2008 at 12:58 PM, Kevin Patterson > wrote: > > > Old thread, but I got a little more data on the function. The function > > actually has a REFIID as the first parameter. This apparently is a standard > > structure for C COM code. I'm not entirely sure why the win32com changes > > the REFIID to be a VT_RECORD. Does the following definition of the functions > > help at all (they are from the IDL file) > > > > HRESULT GetInterface( [in] REFIID riid, [out, retval, iid_is(riid)] > > IUnknown** ppUnknown); > > should be same as: > > HRESULT GetInterface( [in] GUID* pGuid, [out, retval, iid_is(pGuid)] > > IUnknown** ppUnknown); > > > > > > > > On Mon, Feb 4, 2008 at 6:44 PM, Mark Hammond > > wrote: > > > > > > guid = win32com.client.Record("GUID", some_ob) > > > > > > > I don't have the some_obj that allows me to build "GUID". > > > > > > It should be any object from the same typelib - almost certainly > > > whatever > > > object you intend passing this record to. > > > > > > > VB.NET (GetType) and C++ (__uuid) both already know that a GUID is a > > > record. > > > > > > C++ doesn't know it is a COM record. A COM record is something quite > > > different to a C/C++ struct or from .NET types. A COM record is > > > specifically designed to be cross-language. > > > > > > > It seems the python CLSID is the same thing, but i don't know what > > > to call > > > > > > > to get a CLSID that is a com_record type. > > > > > > As I've explained, we are looking for the COM record definition you > > > are > > > trying to use. A C++ struct definition for a GUID is *not* what you > > > are > > > looking for - you are looking for the COM record definition of a GUID. > > > I > > > see now that you simply copied me a C++ struct you found, which is not > > > at > > > all useful in this context. > > > > > > To clarify: in a *typelib* you will find a struct definition that you > > > are > > > trying to use. Finding a struct definition of the same name somewhere > > > else > > > is not suitable. > > > > > > > Am I understanding the win32com.client.Record call correctly? It > > > needs > > > GUID to be defined by the > > > > COM right? > > > > > > Not "defined by COM", but "defined using COM" - the author of a > > > typelib must > > > have defined it somewhere. > > > > > > > Its odd b/c the GIUD (python's CLSID) is all over the COM > > > definitions its > > > just type > > > > VT_RECORD type that I'm not understanding how to convert to. > > > > > > Yes, I'm afraid you are confused. All existing GUID or CLSID > > > definitions > > > you can find are useless - there is only 1 that is relevant, and that > > > will > > > be defined in a typelib. > > > > > > I think the confusion is such that you need to find basic docs for the > > > object, so we can get back to square 1. > > > > > > Mark > > > > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080313/3a571f85/attachment.htm From le.dahut at laposte.net Fri Mar 14 11:38:28 2008 From: le.dahut at laposte.net (le dahut) Date: Fri, 14 Mar 2008 11:38:28 +0100 Subject: [python-win32] Error 1789 during logon, except not really called Message-ID: <47DA55A4.8010601@laposte.net> Hello, I'm using this code : mypdc = 'mypdc' dusers = 'DomName\DomainUsers' obj = 'C:\\Mylogfile.log' try: domainusers_sid = wsec.LookupAccountName(mypdc, dusers)[0] info = wsec.DACL_SECURITY_INFORMATION sd = wsec.GetFileSecurity(obj, info) acl = sd.GetSecurityDescriptorDacl() acl.AddAccessAllowedAceEx(wsec.ACL_REVISION_DS, wsec.OBJECT_INHERIT_ACE, wf.FILE_ALL_ACCESS, domainusers_sid) # maj du Security Descriptor sd.SetSecurityDescriptorDacl(1, acl, 0) # application sur l'objet wsec.SetFileSecurity(obj, info, sd) except Exception, e: logging.error("ACLs error %s"%([obj, dusers, e])) logging.debug('Error %s'%traceback.print_exc()) At logon time, it can occur that wsec.LookupAccountName fails. The except statement is called but an exception is thrown as well and I get a file logon.exe.log in which I can read the traceback. And finally traceback.print_exc() returns None. Why does this produce a traceback instead of really except it ? From siddhartha.veedaluru at gmail.com Fri Mar 14 13:22:49 2008 From: siddhartha.veedaluru at gmail.com (siddhartha veedaluru) Date: Fri, 14 Mar 2008 17:52:49 +0530 Subject: [python-win32] Library not Registered Error while running WMI example script Message-ID: <424b71ec0803140522g2d8da65o4da39dadbacd8e8@mail.gmail.com> Hello, I have installed win32 extensions on my windows 2003 server i'm using python 2.5.1. downloaded the wmi module 1.3.2 to my machine used "python setup.py install" to install the module i tried run an example mentioned in the web page. it gave the following error. File "C:\Python25\Lib\site-packages\wmi.py", line 157, in __init__ comobj._oleobj_.GetTypeInfo().GetContainingTypeLib()[0].GetTypeComp() pywintypes.com_error: (-2147319779, 'Library not registered.', None, None) Script terminated. Can you Please help me in making this working. Thanks a million Siddhartha -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080314/da81400c/attachment.htm From kevin at koconnor.net Fri Mar 14 13:46:25 2008 From: kevin at koconnor.net (Kevin O'Connor) Date: Fri, 14 Mar 2008 08:46:25 -0400 Subject: [python-win32] excelRTDServer demo not working In-Reply-To: <29a42920803131946v7e335b7dt8d2b26bc0e1f96d4@mail.gmail.com> References: <20080314010910.GA16449@double.lan> <29a42920803131946v7e335b7dt8d2b26bc0e1f96d4@mail.gmail.com> Message-ID: <20080314124625.GA19974@double.lan> On Fri, Mar 14, 2008 at 01:46:16PM +1100, Christopher Nilsson wrote: > It's been ages since I looked at this, but you need to make sure the > constants at the top of the module match your version of excel. The > ones that are currently there are for Excel XP (which is the one > before the version you're using, I believe): > > EXCEL_TLB_GUID = '{00020813-0000-0000-C000-000000000046}' > EXCEL_TLB_LCID = 0 > EXCEL_TLB_MAJOR = 1 > EXCEL_TLB_MINOR = 4 Hi Chris, The Python COM browser shows the same GUID for the excel type libraries. It does report 'Microsoft Excel 11.0 Object Library' instead of 'version 10' which is referenced in the code. However, if I change the MAJOR to 2, I can't register the class at all (it reports a library not registered error). I can change the minor (eg, to 5 but it still doesn't work). Any ideas where I could get the actual numbers from? Thanks again, -Kevin From mail at timgolden.me.uk Fri Mar 14 13:59:26 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 14 Mar 2008 12:59:26 +0000 Subject: [python-win32] Library not Registered Error while running WMI example script In-Reply-To: <424b71ec0803140522g2d8da65o4da39dadbacd8e8@mail.gmail.com> References: <424b71ec0803140522g2d8da65o4da39dadbacd8e8@mail.gmail.com> Message-ID: <47DA76AE.2040809@timgolden.me.uk> siddhartha veedaluru wrote: > I have installed win32 extensions on my windows 2003 server > i'm using python 2.5.1. > > downloaded the wmi module 1.3.2 to my machine > used > > "python setup.py install" > > to install the module > > i tried run an example mentioned in the web page. it gave the following > error. > > File "C:\Python25\Lib\site-packages\wmi.py", line 157, in __init__ > comobj._oleobj_.GetTypeInfo().GetContainingTypeLib()[0].GetTypeComp() > pywintypes.com_error: (-2147319779, 'Library not registered.', None, None) > Script terminated. Just to test, could you run this code to see if it produces the same result? (This is basically what the wmi module does behind the scenes). import win32com.client win32com.client.GetObject ("winmgmts:") TJG From le.dahut at laposte.net Fri Mar 14 13:59:25 2008 From: le.dahut at laposte.net (le dahut) Date: Fri, 14 Mar 2008 13:59:25 +0100 Subject: [python-win32] Error 1789 during logon, except not really called In-Reply-To: <47DA55A4.8010601@laposte.net> References: <47DA55A4.8010601@laposte.net> Message-ID: <47DA76AD.4030004@laposte.net> Sorry I forgot some informations. The error is : 1789, 'LookupAccountName', "The trust relationship between this workstation and the primary domain failed." As I said, this doesn't always happen, sometimes logon runs successfully and ACLs are correctly set (this is why I use 'LookupAccountName'). If I try it in command line, the try/except statement is correctly run : >>> import win32security as wsec >>> wsec.LookupAccountName('','DomainUsers') # this should be working (, u'CONDA', 2) >>> wsec.LookupAccountName('fakeserver','DomainUsers') # this not Traceback (most recent call last): File "", line 1, in pywintypes.error: (5, 'LookupAccountName', 'Access denied.') >>> try:wsec.LookupAccountName('fakeserver','DomainUsers') ... except: print 'oo' ... oo Thanks in advance. le dahut wrote : > Hello, > > I'm using this code : > mypdc = 'mypdc' > dusers = 'DomName\DomainUsers' > obj = 'C:\\Mylogfile.log' > try: > domainusers_sid = wsec.LookupAccountName(mypdc, dusers)[0] > info = wsec.DACL_SECURITY_INFORMATION > sd = wsec.GetFileSecurity(obj, info) > acl = sd.GetSecurityDescriptorDacl() > acl.AddAccessAllowedAceEx(wsec.ACL_REVISION_DS, > wsec.OBJECT_INHERIT_ACE, wf.FILE_ALL_ACCESS, domainusers_sid) > # maj du Security Descriptor > sd.SetSecurityDescriptorDacl(1, acl, 0) > # application sur l'objet > wsec.SetFileSecurity(obj, info, sd) > except Exception, e: > logging.error("ACLs error %s"%([obj, dusers, e])) > logging.debug('Error %s'%traceback.print_exc()) > > At logon time, it can occur that wsec.LookupAccountName fails. The > except statement is called but an exception is thrown as well and I get > a file logon.exe.log in which I can read the traceback. And finally > traceback.print_exc() returns None. > > Why does this produce a traceback instead of really except it ? > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From mail at timgolden.me.uk Fri Mar 14 14:24:11 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 14 Mar 2008 13:24:11 +0000 Subject: [python-win32] Error 1789 during logon, except not really called In-Reply-To: <47DA76AD.4030004@laposte.net> References: <47DA55A4.8010601@laposte.net> <47DA76AD.4030004@laposte.net> Message-ID: <47DA7C7B.7030304@timgolden.me.uk> [.. snipped ..] le dahut: I'm not sure which bit is wrong. I could point out that traceback.print_exc () will *print* the current exception (to stdout / stderr, not sure) and *return* None, so your line: logging.debug('Error %s'%traceback.print_exc()) probably doesn't do what you want, as it will log the string "Error None". But this may be no more than incidental to your issue. >> At logon time, it can occur that wsec.LookupAccountName fails. The >> except statement is called but an exception is thrown as well and I get >> a file logon.exe.log in which I can read the traceback. And finally >> traceback.print_exc() returns None. >> >> Why does this produce a traceback instead of really except it ? The fact that you're getting "logon.exe.log" suggests to me that you're using py2exe, which has its own setup for trapping traceback and things which go to stdout. Is this the case? Hopefully someone else can see more clearly than I am, but if they can't, you're going to have to come up with a *really* small example of what does or doesn't work. TJG From Kyle.Rickey at bakerhughes.com Fri Mar 14 15:30:04 2008 From: Kyle.Rickey at bakerhughes.com (Rickey, Kyle W) Date: Fri, 14 Mar 2008 09:30:04 -0500 Subject: [python-win32] Running SQL queries on excel sheets Message-ID: I've got several excel sheets I would like to run SQL queries on and I've worked out a couple of ways, but I'm not sure what the best way would be. I've also got a problem where I can't connect to the excel file if someone is currently editing it. Given the following to code samples, which one is better? So I guess I'm asking if an ODBC or and ADO connection is better. import odbc, win32com.client file = "C:\\file.xls" search_term = "test" ##EXAMPLE 1## conn_string = "Driver={Microsoft Excel Driver (*.xls)};Dbq="+file+";READONLY=true;IMEX=1;" conn = odbc.odbc(conn_string) cur = conn.cursor() cur.execute(""""SELECT F5, F6, F7, F1 FROM [Excel 8.0;HDR=YES;IMEX=1;Database="+file+";].[Sheet1$B:H] WHERE LCASE(F6) LIKE '%"+search_term.lower()+"%'"""") rec = cur.fetchall() ##EXAMPLE 1## ##EXAMPLE 2## try: conn = win32com.client.Dispatch("ADODB.Connection") DSN = r""""PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA SOURCE="+file+"; Extended Properties='Excel 8.0; READONLY=true; IMEX=1';""" conn.Open(DSN) except win32com.client.pywintypes.com_error:#Someone editing file file2 = "C:\\temp.xls" if os.path.exists(file2): os.remove(file2) shutil.copy2(file, file2)#Copy file to C:\\ and read it from there file = file2 conn = win32com.client.Dispatch("ADODB.Connection") DSN = r"""PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA SOURCE="+file+"; Extended Properties='Excel 8.0; READONLY=true; IMEX=1';""" conn.Open(DSN) else: rec = [] rs = win32com.client.Dispatch("ADODB.Recordset") rs_name = "MyRecordset" rs.Open("""SELECT * FROM [Excel 8.0; HDR=YES; IMEX=1; Database="+file+";].[Sheet1$B:H] WHERE LCASE(F6) LIKE '%"""+search_term.lower()+"""%'""", conn) while not rs.EOF: lst = [] lst.append(rs.Fields.Item("F5").Value) lst.append(rs.Fields.Item("F6").Value) lst.append(rs.Fields.Item("F7").Value) lst.append(rs.Fields.Item("F1").Value) rec.append(lst) rs.MoveNext() ##EXAMPLE 2## -Kyle Rickey From mail at timgolden.me.uk Fri Mar 14 15:56:07 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 14 Mar 2008 14:56:07 +0000 Subject: [python-win32] Running SQL queries on excel sheets In-Reply-To: References: Message-ID: <47DA9207.8080402@timgolden.me.uk> Rickey, Kyle W wrote: > I've got several excel sheets I would like to run SQL queries on and > I've worked out a couple of ways, but I'm not sure what the best way > would be. I've also got a problem where I can't connect to the excel > file if someone is currently editing it. Given the following to code > samples, which one is better? So I guess I'm asking if an ODBC or and > ADO connection is better. [... snip code ...] To be frank, they both make me say "Uuughh" (which I think translates into American as "Eeewww"). I did try access Excel via SQL some years ago, but gave up in disgust. It just seemed to be a half-hearted addon to prove the power of ODBC in its early days by connecting to a system which wasn't really designed to support it. But maybe it's improved. Couple of things worth bearing in mind. The odbc module from pywin32 is, I think, effectively unsupported. There are several more modern and maintained alternatives. The option "par excellence" is the mxODBC module, but it's commercially licensed only, which may or may not be a problem. The other two are pyodbc and ceodbc. I've heard good things of both: the sqlalchemy guys use pyodbc as their preferred connection to SQL Server. Secondly, there is an adodbapi module which wraps the messy ADO plumbing into a Python dbapi-compliant module. It was unmaintained for a long while but has recently been picked up again (Vernon Cole?) and is due to be included in the next pywin32 release, I think. Obviously, all that is only helpful up to a point. Is there some reason why you can't just pull the data out straight into Python structures and take it from there (or even push it into a Sqlite memory database)? Perhaps you've got absolutely tons of data so extracting it would be a pain? If not, consider using one of the COM packages (win32com.client or comtypes) or something like pyExcelerator to pull it out. TJG From Kyle.Rickey at bakerhughes.com Fri Mar 14 16:14:36 2008 From: Kyle.Rickey at bakerhughes.com (Rickey, Kyle W) Date: Fri, 14 Mar 2008 10:14:36 -0500 Subject: [python-win32] Running SQL queries on excel sheets In-Reply-To: <47DA9207.8080402@timgolden.me.uk> References: <47DA9207.8080402@timgolden.me.uk> Message-ID: Tim, thanks for your response. I've got 7 excel files that need reading containing a total of ~6100 rows. I agree, about this code making me sick :) In a perfect world I would get all the data into our SQL server and write a front end for everyone that needs to access/modify the data, but that's a ways down the road. I've still got to convince people in the company that excel is NOT a good way to store database info! I don't have a problem extracting all the data and throwing it into sqlite, but the problem is I would need to extract all the data every time I wanted to run my query. I've also got some code laying around to COM into excel and read data, but it's not very pretty either. Now that I think of it, a good temporary solution might be to have an excel macro that runs whenever the file is open, then whenever someone saves changes to the excel file, it would dump all that data into our SQL server. Then whenever I get around to making that frontend, the data will already be in SQL. Thanks for your help. -Kyle Rickey -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Tim Golden Sent: Friday, March 14, 2008 9:56 AM Cc: python-win32 at python.org Subject: Re: [python-win32] Running SQL queries on excel sheets Rickey, Kyle W wrote: > I've got several excel sheets I would like to run SQL queries on and > I've worked out a couple of ways, but I'm not sure what the best way > would be. I've also got a problem where I can't connect to the excel > file if someone is currently editing it. Given the following to code > samples, which one is better? So I guess I'm asking if an ODBC or and > ADO connection is better. [... snip code ...] To be frank, they both make me say "Uuughh" (which I think translates into American as "Eeewww"). I did try access Excel via SQL some years ago, but gave up in disgust. It just seemed to be a half-hearted addon to prove the power of ODBC in its early days by connecting to a system which wasn't really designed to support it. But maybe it's improved. Couple of things worth bearing in mind. The odbc module from pywin32 is, I think, effectively unsupported. There are several more modern and maintained alternatives. The option "par excellence" is the mxODBC module, but it's commercially licensed only, which may or may not be a problem. The other two are pyodbc and ceodbc. I've heard good things of both: the sqlalchemy guys use pyodbc as their preferred connection to SQL Server. Secondly, there is an adodbapi module which wraps the messy ADO plumbing into a Python dbapi-compliant module. It was unmaintained for a long while but has recently been picked up again (Vernon Cole?) and is due to be included in the next pywin32 release, I think. Obviously, all that is only helpful up to a point. Is there some reason why you can't just pull the data out straight into Python structures and take it from there (or even push it into a Sqlite memory database)? Perhaps you've got absolutely tons of data so extracting it would be a pain? If not, consider using one of the COM packages (win32com.client or comtypes) or something like pyExcelerator to pull it out. TJG _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From le.dahut at laposte.net Fri Mar 14 16:40:34 2008 From: le.dahut at laposte.net (le dahut) Date: Fri, 14 Mar 2008 16:40:34 +0100 Subject: [python-win32] Error 1789 during logon, except not really called In-Reply-To: <47DA7C7B.7030304@timgolden.me.uk> References: <47DA55A4.8010601@laposte.net> <47DA76AD.4030004@laposte.net> <47DA7C7B.7030304@timgolden.me.uk> Message-ID: <47DA9C72.5030209@laposte.net> What strange is is that: try: wsec.LookupAccountName(...) except: print 'Error' shows : - a traceback, as if I didn't put LookupAccountName in a try/except statement - the string 'error' so the program has also switched to except as if the try/except has been correctly interpreted So we can say that I get the two behaviours in one. At the exception that the traceback is not complete, it only talks about the line containing LookupAccountName, not entire traceback (the caller function and its parents). Tim Golden a ?crit : > [.. snipped ..] > > le dahut: I'm not sure which bit is wrong. I could > point out that traceback.print_exc () will *print* > the current exception (to stdout / stderr, not sure) > and *return* None, so your line: > > logging.debug('Error %s'%traceback.print_exc()) > > probably doesn't do what you want, as it will > log the string "Error None". But this may be no > more than incidental to your issue. > > >> At logon time, it can occur that wsec.LookupAccountName fails. The > >> except statement is called but an exception is thrown as well and I get > >> a file logon.exe.log in which I can read the traceback. And finally > >> traceback.print_exc() returns None. > >> > >> Why does this produce a traceback instead of really except it ? > > The fact that you're getting "logon.exe.log" suggests to me that > you're using py2exe, which has its own setup for trapping > traceback and things which go to stdout. Is this the case? > > Hopefully someone else can see more clearly than I am, but > if they can't, you're going to have to come up with a *really* > small example of what does or doesn't work. > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From mail at timgolden.me.uk Fri Mar 14 16:53:07 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 14 Mar 2008 15:53:07 +0000 Subject: [python-win32] Error 1789 during logon, except not really called In-Reply-To: <47DA9C72.5030209@laposte.net> References: <47DA55A4.8010601@laposte.net> <47DA76AD.4030004@laposte.net> <47DA7C7B.7030304@timgolden.me.uk> <47DA9C72.5030209@laposte.net> Message-ID: <47DA9F63.4070603@timgolden.me.uk> le dahut wrote: > What strange is is that: > > try: > wsec.LookupAccountName(...) > except: > print 'Error' > > shows : > - a traceback, as if I didn't put LookupAccountName in a try/except > statement > - the string 'error' so the program has also switched to except as if > the try/except has been correctly interpreted > > So we can say that I get the two behaviours in one. At the exception > that the traceback is not complete, it only talks about the line > containing LookupAccountName, not entire traceback (the caller function > and its parents). Well that is an extremely clear description of the problem. And, unsurprisingly, I can't get it to fail at the interpreter or (just in case) from within a file. Is there any possibility that there's an atexit handler or a thread going on which is generating the other traceback? Or even a stray __del__ or something equally bizarre? Or maybe the code's dropping through after handling the exception to some other code which is printing the traceback? TJG From le.dahut at laposte.net Fri Mar 14 17:21:37 2008 From: le.dahut at laposte.net (le dahut) Date: Fri, 14 Mar 2008 17:21:37 +0100 Subject: [python-win32] Error 1789 during logon, except not really called In-Reply-To: <47DA9F63.4070603@timgolden.me.uk> References: <47DA55A4.8010601@laposte.net> <47DA76AD.4030004@laposte.net> <47DA7C7B.7030304@timgolden.me.uk> <47DA9C72.5030209@laposte.net> <47DA9F63.4070603@timgolden.me.uk> Message-ID: <47DAA611.9080502@laposte.net> Tim Golden wrote : > le dahut wrote: >> What strange is is that: >> >> try: >> wsec.LookupAccountName(...) >> except: >> print 'Error' >> >> shows : >> - a traceback, as if I didn't put LookupAccountName in a try/except >> statement >> - the string 'error' so the program has also switched to except as if >> the try/except has been correctly interpreted >> >> So we can say that I get the two behaviours in one. At the exception >> that the traceback is not complete, it only talks about the line >> containing LookupAccountName, not entire traceback (the caller function >> and its parents). > > Well that is an extremely clear description of the problem. And, > unsurprisingly, I can't get it to fail at the interpreter or > (just in case) from within a file. > > > Is there any possibility that there's an atexit handler or a thread > going on which is generating the other traceback? Or even a stray > __del__ or something equally bizarre? Or maybe the code's dropping > through after handling the exception to some other code which is > printing the traceback? > > Actually, the code doesn't break, it continues its execution as if try/except as done its work. It is run in a twisted reactor. "a stray _del_" could you be more precise ? From mail at timgolden.me.uk Fri Mar 14 17:24:11 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 14 Mar 2008 16:24:11 +0000 Subject: [python-win32] Running SQL queries on excel sheets In-Reply-To: References: <47DA9207.8080402@timgolden.me.uk> Message-ID: <47DAA6AB.5020704@timgolden.me.uk> Rickey, Kyle W wrote: > Tim, thanks for your response. I've got 7 excel files that need reading > containing a total of ~6100 rows. I agree, about this code making me > sick :) > > In a perfect world I would get all the data into our SQL server and > write a front end for everyone that needs to access/modify the data, but > that's a ways down the road. I've still got to convince people in the > company that excel is NOT a good way to store database info! > > I don't have a problem extracting all the data and throwing it into > sqlite, but the problem is I would need to extract all the data every > time I wanted to run my query. I've also got some code laying around to > COM into excel and read data, but it's not very pretty either. > > Now that I think of it, a good temporary solution might be to have an > excel macro that runs whenever the file is open, then whenever someone > saves changes to the excel file, it would dump all that data into our > SQL server. Then whenever I get around to making that frontend, the data > will already be in SQL. Thanks for your help. > > -Kyle Rickey Well you obviously know what you're about, but just to compare things a bit, I attach two small but complete pieces of code below. The first generates an Excel workbook of 6000 lines of data, each containing a hundred numbers randomly shuffled. The second (which is what I'm trying to get to) pulls the first 20 values from each row and inserts them into a Noddy table in a sqlite database. On my respectable-but-not-blazing machine, the first takes about thirty seconds, the second about two seconds. Now my data is ridiculously simple but I suppose I wanted to illustrate how easy it *could* be to pull all of the data from an Excel Workbook. Those with more rugged and real-world experience of doing this can chime in with all the crufty bits you'd have to cope with (such as date/time fields, concurrent access and the like). But perhaps some people's data is as simple as mine! import os, sys import random import win32com.client filename = os.path.abspath ("data.xls") if os.path.exists (filename): os.remove (filename) xl = win32com.client.gencache.EnsureDispatch ("Excel.Application") try: wb = xl.Workbooks.Add () ws = wb.ActiveSheet line = range (100) for row in range (1, 6000): print "Row", row random.shuffle (line) ws.Range (ws.Cells (row, 1), ws.Cells (row, len (line))).Value = line wb.SaveAs (filename) finally: xl.Quit () import os, sys import win32com.client import sqlite3 filename = os.path.abspath ("data.xls") db_filename = os.path.abspath ("data.db") if os.path.exists (db_filename): os.remove (db_filename) xl = win32com.client.gencache.EnsureDispatch ("Excel.Application") db = sqlite3.connect (db_filename) db.execute (""" CREATE TABLE data ( a INTEGER, b INTEGER, c INTEGER, d INTEGER, e INTEGER, f INTEGER, g INTEGER, h INTEGER, i INTEGER, j INTEGER, k INTEGER, l INTEGER, m INTEGER, n INTEGER, o INTEGER, p INTEGER, q INTEGER, r INTEGER, s INTEGER, t INTEGER ) """) try: wb = xl.Workbooks.Open (filename) ws = wb.ActiveSheet data = ws.Range (ws.Cells (1, 1), ws.Cells (6000, 20)).Value db.executemany (""" INSERT INTO data ( a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) """, data) finally: xl.Quit () for row in db.execute ("SELECT * FROM data LIMIT 100"): print row db.close () TJG From Kyle.Rickey at bakerhughes.com Fri Mar 14 17:37:21 2008 From: Kyle.Rickey at bakerhughes.com (Rickey, Kyle W) Date: Fri, 14 Mar 2008 11:37:21 -0500 Subject: [python-win32] Running SQL queries on excel sheets In-Reply-To: <47DAA6AB.5020704@timgolden.me.uk> References: <47DA9207.8080402@timgolden.me.uk> <47DAA6AB.5020704@timgolden.me.uk> Message-ID: Tim, thanks for the samples, those are quite handy. I'll play with this some more and see what I can come up. An issue that I can see about reading from the excel files every time is that these files are stored on our network. Our VPN access is horribly slow so it might take a while on a slow connection. I've got some ideas turning in my head now and I'm gonna try a couple of different things. Thanks again for your help. -Kyle Rickey -----Original Message----- From: python-win32-bounces+kyle.rickey=bakerhughes.com at python.org [mailto:python-win32-bounces+kyle.rickey=bakerhughes.com at python.org] On Behalf Of Tim Golden Sent: Friday, March 14, 2008 11:24 AM Cc: python-win32 at python.org Subject: Re: [python-win32] Running SQL queries on excel sheets Rickey, Kyle W wrote: > Tim, thanks for your response. I've got 7 excel files that need reading > containing a total of ~6100 rows. I agree, about this code making me > sick :) > > In a perfect world I would get all the data into our SQL server and > write a front end for everyone that needs to access/modify the data, but > that's a ways down the road. I've still got to convince people in the > company that excel is NOT a good way to store database info! > > I don't have a problem extracting all the data and throwing it into > sqlite, but the problem is I would need to extract all the data every > time I wanted to run my query. I've also got some code laying around to > COM into excel and read data, but it's not very pretty either. > > Now that I think of it, a good temporary solution might be to have an > excel macro that runs whenever the file is open, then whenever someone > saves changes to the excel file, it would dump all that data into our > SQL server. Then whenever I get around to making that frontend, the data > will already be in SQL. Thanks for your help. > > -Kyle Rickey Well you obviously know what you're about, but just to compare things a bit, I attach two small but complete pieces of code below. The first generates an Excel workbook of 6000 lines of data, each containing a hundred numbers randomly shuffled. The second (which is what I'm trying to get to) pulls the first 20 values from each row and inserts them into a Noddy table in a sqlite database. On my respectable-but-not-blazing machine, the first takes about thirty seconds, the second about two seconds. Now my data is ridiculously simple but I suppose I wanted to illustrate how easy it *could* be to pull all of the data from an Excel Workbook. Those with more rugged and real-world experience of doing this can chime in with all the crufty bits you'd have to cope with (such as date/time fields, concurrent access and the like). But perhaps some people's data is as simple as mine! import os, sys import random import win32com.client filename = os.path.abspath ("data.xls") if os.path.exists (filename): os.remove (filename) xl = win32com.client.gencache.EnsureDispatch ("Excel.Application") try: wb = xl.Workbooks.Add () ws = wb.ActiveSheet line = range (100) for row in range (1, 6000): print "Row", row random.shuffle (line) ws.Range (ws.Cells (row, 1), ws.Cells (row, len (line))).Value = line wb.SaveAs (filename) finally: xl.Quit () import os, sys import win32com.client import sqlite3 filename = os.path.abspath ("data.xls") db_filename = os.path.abspath ("data.db") if os.path.exists (db_filename): os.remove (db_filename) xl = win32com.client.gencache.EnsureDispatch ("Excel.Application") db = sqlite3.connect (db_filename) db.execute (""" CREATE TABLE data ( a INTEGER, b INTEGER, c INTEGER, d INTEGER, e INTEGER, f INTEGER, g INTEGER, h INTEGER, i INTEGER, j INTEGER, k INTEGER, l INTEGER, m INTEGER, n INTEGER, o INTEGER, p INTEGER, q INTEGER, r INTEGER, s INTEGER, t INTEGER ) """) try: wb = xl.Workbooks.Open (filename) ws = wb.ActiveSheet data = ws.Range (ws.Cells (1, 1), ws.Cells (6000, 20)).Value db.executemany (""" INSERT INTO data ( a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) """, data) finally: xl.Quit () for row in db.execute ("SELECT * FROM data LIMIT 100"): print row db.close () TJG _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From mail at timgolden.me.uk Fri Mar 14 18:20:40 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 14 Mar 2008 17:20:40 +0000 Subject: [python-win32] Error 1789 during logon, except not really called In-Reply-To: <47DAA611.9080502@laposte.net> References: <47DA55A4.8010601@laposte.net> <47DA76AD.4030004@laposte.net> <47DA7C7B.7030304@timgolden.me.uk> <47DA9C72.5030209@laposte.net> <47DA9F63.4070603@timgolden.me.uk> <47DAA611.9080502@laposte.net> Message-ID: <47DAB3E8.8020608@timgolden.me.uk> le dahut wrote: > > > Tim Golden wrote : >> le dahut wrote: >>> What strange is is that: >>> >>> try: >>> wsec.LookupAccountName(...) >>> except: >>> print 'Error' >>> >>> shows : >>> - a traceback, as if I didn't put LookupAccountName in a try/except >>> statement >>> - the string 'error' so the program has also switched to except as if >>> the try/except has been correctly interpreted >>> >>> So we can say that I get the two behaviours in one. At the exception >>> that the traceback is not complete, it only talks about the line >>> containing LookupAccountName, not entire traceback (the caller >>> function and its parents). >> >> Well that is an extremely clear description of the problem. And, >> unsurprisingly, I can't get it to fail at the interpreter or >> (just in case) from within a file. >> >> >> Is there any possibility that there's an atexit handler or a thread >> going on which is generating the other traceback? Or even a stray >> __del__ or something equally bizarre? Or maybe the code's dropping >> through after handling the exception to some other code which is >> printing the traceback? >> >> > > Actually, the code doesn't break, it continues its execution as if > try/except as done its work. > > It is run in a twisted reactor. > > "a stray _del_" could you be more precise ? Have a look at: http://docs.python.org/ref/customization.html It's not easy to predict what's available when a __del__ is invoked. Indeed, it's not even guaranteed that it's called at all. In particular it may be called when other objects have been destroyed which it's attempting to use. That said, I doubt if that's the issue here since I would only expect __del__-related problems when the interpreter's actually exiting, not when the program carries on which is your case. TJG From timr at probo.com Fri Mar 14 19:01:38 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 14 Mar 2008 11:01:38 -0700 Subject: [python-win32] Running SQL queries on excel sheets In-Reply-To: References: <47DA9207.8080402@timgolden.me.uk> Message-ID: <47DABD82.9030800@probo.com> Rickey, Kyle W wrote: > In a perfect world I would get all the data into our SQL server and > write a front end for everyone that needs to access/modify the data, but > that's a ways down the road. I've still got to convince people in the > company that excel is NOT a good way to store database info! > I read an article in the trade press about two years ago that said Excel was the number one database application in the entire world. It's simple, it's ubiquitous, and it's visual. Until you need reporting, it's not a bad way to go. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From patter001 at gmail.com Fri Mar 14 19:44:37 2008 From: patter001 at gmail.com (Kevin Patterson) Date: Fri, 14 Mar 2008 14:44:37 -0400 Subject: [python-win32] How to create a com_record? In-Reply-To: References: <0a5201c866b5$88447280$98cd5780$@com.au> <0a8d01c866de$b3b97db0$1b2c7910$@com.au> <009001c8677f$8931d0f0$9b9572d0$@com.au> Message-ID: Does anyone have a working example (excel, outlook, etc...) to try the win32com.client.Record function on ? I tried the pythoncom test harness also, but no luck: import win32com.client myarray = win32com.client.DispatchEx ("{F1A51873-24E9-47ED-AE71-925462C5FE3B}") myrecord = win32com.client.Record("tagTestStruct1",myarray) the Record Creation fails with the following exception: Traceback (most recent call last): File "", line 1, in File "C:\Python25\lib\site-packages\win32com\client\__init__.py", line 405, in Record return pythoncom.GetRecordFromGuids(module.CLSID, module.MajorVersion, modul e.MinorVersion, module.LCID, struct_guid) pywintypes.com_error: (-2147024809, 'The parameter is incorrect.', None, None) For refrence, help looks like the below. Only major difference is using Dispatch vs. DispatchEx Record(name, object) Creates a new record object, given the name of the record, and an object from the same type library. Example usage from documentation is: app = win32com.client.Dispatch("Some.Application") point = win32com.client.Record("SomeAppPoint", app) point.x = 0 point.y = 0 app.MoveTo(point) On Thu, Mar 13, 2008 at 11:02 PM, Kevin Patterson wrote: > Ok, more digging, it looks like the OLE Automation TypeLib should have a > GUID Record defined. I see this when using the Python Object Browser > > However, when I generate the py file for the OLE Automation type library, > I don't see GUID in the RecordMap (or any reference to the GUID Record)...Is > there suppose to be something in the generated file, but maybe its not > working ? How do I actually create one of these Records ? > > > On Tue, Mar 11, 2008 at 10:04 PM, Kevin Patterson > wrote: > > > I found the comtypes equivalent if that helps any. The generated > > comtypes file looks like this: > > > > COMMETHOD([dispid(1610743812), helpstring(u'GetInterface() method')], > > HRESULT, 'GetInterface', > > ( ['in'], POINTER(GUID), 'riid' ), > > ( ['retval', 'out'], POINTER(POINTER(IUnknown)), > > 'ppUnknown' )), > > > > With the above, I'm able to use the comtypes.GUID.GUID structure to pass > > the information over through the COM. Unfortunately I still can't find the > > win32com equivalent of passing my structure through the COM. > > > > The win32com generated py file is saying that it expects a VT_RECORD, > > but from above, maybe it should really be expecting a POINTER ? or > > VT_POINTER ? I tried to modify the win32com generated file to take a VT_PTR > > but that didn't seem to help. I really don't want to redo my infastructure > > in comtypes, so if anyone knows the win32com equivalent, that would be > > awesome. > > > > In the meantime, I'll keep digging, and will post if I find more. > > > > > > > > On Tue, Mar 11, 2008 at 12:58 PM, Kevin Patterson > > wrote: > > > > > Old thread, but I got a little more data on the function. The function > > > actually has a REFIID as the first parameter. This apparently is a standard > > > structure for C COM code. I'm not entirely sure why the win32com changes > > > the REFIID to be a VT_RECORD. Does the following definition of the functions > > > help at all (they are from the IDL file) > > > > > > HRESULT GetInterface( [in] REFIID riid, [out, retval, iid_is(riid)] > > > IUnknown** ppUnknown); > > > should be same as: > > > HRESULT GetInterface( [in] GUID* pGuid, [out, retval, iid_is(pGuid)] > > > IUnknown** ppUnknown); > > > > > > > > > > > > On Mon, Feb 4, 2008 at 6:44 PM, Mark Hammond < > > > mhammond at skippinet.com.au> wrote: > > > > > > > > guid = win32com.client.Record("GUID", some_ob) > > > > > > > > > I don't have the some_obj that allows me to build "GUID". > > > > > > > > It should be any object from the same typelib - almost certainly > > > > whatever > > > > object you intend passing this record to. > > > > > > > > > VB.NET (GetType) and C++ (__uuid) both already know that a GUID is > > > > a > > > > record. > > > > > > > > C++ doesn't know it is a COM record. A COM record is something > > > > quite > > > > different to a C/C++ struct or from .NET types. A COM record is > > > > specifically designed to be cross-language. > > > > > > > > > It seems the python CLSID is the same thing, but i don't know what > > > > to call > > > > > > > > > to get a CLSID that is a com_record type. > > > > > > > > As I've explained, we are looking for the COM record definition you > > > > are > > > > trying to use. A C++ struct definition for a GUID is *not* what you > > > > are > > > > looking for - you are looking for the COM record definition of a > > > > GUID. I > > > > see now that you simply copied me a C++ struct you found, which is > > > > not at > > > > all useful in this context. > > > > > > > > To clarify: in a *typelib* you will find a struct definition that > > > > you are > > > > trying to use. Finding a struct definition of the same name > > > > somewhere else > > > > is not suitable. > > > > > > > > > Am I understanding the win32com.client.Record call correctly? It > > > > needs > > > > GUID to be defined by the > > > > > COM right? > > > > > > > > Not "defined by COM", but "defined using COM" - the author of a > > > > typelib must > > > > have defined it somewhere. > > > > > > > > > Its odd b/c the GIUD (python's CLSID) is all over the COM > > > > definitions its > > > > just type > > > > > VT_RECORD type that I'm not understanding how to convert to. > > > > > > > > Yes, I'm afraid you are confused. All existing GUID or CLSID > > > > definitions > > > > you can find are useless - there is only 1 that is relevant, and > > > > that will > > > > be defined in a typelib. > > > > > > > > I think the confusion is such that you need to find basic docs for > > > > the > > > > object, so we can get back to square 1. > > > > > > > > Mark > > > > > > > > > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080314/b37570ea/attachment-0001.htm From kevin.horn at gmail.com Fri Mar 14 20:38:45 2008 From: kevin.horn at gmail.com (Kevin Horn) Date: Fri, 14 Mar 2008 14:38:45 -0500 Subject: [python-win32] Running SQL queries on excel sheets In-Reply-To: <47DABD82.9030800@probo.com> References: <47DA9207.8080402@timgolden.me.uk> <47DABD82.9030800@probo.com> Message-ID: <562bcc10803141238p34b45f54i166a8eb22b72fec6@mail.gmail.com> On Fri, Mar 14, 2008 at 1:01 PM, Tim Roberts wrote: > Rickey, Kyle W wrote: > > In a perfect world I would get all the data into our SQL server and > > write a front end for everyone that needs to access/modify the data, but > > that's a ways down the road. I've still got to convince people in the > > company that excel is NOT a good way to store database info! > > > I would probably run a batch process eevry night to load the Excel sheets into the SQL server, and run my queries against that. Your data would be slightly out of date (not including "today"'s data) but I would think it's an acceptable compromise (your situation may vary). Once you get around to writing a DB frontend, newer web framework projects like TurboGears, when combined with a DataGrid, or using DBSprockets/DBMechanic, can make this a lot easier than it would have been even a couple of years ago. I'm sure Django has similar ways of simplifying this, but I haven't used it much. In the meantime, to cheer yourself up, consider the following: It could be worse, they could be using MS Access! Kevin Horn -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080314/32709794/attachment.htm From Kyle.Rickey at bakerhughes.com Fri Mar 14 21:17:57 2008 From: Kyle.Rickey at bakerhughes.com (Rickey, Kyle W) Date: Fri, 14 Mar 2008 15:17:57 -0500 Subject: [python-win32] Running SQL queries on excel sheets In-Reply-To: <562bcc10803141238p34b45f54i166a8eb22b72fec6@mail.gmail.com> References: <47DA9207.8080402@timgolden.me.uk><47DABD82.9030800@probo.com> <562bcc10803141238p34b45f54i166a8eb22b72fec6@mail.gmail.com> Message-ID: That's also not a bad idea, most of the time, the data I'm interested in will be at least 1-2 weeks old. That would also be better than exporting everything to SQL every time a user saves the document. Thanks for the info about Turbo Gears, etc. I'll have to check those out. -Kyle Rickey ________________________________ From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Kevin Horn Sent: Friday, March 14, 2008 2:39 PM To: python-win32 at python.org Subject: Re: [python-win32] Running SQL queries on excel sheets On Fri, Mar 14, 2008 at 1:01 PM, Tim Roberts wrote: Rickey, Kyle W wrote: > In a perfect world I would get all the data into our SQL server and > write a front end for everyone that needs to access/modify the data, but > that's a ways down the road. I've still got to convince people in the > company that excel is NOT a good way to store database info! > I would probably run a batch process eevry night to load the Excel sheets into the SQL server, and run my queries against that. Your data would be slightly out of date (not including "today"'s data) but I would think it's an acceptable compromise (your situation may vary). Once you get around to writing a DB frontend, newer web framework projects like TurboGears, when combined with a DataGrid, or using DBSprockets/DBMechanic, can make this a lot easier than it would have been even a couple of years ago. I'm sure Django has similar ways of simplifying this, but I haven't used it much. In the meantime, to cheer yourself up, consider the following: It could be worse, they could be using MS Access! Kevin Horn -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080314/6ce8b744/attachment.htm From cjohnson at prospricing.com Fri Mar 14 22:27:29 2008 From: cjohnson at prospricing.com (Chris Johnson) Date: Fri, 14 Mar 2008 16:27:29 -0500 Subject: [python-win32] windows file name property Message-ID: All: I am trying to print the attributes of a file. The want I am most interested in is the owner. This is on windows xp. Any help would be appreciated. Chris J The information contained in this email may be confidential and/or legally privileged. It has been sent for the sole use of the intended recipient(s). If the reader of this message is not an intended recipient, you are hereby notified that any unauthorized review, use, disclosure, dissemination, distribution, or copying of this communication, or any of its contents, is strictly prohibited. If you have received this communication in error, please contact the sender by reply email and destroy all copies of the original message. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080314/85eea144/attachment.htm From cjohnson at prospricing.com Fri Mar 14 22:17:26 2008 From: cjohnson at prospricing.com (Chris Johnson) Date: Fri, 14 Mar 2008 16:17:26 -0500 Subject: [python-win32] windows file name property Message-ID: All: I am trying to print the attributes of a file. The want I am most interested in is the owner. This is on windows xp. Any help would be appreciated. Chris J -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080314/bb812a41/attachment.htm From rwupole at msn.com Fri Mar 14 23:12:30 2008 From: rwupole at msn.com (Roger Upole) Date: Fri, 14 Mar 2008 18:12:30 -0400 Subject: [python-win32] Re: windows file name property Message-ID: Chris Johnson wrote: > All: > I am trying to print the attributes of a file. > The want I am most interested in is the owner. This is on windows xp. > Any help would be appreciated. > Chris J See \win32\demos\FileSecurityTest.py for an example of how to do this. Roger From timr at probo.com Fri Mar 14 23:14:32 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 14 Mar 2008 15:14:32 -0700 Subject: [python-win32] windows file name property In-Reply-To: References: Message-ID: <47DAF8C8.60300@probo.com> Chris Johnson wrote: > > > > I am trying to print the attributes of a file. > > > > The want I am most interested in is the owner. This is on windows xp. > > > > Any help would be appreciated. > import win32security o = win32security.GetFileSecurity( filename, win32security.OWNER_SECURITY_INFORMATION ) s = o.GetSecurityDescriptorOwner() # This prints the SID form: print str(s) # PySID:S-1-5-21-1709892333-1682012616-2269307891-1141 # This gets the human-readable form: s2 = sec.LookupAccountSid( '.', s ) print s2 # (u'timr', u'PROBO', 1) That says this file is owned by user "timr" in domain "PROBO". The "1" means this is a user, not a group (win32security.SidTypeUser). -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mail at timgolden.me.uk Fri Mar 14 23:18:19 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 14 Mar 2008 22:18:19 +0000 Subject: [python-win32] windows file name property In-Reply-To: References: Message-ID: <47DAF9AB.1070907@timgolden.me.uk> Chris Johnson wrote: > I am trying to print the attributes of a file. > The want I am most interested in is the owner. This is on windows xp. http://timgolden.me.uk/python/win32_how_do_i/get-the-owner-of-a-file.html TJG From patter001 at gmail.com Fri Mar 14 23:36:43 2008 From: patter001 at gmail.com (Kevin Patterson) Date: Fri, 14 Mar 2008 18:36:43 -0400 Subject: [python-win32] How to create a com_record? In-Reply-To: References: <0a5201c866b5$88447280$98cd5780$@com.au> <0a8d01c866de$b3b97db0$1b2c7910$@com.au> <009001c8677f$8931d0f0$9b9572d0$@com.au> Message-ID: Sorry for so many posting here, but on the off chance someone is curious and looks in to this: There's two issues I've found so far: On Fri, Mar 14, 2008 at 2:44 PM, Kevin Patterson wrote: > Does anyone have a working example (excel, outlook, etc...) to try the > win32com.client.Record function on ? > > I tried the pythoncom test harness also, but no luck: > > import win32com.client > myarray = win32com.client.DispatchEx > ("{F1A51873-24E9-47ED-AE71-925462C5FE3B}") > myrecord = win32com.client.Record("tagTestStruct1",myarray) > > the Record Creation fails with the following exception: > > Traceback (most recent call last): > File "", line 1, in > File "C:\Python25\lib\site-packages\win32com\client\__init__.py", line > 405, in > Record > return pythoncom.GetRecordFromGuids(module.CLSID, module.MajorVersion, > modul > e.MinorVersion, module.LCID, struct_guid) > pywintypes.com_error: (-2147024809, 'The parameter is incorrect.', None, > None) > > For refrence, help looks like the below. Only major difference is using > Dispatch vs. DispatchEx > > Record(name, object) > Creates a new record object, given the name of the record, > and an object from the same type library. > > > Example usage from documentation is: > > app = win32com.client.Dispatch("Some.Application") > point = win32com.client.Record("SomeAppPoint", app) > point.x = 0 > point.y = 0 > app.MoveTo(point) > > > > On Thu, Mar 13, 2008 at 11:02 PM, Kevin Patterson > wrote: > > > Ok, more digging, it looks like the OLE Automation TypeLib should have a > > GUID Record defined. I see this when using the Python Object Browser > > > > However, when I generate the py file for the OLE Automation type > > library, I don't see GUID in the RecordMap (or any reference to the GUID > > Record)...Is there suppose to be something in the generated file, but maybe > > its not working ? How do I actually create one of these Records ? > > > > > > On Tue, Mar 11, 2008 at 10:04 PM, Kevin Patterson > > wrote: > > > > > I found the comtypes equivalent if that helps any. The generated > > > comtypes file looks like this: > > > > > > COMMETHOD([dispid(1610743812), helpstring(u'GetInterface() > > > method')], HRESULT, 'GetInterface', > > > ( ['in'], POINTER(GUID), 'riid' ), > > > ( ['retval', 'out'], POINTER(POINTER(IUnknown)), > > > 'ppUnknown' )), > > > > > > With the above, I'm able to use the comtypes.GUID.GUID structure to > > > pass the information over through the COM. Unfortunately I still can't find > > > the win32com equivalent of passing my structure through the COM. > > > > > > The win32com generated py file is saying that it expects a VT_RECORD, > > > but from above, maybe it should really be expecting a POINTER ? or > > > VT_POINTER ? I tried to modify the win32com generated file to take a VT_PTR > > > but that didn't seem to help. I really don't want to redo my infastructure > > > in comtypes, so if anyone knows the win32com equivalent, that would be > > > awesome. > > > > > > In the meantime, I'll keep digging, and will post if I find more. > > > > > > > > > > > > On Tue, Mar 11, 2008 at 12:58 PM, Kevin Patterson > > > wrote: > > > > > > > Old thread, but I got a little more data on the function. The > > > > function actually has a REFIID as the first parameter. This apparently is a > > > > standard structure for C COM code. I'm not entirely sure why the win32com > > > > changes the REFIID to be a VT_RECORD. Does the following definition of the > > > > functions help at all (they are from the IDL file) > > > > > > > > HRESULT GetInterface( [in] REFIID riid, [out, retval, iid_is(riid)] > > > > IUnknown** ppUnknown); > > > > should be same as: > > > > HRESULT GetInterface( [in] GUID* pGuid, [out, retval, iid_is(pGuid)] > > > > IUnknown** ppUnknown); > > > > > > > > > > > > > > > > On Mon, Feb 4, 2008 at 6:44 PM, Mark Hammond < > > > > mhammond at skippinet.com.au> wrote: > > > > > > > > > > guid = win32com.client.Record("GUID", some_ob) > > > > > > > > > > > I don't have the some_obj that allows me to build "GUID". > > > > > > > > > > It should be any object from the same typelib - almost certainly > > > > > whatever > > > > > object you intend passing this record to. > > > > > > > > > > > VB.NET (GetType) and C++ (__uuid) both already know that a GUID > > > > > is a > > > > > record. > > > > > > > > > > C++ doesn't know it is a COM record. A COM record is something > > > > > quite > > > > > different to a C/C++ struct or from .NET types. A COM record is > > > > > specifically designed to be cross-language. > > > > > > > > > > > It seems the python CLSID is the same thing, but i don't know > > > > > what to call > > > > > > > > > > > to get a CLSID that is a com_record type. > > > > > > > > > > As I've explained, we are looking for the COM record definition > > > > > you are > > > > > trying to use. A C++ struct definition for a GUID is *not* what > > > > > you are > > > > > looking for - you are looking for the COM record definition of a > > > > > GUID. I > > > > > see now that you simply copied me a C++ struct you found, which is > > > > > not at > > > > > all useful in this context. > > > > > > > > > > To clarify: in a *typelib* you will find a struct definition that > > > > > you are > > > > > trying to use. Finding a struct definition of the same name > > > > > somewhere else > > > > > is not suitable. > > > > > > > > > > > Am I understanding the win32com.client.Record call correctly? It > > > > > needs > > > > > GUID to be defined by the > > > > > > COM right? > > > > > > > > > > Not "defined by COM", but "defined using COM" - the author of a > > > > > typelib must > > > > > have defined it somewhere. > > > > > > > > > > > Its odd b/c the GIUD (python's CLSID) is all over the COM > > > > > definitions its > > > > > just type > > > > > > VT_RECORD type that I'm not understanding how to convert to. > > > > > > > > > > Yes, I'm afraid you are confused. All existing GUID or CLSID > > > > > definitions > > > > > you can find are useless - there is only 1 that is relevant, and > > > > > that will > > > > > be defined in a typelib. > > > > > > > > > > I think the confusion is such that you need to find basic docs for > > > > > the > > > > > object, so we can get back to square 1. > > > > > > > > > > Mark > > > > > > > > > > > > > > > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080314/da35d1b6/attachment.htm From patter001 at gmail.com Fri Mar 14 23:41:29 2008 From: patter001 at gmail.com (Kevin Patterson) Date: Fri, 14 Mar 2008 18:41:29 -0400 Subject: [python-win32] How to create a com_record? In-Reply-To: References: <0a8d01c866de$b3b97db0$1b2c7910$@com.au> <009001c8677f$8931d0f0$9b9572d0$@com.au> Message-ID: Sorry for so many posting here, but on the off chance someone is curious and looks in to this: There's two issues I've found so far: - The generated py files don't have the GUID for the Record (at least not in the relased 210). The generated py file would need GUID from the TestStruct1, for some reason it puts 0-0-0-0 instead of the actual GUID - Even after that manual fix, the win32com.client.Record call still failed for me, but: the pythoncom.GetRecordFromGuids actually returned the record (for the test harness). Wooohoo!! Now the bad news: I can't figure out how to get a Record if the GUID is not present. The one I need is in OLE. When I use the Visual C++ browser, I can see that the GUID struct is defined, but there is no GUID for the GUID struc (ironic huh :)) So now the battle is trying to find a way to get a record without a GUID (so...in essence...back to square one). I'm starting to think it would be easiest to make my own dumb com server JUST to be able to define the struct. But I'm all ears for better ideas :) On Fri, Mar 14, 2008 at 6:36 PM, Kevin Patterson wrote: > Sorry for so many posting here, but on the off chance someone is curious > and looks in to this: > > There's two issues I've found so far: > > > > On Fri, Mar 14, 2008 at 2:44 PM, Kevin Patterson > wrote: > > > Does anyone have a working example (excel, outlook, etc...) to try the > > win32com.client.Record function on ? > > > > I tried the pythoncom test harness also, but no luck: > > > > import win32com.client > > myarray = win32com.client.DispatchEx > > ("{F1A51873-24E9-47ED-AE71-925462C5FE3B}") > > myrecord = win32com.client.Record("tagTestStruct1",myarray) > > > > the Record Creation fails with the following exception: > > > > Traceback (most recent call last): > > File "", line 1, in > > File "C:\Python25\lib\site-packages\win32com\client\__init__.py", line > > 405, in > > Record > > return pythoncom.GetRecordFromGuids(module.CLSID, > > module.MajorVersion, modul > > e.MinorVersion, module.LCID, struct_guid) > > pywintypes.com_error: (-2147024809, 'The parameter is incorrect.', None, > > None) > > > > For refrence, help looks like the below. Only major difference is using > > Dispatch vs. DispatchEx > > > > Record(name, object) > > Creates a new record object, given the name of the record, > > and an object from the same type library. > > > > > > Example usage from documentation is: > > > > app = win32com.client.Dispatch("Some.Application") > > point = win32com.client.Record("SomeAppPoint", app) > > point.x = 0 > > point.y = 0 > > app.MoveTo(point) > > > > > > > > On Thu, Mar 13, 2008 at 11:02 PM, Kevin Patterson > > wrote: > > > > > Ok, more digging, it looks like the OLE Automation TypeLib should have > > > a GUID Record defined. I see this when using the Python Object Browser > > > > > > However, when I generate the py file for the OLE Automation type > > > library, I don't see GUID in the RecordMap (or any reference to the GUID > > > Record)...Is there suppose to be something in the generated file, but maybe > > > its not working ? How do I actually create one of these Records ? > > > > > > > > > On Tue, Mar 11, 2008 at 10:04 PM, Kevin Patterson > > > wrote: > > > > > > > I found the comtypes equivalent if that helps any. The generated > > > > comtypes file looks like this: > > > > > > > > COMMETHOD([dispid(1610743812), helpstring(u'GetInterface() > > > > method')], HRESULT, 'GetInterface', > > > > ( ['in'], POINTER(GUID), 'riid' ), > > > > ( ['retval', 'out'], POINTER(POINTER(IUnknown)), > > > > 'ppUnknown' )), > > > > > > > > With the above, I'm able to use the comtypes.GUID.GUID structure to > > > > pass the information over through the COM. Unfortunately I still can't find > > > > the win32com equivalent of passing my structure through the COM. > > > > > > > > The win32com generated py file is saying that it expects a > > > > VT_RECORD, but from above, maybe it should really be expecting a POINTER ? > > > > or VT_POINTER ? I tried to modify the win32com generated file to take a > > > > VT_PTR but that didn't seem to help. I really don't want to redo my > > > > infastructure in comtypes, so if anyone knows the win32com equivalent, that > > > > would be awesome. > > > > > > > > In the meantime, I'll keep digging, and will post if I find more. > > > > > > > > > > > > > > > > On Tue, Mar 11, 2008 at 12:58 PM, Kevin Patterson < > > > > patter001 at gmail.com> wrote: > > > > > > > > > Old thread, but I got a little more data on the function. The > > > > > function actually has a REFIID as the first parameter. This apparently is a > > > > > standard structure for C COM code. I'm not entirely sure why the win32com > > > > > changes the REFIID to be a VT_RECORD. Does the following definition of the > > > > > functions help at all (they are from the IDL file) > > > > > > > > > > HRESULT GetInterface( [in] REFIID riid, [out, retval, > > > > > iid_is(riid)] IUnknown** ppUnknown); > > > > > should be same as: > > > > > HRESULT GetInterface( [in] GUID* pGuid, [out, retval, > > > > > iid_is(pGuid)] IUnknown** ppUnknown); > > > > > > > > > > > > > > > > > > > > On Mon, Feb 4, 2008 at 6:44 PM, Mark Hammond < > > > > > mhammond at skippinet.com.au> wrote: > > > > > > > > > > > > guid = win32com.client.Record("GUID", some_ob) > > > > > > > > > > > > > I don't have the some_obj that allows me to build "GUID". > > > > > > > > > > > > It should be any object from the same typelib - almost certainly > > > > > > whatever > > > > > > object you intend passing this record to. > > > > > > > > > > > > > VB.NET (GetType) and C++ (__uuid) both already know that a > > > > > > GUID is a > > > > > > record. > > > > > > > > > > > > C++ doesn't know it is a COM record. A COM record is something > > > > > > quite > > > > > > different to a C/C++ struct or from .NET types. A COM record is > > > > > > specifically designed to be cross-language. > > > > > > > > > > > > > It seems the python CLSID is the same thing, but i don't know > > > > > > what to call > > > > > > > > > > > > > to get a CLSID that is a com_record type. > > > > > > > > > > > > As I've explained, we are looking for the COM record definition > > > > > > you are > > > > > > trying to use. A C++ struct definition for a GUID is *not* what > > > > > > you are > > > > > > looking for - you are looking for the COM record definition of a > > > > > > GUID. I > > > > > > see now that you simply copied me a C++ struct you found, which > > > > > > is not at > > > > > > all useful in this context. > > > > > > > > > > > > To clarify: in a *typelib* you will find a struct definition > > > > > > that you are > > > > > > trying to use. Finding a struct definition of the same name > > > > > > somewhere else > > > > > > is not suitable. > > > > > > > > > > > > > Am I understanding the win32com.client.Record call correctly? > > > > > > It needs > > > > > > GUID to be defined by the > > > > > > > COM right? > > > > > > > > > > > > Not "defined by COM", but "defined using COM" - the author of a > > > > > > typelib must > > > > > > have defined it somewhere. > > > > > > > > > > > > > Its odd b/c the GIUD (python's CLSID) is all over the COM > > > > > > definitions its > > > > > > just type > > > > > > > VT_RECORD type that I'm not understanding how to convert to. > > > > > > > > > > > > Yes, I'm afraid you are confused. All existing GUID or CLSID > > > > > > definitions > > > > > > you can find are useless - there is only 1 that is relevant, and > > > > > > that will > > > > > > be defined in a typelib. > > > > > > > > > > > > I think the confusion is such that you need to find basic docs > > > > > > for the > > > > > > object, so we can get back to square 1. > > > > > > > > > > > > Mark > > > > > > > > > > > > > > > > > > > > > > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080314/74e4a1bf/attachment-0001.htm From rwupole at msn.com Sat Mar 15 00:06:42 2008 From: rwupole at msn.com (Roger Upole) Date: Fri, 14 Mar 2008 19:06:42 -0400 Subject: [python-win32] Re: How to create a com_record? Message-ID: Kevin Patterson wrote: > I found the comtypes equivalent if that helps any. The generated comtypes > file looks like this: > > COMMETHOD([dispid(1610743812), helpstring(u'GetInterface() method')], > HRESULT, 'GetInterface', > ( ['in'], POINTER(GUID), 'riid' ), > ( ['retval', 'out'], POINTER(POINTER(IUnknown)), > 'ppUnknown' )), > > With the above, I'm able to use the comtypes.GUID.GUID structure to pass > the information over through the COM. Unfortunately I still can't find the > win32com equivalent of > > passing my structure through the COM. > > The win32com generated py file is saying that it expects a VT_RECORD, but > from above, maybe it should really be expecting a POINTER ? or VT_POINTER > ? I tried to > > > modify the win32com generated file to take a VT_PTR but > that didn't seem to help. I really don't want to redo my infastructure in > comtypes, so if anyone knows the win32com > > equivalent, that would be > awesome. > > In the meantime, I'll keep digging, and will post if I find more. One thing to try is using the method without type info at all. win32com.client.dynamic.DumbDispatch will create a late- bound COM object. Roger From timr at probo.com Sat Mar 15 00:32:31 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 14 Mar 2008 16:32:31 -0700 Subject: [python-win32] How to create a com_record? In-Reply-To: References: <0a8d01c866de$b3b97db0$1b2c7910$@com.au> <009001c8677f$8931d0f0$9b9572d0$@com.au> Message-ID: <47DB0B0F.5020008@probo.com> Kevin Patterson wrote: > > Now the bad news: I can't figure out how to get a Record if the GUID > is not present. The one I need is in OLE. When I use the Visual C++ > browser, I can see that the GUID struct is defined, but there is no > GUID for the GUID struc (ironic huh :)) This path is going to lead nowhere. A GUID is not a COM record. There is no IID for the GUID data type. The GUID struct is defined in stdole2.tlb, which has IID {00020430-0000-0000-C000-000000000046}, but I don't think that's enough. Let's step back for a moment. What are you actually trying to do? GetInterface is usually only called internally by QueryInterface, and there are usually other ways to get one interface from another in Python. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From j at hix.cz Sat Mar 15 01:10:52 2008 From: j at hix.cz (j at hix.cz) Date: Sat, 15 Mar 2008 01:10:52 +0100 (CET) Subject: [python-win32] MAPIInitialize problem Message-ID: <2.2-19797-1470079789-1205539852@seznam.cz> Hi, when I try use MAPI, I get message with pywintypes.com_error ... Can anybody help me? (PyWin32 210) ------------------------------------------------------------ Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from win32com.mapi import mapi >>> from win32com.mapi import mapitags >>> mapi.MAPIInitialize(None) Traceback (most recent call last): File "", line 1, in ? pywintypes.com_error: (-2147467259, 'Nespecifikovan\xe1 error', None, None) >>> --------------------------------------------------------------- Thanks. Hippo From patter001 at gmail.com Sat Mar 15 02:43:51 2008 From: patter001 at gmail.com (Kevin Patterson) Date: Fri, 14 Mar 2008 21:43:51 -0400 Subject: [python-win32] How to create a com_record? In-Reply-To: <47DB0B0F.5020008@probo.com> References: <009001c8677f$8931d0f0$9b9572d0$@com.au> <47DB0B0F.5020008@probo.com> Message-ID: So back to the beginning again: There is a COM function that takes a pointer to the GUID structure as an INPUT. The fact that it happens to be called "GetInterface" may be confusing matters. It just happens to be the name of the function. So lets just say the function is: HRESULT SomeFunction( [in] GUID* pGuid, [out, retval, iid_is(pGuid)] IUnknown** ppUnknown); win32com says that it needs a VT_RECORD in order to pass the GUID information to the COM. But from previous email exchanges I can't just deifne some GUID struct and give it to the function, I have to somehow create a VT_RECORD of a GUID. Its very ironic that it is so hard for me to do this at the user script level when the low level stuff passes the GUID around all over the place :) >A GUID is not a COM record. There is no IID for the GUID data type So currently this is my biggest problem, because the early comment from Mark implies that theres NO way I can get the data to the COM without finding the GUID defined as a VT_RECORD somewhere (which I thought I was getting close with the OLE, but I guess not). On Fri, Mar 14, 2008 at 7:32 PM, Tim Roberts wrote: > Kevin Patterson wrote: > > > > Now the bad news: I can't figure out how to get a Record if the GUID > > is not present. The one I need is in OLE. When I use the Visual C++ > > browser, I can see that the GUID struct is defined, but there is no > > GUID for the GUID struc (ironic huh :)) > > This path is going to lead nowhere. A GUID is not a COM record. There > is no IID for the GUID data type. The GUID struct is defined in > stdole2.tlb, which has IID {00020430-0000-0000-C000-000000000046}, but I > don't think that's enough. > > Let's step back for a moment. What are you actually trying to do? > GetInterface is usually only called internally by QueryInterface, and > there are usually other ways to get one interface from another in Python. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > 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: http://mail.python.org/pipermail/python-win32/attachments/20080314/e19d3999/attachment.htm From tnelson at onresolve.com Sat Mar 15 14:16:50 2008 From: tnelson at onresolve.com (Trent Nelson) Date: Sat, 15 Mar 2008 06:16:50 -0700 Subject: [python-win32] Any interest in a pywin32 open session at PyCon? Message-ID: <87D3F9C72FBF214DB39FA4E3FE618CDC6E160CEE14@EXMBX04.exchhosting.com> Anyone interested in a pywin32-oriented open session at PyCon? I wouldn't mind chewing the fat on the following two ideas: - Using decorators to provide the type information that would be required in order to generate an IDL from a COM-exposed Python class (i.e. @idl(str, int, list, returns=int)). I suspect that would then follow into a discussion regarding how (and when) to generate the IDL. - Using the facilities of dbghelp.dll to allow ctypes to introspect DLLs. I use IPython a lot, once you get a taste for the tab completion facilities, the enhanced console is hard to give up. I'd like to be able to load a cdll in IPython and then use tab to see which methods the DLL exposes. Other perks would be that IDEs could use the information to give completion hints (PyDev etc). Trent. From mail at timgolden.me.uk Sat Mar 15 15:18:43 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Sat, 15 Mar 2008 14:18:43 +0000 Subject: [python-win32] Any interest in a pywin32 open session at PyCon? In-Reply-To: <87D3F9C72FBF214DB39FA4E3FE618CDC6E160CEE14@EXMBX04.exchhosting.com> References: <87D3F9C72FBF214DB39FA4E3FE618CDC6E160CEE14@EXMBX04.exchhosting.com> Message-ID: <47DBDAC3.5030307@timgolden.me.uk> Trent Nelson wrote: > Anyone interested in a pywin32-oriented open session at PyCon? Damn. Wish I were there! Trent, depending on what kind of take up you get, please do at least post up any discussions / conclusions to the list (or a blog or whatever). The more info around on the Windows World of Python, the better. Thanks TJG From tnelson at onresolve.com Sat Mar 15 15:51:59 2008 From: tnelson at onresolve.com (Trent Nelson) Date: Sat, 15 Mar 2008 07:51:59 -0700 Subject: [python-win32] Any interest in a pywin32 open session at PyCon? In-Reply-To: <47DBDAC3.5030307@timgolden.me.uk> References: <87D3F9C72FBF214DB39FA4E3FE618CDC6E160CEE14@EXMBX04.exchhosting.com> <47DBDAC3.5030307@timgolden.me.uk> Message-ID: <87D3F9C72FBF214DB39FA4E3FE618CDC6E168AD0DB@EXMBX04.exchhosting.com> > Trent Nelson wrote: > > Anyone interested in a pywin32-oriented open session at PyCon? > > Damn. Wish I were there! > > Trent, depending on what kind of take up you get, please do > at least post up any discussions / conclusions to the list > (or a blog or whatever). The more info around on the Windows > World of Python, the better. Sure, I don't mind capturing any discussions in a blog. There's an open session tonight on Python with .NET, I might see if there's any time available after that. (Or maybe we could just join in on that session.) Trent. From tnelson at onresolve.com Sat Mar 15 17:17:13 2008 From: tnelson at onresolve.com (Trent Nelson) Date: Sat, 15 Mar 2008 09:17:13 -0700 Subject: [python-win32] Any interest in a pywin32 open session at PyCon? In-Reply-To: <87D3F9C72FBF214DB39FA4E3FE618CDC6E160CEE14@EXMBX04.exchhosting.com> References: <87D3F9C72FBF214DB39FA4E3FE618CDC6E160CEE14@EXMBX04.exchhosting.com> Message-ID: <87D3F9C72FBF214DB39FA4E3FE618CDC6E168AD0EC@EXMBX04.exchhosting.com> > Anyone interested in a pywin32-oriented open session at PyCon? I've booked the 'Love B' room from 6pm-7pm tonight. Same room as the Python & .NET session, which goes from 7pm-8:30pm. Hopefully a few people other than myself turn up, otherwise it's going to be a pretty boring summary blog ;-) Trent. From tnelson at onresolve.com Sat Mar 15 21:44:18 2008 From: tnelson at onresolve.com (Trent Nelson) Date: Sat, 15 Mar 2008 13:44:18 -0700 Subject: [python-win32] Any interest in a pywin32 open session at PyCon? In-Reply-To: <009601c886ba$263621e0$1509140a@bobcat> References: <87D3F9C72FBF214DB39FA4E3FE618CDC6E160CEE14@EXMBX04.exchhosting.com> <009601c886ba$263621e0$1509140a@bobcat> Message-ID: <87D3F9C72FBF214DB39FA4E3FE618CDC6E168AD129@EXMBX04.exchhosting.com> > I'd be happy to chat about this - but I'm not really sure much > face-to-face talk is needed (just action ;) I guess that's what the sprints are for ;-) I'm sticking around 'til Thursday, give or take, and apart from continuing work on the x64 Windows Python build, I'm certainly interested in putting some time into this. (I've booked a session between 6-7pm in 'Love B' (who names these rooms?!) FWIW.) > Actually, using win32com, we could generate the typelib directly > without > going via an IDL - which would seem much better - if for no other > reason > that it could be used by people without MIDL. So for this reason, @idl > might not be a good name. Hmmmm. Would whatever typelib generates be accessible via DumpIDL() in the DLL exposing the Python COM interface? Or is everything done out-of-proc via the pythoncom server? (I haven't ever needed to expose a Python class in COM so I'm not 100% on the details.) Or rather, would your standard run-of-the-mill COM browser be able to view the corresponding IDL? > Secondly, I seem to recall some other decorator patterns for declaring > param types and return types - I see no reason we shouldn't try and use a > generic decorator for this if one exists (which it may not - but its worth > a look) > > Finally, an issue which may conflict with the above is that we need to > specify *variant* types, not Python types. eg, what would 'int' mean > to the typelib? VT_I4? VT_I8? How would unsigned values be declared? What > would 'list' mean here - VT_ARRAY | VT_VARIANT? How would a list of a > specific type be declared? Or maybe you are proposing we only support a subset > of variant types that map directly to python types? Probably the latter. I do something like that with a @dll decorator that wraps ctypes dlls, e.g.: @dll(c_wchar_p, returns=c_wchar_p, raiseExceptionOnError=ReadSettingError) def readSetting(self, setting): pass i.e. restrict the types to ctypes types. (See http://blogs.onresolve.com/?p=48 for more info.) Just off the top of my head, I would think that we'd expose all ints/longs as VT_I8 and convert internally. For lists, VT_SAFEARRAY of VT_VARIANTs perhaps (I believe that's how Qt/ActiveQt expose their list classes, e.g. QStringList, QValueList.) Or for version 0.1, make everything a VT_VARIANT and refine on subsequent iterations ;-) > ie, in summary: +1 on the idea, but I still see a number of questions. > > > - Using the facilities of dbghelp.dll to allow ctypes to > > introspect DLLs. I use IPython a lot, once you get a taste > > for the tab completion facilities, the enhanced console is > > hard to give up. I'd like to be able to load a cdll in > > IPython and then use tab to see which methods the DLL > > exposes. Other perks would be that IDEs could use the > > information to give completion hints (PyDev etc). > Sounds fine to me, although its something I have no personal use for. Many > years ago I tried to allow pythonwin and IDLE, for example, to share some of > the logic for code completion etc. Much of this also ended up in komodo. > Sadly though, none of these projects have taken any steps to actually share > this stuff in an ongoing basis, so I'm not sure there is anything in place > that would actually make sharing this new code practical (although all these > other IDEs may well see benefit in forking/porting your stuff to their > environment) Interesting... I'm only semi-interested in the code-completion facilities for IDEs TBH. What I'd really like to do is, heh, introspect say, ws2_32.dll, figure out all the C-exposed methods, then grok MSDN (via BeautifulSoup or whatever) for the method definitions. Grok each type in the C method definition and figure out how to go from Python type -> Windows type (not that hard, that blog post does a simple job of it for raw C types), then do automatic conversion when the cdll methods are invoked. (The MSDN grok -> Python wrapper would be done offline I guess, but the process would be analogous to running make_py on a COM interface.) The next crack-pot idea I had was leveraging the information in dbghelp.dll to introspect C++ DLLs with exported interfaces. Run depends.exe on any C++ DLL and you get wonderfully decorated descriptions of all class methods, constructors, destructors, even the vtable. Use that to mock Python classes that mimic the C++ classes, where each method calls the corresponding undecorated method in the DLL. And, er, wallah, you have cpptypes. Heh. Trent. From sjmachin at lexicon.net Sun Mar 16 10:40:04 2008 From: sjmachin at lexicon.net (John Machin) Date: Sun, 16 Mar 2008 20:40:04 +1100 Subject: [python-win32] Running SQL queries on excel sheets In-Reply-To: References: <47DA9207.8080402@timgolden.me.uk> Message-ID: <47DCEAF4.30200@lexicon.net> Rickey, Kyle W wrote: > Tim, thanks for your response. I've got 7 excel files that need reading > containing a total of ~6100 rows. I agree, about this code making me > sick :) That's not exactly "absolutely tons of data" :-) One problem with the ODBC approach to reading spreadsheets (at least with the MS Excel ODBC driver) is that it examines a limited number (e.g. 8 or 10) of rows to determine what type a column is. So the first 10 rows have floats in column X then Noddy's managed to get some text in cell X11 which is a fatal error for ODBC -- you can't continue. [snip] > Obviously, all that is only helpful up to a point. Is there some > reason why you can't just pull the data out straight into Python > structures and take it from there (or even push it into a Sqlite > memory database)? Perhaps you've got absolutely tons of data so > extracting it would be a pain? If not, consider using one of > the COM packages (win32com.client or comtypes) or something like > pyExcelerator to pull it out. > Consider the xlrd package (http://www.lexicon.net/sjmachin/xlrd.htm). It'll tell you what type the data is cell-by-cell -- you can then compare that with your expectations. HTH, John From clintonlee.taylor at gmail.com Sun Mar 16 12:49:18 2008 From: clintonlee.taylor at gmail.com (Clinton Lee Taylor) Date: Sun, 16 Mar 2008 13:49:18 +0200 Subject: [python-win32] Windows Address Book Example ... Message-ID: Greetings ... Just for completeness, I thought I would post my final test for dumping just people in the Windows Address Book (WAB) with a Fax number ... Please understand that I'm just a beginner with python, so, no laughing ... ;-) I'm sure that there could be quite a bit more error checking, like the Outlook dumps have, but I don't quite understand yet traps and things like that ... Almost slapped myself because I could not find a switch statement for multiple if and then there was things about create class ... swish, straight over the top of my head ... ;-) Okay, I'm using the Open Source, but LGPL project called WABAccess ... http://wabaccess.sourceforge.net/ I have three files to create an exe file, still working on making it a quite test to see what else I'm missing, so a single click exe with all the DLL's and stuff inside, but that will come much later ... First file ... wab-01.py import win32com.client if win32com.client.gencache.is_readonly == True: #allow gencache to create the cached wrapper objects win32com.client.gencache.is_readonly = False # under p2exe the call in gencache to __init__() does not happen # so we use Rebuild() to force the creation of the gen_py folder win32com.client.gencache.Rebuild() # NB You must ensure that the python...\win32com.client.gen_py dir does not exist # to allow creation of the cache in %temp% from win32com.client.gencache import EnsureDispatch from win32com.client import constants objSession = EnsureDispatch("WABAccess.Session", bForDemand=0) #print objSession #Open the WAB with an identity. If no identity is already open, #the Identity Manager is launch to prompt the user to choose an indentity. #objSession.Open(True) # #The WAB is open without an identity. objSession.Open(False) if objSession.Identities.LastIdentity == "{00000000-0000-0000-0000-000000000000}": print "No Identity Selected" else: print "The Identity " + objSession.Identities(objSession.Identities.LastIdentity).Name + " is selected" #print objSession.Identities.DefaultIdentity #print objSession.Identities.Count #print objSession.Containers.Count for oContU in objSession.Containers: for oItem in oContU.Elements: for oContP in oItem.Properties: if oContP.Id == constants.wabPR_PRIMARY_FAX_NUMBER: print oItem.Name print "Primary Fax " + oContP.Value elif oContP.Id == constants.wabPR_BUSINESS_FAX_NUMBER: print oItem.Name print "Business Fax " + oContP.Value elif oContP.Id == constants.wabPR_HOME_FAX_NUMBER: print oItem.Name print "Home Fax " + oContP.Value objSession.Refresh objSession.Close print "Done." Second file ... setup.py from distutils.core import setup import py2exe setup(console=['wab-01.py']) and last file ... maketest.bat @echo off Rem As per following webpage ... Rem http://www.py2exe.org/index.cgi/UsingEnsureDispatch Rem Rem Rename gen_py to something else before running the setup Rem echo Rename gen_py to org ren C:\Python24\Lib\site-packages\win32com\gen_py C:\Python24\Lib\site-packages\win32com\gen_py.org C:\python24\python wab-01.py pause C:\python24\python setup.py install pause C:\python24\python setup.py py2exe pause Rem rename gen_py.org back gen_py echo Rename gen_py.org to back ren C:\Python24\Lib\site-packages\win32com\gen_py.org C:\Python24\Lib\site-packages\win32com\gen_py I hope this help's anybody else that might be looking for similar code to start with ... Thanks Mailed LeeT From jjjanse at home.nl Sun Mar 16 21:01:09 2008 From: jjjanse at home.nl (jjjanse) Date: Sun, 16 Mar 2008 21:01:09 +0100 Subject: [python-win32] setting labels in outlook calendar Message-ID: <2C1F945536624EF6982F9D87DDE5AFCB@pc2janj> After googling for a few hours I cannot find a solution to set a color on outlook appointments. In the following excerpt, an appointment is written, found and all appointments are read back. I used the makepy utility on the "Microsoft Outlook 11.0 Object Library" to be able to browse through this object lib and try things out. This caused the -well known-? problem of early binding where python constructions like for afspraak in afspraken: start = datetime.datetime.fromtimestamp (int (afspraak.Start)) subject = afspraak.Subject.encode("utf-8") print start, subject used to work fine, suddenly were not recognized anymore and had to be replaced by constructions like stated below with GetFirst() and GetNext(). from win32com.client import constants import win32com.client import time import datetime print ('Writing a new appointment') appointment = outlook.CreateItem(constants.olAppointmentItem) appointment.Start = '2008-03-10 07:00:00' appointment.Subject = 'Generated by Python' appointment.Duration = 15 appointment.Location = 'perron 13a' appointment.Save() #finding this appointment afspraken = namespace.GetDefaultFolder(9).Items aap = afspraken.Find(u"[Subject] = Generated by Python") print aap.Subject.encode("utf-8") #reading all appointments afspraken = namespace.GetDefaultFolder(9).Items afspraken.Sort("[Start]") afspraken.IncludeRecurrences = "True" #Possible columns are Subject, Location, Start, End, Recurrence Pattern, Categories afspraak = afspraken.GetFirst() while afspraak: start = datetime.datetime.fromtimestamp (int (afspraak.Start)) subject = afspraak.Subject.encode("utf-8") if start == datetime.datetime(2008,03,10, 7,0): subject = afspraak.Subject.encode("utf-8") print subject afspraak = afspraken.GetNext() if start.year >nextYear: #avoid to loop until 2038 :-) break So far, so good. But I could only find a VBA example for setting the label on an appointment by using a reference to a 'CDO 1.21' library which is not present on my computer. Furthermore I had a problem translating this example to python. If u know a solution or example, please let me know, Thnx in advance, Joost Janse -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080316/aa58fe21/attachment.htm From chris at slort.org Sun Mar 16 23:34:32 2008 From: chris at slort.org (Christopher Nilsson) Date: Mon, 17 Mar 2008 09:34:32 +1100 Subject: [python-win32] excelRTDServer demo not working In-Reply-To: <20080314124625.GA19974@double.lan> References: <20080314010910.GA16449@double.lan> <29a42920803131946v7e335b7dt8d2b26bc0e1f96d4@mail.gmail.com> <20080314124625.GA19974@double.lan> Message-ID: <29a42920803161534x5ae3c7edmac273988fe8fe965@mail.gmail.com> On 14/03/2008, Kevin O'Connor wrote: > On Fri, Mar 14, 2008 at 01:46:16PM +1100, Christopher Nilsson wrote: > > It's been ages since I looked at this, but you need to make sure the > > constants at the top of the module match your version of excel. The > > ones that are currently there are for Excel XP (which is the one > > before the version you're using, I believe): > > > > EXCEL_TLB_GUID = '{00020813-0000-0000-C000-000000000046}' > > EXCEL_TLB_LCID = 0 > > EXCEL_TLB_MAJOR = 1 > > EXCEL_TLB_MINOR = 4 > > > Hi Chris, > > The Python COM browser shows the same GUID for the excel type > libraries. It does report 'Microsoft Excel 11.0 Object Library' > instead of 'version 10' which is referenced in the code. However, if > I change the MAJOR to 2, I can't register the class at all (it reports > a library not registered error). I can change the minor (eg, to 5 but > it still doesn't work). > > Any ideas where I could get the actual numbers from? > > Thanks again, > > -Kevin > Hey Kevin, There are a few ways, on how to grab these numbers, written up over at: http://www.py2exe.org/index.cgi/IncludingTypelibs As suggested there, you can try running makepy. eg: "%PYTHON_HOME%\Lib\site-packages\win32com\client\makepy.py -i" Then just pick the correct typelib from the list (ie. the "Microsoft Excel 11.0 Object Library" you found). If I had it installed, I could tell you now. :) Let me know how you go. Cheers, Chris. From kevin at koconnor.net Mon Mar 17 01:01:47 2008 From: kevin at koconnor.net (Kevin O'Connor) Date: Sun, 16 Mar 2008 20:01:47 -0400 Subject: [python-win32] excelRTDServer demo not working In-Reply-To: <29a42920803161534x5ae3c7edmac273988fe8fe965@mail.gmail.com> <29a42920803161610u7f721ecau4ecc15db81698fca@mail.gmail.com> References: <20080314010910.GA16449@double.lan> <29a42920803131946v7e335b7dt8d2b26bc0e1f96d4@mail.gmail.com> <20080314124625.GA19974@double.lan> <29a42920803161534x5ae3c7edmac273988fe8fe965@mail.gmail.com> <20080314010910.GA16449@double.lan> <29a42920803131946v7e335b7dt8d2b26bc0e1f96d4@mail.gmail.com> <20080314124625.GA19974@double.lan> <29a42920803161610u7f721ecau4ecc15db81698fca@mail.gmail.com> Message-ID: <20080317000147.GA16676@double.lan> Hi Chris, On Mon, Mar 17, 2008 at 09:34:32AM +1100, Christopher Nilsson wrote: > On 14/03/2008, Kevin O'Connor wrote: > > Any ideas where I could get the actual numbers from? > > As suggested there, you can try running makepy. eg: > > "%PYTHON_HOME%\Lib\site-packages\win32com\client\makepy.py -i" > > Then just pick the correct typelib from the list (ie. the "Microsoft > Excel 11.0 Object Library" you found). Okay, that reports v1.5. I plugged them into the script and then registered it. However, no luck - I still get "#N/A" and nothing in the PythonWin trace collector. On Mon, Mar 17, 2008 at 10:10:23AM +1100, Christopher Nilsson wrote: > One more thing.... > > Here are some things to check in the face of the "#N/A" cell errors > you mentioned you were seeing. This is from the Office XP faq... > Might be worth hunting for any 2003 updates of it, if there are any. > > > Why Do I Always Get #N/A When I Enter My RTD Formulas? > > One of the following is likely the cause: > > * Macros were disabled. If the RTD server is running locally, > under Medium and High security, users see a security warning dialog > box. They must enable macros for the RTD server. If the RTD server is > not code signed, it just silently fails under High security. > * The RTD server didn't start successfully. The ServerStart method > must return 1. Otherwise, Excel calls the ServerTerminate method > because it thinks the RTD server failed to start. > * The RTD server is listed among the disabled items. To check the > disabled items, on the Help menu, click About Microsoft Excel, and > then click Disabled Items. > * The RTD server didn't return anything in the ConnectData method > and hasn't called the UpdateNotify method yet. I've put security to the lowest setting, and I don't see any warnings. Nothing is in the disabled list. I'm hoping the other two would show something in the trace window. I'm really lost. It's as if Excel doesn't see the com object being registered at all. I feel like I'm missing something basic. > Sorry I can't be more help, I haven't looked at this stuff for about 4 > years, so it's a bit slow coming back to me. I do appreciate the help you've given. -Kevin From siddhartha.veedaluru at gmail.com Mon Mar 17 07:37:55 2008 From: siddhartha.veedaluru at gmail.com (siddhartha veedaluru) Date: Mon, 17 Mar 2008 12:07:55 +0530 Subject: [python-win32] Library not Registered Error while running Message-ID: <424b71ec0803162337u54382ca1he7e1183141a373c2@mail.gmail.com> Date: Fri, 14 Mar 2008 12:59:26 +0000 From: Tim Golden Subject: Re: [python-win32] Library not Registered Error while running WMI example script Cc: python-win32 at python.org Message-ID: <47DA76AE.2040809 at timgolden.me.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed siddhartha veedaluru wrote: > I have installed win32 extensions on my windows 2003 server > i'm using python 2.5.1. > > downloaded the wmi module 1.3.2 to my machine > used > > "python setup.py install" > > to install the module > > i tried run an example mentioned in the web page. it gave the following > error. > > File "C:\Python25\Lib\site-packages\wmi.py", line 157, in __init__ > comobj._oleobj_.GetTypeInfo().GetContainingTypeLib()[0].GetTypeComp() > pywintypes.com_error: (-2147319779, 'Library not registered.', None, None) > Script terminated. Just to test, could you run this code to see if it produces the same result? (This is basically what the wmi module does behind the scenes). import win32com.client win32com.client.GetObject ("winmgmts:") TJG ------------------------------------------- Hi , I have tried the snipped The script just terminted with any output or error. Thanks Siddhartha. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080317/cf718808/attachment.htm From mail at timgolden.me.uk Mon Mar 17 09:34:27 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 17 Mar 2008 08:34:27 +0000 Subject: [python-win32] Library not Registered Error while running In-Reply-To: <424b71ec0803162337u54382ca1he7e1183141a373c2@mail.gmail.com> References: <424b71ec0803162337u54382ca1he7e1183141a373c2@mail.gmail.com> Message-ID: <47DE2D13.5000802@timgolden.me.uk> siddhartha veedaluru wrote: >> From: Tim Golden >> Just to test, could you run this code to see if it produces >> the same result? (This is basically what the wmi module >> does behind the scenes). >> >> >> import win32com.client >> win32com.client.GetObject ("winmgmts:") >> >> >> TJG > ------------------------------------------- > Hi , > > I have tried the snipped > The script just terminted with any output or error. Well that's a shame (for me): it means that WMI is working ok on your machine in general... although I'd have been surprised if that weren't the case! Just to narrow down, could you run these lines in the interpreter to see if/where the error comes up: import wmi c = wmi.WMI () c.Win32_OperatingSystem () Thanks TJG From le.dahut at laposte.net Mon Mar 17 12:02:36 2008 From: le.dahut at laposte.net (le dahut) Date: Mon, 17 Mar 2008 12:02:36 +0100 Subject: [python-win32] Skip Alt+F4 Message-ID: <47DE4FCC.4080801@laposte.net> Hello, I'm writting a Wx app and I want to skip Alt+F4. I've used somehting like that : def OnKeyDown(self, event): print event.AltDown(), event.GetKeyCode() if event.AltDown() and event.GetKeyCode() == wx.WXK_F4: print 'try to close' Everything gets printed but my app closes anyway on Alt+F4, is there a way to skip this ? From p.f.moore at gmail.com Mon Mar 17 12:16:53 2008 From: p.f.moore at gmail.com (Paul Moore) Date: Mon, 17 Mar 2008 11:16:53 +0000 Subject: [python-win32] Skip Alt+F4 In-Reply-To: <47DE4FCC.4080801@laposte.net> References: <47DE4FCC.4080801@laposte.net> Message-ID: <79990c6b0803170416hab60f6aoe3c84bbe4ebdf25e@mail.gmail.com> On 17/03/2008, le dahut wrote: > I'm writting a Wx app and I want to skip Alt+F4. I've used somehting > like that : > def OnKeyDown(self, event): > print event.AltDown(), event.GetKeyCode() > if event.AltDown() and event.GetKeyCode() == wx.WXK_F4: > print 'try to close' > > Everything gets printed but my app closes anyway on Alt+F4, is there a > way to skip this ? (a) you should think hard before doing this - about the only reasonable reason for overriding the standard Alt-F4 on Windows, is to minimise to the tray rather than closing (b) if you still want to do this, look at the OnClose event, and override that. Paul. From siddhartha.veedaluru at gmail.com Mon Mar 17 12:24:03 2008 From: siddhartha.veedaluru at gmail.com (siddhartha veedaluru) Date: Mon, 17 Mar 2008 16:54:03 +0530 Subject: [python-win32] python-win32 Digest, Vol 60, Issue 26 In-Reply-To: References: Message-ID: <424b71ec0803170424s1055f7a4u24a937ab07d84703@mail.gmail.com> Hi Tim, I tried the snippet you sent to me. Same error. i opened the python shell and gave "import wmi" It give the same error. comobj._oleobj_.GetTypeInfo().GetContainingTypeLib()[0].GetTypeComp() com_error: (-2147319779, 'Library not registered.', None, None) Thanks for your responce. Siddhartha On Mon, Mar 17, 2008 at 4:30 PM, wrote: > Send python-win32 mailing list submissions to > python-win32 at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-win32 > or, via email, send a message with subject or body 'help' to > python-win32-request at python.org > > You can reach the person managing the list at > python-win32-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of python-win32 digest..." > > > Today's Topics: > > 1. Library not Registered Error while running (siddhartha veedaluru) > 2. Re: Library not Registered Error while running (Tim Golden) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 17 Mar 2008 12:07:55 +0530 > From: "siddhartha veedaluru" > Subject: [python-win32] Library not Registered Error while running > To: python-win32 at python.org > Message-ID: > <424b71ec0803162337u54382ca1he7e1183141a373c2 at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > Date: Fri, 14 Mar 2008 12:59:26 +0000 > From: Tim Golden > Subject: Re: [python-win32] Library not Registered Error while running > WMI example script > Cc: python-win32 at python.org > Message-ID: <47DA76AE.2040809 at timgolden.me.uk> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > siddhartha veedaluru wrote: > > I have installed win32 extensions on my windows 2003 server > > i'm using python 2.5.1. > > > > downloaded the wmi module 1.3.2 to my machine > > used > > > > "python setup.py install" > > > > to install the module > > > > i tried run an example mentioned in the web page. it gave the following > > error. > > > > File "C:\Python25\Lib\site-packages\wmi.py", line 157, in __init__ > > comobj._oleobj_.GetTypeInfo().GetContainingTypeLib()[0].GetTypeComp() > > pywintypes.com_error: (-2147319779, 'Library not registered.', None, > None) > > Script terminated. > > Just to test, could you run this code to see if it produces > the same result? (This is basically what the wmi module > does behind the scenes). > > > import win32com.client > win32com.client.GetObject ("winmgmts:") > > > TJG > ------------------------------------------- > Hi , > > I have tried the snipped > The script just terminted with any output or error. > > > Thanks > Siddhartha. > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > http://mail.python.org/pipermail/python-win32/attachments/20080317/cf718808/attachment-0001.htm > > ------------------------------ > > Message: 2 > Date: Mon, 17 Mar 2008 08:34:27 +0000 > From: Tim Golden > Subject: Re: [python-win32] Library not Registered Error while running > Cc: python-win32 at python.org > Message-ID: <47DE2D13.5000802 at timgolden.me.uk> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > siddhartha veedaluru wrote: > >> From: Tim Golden > >> Just to test, could you run this code to see if it produces > >> the same result? (This is basically what the wmi module > >> does behind the scenes). > >> > >> > >> import win32com.client > >> win32com.client.GetObject ("winmgmts:") > >> > >> > >> TJG > > > ------------------------------------------- > > Hi , > > > > I have tried the snipped > > The script just terminted with any output or error. > > Well that's a shame (for me): it means that WMI is working > ok on your machine in general... although I'd have been > surprised if that weren't the case! > > Just to narrow down, could you run these lines in the interpreter > to see if/where the error comes up: > > > import wmi > c = wmi.WMI () > c.Win32_OperatingSystem () > > > Thanks > TJG > > > ------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > End of python-win32 Digest, Vol 60, Issue 26 > ******************************************** > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080317/f870cfb5/attachment.htm From siddhartha.veedaluru at gmail.com Mon Mar 17 12:27:34 2008 From: siddhartha.veedaluru at gmail.com (siddhartha veedaluru) Date: Mon, 17 Mar 2008 16:57:34 +0530 Subject: [python-win32] Library not Registered Error while running Message-ID: <424b71ec0803170427q7fd4f826x2955c9f835e5c2ef@mail.gmail.com> Hi Tim, I tried the snippet you sent to me. Same error. i opened the python shell and gave "import wmi" It give the same error. comobj._oleobj_.GetTypeInfo().GetContainingTypeLib()[0].GetTypeComp() com_error: (-2147319779, 'Library not registered.', None, None) Thanks for your responce. Siddhartha On Mon, Mar 17, 2008 at 4:30 PM, wrote: > Send python-win32 mailing list submissions to > python-win32 at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-win32 > or, via email, send a message with subject or body 'help' to > python-win32-request at python.org > > You can reach the person managing the list at > python-win32-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of python-win32 digest..." > > > Today's Topics: > > 1. Library not Registered Error while running (siddhartha veedaluru) > 2. Re: Library not Registered Error while running (Tim Golden) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 17 Mar 2008 12:07:55 +0530 > From: "siddhartha veedaluru" > Subject: [python-win32] Library not Registered Error while running > To: python-win32 at python.org > Message-ID: > <424b71ec0803162337u54382ca1he7e1183141a373c2 at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > Date: Fri, 14 Mar 2008 12:59:26 +0000 > From: Tim Golden > Subject: Re: [python-win32] Library not Registered Error while running > WMI example script > Cc: python-win32 at python.org > Message-ID: <47DA76AE.2040809 at timgolden.me.uk> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > siddhartha veedaluru wrote: > > I have installed win32 extensions on my windows 2003 server > > i'm using python 2.5.1. > > > > downloaded the wmi module 1.3.2 to my machine > > used > > > > "python setup.py install" > > > > to install the module > > > > i tried run an example mentioned in the web page. it gave the following > > error. > > > > File "C:\Python25\Lib\site-packages\wmi.py", line 157, in __init__ > > comobj._oleobj_.GetTypeInfo().GetContainingTypeLib()[0].GetTypeComp() > > pywintypes.com_error: (-2147319779, 'Library not registered.', None, > None) > > Script terminated. > > Just to test, could you run this code to see if it produces > the same result? (This is basically what the wmi module > does behind the scenes). > > > import win32com.client > win32com.client.GetObject ("winmgmts:") > > > TJG > ------------------------------------------- > Hi , > > I have tried the snipped > The script just terminted with any output or error. > > > Thanks > Siddhartha. > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > http://mail.python.org/pipermail/python-win32/attachments/20080317/cf718808/attachment-0001.htm > > ------------------------------ > > Message: 2 > Date: Mon, 17 Mar 2008 08:34:27 +0000 > From: Tim Golden > Subject: Re: [python-win32] Library not Registered Error while running > Cc: python-win32 at python.org > Message-ID: <47DE2D13.5000802 at timgolden.me.uk> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > siddhartha veedaluru wrote: > >> From: Tim Golden > >> Just to test, could you run this code to see if it produces > >> the same result? (This is basically what the wmi module > >> does behind the scenes). > >> > >> > >> import win32com.client > >> win32com.client.GetObject ("winmgmts:") > >> > >> > >> TJG > > > ------------------------------------------- > > Hi , > > > > I have tried the snipped > > The script just terminted with any output or error. > > Well that's a shame (for me): it means that WMI is working > ok on your machine in general... although I'd have been > surprised if that weren't the case! > > Just to narrow down, could you run these lines in the interpreter > to see if/where the error comes up: > > > import wmi > c = wmi.WMI () > c.Win32_OperatingSystem () > > > Thanks > TJG > > > ------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > End of python-win32 Digest, Vol 60, Issue 26 > ******************************************** > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080317/7926d8d5/attachment-0001.htm From mail at timgolden.me.uk Mon Mar 17 12:51:01 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 17 Mar 2008 11:51:01 +0000 Subject: [python-win32] python-win32 Digest, Vol 60, Issue 26 In-Reply-To: <424b71ec0803170424s1055f7a4u24a937ab07d84703@mail.gmail.com> References: <424b71ec0803170424s1055f7a4u24a937ab07d84703@mail.gmail.com> Message-ID: <47DE5B25.6070804@timgolden.me.uk> siddhartha veedaluru wrote: > Hi Tim, > > I tried the snippet you sent to me. > Same error. > > i opened the python shell and gave "import wmi" > It give the same error. > > comobj._oleobj_.GetTypeInfo().GetContainingTypeLib()[0].GetTypeComp() > com_error: (-2147319779, 'Library not registered.', None, None) Aha. That's what I wanted to know. (In fact, now I look at your original post, the same information's shown there. Shame on me for not checking). It *looks* as though one (or more) of the WMI DLLs which in my system are in c:\windows\system32\wbem need to be reregistered. It might be something else, however. Can you try running regsvr32.exe against the DLLs in (your equivalent of) c:\windows\system32\wbem? I'm sorry this is so involved: I've never encountered someone with this error before when running WMI. TJG From le.dahut at laposte.net Mon Mar 17 14:11:14 2008 From: le.dahut at laposte.net (le dahut) Date: Mon, 17 Mar 2008 14:11:14 +0100 Subject: [python-win32] Skip Alt+F4 In-Reply-To: <79990c6b0803170416hab60f6aoe3c84bbe4ebdf25e@mail.gmail.com> References: <47DE4FCC.4080801@laposte.net> <79990c6b0803170416hab60f6aoe3c84bbe4ebdf25e@mail.gmail.com> Message-ID: <47DE6DF2.6050108@laposte.net> Oh yes ! That's it. Thank you. It is a frame that's used by a service to display some information before uncancelable forced reboot. I now have to determinate how to modify the informations displayed in the frame. Should my program run in the class of the frame ? Or should it get a sort of handler to the frame and modify the content of a text box ? I don't know if the second way is possible. Paul Moore a ?crit : > On 17/03/2008, le dahut wrote: >> I'm writting a Wx app and I want to skip Alt+F4. I've used somehting >> like that : >> def OnKeyDown(self, event): >> print event.AltDown(), event.GetKeyCode() >> if event.AltDown() and event.GetKeyCode() == wx.WXK_F4: >> print 'try to close' >> >> Everything gets printed but my app closes anyway on Alt+F4, is there a >> way to skip this ? > > (a) you should think hard before doing this - about the only > reasonable reason for overriding the standard Alt-F4 on Windows, is to > minimise to the tray rather than closing > > (b) if you still want to do this, look at the OnClose event, and override that. > > Paul. > > From Kyle.Rickey at bakerhughes.com Mon Mar 17 14:40:45 2008 From: Kyle.Rickey at bakerhughes.com (Rickey, Kyle W) Date: Mon, 17 Mar 2008 08:40:45 -0500 Subject: [python-win32] Running SQL queries on excel sheets In-Reply-To: <47DCEAF4.30200@lexicon.net> References: <47DA9207.8080402@timgolden.me.uk> <47DCEAF4.30200@lexicon.net> Message-ID: Thanks John, I'll check that out. -Kyle Rickey -----Original Message----- From: John Machin [mailto:sjmachin at lexicon.net] Sent: Sunday, March 16, 2008 4:40 AM To: Rickey, Kyle W Cc: python-win32 at python.org Subject: Re: [python-win32] Running SQL queries on excel sheets Rickey, Kyle W wrote: > Tim, thanks for your response. I've got 7 excel files that need reading > containing a total of ~6100 rows. I agree, about this code making me > sick :) That's not exactly "absolutely tons of data" :-) One problem with the ODBC approach to reading spreadsheets (at least with the MS Excel ODBC driver) is that it examines a limited number (e.g. 8 or 10) of rows to determine what type a column is. So the first 10 rows have floats in column X then Noddy's managed to get some text in cell X11 which is a fatal error for ODBC -- you can't continue. [snip] > Obviously, all that is only helpful up to a point. Is there some > reason why you can't just pull the data out straight into Python > structures and take it from there (or even push it into a Sqlite > memory database)? Perhaps you've got absolutely tons of data so > extracting it would be a pain? If not, consider using one of > the COM packages (win32com.client or comtypes) or something like > pyExcelerator to pull it out. > Consider the xlrd package (http://www.lexicon.net/sjmachin/xlrd.htm). It'll tell you what type the data is cell-by-cell -- you can then compare that with your expectations. HTH, John From patter001 at gmail.com Mon Mar 17 17:18:26 2008 From: patter001 at gmail.com (Kevin Patterson) Date: Mon, 17 Mar 2008 12:18:26 -0400 Subject: [python-win32] How to create a com_record? In-Reply-To: <000001c886bd$51f8cd20$030a0a0a@bobcat> References: <47DB0B0F.5020008@probo.com> <000001c886bd$51f8cd20$030a0a0a@bobcat> Message-ID: In case it helps, here's the overall description of the COM/app and what how this function fits: "COM_App" is a typelib (with multiple classes) for interfacing to an application that controls hardware on a USB port. When multiple applications are started it becomes impossible for users to write code for accessing a particular instance of the app, therefore a manager com "COM_Manager" was created. There are two important level of the COM_Manager. The first call gets you an object representing the particular application (Its not really "COM_App" per-se, its just another object that handles that app). Then there is "SomeFunction" below, it gives you the particular class for the particular COM_App. That is why it is takes a GUID as a parameter. I'm still learning about the details of the COM, I guess VT_RECORD is sort of the standard way of passing any structure information back and forth? My email access for the first half of the week is fairly limited but I'll still try to learn my way around the test harness to see if I can create an example. On Sat, Mar 15, 2008 at 12:54 PM, Mark Hammond wrote: > Just to clarify: > > > HRESULT SomeFunction( [in] GUID* pGuid, [out, retval, > iid_is(pGuid)] > IUnknown** ppUnknown); > > > win32com says that it needs a VT_RECORD in order to pass the GUID > information > > to the COM. But from previous email exchanges I can't just deifne some > GUID > > My understanding is that the IDispatch implementation of this method > declares that it wants a VT_RECORD - which win32com is trying to comply > with. > > When I get back home, my approach will be to simply try and repro the > issue > in the win32com test suite, which will at least give me a clearer picture > of > what is happening. If Kevin could take some steps towards this it would > help. > > Cheers, > > Mark > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080317/a1a03bc2/attachment.htm From sirgnip at gmail.com Mon Mar 17 18:09:32 2008 From: sirgnip at gmail.com (Scott Nelson) Date: Mon, 17 Mar 2008 12:09:32 -0500 Subject: [python-win32] Confusion with 'SetForegroundWindow() Message-ID: <2682ac9b0803171009h25213a3bsbd55b93760bbf988@mail.gmail.com> Greets... I'm looking to use the win32api and win32gui modules to do a bit of Windows tinkering (win2k, ActiveState's Python 2.4.1 distribution) and I've hit a snag. I'd like to have my process/window "steal" the focus from whatever window currently has it, get a bit of input from the keyboard, and then restore the focus back to the original window. In simple cases win32gui.SetForegroundWindow(hwnd) seems to be what I'm looking for. It works fine when I simply try to set focus to another window from my app. But, I'm seeing unexpected behavior when I go beyond that. I wrote a simple test script that enumerates through all visible windows and tries to give each one the focus in turn, after a short delay. It gets through 1-2 windows out of the 8-10 non-minimized windows I have open (IE, notepad, wordpad, etc.) and then gives me this: Traceback (most recent call last): File "D:\_code\python\apps\WinTests.py", line 25, in ? cycle_foreground() File "D:\_code\python\apps\WinTests.py", line 20, in cycle_foreground win32gui.SetForegroundWindow(handle) pywintypes.error: (0, 'SetForegroundWindow', 'No error message is available') What am I doing wrong in this case? Do I have some bad assumptions? Is my app allowed to "give away" its focus but can't force a different app's window with focus to "give away" its focus? Is there any other way to accomplish this? I've attempted using a mix of SetFocus(), BringWindowToTop(), and EnableWindow() but couldn't find a magic combo. I've attached my test script. Run it as "WinTests cycle" to attempt to cycle the focus through all top level windows and see the traceback. Run it as "WinTests 12345" to successfully set the focus to the window with hwnd of 12345. Run it as "WinTests" to get a list of all top level window names and their hwnd's. I've tried reading the win32 docs provided with ActiveState's PythonWin, I've read a bit on the win32 API on MSDN and I've googled around a bit, and haven't found much. So, I got curious and tried to code up something similar in C++. It uses the identical API calls (from what I can tell) and It seems to have no problem cycling through all the top-level windows. I've attached my .cpp file as well. Why the discrepancy between what I'm seeing with win32gui and c++? Thoughts? -Scott -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: SetForegroundWindow.cpp Url: http://mail.python.org/pipermail/python-win32/attachments/20080317/b29565b5/attachment.txt -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: WinTests.py Url: http://mail.python.org/pipermail/python-win32/attachments/20080317/b29565b5/attachment-0001.txt From tkapoor at wscm.net Mon Mar 17 18:53:23 2008 From: tkapoor at wscm.net (Tarun Kapoor) Date: Mon, 17 Mar 2008 12:53:23 -0500 Subject: [python-win32] python 2.5 Message-ID: I want to use python win32 extensions on python 2.5 but it seems like they were built for 2.3... I copied the win32 folders from C:\python23\lib\site-packages to C:\python25\lib\site-packages but it does not work.... Is there a workaround ? anyone using it ? -TK Disclaimer This e-mail and any attachments is confidential and intended solely for the use of the individual(s) to whom it is addressed. Any views or opinions presented are solely those of the author and do not necessarily represent those of Waterstone Capital Management, L.P and affiliates. If you are not the intended recipient, be advised that you have received this e-mail in error and that any use, dissemination, printing, forwarding or copying of this email is strictly prohibited. Please contact the sender if you have received this e-mail in error. You should also be aware that e-mails are susceptible to interference and you should not assume that the contents of this e-mail originated from the sender above or that they have been accurately reproduced in their original form. Waterstone Capital Management, L.P. and affiliates accepts no responsibility for information, or errors or omissions in this e-mail or use or misuse thereof. If in doubt, please verify the authenticity with the sender. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080317/82b9be5d/attachment-0001.htm From werner.bruhin at free.fr Mon Mar 17 19:05:55 2008 From: werner.bruhin at free.fr (Werner F. Bruhin) Date: Mon, 17 Mar 2008 19:05:55 +0100 Subject: [python-win32] python 2.5 In-Reply-To: References: Message-ID: <47DEB303.6010001@free.fr> Tarun Kapoor wrote: > I want to use python win32 extensions on python 2.5 but it seems like > they were built for 2.3? the newer builds are on sourceforge, including ones for Python 2.5 and 2.6. https://sourceforge.net/project/platformdownload.php?group_id=78018 Werner From tkapoor at wscm.net Mon Mar 17 19:09:37 2008 From: tkapoor at wscm.net (Tarun Kapoor) Date: Mon, 17 Mar 2008 13:09:37 -0500 Subject: [python-win32] python 2.5 In-Reply-To: <47DEB303.6010001@free.fr> References: <47DEB303.6010001@free.fr> Message-ID: Worked !! Mucho Gracias ! -----Original Message----- From: Werner F. Bruhin [mailto:werner.bruhin at free.fr] Sent: Monday, March 17, 2008 1:06 PM To: Tarun Kapoor Cc: python-win32 at python.org Subject: Re: python 2.5 Tarun Kapoor wrote: > I want to use python win32 extensions on python 2.5 but it seems like > they were built for 2.3... the newer builds are on sourceforge, including ones for Python 2.5 and 2.6. https://sourceforge.net/project/platformdownload.php?group_id=78018 Werner Disclaimer This e-mail and any attachments is confidential and intended solely for the use of the individual(s) to whom it is addressed. Any views or opinions presented are solely those of the author and do not necessarily represent those of Waterstone Capital Management, L.P and affiliates. If you are not the intended recipient, be advised that you have received this e-mail in error and that any use, dissemination, printing, forwarding or copying of this email is strictly prohibited. Please contact the sender if you have received this e-mail in error. You should also be aware that e-mails are susceptible to interference and you should not assume that the contents of this e-mail originated from the sender above or that they have been accurately reproduced in their original form. Waterstone Capital Management, L.P. and affiliates accepts no responsibility for information, or errors or omissions in this e-mail or use or misuse thereof. If in doubt, please verify the authenticity with the sender. From timr at probo.com Mon Mar 17 19:37:56 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 17 Mar 2008 11:37:56 -0700 Subject: [python-win32] python 2.5 In-Reply-To: References: Message-ID: <47DEBA84.3070902@probo.com> Tarun Kapoor wrote: > > I want to use python win32 extensions on python 2.5 but it seems like > they were built for 2.3? > > I copied the win32 folders from C:\python23\lib\site-packages to > C:\python25\lib\site-packages but it does not work?. > > Is there a workaround ? anyone using it ? > For future reference, a Python extension written in C only works for a single major version. That is, an extension built for 2.4.1 will work with any 2.4 version, but not with 2.3 or 2.5. This is because the Python interpreter actually lives in a DLL (python23.dll, python24.dll. python25.dll), and the extension must link with a single version of that DLL. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Mon Mar 17 19:41:35 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 17 Mar 2008 11:41:35 -0700 Subject: [python-win32] Confusion with 'SetForegroundWindow() In-Reply-To: <2682ac9b0803171009h25213a3bsbd55b93760bbf988@mail.gmail.com> References: <2682ac9b0803171009h25213a3bsbd55b93760bbf988@mail.gmail.com> Message-ID: <47DEBB5F.20300@probo.com> Scott Nelson wrote: > I'm looking to use the win32api and win32gui modules to do a bit of > Windows tinkering (win2k, ActiveState's Python 2.4.1 distribution) and > I've hit a snag. > > I'd like to have my process/window "steal" the focus from whatever > window currently has it, get a bit of input from the keyboard, and > then restore the focus back to the original window. > ... > But, I'm seeing unexpected behavior when I go beyond that. I wrote a > simple test script that enumerates through all visible windows and > tries to give each one the focus in turn, after a short delay. It > gets through 1-2 windows out of the 8-10 non-minimized windows I have > open (IE, notepad, wordpad, etc.) and then gives me this: > > Traceback (most recent call last): > File "D:\_code\python\apps\WinTests.py", line 25, in ? > cycle_foreground() > File "D:\_code\python\apps\WinTests.py", line 20, in cycle_foreground > win32gui.SetForegroundWindow(handle) > pywintypes.error: (0, 'SetForegroundWindow', 'No error message is available') > > What am I doing wrong in this case? ... > > I've attached my test script. Run it as "WinTests cycle" to attempt > to cycle the focus through all top level windows and see the > traceback. Your test runs to completion without error on my XP machine. Is it always the same window that causes it to explode? You didn't say what window it is. It is possible that there are some applications that do not want to become foreground unless it was their idea. SetForegroundWindow sends a WM_ACTIVATE message, and the application can veto the suggestion. Also, an application can call LockSetForegroundWindow to prevent another application from "stealing" the focus away. You may simply need to trap this error. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mdriscoll at co.marshall.ia.us Tue Mar 18 14:30:11 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Tue, 18 Mar 2008 08:30:11 -0500 (CDT) Subject: [python-win32] Skip Alt+F4 (le dahut) In-Reply-To: References: Message-ID: <011f01c888fc$71e7c550$96c051d8@mcis0492> Hi, > Date: Mon, 17 Mar 2008 14:11:14 +0100 > From: le dahut > Subject: Re: [python-win32] Skip Alt+F4 > To: Paul Moore > Cc: Python-Win32 List > Message-ID: <47DE6DF2.6050108 at laposte.net> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Oh yes ! That's it. Thank you. > > It is a frame that's used by a service to display some > information before uncancelable forced reboot. > > I now have to determinate how to modify the informations > displayed in the frame. > > Should my program run in the class of the frame ? Or should > it get a sort of handler to the frame and modify the content > of a text box ? > I don't know if the second way is possible. If you created the frame and the TextCtrl in wxPython, then it's pretty trivial to grab the contents from it and edit it as much as you like. Something like this will get the info: text = myTextCtrl.GetValue() Now it's up to you what you want to do with it. You can use the SetValue() method to change it to something else. If you're using StaticText controls, the methods would be GetLabel() and SetLabel() respectively. All of this is in the wx docs: http://www.wxpython.org/docs/api/wx.TextCtrl-class.html http://www.wxpython.org/docs/api/wx.StaticText-class.html And why are you posting wx questions to the pywin32 list anyway? Mike > > Paul Moore a ?crit : > > On 17/03/2008, le dahut wrote: > >> I'm writting a Wx app and I want to skip Alt+F4. I've used > somehting > >> like that : > >> def OnKeyDown(self, event): > >> print event.AltDown(), event.GetKeyCode() > >> if event.AltDown() and event.GetKeyCode() == wx.WXK_F4: > >> print 'try to close' > >> > >> Everything gets printed but my app closes anyway on > Alt+F4, is there > >> a way to skip this ? > > > > (a) you should think hard before doing this - about the only > > reasonable reason for overriding the standard Alt-F4 on > Windows, is to > > minimise to the tray rather than closing > > > > (b) if you still want to do this, look at the OnClose > event, and override that. > > > > Paul. > > From siddhartha.veedaluru at gmail.com Tue Mar 18 06:59:41 2008 From: siddhartha.veedaluru at gmail.com (siddhartha veedaluru) Date: Tue, 18 Mar 2008 11:29:41 +0530 Subject: [python-win32] Library not Registered Error while running Message-ID: <424b71ec0803172259v1e254a02mb45021bd55448c3c@mail.gmail.com> Bingo That Worked. Thanks, Tim On Mon, Mar 17, 2008 at 11:25 PM, wrote: > Send python-win32 mailing list submissions to > python-win32 at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-win32 > or, via email, send a message with subject or body 'help' to > python-win32-request at python.org > > You can reach the person managing the list at > python-win32-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of python-win32 digest..." > > > Today's Topics: > > 1. Re: python-win32 Digest, Vol 60, Issue 26 (Tim Golden) > 2. Re: Skip Alt+F4 (le dahut) > 3. Re: Running SQL queries on excel sheets (Rickey, Kyle W) > 4. Re: How to create a com_record? (Kevin Patterson) > 5. Confusion with 'SetForegroundWindow() (Scott Nelson) > 6. python 2.5 (Tarun Kapoor) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 17 Mar 2008 11:51:01 +0000 > From: Tim Golden > Subject: Re: [python-win32] python-win32 Digest, Vol 60, Issue 26 > Cc: python-win32 at python.org > Message-ID: <47DE5B25.6070804 at timgolden.me.uk> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > siddhartha veedaluru wrote: > > Hi Tim, > > > > I tried the snippet you sent to me. > > Same error. > > > > i opened the python shell and gave "import wmi" > > It give the same error. > > > > comobj._oleobj_.GetTypeInfo().GetContainingTypeLib()[0].GetTypeComp() > > com_error: (-2147319779, 'Library not registered.', None, None) > > Aha. That's what I wanted to know. (In fact, now I look > at your original post, the same information's shown there. > Shame on me for not checking). > > It *looks* as though one (or more) of the WMI DLLs which in > my system are in c:\windows\system32\wbem need to be reregistered. > It might be something else, however. Can you try running > > regsvr32.exe against the DLLs in (your equivalent of) > c:\windows\system32\wbem? > > I'm sorry this is so involved: I've never encountered someone > with this error before when running WMI. > > TJG > > > ------------------------------ > > Message: 2 > Date: Mon, 17 Mar 2008 14:11:14 +0100 > From: le dahut > Subject: Re: [python-win32] Skip Alt+F4 > To: Paul Moore > Cc: Python-Win32 List > Message-ID: <47DE6DF2.6050108 at laposte.net> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Oh yes ! That's it. Thank you. > > It is a frame that's used by a service to display some information > before uncancelable forced reboot. > > I now have to determinate how to modify the informations displayed in > the frame. > > Should my program run in the class of the frame ? Or should it get a > sort of handler to the frame and modify the content of a text box ? > I don't know if the second way is possible. > > Paul Moore a ?crit : > > On 17/03/2008, le dahut wrote: > >> I'm writting a Wx app and I want to skip Alt+F4. I've used somehting > >> like that : > >> def OnKeyDown(self, event): > >> print event.AltDown(), event.GetKeyCode() > >> if event.AltDown() and event.GetKeyCode() == wx.WXK_F4: > >> print 'try to close' > >> > >> Everything gets printed but my app closes anyway on Alt+F4, is there a > >> way to skip this ? > > > > (a) you should think hard before doing this - about the only > > reasonable reason for overriding the standard Alt-F4 on Windows, is to > > minimise to the tray rather than closing > > > > (b) if you still want to do this, look at the OnClose event, and > override that. > > > > Paul. > > > > > > > ------------------------------ > > Message: 3 > Date: Mon, 17 Mar 2008 08:40:45 -0500 > From: "Rickey, Kyle W" > Subject: Re: [python-win32] Running SQL queries on excel sheets > To: > Message-ID: > > > Content-Type: text/plain; charset="us-ascii" > > Thanks John, I'll check that out. > > -Kyle Rickey > > -----Original Message----- > From: John Machin [mailto:sjmachin at lexicon.net] > Sent: Sunday, March 16, 2008 4:40 AM > To: Rickey, Kyle W > Cc: python-win32 at python.org > Subject: Re: [python-win32] Running SQL queries on excel sheets > > Rickey, Kyle W wrote: > > Tim, thanks for your response. I've got 7 excel files that need > reading > > containing a total of ~6100 rows. I agree, about this code making me > > sick :) > > That's not exactly "absolutely tons of data" :-) > > One problem with the ODBC approach to reading spreadsheets (at least > with the MS Excel ODBC driver) is that it examines a limited number > (e.g. 8 or 10) of rows to determine what type a column is. So the first > 10 rows have floats in column X then Noddy's managed to get some text in > > cell X11 which is a fatal error for ODBC -- you can't continue. > > [snip] > > > Obviously, all that is only helpful up to a point. Is there some > > reason why you can't just pull the data out straight into Python > > structures and take it from there (or even push it into a Sqlite > > memory database)? Perhaps you've got absolutely tons of data so > > extracting it would be a pain? If not, consider using one of > > the COM packages (win32com.client or comtypes) or something like > > pyExcelerator to pull it out. > > > > Consider the xlrd package (http://www.lexicon.net/sjmachin/xlrd.htm). > It'll tell you what type the data is cell-by-cell -- you can then > compare that with your expectations. > > HTH, > John > > > > > ------------------------------ > > Message: 4 > Date: Mon, 17 Mar 2008 12:18:26 -0400 > From: "Kevin Patterson" > Subject: Re: [python-win32] How to create a com_record? > To: mhammond at skippinet.com.au > Cc: Python-Win32 List > Message-ID: > > Content-Type: text/plain; charset="iso-8859-1" > > In case it helps, here's the overall description of the COM/app and what > how > this function fits: "COM_App" is a typelib (with multiple classes) for > interfacing to an application that controls hardware on a USB port. When > multiple applications are started it becomes impossible for users to write > code for accessing a particular instance of the app, therefore a manager > com > "COM_Manager" was created. There are two important level of the > COM_Manager. > The first call gets you an object representing the particular application > (Its not really "COM_App" per-se, its just another object that handles > that > app). Then there is "SomeFunction" below, it gives you the particular > class > for the particular COM_App. That is why it is takes a GUID as a parameter. > > I'm still learning about the details of the COM, I guess VT_RECORD is > sort > of the standard way of passing any structure information back and forth? > My > email access for the first half of the week is fairly limited but I'll > still > try to learn my way around the test harness to see if I can create an > example. > > On Sat, Mar 15, 2008 at 12:54 PM, Mark Hammond > wrote: > > > Just to clarify: > > > > > HRESULT SomeFunction( [in] GUID* pGuid, [out, retval, > > iid_is(pGuid)] > > IUnknown** ppUnknown); > > > > > win32com says that it needs a VT_RECORD in order to pass the > GUID > > information > > > to the COM. But from previous email exchanges I can't just deifne some > > GUID > > > > My understanding is that the IDispatch implementation of this method > > declares that it wants a VT_RECORD - which win32com is trying to comply > > with. > > > > When I get back home, my approach will be to simply try and repro the > > issue > > in the win32com test suite, which will at least give me a clearer > picture > > of > > what is happening. If Kevin could take some steps towards this it would > > help. > > > > Cheers, > > > > Mark > > > > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > http://mail.python.org/pipermail/python-win32/attachments/20080317/a1a03bc2/attachment-0001.htm > > ------------------------------ > > Message: 5 > Date: Mon, 17 Mar 2008 12:09:32 -0500 > From: "Scott Nelson" > Subject: [python-win32] Confusion with 'SetForegroundWindow() > To: python-win32 at python.org > Message-ID: > <2682ac9b0803171009h25213a3bsbd55b93760bbf988 at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > Greets... > > I'm looking to use the win32api and win32gui modules to do a bit of > Windows tinkering (win2k, ActiveState's Python 2.4.1 distribution) and > I've hit a snag. > > I'd like to have my process/window "steal" the focus from whatever > window currently has it, get a bit of input from the keyboard, and > then restore the focus back to the original window. > > In simple cases win32gui.SetForegroundWindow(hwnd) seems to be what > I'm looking for. It works fine when I simply try to set focus to > another window from my app. > > But, I'm seeing unexpected behavior when I go beyond that. I wrote a > simple test script that enumerates through all visible windows and > tries to give each one the focus in turn, after a short delay. It > gets through 1-2 windows out of the 8-10 non-minimized windows I have > open (IE, notepad, wordpad, etc.) and then gives me this: > > Traceback (most recent call last): > File "D:\_code\python\apps\WinTests.py", line 25, in ? > cycle_foreground() > File "D:\_code\python\apps\WinTests.py", line 20, in cycle_foreground > win32gui.SetForegroundWindow(handle) > pywintypes.error: (0, 'SetForegroundWindow', 'No error message is > available') > > What am I doing wrong in this case? Do I have some bad assumptions? > Is my app allowed to "give away" its focus but can't force a different > app's window with focus to "give away" its focus? Is there any other > way to accomplish this? I've attempted using a mix of SetFocus(), > BringWindowToTop(), and EnableWindow() but couldn't find a magic > combo. > > I've attached my test script. Run it as "WinTests cycle" to attempt > to cycle the focus through all top level windows and see the > traceback. Run it as "WinTests 12345" to successfully set the focus > to the window with hwnd of 12345. Run it as "WinTests" to get a list > of all top level window names and their hwnd's. > > I've tried reading the win32 docs provided with ActiveState's > PythonWin, I've read a bit on the win32 API on MSDN and I've googled > around a bit, and haven't found much. > > So, I got curious and tried to code up something similar in C++. It > uses the identical API calls (from what I can tell) and It seems to > have no problem cycling through all the top-level windows. I've > attached my .cpp file as well. > > Why the discrepancy between what I'm seeing with win32gui and c++? > Thoughts? > > -Scott > -------------- next part -------------- > An embedded and charset-unspecified text was scrubbed... > Name: SetForegroundWindow.cpp > Url: > http://mail.python.org/pipermail/python-win32/attachments/20080317/b29565b5/attachment-0002.txt > -------------- next part -------------- > An embedded and charset-unspecified text was scrubbed... > Name: WinTests.py > Url: > http://mail.python.org/pipermail/python-win32/attachments/20080317/b29565b5/attachment-0003.txt > > ------------------------------ > > Message: 6 > Date: Mon, 17 Mar 2008 12:53:23 -0500 > From: "Tarun Kapoor" > Subject: [python-win32] python 2.5 > To: > Message-ID: > > Content-Type: text/plain; charset="us-ascii" > > I want to use python win32 extensions on python 2.5 but it seems like > they were built for 2.3... > > I copied the win32 folders from C:\python23\lib\site-packages to > C:\python25\lib\site-packages but it does not work.... > > Is there a workaround ? anyone using it ? > > -TK > > > > Disclaimer > > This e-mail and any attachments is confidential and intended solely for > the use of the individual(s) to whom it is addressed. Any views or opinions > presented are solely those of the author and do not necessarily represent > those of Waterstone Capital Management, L.P and affiliates. If you are not > the intended recipient, be advised that you have received this e-mail in > error and that any use, dissemination, printing, forwarding or copying of > this email is strictly prohibited. Please contact the sender if you have > received this e-mail in error. You should also be aware that e-mails are > susceptible to interference and you should not assume that the contents of > this e-mail originated from the sender above or that they have been > accurately reproduced in their original form. Waterstone Capital Management, > L.P. and affiliates accepts no responsibility for information, or errors > or omissions in this e-mail or use or misuse thereof. If in doubt, please > verify the authenticity with the! > sender. > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > http://mail.python.org/pipermail/python-win32/attachments/20080317/82b9be5d/attachment.htm > > ------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > End of python-win32 Digest, Vol 60, Issue 28 > ******************************************** > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080318/8de50596/attachment-0001.htm From mail at timgolden.me.uk Tue Mar 18 16:33:11 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 18 Mar 2008 15:33:11 +0000 Subject: [python-win32] Library not Registered Error while running In-Reply-To: <424b71ec0803172259v1e254a02mb45021bd55448c3c@mail.gmail.com> References: <424b71ec0803172259v1e254a02mb45021bd55448c3c@mail.gmail.com> Message-ID: <47DFE0B7.7070705@timgolden.me.uk> siddhartha veedaluru wrote: > Bingo That Worked. > > Thanks, > Tim Goodness! It's so long ago I've forgotten what I even suggested. I'm glad it worked (whatever it was). Probably worth trimming the digest next time, tho', so people know what you're so happy about ;) (For the archives, I assume it's re-registering the various WBEM .DLLs which did the trick). TJG From timr at probo.com Tue Mar 18 18:10:03 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 18 Mar 2008 10:10:03 -0700 Subject: [python-win32] Confusion with 'SetForegroundWindow() In-Reply-To: <2682ac9b0803180633h19a82b16ud29ed639d43dd2e7@mail.gmail.com> References: <2682ac9b0803171009h25213a3bsbd55b93760bbf988@mail.gmail.com> <47DEBB5F.20300@probo.com> <2682ac9b0803180633h19a82b16ud29ed639d43dd2e7@mail.gmail.com> Message-ID: <47DFF76B.3010608@probo.com> Scott Nelson wrote: > FWIW, when the exception is thrown and caught, the window's icon in > the taskbar will blink. I believe this means the window received an > event it can't handle or display? > Right. Either the event loop is busy, or the current foreground application refused to yield. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From le.dahut at laposte.net Tue Mar 18 18:12:02 2008 From: le.dahut at laposte.net (le dahut) Date: Tue, 18 Mar 2008 18:12:02 +0100 Subject: [python-win32] Py2exe and try/except Message-ID: <47DFF7E2.10602@laposte.net> Hello, I've noticed that when using win32 api in a try/except statement, if the error doesn't appear on the line just after try, I get a .exe.log file. Example : * This genreates .exe.log : try: logging.info('mounting printer') w32print.AddPrinterConnection(printer) except Exception, e: logging.error('Error mounting printer') * This does not : logging.info('mounting printer') try: w32print.AddPrinterConnection(printer) except Exception, e: logging.error('Error mounting printer') Any idea ? From darenr at madaboutcable.com Wed Mar 19 10:46:41 2008 From: darenr at madaboutcable.com (Daren Russell) Date: Wed, 19 Mar 2008 09:46:41 +0000 Subject: [python-win32] Reading events from event logs using wmi Message-ID: Hi I've been having a look at the wmi module in the hope of being able to read the event logs of a windows server and save them as a standard text file for archival purposes. However, the only method I can see is the BackupEventLog method. I kind of figured if I opened the log, and did a for loop through it I could read each event logged - this doesn't seem to be the case ;-) (or I'm being a bit dumb ;-) ) Is it possible to read individual events from an already written log file using this module? If there is a documented method (I've found the watcher method, but do not want this) then all pointers to relevant documentation (or snippets of code!) appreciated. Thanks Daren From mail at timgolden.me.uk Wed Mar 19 13:03:15 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 19 Mar 2008 12:03:15 +0000 Subject: [python-win32] Reading events from event logs using wmi In-Reply-To: References: Message-ID: <47E10103.5060705@timgolden.me.uk> Daren Russell wrote: > I've been having a look at the wmi module in the hope of being able to > read the event logs of a windows server and save them as a standard text > file for archival purposes. > > However, the only method I can see is the BackupEventLog method. I kind > of figured if I opened the log, and did a for loop through it I could > read each event logged - this doesn't seem to be the case ;-) (or I'm > being a bit dumb ;-) ) > > Is it possible to read individual events from an already written log > file using this module? If there is a documented method (I've found the > watcher method, but do not want this) then all pointers to relevant > documentation (or snippets of code!) appreciated. Welcome to WMI! There's so much WMI stuff around the web (not usually referring to Python) that usually a search such as "wmi read event log" will be enough to set you on the right path: http://www.google.co.uk/search?q=wmi+read+event+log Obviously, you then have to translate the examples into Python, which is rarely difficult once you've got the hang... To get you going here's a really basic query making use only of the fact that I can get the name of the relevant WMI class from the watcher example you refer to: import wmi c = wmi.WMI () # can put other server here if needed for i in c.Win32_NTLogEvent (): print i break Since the "print i" bit outputs a useful dump, we can see that the Win32_NTLogEvent records have fields such as: EventType and Logfile. The EventType you have to search for: http://www.google.co.uk/search?q=Win32_NTlogevent+eventtype but amounts to 2 for, say, Warnings. Taken all together, you can query the System log for Warnings like this (you might want to qualify the time as well): import wmi c = wmi.WMI () for log in c.Win32_NTLogEvent (EventType=2, Logfile="System"): print log Hope that gets you on your way. TJG From darenr at madaboutcable.com Wed Mar 19 14:45:41 2008 From: darenr at madaboutcable.com (Daren Russell) Date: Wed, 19 Mar 2008 13:45:41 +0000 Subject: [python-win32] Reading events from event logs using wmi In-Reply-To: <47E10103.5060705@timgolden.me.uk> References: <47E10103.5060705@timgolden.me.uk> Message-ID: Tim Golden wrote: > Daren Russell wrote: >> I've been having a look at the wmi module in the hope of being able to >> read the event logs of a windows server and save them as a standard text >> file for archival purposes. >> >> However, the only method I can see is the BackupEventLog method. I kind >> of figured if I opened the log, and did a for loop through it I could >> read each event logged - this doesn't seem to be the case ;-) (or I'm >> being a bit dumb ;-) ) >> >> Is it possible to read individual events from an already written log >> file using this module? If there is a documented method (I've found the >> watcher method, but do not want this) then all pointers to relevant >> documentation (or snippets of code!) appreciated. > > Welcome to WMI! There's so much WMI stuff around the web (not usually > referring to Python) that usually a search such as "wmi read event log" > will be enough to set you on the right path: > > http://www.google.co.uk/search?q=wmi+read+event+log > > Obviously, you then have to translate the examples into Python, > which is rarely difficult once you've got the hang... To get you > going here's a really basic query making use only of the fact > that I can get the name of the relevant WMI class from the > watcher example you refer to: > > > import wmi > > c = wmi.WMI () # can put other server here if needed > for i in c.Win32_NTLogEvent (): > print i > break > > > > Since the "print i" bit outputs a useful dump, we can > see that the Win32_NTLogEvent records have fields such > as: EventType and Logfile. The EventType you have to > search for: > > http://www.google.co.uk/search?q=Win32_NTlogevent+eventtype > > but amounts to 2 for, say, Warnings. > > Taken all together, you can query the System log for Warnings > like this (you might want to qualify the time as well): > > > import wmi > > c = wmi.WMI () > for log in c.Win32_NTLogEvent (EventType=2, Logfile="System"): > print log > > > > Hope that gets you on your way. > > TJG Hi Tim, Thanks for that. I have found an example for what I want written in VBS, which is why I tried the for... loop I mentioned, as that is basically what that script did (though I'm even worse at vbs than I am with Python ;-) ) I've found details on the MSDN site, listing the class and now I (sort of!!) understand how it links in with your wmi module, but is there a way to get all events in one go, as that is basically what I need to do to write a text version of the log to an archive. If I leave the EventType parameter out, it defaults to '3' - I guess I could do multiple queries and then sort the output by retrieved dates, but it seems a bit long winded! Thanks again for your help and the pointers. Daren From mail at timgolden.me.uk Wed Mar 19 15:08:33 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 19 Mar 2008 14:08:33 +0000 Subject: [python-win32] Reading events from event logs using wmi In-Reply-To: References: <47E10103.5060705@timgolden.me.uk> Message-ID: <47E11E61.30706@timgolden.me.uk> Daren Russell wrote: > Thanks for that. I have found an example for what I want written in > VBS, which is why I tried the for... loop I mentioned, as that is > basically what that script did (though I'm even worse at vbs than I am > with Python ;-) ) > > I've found details on the MSDN site, listing the class and now I (sort > of!!) understand how it links in with your wmi module, but is there a > way to get all events in one go, as that is basically what I need to do > to write a text version of the log to an archive. If I leave the > EventType parameter out, it defaults to '3' - I guess I could do > multiple queries and then sort the output by retrieved dates, but it > seems a bit long winded! The way WMI works in general is that you issue a pseudo-SQL query against a pseudo-database and wait for a pseudo-rowset to be returned. You can add a WHERE clause to narrow things down. The wmi module wraps the fiddly plumbing needed to make the connection in the first place and makes typical queries pythonic so that a WQL query like: SELECT Logfile, RecordNumber FROM Win32_NTLogEvent WHERE Logfile = "Application" becomes wmi.WMI ().Win32_NTLogEvent (Logfile="Application") (Most queries are along the lines of: What are the network devices active on my machine? What are the phyiscal partitions on my disks? etc.) Clearly this only works for equi-filters; if you need to do things like "AND TimeGenerated > '20080101'" then you'll need to call the .query method of the wmi namespace which passes the WQL along to the WMI subsystem directly. Even then, the objects returned are wrapped to be easier to handle under Python. To get any of the WMI stuff unqualified, you simply pass no qualifiers at all. So... (be prepared for a long wait). import csv import wmi c = wmi.WMI () writer = csv.writer (open ("logs.csv", "wb")) writer.writerows ( (( log.Logfile, log.RecordNumber, log.Type, log.EventCode, log.Message, log.Type, log.TimeGenerated ) for log in c.Win32_NTLogEvent ()) ) TJG From darenr at madaboutcable.com Wed Mar 19 15:41:40 2008 From: darenr at madaboutcable.com (Daren Russell) Date: Wed, 19 Mar 2008 14:41:40 +0000 Subject: [python-win32] Reading events from event logs using wmi In-Reply-To: <47E11E61.30706@timgolden.me.uk> References: <47E10103.5060705@timgolden.me.uk> <47E11E61.30706@timgolden.me.uk> Message-ID: Tim Golden wrote: > Daren Russell wrote: >> Thanks for that. I have found an example for what I want written in >> VBS, which is why I tried the for... loop I mentioned, as that is >> basically what that script did (though I'm even worse at vbs than I am >> with Python ;-) ) >> >> I've found details on the MSDN site, listing the class and now I (sort >> of!!) understand how it links in with your wmi module, but is there a >> way to get all events in one go, as that is basically what I need to do >> to write a text version of the log to an archive. If I leave the >> EventType parameter out, it defaults to '3' - I guess I could do >> multiple queries and then sort the output by retrieved dates, but it >> seems a bit long winded! > > The way WMI works in general is that you issue a pseudo-SQL > query against a pseudo-database and wait for a pseudo-rowset > to be returned. You can add a WHERE clause to narrow things down. > > The wmi module wraps the fiddly plumbing needed to make > the connection in the first place and makes typical > queries pythonic so that a WQL query like: > > SELECT Logfile, RecordNumber > FROM Win32_NTLogEvent > WHERE Logfile = "Application" > > becomes > > wmi.WMI ().Win32_NTLogEvent (Logfile="Application") > > (Most queries are along the lines of: What are the > network devices active on my machine? What are the > phyiscal partitions on my disks? etc.) > > Clearly this only works for equi-filters; if you need > to do things like "AND TimeGenerated > '20080101'" then > you'll need to call the .query method of the wmi namespace > which passes the WQL along to the WMI subsystem directly. > Even then, the objects returned are wrapped to be easier > to handle under Python. > > To get any of the WMI stuff unqualified, you simply pass no qualifiers > at all. So... (be prepared for a long wait). > > > import csv > import wmi > c = wmi.WMI () > > writer = csv.writer (open ("logs.csv", "wb")) > writer.writerows ( > (( > log.Logfile, > log.RecordNumber, > log.Type, > log.EventCode, > log.Message, > log.Type, > log.TimeGenerated > ) for log in c.Win32_NTLogEvent ()) > ) > > > > TJG Ah! That 'eureka' moment!. Thank-you for the explanation and code. It is very much appreciated. I did notice the pseudo-sql query in the examples I was attempting to convert, but did not understand how to get the attributes of the event. Thanks for clearing it all up for me. Regards Daren From le.dahut at laposte.net Thu Mar 20 11:01:34 2008 From: le.dahut at laposte.net (le dahut) Date: Thu, 20 Mar 2008 11:01:34 +0100 Subject: [python-win32] Reboot apis don't work in a NT service Message-ID: <47E235FE.4020409@laposte.net> Hello, I use a service tu update another. It download an InnoSetup file, launch it with /silent and restart the computer at the end of the process. To reboot the computer I've tried this different functions : win32api.ExitWindowsEx(EWX_REBOOT | EWX_FORCE) win32api.InitiateSystemShutdown(None, '', 0, True, 1) win32ts.WTSShutdownSystem(wts.WTS_CURRENT_SERVER_HANDLE, wts.WTS_WSD_REBOOT) wa.WinExec('shutdown -r -t 0 -f') I've correctly setup 'SeShutdownPrivilege' before calling them. The "bForceAppsClosed" is set to True Since I noticed that they didn't reboot the computer but raised an error, I've put them in a loop : while True: try: wa.ExitWindowsEx(...) break except Exception, e: logging.error('%s'%e) time.sleep(0.5) This permits to reboot the workstation after several minutes (between 3 and 9 minutes). I there a way to reboot a workstation while nobody has loged on ? From tejovathi.p at gmail.com Thu Mar 20 11:37:15 2008 From: tejovathi.p at gmail.com (Tejovathi P) Date: Thu, 20 Mar 2008 16:07:15 +0530 Subject: [python-win32] Regarding Threads and locals() Message-ID: Hi all, I have a GUI applicaion(along with threads). When the run button is pressed in the GUI a separate thread starts( Thread is created using beginthreadex) and does the required activity. Now, while the thread is being executed, i want the locals() present inside the thread's run function to be avaialbe in the GUI class from where the thread class is being created EG: *main.py* class WorkerThread(threading.Thread): def __init__(self, ): threading.Thread.__init__(self) # Start the thread and invoke the run method self.start() def run(self): # Start the thread. It executed self.func() as a separate thread self.workerThread, tid = win32process.beginthreadex(None, 0 , self.func ,(), 1) ....... def func(self): execfile(temp.py) class GUI(wxFrame): def __init__(self): ..... ..... def CreateThread(self): self.workerThread = WorkerThread() if name == _main_: ..... . .... . ..... *temp.py* i = 1 j = 2 k = 4 while(10000): print i print j print k i = 1+1 j = j+2 k = k + 3 Now, while the thread is executin func and printing i, j, k , In the main GUI thread how do i get the values of i, j ,k I tried with sys.modules, sys._current_frames, vars(). But nothing worked out. Ideally the locals() of func() should be passed to the GUI thread, how? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080320/ee00efd5/attachment.htm From mdriscoll at co.marshall.ia.us Thu Mar 20 15:13:38 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Thu, 20 Mar 2008 09:13:38 -0500 (CDT) Subject: [python-win32] Regarding Threads and locals() In-Reply-To: References: Message-ID: <003101c88a94$c1bb7560$96c051d8@mcis0492> > Message: 6 > Date: Thu, 20 Mar 2008 16:07:15 +0530 > From: "Tejovathi P" > Subject: [python-win32] Regarding Threads and locals() > To: python-win32 at python.org, py2exe-users at lists.sourceforge.net > Message-ID: > > Content-Type: text/plain; charset="iso-8859-1" > > Hi all, > > I have a GUI applicaion(along with threads). When the run > button is pressed > in the GUI a separate thread starts( Thread is created using > beginthreadex) > and does the > required activity. > Now, while the thread is being executed, i want the locals() > present inside > the thread's run function to be avaialbe in the GUI class > from where the > thread class is being created > > EG: > > *main.py* > > class WorkerThread(threading.Thread): > > def __init__(self, ): > threading.Thread.__init__(self) > # Start the thread and invoke the run method > self.start() > > def run(self): > # Start the thread. It executed self.func() as a > separate thread > self.workerThread, tid = > win32process.beginthreadex(None, 0 , > self.func ,(), 1) > ....... > > def func(self): > execfile(temp.py) > > class GUI(wxFrame): > def __init__(self): > ..... > ..... > def CreateThread(self): > > self.workerThread = WorkerThread() > > > if name == _main_: > ..... > . .... > . ..... > > *temp.py* > > i = 1 j = 2 > k = 4 > while(10000): > print i > print j > print k > i = 1+1 > j = j+2 > k = k + 3 > > > Now, while the thread is executin func and printing i, j, k , > In the main > GUI thread how do i get the values of i, j ,k > I tried with sys.modules, sys._current_frames, vars(). But > nothing worked > out. > > Ideally the locals() of func() should be passed to the GUI > thread, how? One of the recommended ways of doing this is to have the thread write that information to a file either send an event to the GUI that there's data there or use a timer in the GUI event loop that looks for that file. I'm actually messing with Tim Golden's watch_directory.py file for a VPN project I'm working on in which my wxPython GUI app watches a file for changes and then reads it. You can check out Golden's work here: http://tgolden.sc.sabren.com/python/win32_how_do_i/watch_directory_for_cha nges.html The Python docs talk about using the threading module's event object for basic communication, which is what I was talking about: http://docs.python.org/lib/event-objects.html In wxPython, I can wait for a threading event and then use a wx.PostEvent to let my GUI know that the thread had an event. I'm sure there are similar methods in Tkinter and pyGTK or whatever you're using. Mike From timr at probo.com Thu Mar 20 18:22:49 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 20 Mar 2008 10:22:49 -0700 Subject: [python-win32] Regarding Threads and locals() In-Reply-To: References: Message-ID: <47E29D69.70801@probo.com> Tejovathi P wrote: > Hi all, > > I have a GUI applicaion(along with threads). When the run button is > pressed in the GUI a separate thread starts( Thread is created using > beginthreadex) and does the > required activity. > Now, while the thread is being executed, i want the locals() present > inside the thread's run function to be avaialbe in the GUI class from > where the thread class is being created Why do you use execfile for this? That seems very odd to me. Also, why use beginthreadex instead of the native Thread module? Adding threading doesn't really change this problem. Just think about how you'd solve it without threading: by creating a class and using import: test.py: class Handler(): def run(): self.i = 1 self.j = 2 self.k = 4 while(10000): print i print j print k self.i = 1+1 self.j += 2 self.k += 3 main.py: def func(self): import temp self.thread = temp.Handler() self.thread.run() Now, the rest of the GUI can examine self.thread.i, self.thread.j, and self.thread.k. There are locking issues here, but that's left as an exercise for the reader. That's probably not the perfect solution, but it gives you the general direction. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mail at timgolden.me.uk Thu Mar 20 16:50:42 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 20 Mar 2008 15:50:42 +0000 Subject: [python-win32] Reboot apis don't work in a NT service In-Reply-To: <47E235FE.4020409@laposte.net> References: <47E235FE.4020409@laposte.net> Message-ID: <47E287D2.6050904@timgolden.me.uk> le dahut wrote: > To reboot the computer I've tried this different functions : > win32api.ExitWindowsEx(EWX_REBOOT | EWX_FORCE) > win32api.InitiateSystemShutdown(None, '', 0, True, 1) > win32ts.WTSShutdownSystem(wts.WTS_CURRENT_SERVER_HANDLE, wts.WTS_WSD_REBOOT) > wa.WinExec('shutdown -r -t 0 -f') > > I've correctly setup 'SeShutdownPrivilege' before calling them. > The "bForceAppsClosed" is set to True > > > Since I noticed that they didn't reboot the computer but raised an > error, I've put them in a loop : > while True: > try: > wa.ExitWindowsEx(...) > break > except Exception, e: > logging.error('%s'%e) > time.sleep(0.5) > > This permits to reboot the workstation after several minutes (between 3 > and 9 minutes). I'm not sure I can personally offer much here, le dahut, but it would help if you showed the traceback you *are* getting. Surely there's some clue in there which might suggest why you're prevented from rebooting before a delay period. TJG From rugginello at gmail.com Fri Mar 21 10:45:29 2008 From: rugginello at gmail.com (guerrino di massa) Date: Fri, 21 Mar 2008 10:45:29 +0100 Subject: [python-win32] Null Session ipc$ Message-ID: <142f56a30803210245u25e33684m63cd27c7573b47e7@mail.gmail.com> Hello i wrote this: import win32net ui2={} ui2['local'] = "K:" ui2['remote'] = "\\\\pc-test\\C$" ui2['asg_type'] = 0 ui2['username'] = "administrator" ui2['domainname'] = "" ui2['password'] = "password" win32net.NetUseAdd(None,2,ui2) and it works... but i i try an anonymous bind to ipc$ it doesn't work import win32net ui2={} ui2['local'] = "" ui2['remote'] = "\\\\pc-test\\IPC$" ui2['asg_type'] = 0 ui2['username'] = "" ui2['domainname'] = "" ui2['password'] = "" win32net.NetUseAdd(None,2,ui2) and say -> error: (66, 'NetUseAdd', 'Tipo di risorsa di rete non corretto.') is it possible to bind a null session to ipc$ win win32.NetUseAdd? Many thanks guerrino -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080321/eff1fe8d/attachment.htm From lreenaers at ressource-toi.org Fri Mar 21 12:18:07 2008 From: lreenaers at ressource-toi.org (Ludovic Reenaers) Date: Fri, 21 Mar 2008 12:18:07 +0100 Subject: [python-win32] Null Session ipc$ In-Reply-To: <142f56a30803210245u25e33684m63cd27c7573b47e7@mail.gmail.com> References: <142f56a30803210245u25e33684m63cd27c7573b47e7@mail.gmail.com> Message-ID: <47E3996F.8040800@ressource-toi.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'm not sure, but I guess It is depending on the version of windows, I think I had read somewhere null connection is not applicable on most recent windows versions... guerrino di massa a ?crit : > Hello i wrote this: > > import win32net > ui2={} > ui2['local'] = "K:" > ui2['remote'] = "\\\\pc-test\\C$" > ui2['asg_type'] = 0 > ui2['username'] = "administrator" > ui2['domainname'] = "" > ui2['password'] = "password" > win32net.NetUseAdd(None,2,ui2) > > and it works... > > but i i try an anonymous bind to ipc$ it doesn't work > > import win32net > ui2={} > ui2['local'] = "" > ui2['remote'] = "\\\\pc-test\\IPC$" > ui2['asg_type'] = 0 > ui2['username'] = "" > ui2['domainname'] = "" > ui2['password'] = "" > win32net.NetUseAdd(None,2,ui2) > > and say -> error: (66, 'NetUseAdd', 'Tipo di risorsa di rete non corretto.') > > is it possible to bind a null session to ipc$ win win32.NetUseAdd? > > > Many thanks > > guerrino > > > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFH45luabe5k24WqmcRAlHYAJ48+MzSmCIBqfrvYlNIibsgiidbiQCg1CEC 2zDxe4iQerMarOl1tMZ3Gdk= =lhNL -----END PGP SIGNATURE----- From kevin.horn at gmail.com Fri Mar 21 16:27:59 2008 From: kevin.horn at gmail.com (Kevin Horn) Date: Fri, 21 Mar 2008 10:27:59 -0500 Subject: [python-win32] Null Session ipc$ In-Reply-To: <47E3996F.8040800@ressource-toi.org> References: <142f56a30803210245u25e33684m63cd27c7573b47e7@mail.gmail.com> <47E3996F.8040800@ressource-toi.org> Message-ID: <562bcc10803210827l37300f1fm7ec77d027c08ba9e@mail.gmail.com> On Fri, Mar 21, 2008 at 6:18 AM, Ludovic Reenaers < lreenaers at ressource-toi.org> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > I'm not sure, but I guess It is depending on the version of windows, I > think I had read somewhere null connection is not applicable on most > recent windows versions... > > according to: http://www.brown.edu/Facilities/CIS/CIRT/help/netbiosnull.html "NetBIOS NULL sessions are enabled by default in Windows NT and 2000. Windows XP and 2003 will allow anonymous enumeration of shares, but not SAM accounts." Note that these are only default settings...Windows systems can be configured to allow or disallow null sessions using the registry. Kevin Horn -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080321/df5e245e/attachment.htm From le.dahut at laposte.net Fri Mar 21 17:37:27 2008 From: le.dahut at laposte.net (le dahut) Date: Fri, 21 Mar 2008 17:37:27 +0100 Subject: [python-win32] Reboot apis don't work in a NT service In-Reply-To: <47E287D2.6050904@timgolden.me.uk> References: <47E235FE.4020409@laposte.net> <47E287D2.6050904@timgolden.me.uk> Message-ID: <47E3E447.1050703@laposte.net> With "InitiateSystemShutdown" I get : 21, "Device is not ready." with "WTSShutdownSystem" : 1702, "The binding handle is invalid." but even if I don't logon, it reboots after approximately 15 loops of 2 seconds but after reboot the machine is extremely slow and has a strange behavior "ExitWindowsEx" does its job correctly excepted that the workstation is extremly slow and need a manual reboot to work fine... Klaas Tim Golden wrote : > le dahut wrote: >> To reboot the computer I've tried this different functions : >> win32api.ExitWindowsEx(EWX_REBOOT | EWX_FORCE) >> win32api.InitiateSystemShutdown(None, '', 0, True, 1) >> win32ts.WTSShutdownSystem(wts.WTS_CURRENT_SERVER_HANDLE, wts.WTS_WSD_REBOOT) >> wa.WinExec('shutdown -r -t 0 -f') >> >> I've correctly setup 'SeShutdownPrivilege' before calling them. >> The "bForceAppsClosed" is set to True >> >> >> Since I noticed that they didn't reboot the computer but raised an >> error, I've put them in a loop : >> while True: >> try: >> wa.ExitWindowsEx(...) >> break >> except Exception, e: >> logging.error('%s'%e) >> time.sleep(0.5) >> >> This permits to reboot the workstation after several minutes (between 3 >> and 9 minutes). > > I'm not sure I can personally offer much here, le dahut, but > it would help if you showed the traceback you *are* getting. > Surely there's some clue in there which might suggest why > you're prevented from rebooting before a delay period. > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From charlie at sallyandcharlie.com Sat Mar 22 10:51:51 2008 From: charlie at sallyandcharlie.com (Charlie Taylor) Date: Sat, 22 Mar 2008 02:51:51 -0700 Subject: [python-win32] Biggles on Windows with python2.5 Message-ID: <20080322095154.E5FC01E401E@bag.python.org> Has anyone installed a version of biggles on Windows with python 2.5? The Martin Lamar version for python 2.3 was a big help, but I finally upgraded to python 2.5 and I am having trouble with the biggles build. Thanks, Charlie -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080322/958c7910/attachment.htm From billiejoex at gmail.com Sat Mar 22 19:16:51 2008 From: billiejoex at gmail.com (Giampaolo Rodola') Date: Sat, 22 Mar 2008 19:16:51 +0100 Subject: [python-win32] Using LogonUser with Guest account Message-ID: <729626cc0803221116u41cfcf54sdaa017df636bd6e6@mail.gmail.com> Hi, I'm trying to write a plug-in for a ftp server of mine to permit the integration with accounts defined on the Windows system. What I basically need is impersonating a user, execute e filesystem call (e.g. create a directory via os.mkdir()) and then switch back to the original user (Administrator). I wrote down this simple class which seems to fit pretty well for my purposes: class WinNTAuthorizer: def impersonate_user(self, username, password): self.impersonated_user_handler = win32security.LogonUser( username, None, password, win32con.LOGON32_LOGON_INTERACTIVE, win32con.LOGON32_PROVIDER_DEFAULT) win32security.ImpersonateLoggedOnUser(self.impersonated_user_handler) def terminate_impersonation(self): win32security.RevertToSelf() self.impersonated_user_handler.Close() What I need now is impersonating the Guest user to handle the anonymous logins (which it's exactly what IIS FTPd does) but I don't know how to do it. Does Guest account has a password or do I have to use something different than LogonUser to manage it? Could someone point me in the right direction? Thanks in advance. --- Giampaolo http://code.google.com/p/pyftpdlib From arunvn_ind at yahoo.co.uk Sun Mar 23 14:18:00 2008 From: arunvn_ind at yahoo.co.uk (Arun v n) Date: Sun, 23 Mar 2008 06:18:00 -0700 (PDT) Subject: [python-win32] Using .chm files. Message-ID: <523990.27054.qm@web27402.mail.ukl.yahoo.com> Im in need of using a .chm help file where .hlp help fines are curretly being used.. Winhelp() method is used for opening .hlp files.. Mine is a win32 applicatio... How could I make use of HTMLHelp() method in Win32.. Is there any specific headers and libs that I will have to include.. Or is there any or method that can be used...? Experts gve me user inputs pls... Let me also know the headers and libs that shold be used if there is any other method to do this... --------------------------------- Never miss a thing. Make Yahoo your homepage. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080323/153eae6e/attachment.htm From mail at timgolden.me.uk Sun Mar 23 16:01:43 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Sun, 23 Mar 2008 15:01:43 +0000 Subject: [python-win32] Using .chm files. In-Reply-To: <523990.27054.qm@web27402.mail.ukl.yahoo.com> References: <523990.27054.qm@web27402.mail.ukl.yahoo.com> Message-ID: <47E670D7.5070702@timgolden.me.uk> Arun v n wrote: > Im in need of using a .chm help file where .hlp help fines are curretly > being used.. > Winhelp() method is used for opening .hlp files.. Mine is a win32 > applicatio... How could I make use of HTMLHelp() method in Win32.. Is > there any specific headers and libs that I will have to include.. > Or is there any or method that can be used...? Experts gve me user > inputs pls... Let me also know the headers and libs that shold be used > if there is any other method to do this... I'm afraid it's not entirely clear what you're asking for here. To open a .chm file you can just use os.startfile. To open it a little more precisely, you can call hh.exe with the subprocess.call function and some suitable params. If you need more than that, you'd better come back with a more specific enquiry. TJG From marcus at internetnowasp.net Mon Mar 24 06:22:08 2008 From: marcus at internetnowasp.net (Marcus Low) Date: Mon, 24 Mar 2008 13:22:08 +0800 Subject: [python-win32] Using .chm files. In-Reply-To: <523990.27054.qm@web27402.mail.ukl.yahoo.com> References: <523990.27054.qm@web27402.mail.ukl.yahoo.com> Message-ID: <2CF1D67E1E984D07941771852CF2DD92@ToolBox> Hi, Are you just interested to launch the chm file to see the help content? Or are you using context sensitive reference? Launching is as simple as using shellexecute , the *.chm files will be launched correctly as though as you are double clicking on it... Marcus. ----- Original Message ----- From: Arun v n To: python-win32 at python.org Sent: Sunday, March 23, 2008 9:18 PM Subject: [python-win32] Using .chm files. Im in need of using a .chm help file where .hlp help fines are curretly being used.. Winhelp() method is used for opening .hlp files.. Mine is a win32 applicatio... How could I make use of HTMLHelp() method in Win32.. Is there any specific headers and libs that I will have to include.. Or is there any or method that can be used...? Experts gve me user inputs pls... Let me also know the headers and libs that shold be used if there is any other method to do this... ------------------------------------------------------------------------------ Never miss a thing. Make Yahoo your homepage. ------------------------------------------------------------------------------ _______________________________________________ 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: http://mail.python.org/pipermail/python-win32/attachments/20080324/aa2bf65e/attachment.htm From mark.a.brand at gmail.com Mon Mar 24 03:06:18 2008 From: mark.a.brand at gmail.com (mark.a.brand) Date: Mon, 24 Mar 2008 13:06:18 +1100 Subject: [python-win32] wmi query. Message-ID: <1f40e84a0803231906w1b2fc94es98d754bb305704e4@mail.gmail.com> hi: how do you incorporate a where clause and selected field clause in a wmi query ? this gets me caption and state fields for all services c = wmi.WMI() for service in c.Win32_Service (['Caption', 'State']) ... this gets me all fields for stopped services c = wmi.WMI() for service in c.Win32_Service ('State == 'Stopped') .... is the way to incorporate both queries into one something like this c = wmi.WMI() for service in c.Win32_Service (['Caption', 'State']) WHERE ('State == 'Stopped') cheers mark -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080324/6d94d12f/attachment.htm From marcus at internetnowasp.net Mon Mar 24 10:36:53 2008 From: marcus at internetnowasp.net (Marcus Low) Date: Mon, 24 Mar 2008 17:36:53 +0800 Subject: [python-win32] wmi query. In-Reply-To: <1f40e84a0803231906w1b2fc94es98d754bb305704e4@mail.gmail.com> References: <1f40e84a0803231906w1b2fc94es98d754bb305704e4@mail.gmail.com> Message-ID: Hi, > c = wmi.WMI() > for service in c.Win32_Service ('State == 'Stopped') I would think that using c.Win32_Service() and iterating would get you anything you want. In ur case of using ('State == 'Stopped') ... (if this ever works) c.Caption would have given you the caption.... Marcus. ----- Original Message ----- From: mark.a.brand To: Python-Win32 List Sent: Monday, March 24, 2008 10:06 AM Subject: [python-win32] wmi query. hi: how do you incorporate a where clause and selected field clause in a wmi query ? this gets me caption and state fields for all services c = wmi.WMI() for service in c.Win32_Service (['Caption', 'State']) ... this gets me all fields for stopped services c = wmi.WMI() for service in c.Win32_Service ('State == 'Stopped') .... is the way to incorporate both queries into one something like this c = wmi.WMI() for service in c.Win32_Service (['Caption', 'State']) WHERE ('State == 'Stopped') cheers mark ------------------------------------------------------------------------------ _______________________________________________ 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: http://mail.python.org/pipermail/python-win32/attachments/20080324/b087137a/attachment.htm From niki at vintech.bg Mon Mar 24 09:14:42 2008 From: niki at vintech.bg (niki) Date: Mon, 24 Mar 2008 10:14:42 +0200 Subject: [python-win32] Using .chm files. In-Reply-To: <523990.27054.qm@web27402.mail.ukl.yahoo.com> References: <523990.27054.qm@web27402.mail.ukl.yahoo.com> Message-ID: <47E762F2.7060404@vintech.bg> Arun v n wrote: > Im in need of using a .chm help file where .hlp help fines are curretly > being used.. > Winhelp() method is used for opening .hlp files.. Mine is a win32 > applicatio... How could I make use of HTMLHelp() method in Win32.. Is > there any specific headers and libs that I will have to include.. > Or is there any or method that can be used...? Experts gve me user > inputs pls... Let me also know the headers and libs that shold be used > if there is any other method to do this... url = 'some.html' chm = os.path.join(base, lang, 'raskroy.chm') import win32help h = win32help.HtmlHelp(0, chm, 0, url) HTH Niki Spahiev From mail at timgolden.me.uk Mon Mar 24 21:52:12 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 24 Mar 2008 20:52:12 +0000 Subject: [python-win32] wmi query. In-Reply-To: <1f40e84a0803231906w1b2fc94es98d754bb305704e4@mail.gmail.com> References: <1f40e84a0803231906w1b2fc94es98d754bb305704e4@mail.gmail.com> Message-ID: <47E8147C.5070603@timgolden.me.uk> mark.a.brand wrote: > hi: > > how do you incorporate a where clause and selected field clause in a wmi > query ? > > this gets me caption and state fields for all services > c = wmi.WMI() > for service in c.Win32_Service (['Caption', 'State']) > ... > > this gets me all fields for stopped services > c = wmi.WMI() > for service in c.Win32_Service ('State == 'Stopped') > .... > > is the way to incorporate both queries into one something like this > c = wmi.WMI() > for service in c.Win32_Service (['Caption', 'State']) WHERE ('State == > 'Stopped') Well, I can answer this a couple of ways: 1) You can always pass raw WQL to the namespace (the result of calling wmi.WMI () - in your case, c). So: import wmi c = wmi.WMI () Q = "SELECT caption FROM Win32_Service WHERE state = 'Stopped'" for service in c.query (Q): print service.caption but... 2) ...you'd only really need to do this is you were doing something sophisticated with the where clause. Normally you'd write it like this: import wmi c = wmi.WMI () for service in c.Win32_Service (['caption'], state="Stopped"): print service.caption Even that is a slight optimisation. It usually costs little to pull back all the fields, so I generally write: import wmi c = wmi.WMI () for service in c.Win32_Service (state="Stopped"): print c.Caption, c.Status TJG From mail at timgolden.me.uk Mon Mar 24 21:53:34 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 24 Mar 2008 20:53:34 +0000 Subject: [python-win32] wmi query. In-Reply-To: <1f40e84a0803231906w1b2fc94es98d754bb305704e4@mail.gmail.com> References: <1f40e84a0803231906w1b2fc94es98d754bb305704e4@mail.gmail.com> Message-ID: <47E814CE.9030403@timgolden.me.uk> mark.a.brand wrote: > hi: > > how do you incorporate a where clause and selected field clause in a wmi > query ? > > this gets me caption and state fields for all services > c = wmi.WMI() > for service in c.Win32_Service (['Caption', 'State']) > ... > > this gets me all fields for stopped services > c = wmi.WMI() > for service in c.Win32_Service ('State == 'Stopped') > .... > > is the way to incorporate both queries into one something like this > c = wmi.WMI() > for service in c.Win32_Service (['Caption', 'State']) WHERE ('State == > 'Stopped') Well, I can answer this a couple of ways: 1) You can always pass raw WQL to the namespace (the result of calling wmi.WMI () - in your case, c). So: import wmi c = wmi.WMI () Q = "SELECT caption FROM Win32_Service WHERE state = 'Stopped'" for service in c.query (Q): print service.caption but... 2) ...you'd only really need to do this is you were doing something sophisticated with the where clause. Normally you'd write it like this: import wmi c = wmi.WMI () for service in c.Win32_Service (['caption'], state="Stopped"): print service.caption Even that is a slight optimisation. It usually costs little to pull back all the fields, so I generally write: import wmi c = wmi.WMI () for service in c.Win32_Service (state="Stopped"): print c.Caption, c.Status TJG From mail at timgolden.me.uk Mon Mar 24 22:02:45 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 24 Mar 2008 21:02:45 +0000 Subject: [python-win32] wmi query. In-Reply-To: <1f40e84a0803231906w1b2fc94es98d754bb305704e4@mail.gmail.com> References: <1f40e84a0803231906w1b2fc94es98d754bb305704e4@mail.gmail.com> Message-ID: <47E816F5.60401@timgolden.me.uk> mark.a.brand wrote: > hi: > > how do you incorporate a where clause and selected field clause in a wmi > query ? > > this gets me caption and state fields for all services > c = wmi.WMI() > for service in c.Win32_Service (['Caption', 'State']) > ... > > this gets me all fields for stopped services > c = wmi.WMI() > for service in c.Win32_Service ('State == 'Stopped') > .... > > is the way to incorporate both queries into one something like this > c = wmi.WMI() > for service in c.Win32_Service (['Caption', 'State']) WHERE ('State == > 'Stopped') Well, I can answer this a couple of ways: 1) You can always pass raw WQL to the namespace (the result of calling wmi.WMI () - in your case, c). So: import wmi c = wmi.WMI () Q = "SELECT caption FROM Win32_Service WHERE state = 'Stopped'" for service in c.query (Q): print service.caption but... 2) ...you'd only really need to do this is you were doing something sophisticated with the where clause. Normally you'd write it like this: import wmi c = wmi.WMI () for service in c.Win32_Service (['caption'], state="Stopped"): print service.caption Even that is a slight optimisation. It usually costs little to pull back all the fields, so I generally write: import wmi c = wmi.WMI () for service in c.Win32_Service (state="Stopped"): print c.Caption, c.Status TJG From mail at timgolden.me.uk Mon Mar 24 21:53:34 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 24 Mar 2008 20:53:34 +0000 Subject: [python-win32] wmi query. In-Reply-To: <1f40e84a0803231906w1b2fc94es98d754bb305704e4@mail.gmail.com> References: <1f40e84a0803231906w1b2fc94es98d754bb305704e4@mail.gmail.com> Message-ID: <47E814CE.9030403@timgolden.me.uk> <<< No Message Collected >>> From rwupole at msn.com Tue Mar 25 00:23:58 2008 From: rwupole at msn.com (Roger Upole) Date: Mon, 24 Mar 2008 19:23:58 -0400 Subject: [python-win32] Re: Using LogonUser with Guest account Message-ID: Giampaolo Rodola wrote: > Hi, > I'm trying to write a plug-in for a ftp server of mine to permit the > integration with accounts defined on the Windows system. > What I basically need is impersonating a user, execute e filesystem > call (e.g. create a directory via os.mkdir()) and then switch back to > the original user (Administrator). > I wrote down this simple class which seems to fit pretty well for my > purposes: > > class WinNTAuthorizer: > > def impersonate_user(self, username, password): > self.impersonated_user_handler = win32security.LogonUser( > username, > None, > password, > win32con.LOGON32_LOGON_INTERACTIVE, > win32con.LOGON32_PROVIDER_DEFAULT) > > win32security.ImpersonateLoggedOnUser(self.impersonated_user_handler) > > def terminate_impersonation(self): > win32security.RevertToSelf() > self.impersonated_user_handler.Close() > > > What I need now is impersonating the Guest user to handle the > anonymous logins (which it's exactly what IIS FTPd does) but I don't > know how to do it. > Does Guest account has a password or do I have to use something > different than LogonUser to manage it? > Could someone point me in the right direction? > > Thanks in advance. > > I think you're looking for win32security.ImpersonateAnonymousToken. Note that Anonymous is not the same thing as the Guest account. Roger From djkoustubh at gmail.com Tue Mar 25 05:52:25 2008 From: djkoustubh at gmail.com (K-Factory) Date: Tue, 25 Mar 2008 10:22:25 +0530 Subject: [python-win32] FTP Task Schedule in Python Message-ID: Hi Forum, I need to automate a scheduled weekly task i.e. downloading a file from FTP. This is to be done on WINDOWS but I am unable to make any further development on this as I am stuck with the python scheduler itself. Can somebody help me with this, I just need a skeleton of code further things I can personally input. Also can any one provide me with the link for any such scheduler code or project. Thanks Dylan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080325/4e4c35ab/attachment.htm From mail at timgolden.me.uk Tue Mar 25 10:28:31 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 25 Mar 2008 09:28:31 +0000 Subject: [python-win32] FTP Task Schedule in Python In-Reply-To: References: Message-ID: <47E8C5BF.4040407@timgolden.me.uk> K-Factory wrote: > I need to automate a scheduled weekly task i.e. downloading a file from FTP. > This is to be done on WINDOWS but I am unable to make any further > development on this as I am stuck with the python scheduler itself. Can > somebody help me with this, I just need a skeleton of code further things I > can personally input. Also can any one provide me with the link for any such > scheduler code or project. Is there some reason why you couldn't use either the AT service or the Scheduled Tasks service from within Windows itself? Both are scriptable from the command line and elsewhere and the pywin32 packages include an interface to Scheduled Tasks. TJG From Kyle.Rickey at bakerhughes.com Tue Mar 25 14:00:11 2008 From: Kyle.Rickey at bakerhughes.com (Rickey, Kyle W) Date: Tue, 25 Mar 2008 08:00:11 -0500 Subject: [python-win32] FTP Task Schedule in Python In-Reply-To: <47E8C5BF.4040407@timgolden.me.uk> References: <47E8C5BF.4040407@timgolden.me.uk> Message-ID: I agree with Tim here. I set up a simple script to backup a few files, then scheduled a task to run daily at 2am. -Kyle Rickey -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Tim Golden Sent: Tuesday, March 25, 2008 4:29 AM Cc: python-win32 at python.org Subject: Re: [python-win32] FTP Task Schedule in Python K-Factory wrote: > I need to automate a scheduled weekly task i.e. downloading a file from FTP. > This is to be done on WINDOWS but I am unable to make any further > development on this as I am stuck with the python scheduler itself. Can > somebody help me with this, I just need a skeleton of code further things I > can personally input. Also can any one provide me with the link for any such > scheduler code or project. Is there some reason why you couldn't use either the AT service or the Scheduled Tasks service from within Windows itself? Both are scriptable from the command line and elsewhere and the pywin32 packages include an interface to Scheduled Tasks. TJG _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From mail at timgolden.me.uk Tue Mar 25 15:04:15 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 25 Mar 2008 14:04:15 +0000 Subject: [python-win32] wmi query. In-Reply-To: <47E814CE.9030403@timgolden.me.uk> References: <1f40e84a0803231906w1b2fc94es98d754bb305704e4@mail.gmail.com> <47E814CE.9030403@timgolden.me.uk> Message-ID: <47E9065F.9040604@timgolden.me.uk> Tim Golden wrote: [... snip other examples ...] > Even that is a slight optimisation. It usually costs little > to pull back all the fields, so I generally write: > > > import wmi > > c = wmi.WMI () > for service in c.Win32_Service (state="Stopped"): > print c.Caption, c.Status > > Sorry. I nearly always drop my samples into the interpreter before pressing [Send]. And this is why! That should have been: import wmi c = wmi.WMI () for service in c.Win32_Service (state="Stopped"): print service.Caption, service.Status (And I actually ran it this time). TJG From vernondcole at gmail.com Tue Mar 25 17:51:41 2008 From: vernondcole at gmail.com (Vernon Cole) Date: Tue, 25 Mar 2008 10:51:41 -0600 Subject: [python-win32] FTP Task Schedule in Python In-Reply-To: References: <47E8C5BF.4040407@timgolden.me.uk> Message-ID: Me too. Sometimes I have had problems with running a Python script directly from the task scheduler, so I usually use a small .bat file to start the Python. I will often redirect standard output to a file for logging, then use another Python script to Email the log to myself. On Tue, Mar 25, 2008 at 7:00 AM, Rickey, Kyle W wrote: > I agree with Tim here. I set up a simple script to backup a few files, > then scheduled a task to run daily at 2am. > > -Kyle Rickey > > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org] On Behalf Of Tim Golden > Sent: Tuesday, March 25, 2008 4:29 AM > Cc: python-win32 at python.org > Subject: Re: [python-win32] FTP Task Schedule in Python > > K-Factory wrote: > > I need to automate a scheduled weekly task i.e. downloading a file > from FTP. > > This is to be done on WINDOWS but I am unable to make any further > > development on this as I am stuck with the python scheduler itself. > Can > > somebody help me with this, I just need a skeleton of code further > things I > > can personally input. Also can any one provide me with the link for > any such > > scheduler code or project. > > Is there some reason why you couldn't use either the > AT service or the Scheduled Tasks service from within > Windows itself? Both are scriptable from the command > line and elsewhere and the pywin32 packages include an > interface to Scheduled Tasks. > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > _______________________________________________ > 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: http://mail.python.org/pipermail/python-win32/attachments/20080325/a43adde2/attachment.htm From djkoustubh at gmail.com Wed Mar 26 08:15:03 2008 From: djkoustubh at gmail.com (dylan.travis) Date: Wed, 26 Mar 2008 00:15:03 -0700 (PDT) Subject: [python-win32] FTP Task Schedule in Python In-Reply-To: <47E8C5BF.4040407@timgolden.me.uk> References: <47E8C5BF.4040407@timgolden.me.uk> Message-ID: <16296683.post@talk.nabble.com> Hi All, Thanks for the prompt reply. But the catch here is I am not well-versed with any of the things mentioned by TJG & that is the reason I had to take help of this forum. Still I'll have a look into the scheduled task for WINDOWS. If any bothers me I'll just post a new message here. Thanks Again Tim Golden-4 wrote: > > K-Factory wrote: >> I need to automate a scheduled weekly task i.e. downloading a file from >> FTP. >> This is to be done on WINDOWS but I am unable to make any further >> development on this as I am stuck with the python scheduler itself. Can >> somebody help me with this, I just need a skeleton of code further things >> I >> can personally input. Also can any one provide me with the link for any >> such >> scheduler code or project. > > Is there some reason why you couldn't use either the > AT service or the Scheduled Tasks service from within > Windows itself? Both are scriptable from the command > line and elsewhere and the pywin32 packages include an > interface to Scheduled Tasks. > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -- View this message in context: http://www.nabble.com/FTP-Task-Schedule-in-Python-tp16268345p16296683.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From mark.a.brand at gmail.com Wed Mar 26 09:16:31 2008 From: mark.a.brand at gmail.com (mark.a.brand) Date: Wed, 26 Mar 2008 19:16:31 +1100 Subject: [python-win32] wmi query. In-Reply-To: <47E907C8.3040008@timgolden.me.uk> References: <1f40e84a0803231906w1b2fc94es98d754bb305704e4@mail.gmail.com> <47E814CE.9030403@timgolden.me.uk> <47E9065F.9040604@timgolden.me.uk> <1f40e84a0803250706o7d414957id24d387eda6f342e@mail.gmail.com> <47E907C8.3040008@timgolden.me.uk> Message-ID: <1f40e84a0803260116s5c1e1f96ya8c917d7139fbc25@mail.gmail.com> hi tim: what about events, for example i only want to return error and warning events for the last 4 days from all logs. getting all the events and then filtering them will be terrribly slow. cheers mark On 26/03/2008, Tim Golden wrote: > > mark.a.brand wrote: > > thanks tim. > > My pleasure. > > TJG > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080326/6b26c955/attachment.htm From mail at timgolden.me.uk Wed Mar 26 09:59:54 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 26 Mar 2008 08:59:54 +0000 Subject: [python-win32] wmi query. In-Reply-To: <1f40e84a0803260116s5c1e1f96ya8c917d7139fbc25@mail.gmail.com> References: <1f40e84a0803231906w1b2fc94es98d754bb305704e4@mail.gmail.com> <47E814CE.9030403@timgolden.me.uk> <47E9065F.9040604@timgolden.me.uk> <1f40e84a0803250706o7d414957id24d387eda6f342e@mail.gmail.com> <47E907C8.3040008@timgolden.me.uk> <1f40e84a0803260116s5c1e1f96ya8c917d7139fbc25@mail.gmail.com> Message-ID: <47EA108A.3080400@timgolden.me.uk> mark.a.brand wrote: > what about events, > > for example i only want to return error and warning events for the last 4 > days from all logs. getting all the events and then filtering them will be > terrribly slow. You let WMI do the filtering. For this, since it's a non-equi filter (you want the last 4 days) you'll have to pass the WQL through yourself. It's still advantageous to use the wmi module for this, even though you're producing your own query, since it wraps the results for you as _wmi_objects and gives you easy access to their properties, methods etc. import wmi import datetime five_days_ago = datetime.date.today () - datetime.timedelta (5) wmi_five_days_ago = wmi.from_time (*five_days_ago.timetuple ()[:-1]) # # WQL won't like the line feeds. Strip them out later. # WQL = """ SELECT * FROM Win32_NTLogEvent WHERE (EventType = 1 OR EventType = 2) AND TimeGenerated >= "%s" """ % wmi_five_days_ago c = wmi.WMI () for event in c.query (" ".join (WQL.split ())): print event.Logfile, \ event.RecordNumber, \ wmi.to_time (event.TimeGenerated) There's some slight messiness involved in the time aspects of this. And I realise that, although the wmi module does have a couple of helper functions (to_time and from_time) they don't actually play all that well with the datetime module. Still, they do return a recognisable tuple which you can play with. I'll try to improve them anyway. TJG From mark.a.brand at gmail.com Wed Mar 26 11:11:56 2008 From: mark.a.brand at gmail.com (mark.a.brand) Date: Wed, 26 Mar 2008 21:11:56 +1100 Subject: [python-win32] wmi query. In-Reply-To: <47EA108A.3080400@timgolden.me.uk> References: <1f40e84a0803231906w1b2fc94es98d754bb305704e4@mail.gmail.com> <47E814CE.9030403@timgolden.me.uk> <47E9065F.9040604@timgolden.me.uk> <1f40e84a0803250706o7d414957id24d387eda6f342e@mail.gmail.com> <47E907C8.3040008@timgolden.me.uk> <1f40e84a0803260116s5c1e1f96ya8c917d7139fbc25@mail.gmail.com> <47EA108A.3080400@timgolden.me.uk> Message-ID: <1f40e84a0803260311v7f84c1a0m443d705cacfb613f@mail.gmail.com> lovely, thanks again. On 26/03/2008, Tim Golden wrote: > > mark.a.brand wrote: > > what about events, > > > > for example i only want to return error and warning events for the last > 4 > > days from all logs. getting all the events and then filtering them will > be > > terrribly slow. > > > You let WMI do the filtering. For this, since it's a non-equi > filter (you want the last 4 days) you'll have to pass the WQL > through yourself. It's still advantageous to use the wmi > module for this, even though you're producing your own query, > since it wraps the results for you as _wmi_objects and gives > you easy access to their properties, methods etc. > > > import wmi > import datetime > > five_days_ago = datetime.date.today () - datetime.timedelta (5) > wmi_five_days_ago = wmi.from_time (*five_days_ago.timetuple ()[:-1]) > > # > # WQL won't like the line feeds. Strip them out later. > # > WQL = """ > SELECT * > FROM Win32_NTLogEvent > WHERE (EventType = 1 OR EventType = 2) > AND TimeGenerated >= "%s" > """ % wmi_five_days_ago > > c = wmi.WMI () > for event in c.query (" ".join (WQL.split ())): > print event.Logfile, \ > event.RecordNumber, \ > wmi.to_time (event.TimeGenerated) > > > > There's some slight messiness involved in the time aspects > of this. And I realise that, although the wmi module does > have a couple of helper functions (to_time and from_time) > they don't actually play all that well with the datetime > module. Still, they do return a recognisable tuple which > you can play with. I'll try to improve them anyway. > > > TJG > _______________________________________________ > 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: http://mail.python.org/pipermail/python-win32/attachments/20080326/5f690e9b/attachment-0001.htm From Brad.Johnson at ballardtech.com Wed Mar 26 22:31:34 2008 From: Brad.Johnson at ballardtech.com (Brad Johnson) Date: Wed, 26 Mar 2008 21:31:34 +0000 (UTC) Subject: [python-win32] Max parameters in method of IConnectionPoint interface? Message-ID: I have implemented an object that supports connection points in COM. In ATL, there is a #define that limits the number of parameters supported for a connection point client: #define _ATL_MAX_VARTYPES 8 I have one function that has 11 parameters, so for my C++ client (using ATL) I had to redefine this to a larger number. However, my Python clients return E_OUTOFMEMORY when the Source interface attempts to call into the client. I assume (maybe wrongly) that this is due to an arbitrary maximum on number of parameters. If so, can I change win32com to support more than the current maximum number of parameters? From mhammond at skippinet.com.au Wed Mar 26 23:42:11 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 27 Mar 2008 09:42:11 +1100 Subject: [python-win32] Max parameters in method of IConnectionPoint interface? In-Reply-To: References: Message-ID: <033a01c88f92$a4580c10$ed082430$@com.au> > I have implemented an object that supports connection points in COM. > > In ATL, there is a #define that limits the number of parameters > supported for a > connection point client: > > #define _ATL_MAX_VARTYPES 8 > > I have one function that has 11 parameters, so for my C++ client (using > ATL) I > had to redefine this to a larger number. > > However, my Python clients return E_OUTOFMEMORY when the Source > interface > attempts to call into the client. I assume (maybe wrongly) that this is > due to > an arbitrary maximum on number of parameters. There is no arbitrary limit that I recall. Can you show us a snippet of failing code and the traceback? Thanks, Mark From Brad.Johnson at ballardtech.com Thu Mar 27 22:00:48 2008 From: Brad.Johnson at ballardtech.com (Brad Johnson) Date: Thu, 27 Mar 2008 21:00:48 +0000 (UTC) Subject: [python-win32] =?utf-8?q?Max_parameters_in_method_of=09IConnectio?= =?utf-8?q?nPoint=09interface=3F?= References: <033a01c88f92$a4580c10$ed082430$@com.au> Message-ID: Mark Hammond skippinet.com.au> writes: > There is no arbitrary limit that I recall. Can you show us a snippet of > failing code and the traceback? > > Thanks, > > Mark > Hi Mark, I've gotten right down to the problem. Has nothing to do with the number of parameters. One of the parameters is of type VT_VARIANT (0x000c). That variant type is not supported by the function PyCom_PyObjectFromVariant, which gets called along the chain of getting the values down to Python. The default case statement returns E_OUTOFMEMORY if the type can't be converted to a BSTR. So, obviously PyCom doesn't like a variant of type VT_VARIANT. The object actually held inside the variant is a SAFEARRAY of 32 elements. Passing it in as type VT_VARIANT made my C++ clients happy. So I guess my question becomes how can I change the parameter type so everyone is happy? From Brad.Johnson at ballardtech.com Thu Mar 27 22:55:44 2008 From: Brad.Johnson at ballardtech.com (Brad Johnson) Date: Thu, 27 Mar 2008 21:55:44 +0000 (UTC) Subject: [python-win32] =?utf-8?q?Max_parameters_in_method_of=09IConnectio?= =?utf-8?q?nPoint=09interface=3F?= References: <033a01c88f92$a4580c10$ed082430$@com.au> Message-ID: Brad Johnson ballardtech.com> writes: > So I guess my question becomes how can I change the parameter type so everyone > is happy? > Never mind. I managed to make it a reference to a SAFEARRAY of USHORTS without a hiccup from either client. I guess I need to brush up a little bit on my COM. From mhammond at skippinet.com.au Thu Mar 27 22:58:48 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 28 Mar 2008 08:58:48 +1100 Subject: [python-win32] Max parameters in method of IConnectionPoint interface? In-Reply-To: References: <033a01c88f92$a4580c10$ed082430$@com.au> Message-ID: <048601c89055$bf0a6ad0$3d1f4070$@com.au> > I've gotten right down to the problem. Has nothing to do with the > number of > parameters. One of the parameters is of type VT_VARIANT (0x000c). That > variant > type is not supported by the function PyCom_PyObjectFromVariant, which > gets > called along the chain of getting the values down to Python. The > default case > statement returns E_OUTOFMEMORY if the type can't be converted to a > BSTR. That is strange - that function usually gets called with a variant holding a specific type. Why are you passing a variant holding a variant? Why not just pass a variant holding the actual value and type? > So, obviously PyCom doesn't like a variant of type VT_VARIANT. In all other cases, it handles VT_VARIANT fine - its just that we are not expecting a variant holding a variant (other than a byref one) and if it was a general requirement, I'm extremely surprised we haven't hit it before - or maybe we have and people are living with the BSTR conversion? > So I guess my question becomes how can I change the parameter type so > everyone is happy? Pass it as a variant holding the actual type instead of adding a kind of "indirection". Cheers, Mark From Brad.Johnson at ballardtech.com Thu Mar 27 23:06:10 2008 From: Brad.Johnson at ballardtech.com (Brad Johnson) Date: Thu, 27 Mar 2008 22:06:10 +0000 (UTC) Subject: [python-win32] =?utf-8?q?Max_parameters_in_method=09of=09IConnect?= =?utf-8?q?ionPoint=09interface=3F?= References: <033a01c88f92$a4580c10$ed082430$@com.au> <048601c89055$bf0a6ad0$3d1f4070$@com.au> Message-ID: Mark Hammond skippinet.com.au> writes: > Pass it as a variant holding the actual type instead of adding a kind of > "indirection". > > Cheers, > > Mark > Thanks. That's exactly what I ended up doing. I guess I was just a little too green to do it right the first time. I didn't know how to pass a SAFEARRAY correctly, so I thought I'd hide the problem and put it in a VARIANT :-) Strangely, this actually worked for my C++ clients. From mhammond at skippinet.com.au Fri Mar 28 00:42:57 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 28 Mar 2008 10:42:57 +1100 Subject: [python-win32] Max parameters in method of IConnectionPoint interface? In-Reply-To: References: <033a01c88f92$a4580c10$ed082430$@com.au> <048601c89055$bf0a6ad0$3d1f4070$@com.au> Message-ID: <04a501c89064$4bc88160$e3598420$@com.au> > That's exactly what I ended up doing. I guess I was just a little too > green to do it right the first time. I didn't know how to pass a SAFEARRAY > correctly, so I thought I'd hide the problem and put it in a VARIANT :-) > > Strangely, this actually worked for my C++ clients. Best I can tell, there is no reason it's not legal - it's just unusual :) You could argue that we should just recurse away on VT_VARIANT until we find a real type. I was kinda hoping you had a legitimate case it was failing with, as then it would have been clearer it was a bug :) Particularly, the top of that function has: /* skip past any variant references to a "real" variant (Why do we do this? Why is it only a VARIANT? whats the story, morning glory? */ while ( V_VT(var) == (VT_BYREF | VT_VARIANT) ) var = V_VARIANTREF(var); but the code fails to gracefully handle the non-byref variant case, as you found. Oh well, some other day (or if someone is keen, a bug couldn't hurt...) Cheers, Mark From Brad.Johnson at ballardtech.com Fri Mar 28 01:06:45 2008 From: Brad.Johnson at ballardtech.com (Brad Johnson) Date: Fri, 28 Mar 2008 00:06:45 +0000 (UTC) Subject: [python-win32] =?utf-8?q?Max_parameters_in=09method=09of=09IConne?= =?utf-8?q?ctionPoint=09interface=3F?= References: <033a01c88f92$a4580c10$ed082430$@com.au> <048601c89055$bf0a6ad0$3d1f4070$@com.au> <04a501c89064$4bc88160$e3598420$@com.au> Message-ID: Mark Hammond skippinet.com.au> writes: > but the code fails to gracefully handle the non-byref variant case, as you > found. Oh well, some other day (or if someone is keen, a bug couldn't > hurt...) > > Cheers, > > Mark > I added a bug to the SourceForge bug tracker :-). From gerdusvanzyl at gmail.com Fri Mar 28 10:59:50 2008 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Fri, 28 Mar 2008 11:59:50 +0200 Subject: [python-win32] Idle Event Message-ID: <91882ea90803280259t2810020cgac0e6755b75e0a83@mail.gmail.com> Hi, How can I run a function when the event loop is idle? It's for animation and some layout calculation. Currently I am doing that using threads but the responsiveness of my application is suffering. Thank you ~Gerdus From billiejoex at gmail.com Fri Mar 28 13:23:38 2008 From: billiejoex at gmail.com (Giampaolo Rodola') Date: Fri, 28 Mar 2008 13:23:38 +0100 Subject: [python-win32] Using LogonUser with Guest account Message-ID: <729626cc0803280523x20479a9y4a6e9cf42e3ce973@mail.gmail.com> Roger Upole wrote: >> Hi, >> I'm trying to write a plug-in for a ftp server of mine to permit the >> integration with accounts defined on the Windows system. >> What I basically need is impersonating a user, execute e filesystem >> call (e.g. create a directory via os.mkdir()) and then switch back to >> the original user (Administrator). >> I wrote down this simple class which seems to fit pretty well for my >> purposes: >> >> class WinNTAuthorizer: >> >> def impersonate_user(self, username, password): >> self.impersonated_user_handler = win32security.LogonUser( >> username, >> None, >> password, >> win32con.LOGON32_LOGON_INTERACTIVE, >> win32con.LOGON32_PROVIDER_DEFAULT) >> >> win32security.ImpersonateLoggedOnUser(self.impersonated_user_handler) >> >> def terminate_impersonation(self): >> win32security.RevertToSelf() >> self.impersonated_user_handler.Close() >> >> >> What I need now is impersonating the Guest user to handle the >> anonymous logins (which it's exactly what IIS FTPd does) but I don't >> know how to do it. >> Does Guest account has a password or do I have to use something >> different than LogonUser to manage it? >> Could someone point me in the right direction? >> >> Thanks in advance. > I think you're looking for win32security.ImpersonateAnonymousToken. > Note that Anonymous is not the same thing as the Guest account. By reading MSDN it seems it should be used with threads (while I'm in an asynchronous environment) and I'm not even sure that's what I need. Could you provide an example code? --- Giampaolo http://code.google.com/p/pyftpdlib/ From mail at timgolden.me.uk Fri Mar 28 14:44:17 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 28 Mar 2008 13:44:17 +0000 Subject: [python-win32] Using LogonUser with Guest account In-Reply-To: <729626cc0803280523x20479a9y4a6e9cf42e3ce973@mail.gmail.com> References: <729626cc0803280523x20479a9y4a6e9cf42e3ce973@mail.gmail.com> Message-ID: <47ECF631.6020703@timgolden.me.uk> Giampaolo Rodola' wrote: > Roger Upole wrote: >> I think you're looking for win32security.ImpersonateAnonymousToken. >> Note that Anonymous is not the same thing as the Guest account. > > By reading MSDN it seems it should be used with threads (while I'm in > an asynchronous environment) and I'm not even sure that's what I need. > Could you provide an example code? Well you've still *got* a thread, even if you're not spawning any more to handle multithreading. Hopefully the code below illustrates what's going on. Obviously you'll have to to adapt to your circumstances. TJG import win32api import win32security import ntsecuritycon ANONYMOUS_SID = win32security.CreateWellKnownSid ( win32security.WinAnonymousSid ) if __name__ == '__main__': flags = ntsecuritycon.MAXIMUM_ALLOWED # # At the start, this thread probably doesn't have # its own token (unless it's impersonating already) # try: hToken = win32security.OpenThreadToken ( win32api.GetCurrentThread (), flags, True ) except win32security.error, (errno, errcontext, errmsg): if errno == 1008: hToken = win32security.OpenProcessToken ( win32api.GetCurrentProcess (), flags ) else: raise # # Just for show, indicate who owns the token before impersonation # sid, attr = win32security.GetTokenInformation ( hToken, win32security.TokenUser ) print "BEFORE: Token is for", sid # # Impersonate the anonymous user and show that the # resulting token owner is the anonymous sid # win32security.ImpersonateAnonymousToken (win32api.GetCurrentThread ()) hToken = win32security.OpenThreadToken ( win32api.GetCurrentThread (), flags, True ) sid, attr = win32security.GetTokenInformation ( hToken, win32security.TokenUser ) if sid == ANONYMOUS_SID: print "AFTER: Token is now Anonymous:", sid else: print "AFTER: Token is", sid From patter001 at gmail.com Sun Mar 30 06:22:31 2008 From: patter001 at gmail.com (Kevin Patterson) Date: Sun, 30 Mar 2008 00:22:31 -0400 Subject: [python-win32] [pywin32-bugs] ISAPI Set-Cookie Probs In-Reply-To: References: <00b301c875a4$7e6406b0$7b2c1410$@com.au> <020401c877b5$561805e0$024811a0$@com.au> Message-ID: I also received this error message. I backed up to tag "b209" and everything compiled o.k. Is this error below a known issue? > > On Mon, Feb 25, 2008 at 11:36 AM, Tom Wells wrote: > > > Just tried to run a build, and getting the following errors: > > C:\temp\pywin32>python setup.py -q build > > Building pywin32 2.5.210.9 > > Skipping win32cred WINDOWS.H with version 0x501 is required, but only > > version 0x500 is installed. > > win32servicemodule.cpp > > win32\src\win32servicemodule.cpp(2675) : error C2065: > > 'SERVICE_CONTROL_PRESHUTDOWN' : undeclared identifier > > win32\src\win32servicemodule.cpp(2733) : error C2065: > > 'SERVICE_ACCEPT_PRESHUTDOWN' : undeclared identifier > > error: command '"C:\Program Files\Microsoft Visual Studio .NET > > 2003\Vc7\bin\cl.exe"' failed with exit status 2 > > > > I have vs2003 installed (for python 2.5.1), plus just downloaded and > > installed the latest platform sdk from ( > > http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5&displaylang=en#filelist > > ). > > > > Any ideas? I'm purely after the ISAPI bits. > > > > Thanks, > > Tom > > > > > > > > On Mon, Feb 25, 2008 at 4:28 PM, Tom Wells wrote: > > > > > Mark, Hi > > > > > > A test build would be great - I just sync'd CVS and saw your changes > > > and about to download platform SDK etc to compile the newest version, but > > > i'm sure you can probably get me something sooner! I will however get the > > > sources anyways, as it's a good reference plus I may feel inclined to finish > > > off some of your TBD's (such as the SF_NOTIFY_SEND_RESPONSE notification, > > > which should be very easy as it takes exactly the same notificationtype as > > > SF_NOTIFY_PREPROC_HEADERS according to ISAPI documentation). > > > > > > Thanks for the support so far - really appreciate it! > > > > > > Please let me know once you have a build available, I am running > > > python 2.5.1 (32 bit), but would also require an amd64 build if > > > possible? > > > > > > Thanks, > > > Tom > > > > > > > > > > > > On Mon, Feb 25, 2008 at 3:50 PM, Mark Hammond < > > > mhammond at skippinet.com.au> wrote: > > > > > > > > Actually there is no such fc.SetHeader() function ... > > > > > > > > Yep - it was PREPROC_HEADERS I was referring to. > > > > > > > > > SendResponseHeaders() not working is odd, and maybe i'm just > > > > misunderstanding it's use > > > > > > > > Sadly, there is a layer of indirection here I inherited from the > > > > original > > > > author which isn't necessarily intuitive. SendResponseHeaders() is > > > > used by > > > > an extension and which as the docs mention (or at least do in CVS - > > > > its > > > > likely they do not in your copy), "calls ServerSupportFunction with > > > > HSE_REQ_SEND_RESPONSE_HEADER_EX" - which you will find takes 3 > > > > params - > > > > response, complete_headers, keep_alive, where response is the "200 > > > > OK" > > > > string, complete_headers is a string with \r\n terminators, and > > > > keep_alive > > > > is a bool (which, best I can tell, has no effect on anything!) > > > > > > > > I have added HTTP_FILTER_CONTEXT AddResponseHeaders() to CVS though > > > > - let me > > > > know if you would like a build to test (and let me know your Python > > > > version) > > > > - and that goes for anyone else too - build 211 gets closer by the > > > > day (just > > > > get Roger to stop fixing lots of pythonwin bugs ) so I'll > > > > point anyone > > > > who asks at test builds... > > > > > > > > Cheers, > > > > > > > > Mark. > > > > > > > > > > > > > > > > > -- > > > http://www.tomwells.org > > > > > > > > > > -- > > http://www.tomwells.org > > _______________________________________________ > > 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: http://mail.python.org/pipermail/python-win32/attachments/20080330/4b985ff9/attachment.htm From mhammond at skippinet.com.au Sun Mar 30 08:49:21 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 30 Mar 2008 17:49:21 +1100 Subject: [python-win32] [pywin32-bugs] ISAPI Set-Cookie Probs In-Reply-To: References: <00b301c875a4$7e6406b0$7b2c1410$@com.au> <020401c877b5$561805e0$024811a0$@com.au> Message-ID: <00bc01c89232$33c137e0$9b43a7a0$@com.au> Oops - forgot to "reply all": The problem is that win32service needs a later platform SDK - try changing the line in setup.py from: ("win32service", "advapi32 oleaut32 user32", True, 0x0500), To: ("win32service", "advapi32 oleaut32 user32", True, 0x0501), And it should be skipped. You might need to do it to pythonservice.exe too. Or just install the Vista SDK. Mark From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Kevin Patterson Sent: Sunday, 30 March 2008 3:23 PM To: Tom Wells; Python-Win32 List Subject: Re: [python-win32] [pywin32-bugs] ISAPI Set-Cookie Probs I also received this error message. I backed up to tag "b209" and everything compiled o.k. Is this error below a known issue? On Mon, Feb 25, 2008 at 11:36 AM, Tom Wells wrote: Just tried to run a build, and getting the following errors: C:\temp\pywin32>python setup.py -q build Building pywin32 2.5.210.9 Skipping win32cred WINDOWS.H with version 0x501 is required, but only version 0x500 is installed. win32servicemodule.cpp win32\src\win32servicemodule.cpp(2675) : error C2065: 'SERVICE_CONTROL_PRESHUTDOWN' : undeclared identifier win32\src\win32servicemodule.cpp(2733) : error C2065: 'SERVICE_ACCEPT_PRESHUTDOWN' : undeclared identifier error: command '"C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe"' failed with exit status 2 I have vs2003 installed (for python 2.5.1), plus just downloaded and installed the latest platform sdk from (http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3 -A93E-40C0EC4F68E5 &displaylang=en#filelist). Any ideas? I'm purely after the ISAPI bits. Thanks, Tom On Mon, Feb 25, 2008 at 4:28 PM, Tom Wells wrote: Mark, Hi A test build would be great - I just sync'd CVS and saw your changes and about to download platform SDK etc to compile the newest version, but i'm sure you can probably get me something sooner! I will however get the sources anyways, as it's a good reference plus I may feel inclined to finish off some of your TBD's (such as the SF_NOTIFY_SEND_RESPONSE notification, which should be very easy as it takes exactly the same notificationtype as SF_NOTIFY_PREPROC_HEADERS according to ISAPI documentation). Thanks for the support so far - really appreciate it! Please let me know once you have a build available, I am running python 2.5.1 (32 bit), but would also require an amd64 build if possible? Thanks, Tom On Mon, Feb 25, 2008 at 3:50 PM, Mark Hammond wrote: > Actually there is no such fc.SetHeader() function ... Yep - it was PREPROC_HEADERS I was referring to. > SendResponseHeaders() not working is odd, and maybe i'm just misunderstanding it's use Sadly, there is a layer of indirection here I inherited from the original author which isn't necessarily intuitive. SendResponseHeaders() is used by an extension and which as the docs mention (or at least do in CVS - its likely they do not in your copy), "calls ServerSupportFunction with HSE_REQ_SEND_RESPONSE_HEADER_EX" - which you will find takes 3 params - response, complete_headers, keep_alive, where response is the "200 OK" string, complete_headers is a string with \r\n terminators, and keep_alive is a bool (which, best I can tell, has no effect on anything!) I have added HTTP_FILTER_CONTEXT AddResponseHeaders() to CVS though - let me know if you would like a build to test (and let me know your Python version) - and that goes for anyone else too - build 211 gets closer by the day (just get Roger to stop fixing lots of pythonwin bugs ) so I'll point anyone who asks at test builds... Cheers, Mark. -- http://www.tomwells.org -- http://www.tomwells.org _______________________________________________ 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: http://mail.python.org/pipermail/python-win32/attachments/20080330/25cf7c41/attachment.htm From gerdusvanzyl at gmail.com Sun Mar 30 11:45:04 2008 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Sun, 30 Mar 2008 11:45:04 +0200 Subject: [python-win32] Idle Event In-Reply-To: <91882ea90803280259t2810020cgac0e6755b75e0a83@mail.gmail.com> References: <91882ea90803280259t2810020cgac0e6755b75e0a83@mail.gmail.com> Message-ID: <91882ea90803300245n3b85d977w3c82faadb2c4490b@mail.gmail.com> So to answer my own question: use win32gui.PumpWaitingMessages, it uses peekmessage. so you can then replace PumpMessages() with: while PumpWaitingMessages() == 0: #some idle function or processing here ~gvz On Fri, Mar 28, 2008 at 11:59 AM, Gerdus van Zyl wrote: > Hi, > > How can I run a function when the event loop is idle? It's for > animation and some layout calculation. Currently I am doing that using > threads but the responsiveness of my application is suffering. > > Thank you > ~Gerdus > From patter001 at gmail.com Mon Mar 31 03:05:23 2008 From: patter001 at gmail.com (Kevin Patterson) Date: Sun, 30 Mar 2008 21:05:23 -0400 Subject: [python-win32] [pywin32-bugs] ISAPI Set-Cookie Probs In-Reply-To: <00bc01c89232$33c137e0$9b43a7a0$@com.au> References: <00b301c875a4$7e6406b0$7b2c1410$@com.au> <020401c877b5$561805e0$024811a0$@com.au> <00bc01c89232$33c137e0$9b43a7a0$@com.au> Message-ID: Thanks that helped. In case anyone else needs it, I also did the following Remove the service manager: win32_extensions += [ WinExt_win32('servicemanager', extra_compile_args = ['-DUNICODE', '-D_UNICODE', '-DWINNT', '-DPYSERVICE_BUILD_DLL'], libraries = "user32 ole32 advapi32 shell32", dsp_file = r"win32\Pythonservice servicemanager.dsp", windows_h_version = 0x500), ############ change to 0x501 ] Comment out the whole section of: # WinExt_win32com('shell', libraries='shell32', pch_header="shell_pch.h", # sources=(""" # %(shell)s/PyIActiveDesktop.cpp etc... # """ % dirs).split()), I know that's a lot of stuff, and is definitely not the way to go. I tried the Windows Server 2008+.NET 3.5 SDK, but I was still having some issues. I think it is probably just some setup issue on my side so I went with this temporarily. On Sun, Mar 30, 2008 at 2:49 AM, Mark Hammond wrote: > Oops ? forgot to "reply all": > > > > The problem is that win32service needs a later platform SDK ? try changing > the line in setup.py from: > > > > ("win32service", "advapi32 oleaut32 user32", True, 0x0500), > > > > To: > > > > ("win32service", "advapi32 oleaut32 user32", True, 0x0501), > > > > And it should be skipped. You might need to do it to pythonservice.exetoo. Or just install the Vista SDK. > > > > Mark > > > > *From:* python-win32-bounces at python.org [mailto: > python-win32-bounces at python.org] *On Behalf Of *Kevin Patterson > *Sent:* Sunday, 30 March 2008 3:23 PM > *To:* Tom Wells; Python-Win32 List > *Subject:* Re: [python-win32] [pywin32-bugs] ISAPI Set-Cookie Probs > > > > I also received this error message. I backed up to tag "b209" and > everything compiled o.k. Is this error below a known issue? > > > > On Mon, Feb 25, 2008 at 11:36 AM, Tom Wells wrote: > > Just tried to run a build, and getting the following errors: > C:\temp\pywin32>python setup.py -q build > Building pywin32 2.5.210.9 > Skipping win32cred WINDOWS.H with version 0x501 is required, but only > version 0x500 is installed. > win32servicemodule.cpp > win32\src\win32servicemodule.cpp(2675) : error C2065: > 'SERVICE_CONTROL_PRESHUTDOWN' : undeclared identifier > win32\src\win32servicemodule.cpp(2733) : error C2065: > 'SERVICE_ACCEPT_PRESHUTDOWN' : undeclared identifier > error: command '"C:\Program Files\Microsoft Visual Studio .NET > 2003\Vc7\bin\cl.exe"' failed with exit status 2 > > I have vs2003 installed (for python 2.5.1), plus just downloaded and > installed the latest platform sdk from ( > http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5&displaylang=en#filelist > ). > > Any ideas? I'm purely after the ISAPI bits. > > Thanks, > Tom > > > > On Mon, Feb 25, 2008 at 4:28 PM, Tom Wells wrote: > > Mark, Hi > > A test build would be great - I just sync'd CVS and saw your changes and > about to download platform SDK etc to compile the newest version, but i'm > sure you can probably get me something sooner! I will however get the > sources anyways, as it's a good reference plus I may feel inclined to finish > off some of your TBD's (such as the SF_NOTIFY_SEND_RESPONSE notification, > which should be very easy as it takes exactly the same notificationtype as > SF_NOTIFY_PREPROC_HEADERS according to ISAPI documentation). > > Thanks for the support so far - really appreciate it! > > Please let me know once you have a build available, I am running python > 2.5.1 (32 bit), but would also require an amd64 build if possible? > > Thanks, > Tom > > > > On Mon, Feb 25, 2008 at 3:50 PM, Mark Hammond > wrote: > > > Actually there is no such fc.SetHeader() function ... > > Yep - it was PREPROC_HEADERS I was referring to. > > > > SendResponseHeaders() not working is odd, and maybe i'm just > misunderstanding it's use > > Sadly, there is a layer of indirection here I inherited from the original > author which isn't necessarily intuitive. SendResponseHeaders() is used > by > an extension and which as the docs mention (or at least do in CVS - its > likely they do not in your copy), "calls ServerSupportFunction with > HSE_REQ_SEND_RESPONSE_HEADER_EX" - which you will find takes 3 params - > response, complete_headers, keep_alive, where response is the "200 OK" > string, complete_headers is a string with \r\n terminators, and keep_alive > is a bool (which, best I can tell, has no effect on anything!) > > I have added HTTP_FILTER_CONTEXT AddResponseHeaders() to CVS though - let > me > know if you would like a build to test (and let me know your Python > version) > - and that goes for anyone else too - build 211 gets closer by the day > (just > get Roger to stop fixing lots of pythonwin bugs ) so I'll point > anyone > who asks at test builds... > > Cheers, > > Mark. > > > > -- > http://www.tomwells.org > > > > -- > http://www.tomwells.org > > _______________________________________________ > 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: http://mail.python.org/pipermail/python-win32/attachments/20080330/5c71c373/attachment.htm From marcus at internetnowasp.net Mon Mar 31 10:48:30 2008 From: marcus at internetnowasp.net (Marcus Low) Date: Mon, 31 Mar 2008 16:48:30 +0800 Subject: [python-win32] Threads in COM not given time to execute? Message-ID: Hi, I am testing a COM component, when i execute it under pythonwin idle and single stepping F10 to "SmtpMail.Start()" : SmtpMail = win32com.client.Dispatch("SomeSMTPCom") SmtpMail.Start() I can telnet to 127.0.0.1 25 and get a proper SMTP response But when i run the program it just quits so i am assuming SmtpMail.Start() does not block. So i added a function to wait for an event before allowing the function to quit to that SmtpMail.Start() can run as long as it want :- def MainEntry () : global FlagToStop SmtpMail = win32com.client.Dispatch("SomeSMTPCom") SmtpMail.Start() thread.start_new(CheckForQuit,(0,)) while FlagToStop == False : win32api.Sleep(1000) # i tried os.sleep(0), pass but the uses 50% of cpu SmtpMail.Stop() i have confirmed that the it will loop in "While FlagToStop ..." however when i telnet 127.0.0.1 25, it gets connected but i don't get a reply from the COM which is a STMP component. I can get a response if i use single step to where ".Start()" but if i just run the program i get this feeling that the COM object here doesnt get the time to execute and thus could not respond. Am i missing out some basic steps here? Marcus. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080331/47e3ea3f/attachment.htm From marcus at internetnowasp.net Mon Mar 31 11:23:26 2008 From: marcus at internetnowasp.net (Marcus Low) Date: Mon, 31 Mar 2008 17:23:26 +0800 Subject: [python-win32] Threads in COM not given time to execute? In-Reply-To: References: Message-ID: Hi, Found the reason. The COM component in this case somehow depends on the windows message pump. while FlagToStop == False : win32gui.PumpMessages(); Solved the issue. Marcus. ----- Original Message ----- From: Marcus Low To: 'Python-Win32 List' Sent: Monday, March 31, 2008 4:48 PM Subject: [python-win32] Threads in COM not given time to execute? Hi, I am testing a COM component, when i execute it under pythonwin idle and single stepping F10 to "SmtpMail.Start()" : SmtpMail = win32com.client.Dispatch("SomeSMTPCom") SmtpMail.Start() I can telnet to 127.0.0.1 25 and get a proper SMTP response But when i run the program it just quits so i am assuming SmtpMail.Start() does not block. So i added a function to wait for an event before allowing the function to quit to that SmtpMail.Start() can run as long as it want :- def MainEntry () : global FlagToStop SmtpMail = win32com.client.Dispatch("SomeSMTPCom") SmtpMail.Start() thread.start_new(CheckForQuit,(0,)) while FlagToStop == False : win32api.Sleep(1000) # i tried os.sleep(0), pass but the uses 50% of cpu SmtpMail.Stop() i have confirmed that the it will loop in "While FlagToStop ..." however when i telnet 127.0.0.1 25, it gets connected but i don't get a reply from the COM which is a STMP component. I can get a response if i use single step to where ".Start()" but if i just run the program i get this feeling that the COM object here doesnt get the time to execute and thus could not respond. Am i missing out some basic steps here? Marcus. ------------------------------------------------------------------------------ _______________________________________________ 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: http://mail.python.org/pipermail/python-win32/attachments/20080331/f119d6a9/attachment-0001.htm From kieran at e-spatial.co.nz Mon Mar 31 22:54:50 2008 From: kieran at e-spatial.co.nz (Kieran Martin) Date: Tue, 1 Apr 2008 09:54:50 +1300 Subject: [python-win32] creating a Word AddIn based on the Excel one Message-ID: <20080331205425.4FF90C9C456@linda.dts.net.nz> I tried to create a really basic Word AddIn based on the Excel example (which works fine for me). I've pasted the code below. Apologies for my general ignorance - I've trolled the Archives looking for something close but no dice. I've had luck making an Excel AddIns in the past and can make my way round the Word Object model, VBA et al. But I'm really winging it with the COM stuff. Thanks in advance to who-ever takes a look at this . Kieran Martin e-Spatial Ltd New Zealand Here's the trace collector data: # This window will display output from any programs that import win32traceutil # win32com servers registered with '--debug' are in this category. Object with win32trace dispatcher created (object=None) OnConnection Microsoft Word 0 A Simple Word Addin (2,) pythoncom error: Failed to call the universal dispatcher Traceback (most recent call last): File "C:\Python24\lib\site-packages\win32com\universal.py", line 177, in dispatch retVal = ob._InvokeEx_(meth.dispid, 0, meth.invkind, args, None, None) File "C:\Python24\lib\site-packages\win32com\server\policy.py", line 332, in _InvokeEx_ return self._invokeex_(dispid, lcid, wFlags, args, kwargs, serviceProvider) File "C:\Python24\lib\site-packages\win32com\server\policy.py", line 654, in _invokeex_ return DesignatedWrapPolicy._invokeex_( self, dispid, lcid, wFlags, args, kwArgs, serviceProvider) File "C:\Python24\lib\site-packages\win32com\server\policy.py", line 588, in _invokeex_ return func(*args) File "c:\Python24\Lib\site-packages\win32com\demos\wordAddin.py", line 62, in OnConnection print "OnDisconnection" exceptions.NameError: global name 'appHostApp' is not defined pythoncom error: Unexpected gateway error Traceback (most recent call last): File "C:\Python24\lib\site-packages\win32com\universal.py", line 177, in dispatch retVal = ob._InvokeEx_(meth.dispid, 0, meth.invkind, args, None, None) File "C:\Python24\lib\site-packages\win32com\server\policy.py", line 332, in _InvokeEx_ return self._invokeex_(dispid, lcid, wFlags, args, kwargs, serviceProvider) File "C:\Python24\lib\site-packages\win32com\server\policy.py", line 654, in _invokeex_ return DesignatedWrapPolicy._invokeex_( self, dispid, lcid, wFlags, args, kwArgs, serviceProvider) File "C:\Python24\lib\site-packages\win32com\server\policy.py", line 588, in _invokeex_ return func(*args) File "c:\Python24\Lib\site-packages\win32com\demos\wordAddin.py", line 62, in OnConnection print "OnDisconnection" exceptions.NameError: global name 'appHostApp' is not defined >>>> here's the code # from win32com import universal from win32com.server.exception import COMException from win32com.client import gencache, DispatchWithEvents import winerror import pythoncom from win32com.client import constants, Dispatch import sys # Support for COM objects we use. gencache.EnsureModule('{00020905-0000-0000-C000-000000000046}', 0, 1, 3, bForDemand=True) # Word 11 gencache.EnsureModule('{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}', 0, 2, 1, bForDemand=True) # Office 11 # The TLB defiining the interfaces we implement universal.RegisterInterfaces('{AC0714F2-3D04-11D1-AE7D-00A0C90F26F4}', 0, 1, 0, ["_IDTExtensibility2"]) class ButtonEvent: def OnClick(self, button, cancel): import win32ui # Possible, but not necessary, to use a Pythonwin GUI import win32con win32ui.MessageBox("Hello from Python", "Python Test",win32con.MB_OKCANCEL) return cancel class WordAddin: _com_interfaces_ = ['_IDTExtensibility2'] _public_methods_ = [] _reg_clsctx_ = pythoncom.CLSCTX_INPROC_SERVER _reg_clsid_ = "{C5482ECA-F559-45A0-B078-B2036E6F011A}" _reg_progid_ = "Python.Test.WordAddin" _reg_policy_spec_ = "win32com.server.policy.EventHandlerPolicy" def __init__(self): return def OnConnection(self, application, connectMode, addin, custom): print "OnConnection", application, connectMode, addin, custom def OnDisconnection(self, mode, custom): print "OnDisconnection" def OnAddInsUpdate(self, custom): print "OnAddInsUpdate", custom def OnStartupComplete(self, custom): print "OnStartupComplete", custom def OnBeginShutdown(self, custom): print "OnBeginShutdown", custom def RegisterAddin(klass): import _winreg key = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Office\\Word\\Addins") subkey = _winreg.CreateKey(key, klass._reg_progid_) _winreg.SetValueEx(subkey, "CommandLineSafe", 0, _winreg.REG_DWORD, 0) _winreg.SetValueEx(subkey, "LoadBehavior", 0, _winreg.REG_DWORD, 3) _winreg.SetValueEx(subkey, "Description", 0, _winreg.REG_SZ, "Word Addin") _winreg.SetValueEx(subkey, "FriendlyName", 0, _winreg.REG_SZ, "A Simple Word Addin") def UnregisterAddin(klass): import _winreg try: _winreg.DeleteKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Office\\Word\\Addins\\" + klass._reg_progid_) except WindowsError: pass if __name__ == '__main__': import win32com.server.register win32com.server.register.UseCommandLine(WordAddin) if "--unregister" in sys.argv: UnregisterAddin(WordAddin) else: RegisterAddin(WordAddin) _______________________________________________________ Kieran Martin e-Spatial Limited PO Box 10015 Phone: + 64 4 499 3546 Wellington 6143 Fax: + 64 4 499 3547 NEW ZEALAND Cell: + 64 274 9000 77 www.e-spatial.co.nz location based business intelligence -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080401/a4cd9dcc/attachment-0001.htm