From tim.golden at viacom-outdoor.co.uk Mon Dec 1 03:13:36 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon Dec 1 03:20:43 2003 Subject: [python-win32] win32print Message-ID: > -----Original Message----- > From: Guy Robinson [mailto:guy@r-e-d.co.nz] > Sent: 29 November 2003 08:41 > To: python-win32@python.org > Subject: [python-win32] win32print > > My question is, is there an 'intelligient' way of monitoring the > spooler? I guess what I'm thinking is some low cpu method of watching > for activity on the spooler, and triggering my program as the spooler > stops and starts. Is this of any use to you? http://tgolden.sc.sabren.com/python/wmi_cookbook.html#watch_print_jobs TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From bgailer at alum.rpi.edu Mon Dec 1 15:14:25 2003 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Mon Dec 1 15:14:30 2003 Subject: [python-win32] Win32 Mode In-Reply-To: <3FC89729.2010908@hotpop.com> References: <001001c3b62c$7da3d110$0200a8c0@eden> <3FC89729.2010908@hotpop.com> Message-ID: <6.0.0.22.0.20031201131309.02a63990@mail.mric.net> At 05:55 AM 11/29/2003, Ray Pasco wrote: >That's not what seems to be happening. Here's the entire code: > > import win32api > win32api.InitiateSystemShutdown ('', '', 0, 1, 1) > >and this is the result: > > Traceback (most recent call last): > File "try.py", line 9, in ? > win32api.InitiateSystemShutdown ('', '', 0, 1, 1) > pywintypes.error: (120, 'InitiateSystemShutdown', 'This function is > only valid in Win32 mode.') Doing this on Win 2003 Server, logged on as administrator, yields: >>> win32api.InitiateSystemShutdown ('', '', 0, 1, 1) Traceback (most recent call last): File "", line 1, in ? pywintypes.error: (5, 'InitiateSystemShutdown', 'Access is denied.') Bob Gailer bgailer@alum.rpi.edu 303 442 2625 home 720 938 2625 cell -------------- next part -------------- --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.545 / Virus Database: 339 - Release Date: 11/27/2003 From mhammond at skippinet.com.au Mon Dec 1 19:50:19 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon Dec 1 19:50:33 2003 Subject: [python-win32] Win32 Mode In-Reply-To: <6.0.0.22.0.20031201131309.02a63990@mail.mric.net> Message-ID: <010801c3b86e$43f440a0$0200a8c0@eden> > >That's not what seems to be happening. Here's the entire code: > > > > import win32api > > win32api.InitiateSystemShutdown ('', '', 0, 1, 1) > > > >and this is the result: > > > > Traceback (most recent call last): > > File "try.py", line 9, in ? > > win32api.InitiateSystemShutdown ('', '', 0, 1, 1) > > pywintypes.error: (120, 'InitiateSystemShutdown', 'This > function is > > only valid in Win32 mode.') This error means "not available on Win9x" - I wish they just said that in the error message :) > Doing this on Win 2003 Server, logged on as administrator, yields: > > >>> win32api.InitiateSystemShutdown ('', '', 0, 1, 1) > Traceback (most recent call last): > File "", line 1, in ? > pywintypes.error: (5, 'InitiateSystemShutdown', 'Access is denied.') This is also expected - you have to use the win32security module to gain the 'privilege' to perform this operation - google should have a number of example (and 'Python Programming on Win32' certainly does ;) Mark. From mhammond at skippinet.com.au Mon Dec 1 20:03:43 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon Dec 1 20:03:52 2003 Subject: [python-win32] PyWin32 extensions can now be built using distutils Message-ID: <010901c3b870$2202c280$0200a8c0@eden> This is for anyone who builds PyWin32/win32all from CVS source code. Currently, the instructions for building these extensions require you to use Visual Studio, and perform lots of magic fiddling to get everything installed and working. But thanks to Thomas Heller, we now have a 'distutils' setup script that does all this magic for you. I'd like anyone who builds from sources (or anyone who would like to, but failed in the past) to try this out for me. Eventually, I will update the build instructions accordingly to make this the 'official' way to build and install these extensions from source. You still need MSVC (but should *not* need Visual Studio - only the command-line compiler is used) To test this, follow these instructions: * Remove any win32all installations, and remove any previously built win32all extensions. This isn't strictly necessary, but will help me to ensure that everything works. It will also avoid one or 2 duplicate files (notably, the .exe files) * Pull the latest source-code from CVS - see the project sourceforge page. * In the root directory, execute 'setup_win32all.py', with no arguments. This will print a couple of pages of usage information, including what params you use to build and install. The short course is "setup_win32all.py install" will build and install all the extensions. Once installed, you will find all built .pyd/.dll/.exe files, and .py files, installed into your "site-packages" directory, as a normal win32all installation would do. You can build for multiple versions of Python simply by changing the 'python.exe' used to execute 'setup_win32all.py'. Instructions are also provided for building (and installing) debug versions of the extensions. If anyone does try this, please let me know how you go - successful or otherwise. Thanks! Mark. From theller at python.net Tue Dec 2 04:44:28 2003 From: theller at python.net (Thomas Heller) Date: Tue Dec 2 04:44:36 2003 Subject: [python-win32] Re: PyWin32 extensions can now be built using distutils References: <010901c3b870$2202c280$0200a8c0@eden> Message-ID: "Mark Hammond" writes: > This is for anyone who builds PyWin32/win32all from CVS source code. > > Currently, the instructions for building these extensions require you to use > Visual Studio, and perform lots of magic fiddling to get everything > installed and working. But thanks to Thomas Heller, we now have a > 'distutils' setup script that does all this magic for you. > > I'd like anyone who builds from sources (or anyone who would like to, but > failed in the past) to try this out for me. Eventually, I will update the > build instructions accordingly to make this the 'official' way to build and > install these extensions from source. You still need MSVC (but should *not* > need Visual Studio - only the command-line compiler is used) > > To test this, follow these instructions: > * Remove any win32all installations, and remove any previously built > win32all extensions. This isn't strictly necessary, but will help me to > ensure that everything works. It will also avoid one or 2 duplicate files > (notably, the .exe files) > * Pull the latest source-code from CVS - see the project sourceforge page. > * In the root directory, execute 'setup_win32all.py', with no arguments. > This will print a couple of pages of usage information, including what > params you use to build and install. The short course is "setup_win32all.py > install" will build and install all the extensions. > > Once installed, you will find all built .pyd/.dll/.exe files, and .py files, > installed into your "site-packages" directory, as a normal win32all > installation would do. You can build for multiple versions of Python simply > by changing the 'python.exe' used to execute 'setup_win32all.py'. > Instructions are also provided for building (and installing) debug versions > of the extensions. > > If anyone does try this, please let me know how you go - successful or > otherwise. Well, I had to make a couple of changes to get this to work on a fresh CVS checkout (diffs are attached): - I had to comment out 'pywin32.chm', this is not (yet) built. - I commented out the exchange and exchdapi extensions because some files were not found by the compiler (but I don't care about these). - I had to comment out the shell extension, this failed with linker errors (Hm, seems I cannot reproduce this). Then building of permondata.dll failed, because the script tries to compile perfmondata.cpp first, and complais about a missing PyPerfMsgs.h file. The latter would be created by processing PyPerfMsgs.mc with the messaage compiler. Therefore I changed the WinExt.get_sourcefile() method to sort the source files depending on the filename extension - but this requires a change to the msvccompiler class also. After these changes, I could build an install everything, and even Pythonwin.exe works! 'setup.py bdist_wininst' doesn't really work, but that is for later. Thomas -------------- next part -------------- A non-text attachment was scrubbed... Name: setup_win32all.py.diff Type: text/x-patch Size: 3463 bytes Desc: Patch for setup_win32all.py Url : http://mail.python.org/pipermail/python-win32/attachments/20031202/ce4a4da7/setup_win32all.py.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: msvccompiler.py.diff Type: text/x-patch Size: 949 bytes Desc: Patch for msvccompiler.py Url : http://mail.python.org/pipermail/python-win32/attachments/20031202/ce4a4da7/msvccompiler.py.bin From mhammond at skippinet.com.au Tue Dec 2 07:35:36 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue Dec 2 07:35:52 2003 Subject: [python-win32] Re: PyWin32 extensions can now be built usingdistutils In-Reply-To: Message-ID: <015401c3b8d0$c98c2860$2c00a8c0@eden> Thanks Thomas, I think I have fixed all your issues (your patch for the .mc, and a slighly different one for the .chm). It looks like I had an outstanding change related to exchange and exchdapi, which I have also incorporated, so I would be interested to know how that goes. Mark. > -----Original Message----- > From: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org]On Behalf Of Thomas Heller > Sent: Tuesday, 2 December 2003 8:44 PM > To: python-win32@python.org > Subject: [python-win32] Re: PyWin32 extensions can now be built > usingdistutils > > > "Mark Hammond" writes: > > > This is for anyone who builds PyWin32/win32all from CVS source code. > > > > Currently, the instructions for building these extensions > require you to use > > Visual Studio, and perform lots of magic fiddling to get everything > > installed and working. But thanks to Thomas Heller, we now have a > > 'distutils' setup script that does all this magic for you. > > > > I'd like anyone who builds from sources (or anyone who > would like to, but > > failed in the past) to try this out for me. Eventually, I > will update the > > build instructions accordingly to make this the 'official' > way to build and > > install these extensions from source. You still need MSVC > (but should *not* > > need Visual Studio - only the command-line compiler is used) > > > > To test this, follow these instructions: > > * Remove any win32all installations, and remove any previously built > > win32all extensions. This isn't strictly necessary, but > will help me to > > ensure that everything works. It will also avoid one or 2 > duplicate files > > (notably, the .exe files) > > * Pull the latest source-code from CVS - see the project > sourceforge page. > > * In the root directory, execute 'setup_win32all.py', with > no arguments. > > This will print a couple of pages of usage information, > including what > > params you use to build and install. The short course is > "setup_win32all.py > > install" will build and install all the extensions. > > > > Once installed, you will find all built .pyd/.dll/.exe > files, and .py files, > > installed into your "site-packages" directory, as a normal win32all > > installation would do. You can build for multiple versions > of Python simply > > by changing the 'python.exe' used to execute 'setup_win32all.py'. > > Instructions are also provided for building (and > installing) debug versions > > of the extensions. > > > > If anyone does try this, please let me know how you go - > successful or > > otherwise. > > Well, I had to make a couple of changes to get this to work on a fresh > CVS checkout (diffs are attached): > > - I had to comment out 'pywin32.chm', this is not (yet) built. > > - I commented out the exchange and exchdapi extensions because some > files were not found by the compiler (but I don't care about these). > > - I had to comment out the shell extension, this failed with linker > errors (Hm, seems I cannot reproduce this). > > Then building of permondata.dll failed, because the script tries to > compile perfmondata.cpp first, and complais about a missing > PyPerfMsgs.h > file. The latter would be created by processing > PyPerfMsgs.mc with the > messaage compiler. Therefore I changed the WinExt.get_sourcefile() > method to sort the source files depending on the filename extension - > but this requires a change to the msvccompiler class also. > > After these changes, I could build an install everything, and even > Pythonwin.exe works! > > 'setup.py bdist_wininst' doesn't really work, but that is for later. > > Thomas > > From henni at brainbot.com Tue Dec 2 14:22:16 2003 From: henni at brainbot.com (Thorsten Henninger) Date: Tue Dec 2 14:28:40 2003 Subject: [python-win32] win32com and McMillan Installer do not work together Message-ID: <3FCCE668.50108@brainbot.com> Hi, I do not get the McMillan Installer work together with the latest win32all package. Does anybody have similar problems? regards, Thorsten -- brainbot technologies AG boppstrasse . 64 . 55118 mainz . germany fon +49 6131 211639-1 . fax +49 6131 211639-2 http://brainbot.com/ mailto:henni@brainbot.com From cbrandson at triant.com Wed Dec 3 13:50:23 2003 From: cbrandson at triant.com (Chris Brandson) Date: Wed Dec 3 14:06:41 2003 Subject: [python-win32] COM and Makepy when DLL and TLB are separated Message-ID: I need to access an InProc COM interface which was originally designed for VB and has a separate type library (".tlb" file) and DLL. An additional problem is that some of the arguments are ByRef and are modified during invocation. Makepy can generate source files for both the DLL and typelib. The typelib has interfaces defined but CLSIDToClassMap is empty. The DLL has a CLSIDToClassMap for the classes but no interfaces defined (they are in the tlb). I had hoped that win32com.client would combine TLB and DLL and allow access, but when I create the top level object from the ProgID with Dispatch, none of the properties or methods seen to be found e.g. "AttributeError: '.' object has no attribute 'Initialize'. Is there documentation somewhere on what makepy is actually doing. There is some info in "Python Programming on Win32", but I haven't been able to map what is there to my case with a DLL and TLB. Is there something I need to do to link the DLL and TLB or is the issue related to the fact that just about every method needs arguments passed by reference? Any assistance would be greatly appreciated. Thanks, - Chris From fredm at smartypantsco.com Wed Dec 3 19:36:34 2003 From: fredm at smartypantsco.com (Alfred Milgrom) Date: Wed Dec 3 19:37:07 2003 Subject: [python-win32] beginner's question on network programming Message-ID: <5.1.0.14.0.20031204113134.03433ec0@192.168.1.1> Hi: I am familiar with Python and can program what I want for a single machine without too much trouble, but now I want to develop a network version of my program. I am a complete beginner as far as networks are concerned. For a single machine I can distribute my program as *.py files and data files, or as an .exe using py2exe. (The program accesses data files). My question is what do I need to make a program network-compatible? Do I need a client-server module or something similar? If so, has anyone already written one? Thanks in anticipation, Alfred Milgrom From rasjidw at openminddev.net Thu Dec 4 06:48:41 2003 From: rasjidw at openminddev.net (Rasjid Wilcox) Date: Thu Dec 4 06:47:49 2003 Subject: [python-win32] beginner's question on network programming In-Reply-To: <5.1.0.14.0.20031204113134.03433ec0@192.168.1.1> References: <5.1.0.14.0.20031204113134.03433ec0@192.168.1.1> Message-ID: <200312042248.41145.rasjidw@openminddev.net> On Thursday 04 December 2003 11:36, Alfred Milgrom wrote: > My question is what do I need to make a program network-compatible? What precisely do you mean by 'network compatible'? > Do I > need a client-server module or something similar? If so, has anyone already > written one? Not quite sure if this is what you are after, but have a look at http://www.markcarter.me.uk/computing/python/python.html. The page lists several frameworks (including XML-RPC, Twisted, Pyro and Corba) which may be what you are after. Cheers, Rasjid. -- Rasjid Wilcox Canberra, Australia (UTC +10 hrs) http://www.openminddev.net From TMitchell at lignum.com Thu Dec 4 11:01:53 2003 From: TMitchell at lignum.com (Tyler Mitchell) Date: Thu Dec 4 11:02:09 2003 Subject: [python-win32] beginner's question on network programming In-Reply-To: <5.1.0.14.0.20031204113134.03433ec0@192.168.1.1> Message-ID: Alfred, Rasjid already noted XML-RPC. Don't let the complexity of the name fool you though, I've found it's really nice to use. I'm using it for my first "networked" application. Basically, you create a python server script that have all the functions/methods in it that you want and when you run it, it just sits and waits for incoming requests. On the client side, you do whatever you want, but when you want to communicate with the server, you call it almost like calling a regular function, but you point to the server instead. The client and server both send requests back and forth, and can actually send python objects! It's neat. I should say, I found the documentation of XML-RPC, specifically for python, to be sketchy and irritating from a new user perspective. So I suggest you don't waste your time reading until you've found a good tutorial. I was barely able to find a good server example of xml-rpc in python! If you or others on the list would like, I could walk you through my most simple application as a tutorial. Tyler Alfred Milgrom To Sent by: python-win32-boun cc ces@python.org Fax to 12/03/2003 04:36 Subject PM [python-win32] beginner's question on network programming Hi: I am familiar with Python and can program what I want for a single machine without too much trouble, but now I want to develop a network version of my program. I am a complete beginner as far as networks are concerned. For a single machine I can distribute my program as *.py files and data files, or as an .exe using py2exe. (The program accesses data files). My question is what do I need to make a program network-compatible? Do I need a client-server module or something similar? If so, has anyone already written one? Thanks in anticipation, Alfred Milgrom _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From mhammond at skippinet.com.au Thu Dec 4 18:04:48 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu Dec 4 18:05:02 2003 Subject: [python-win32] COM and Makepy when DLL and TLB are separated In-Reply-To: Message-ID: <07e201c3babb$04e0d500$2c00a8c0@eden> tlb and the dlls should be able to work when they are discrete, and does for most other objects. Even when they are in the same file, it is quite common that the typelib is just a "blob" in the file anyway. makepy just uses LoadRegTypeLib in most cases, but depending on the params you pass, may open using the .tlb name directly. I'm not completely clear on your environment though. It sounds like your DLL *also* has a typelib - if you try and run makepy over a DLL without a typelib it will fail. If your DLL attempting to extend interfaces in the .tlb? If not, why is there type info available in both the .tlb and the .dll? Mark. > -----Original Message----- > From: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org]On Behalf Of Chris Brandson > Sent: Thursday, 4 December 2003 5:50 AM > To: python-win32@python.org > Subject: [python-win32] COM and Makepy when DLL and TLB are separated > > > I need to access an InProc COM interface which was originally > designed for > VB and has a separate type library (".tlb" file) and DLL. An > additional > problem is that some of the arguments are ByRef and are > modified during > invocation. Makepy can generate source files for both the DLL > and typelib. > The typelib has interfaces defined but CLSIDToClassMap is > empty. The DLL has > a CLSIDToClassMap for the classes but no interfaces defined > (they are in > the tlb). I had hoped that win32com.client would combine TLB > and DLL and > allow access, but when I create the top level object from the > ProgID with > Dispatch, none of the properties or methods seen to be found e.g. > "AttributeError: '. name>' object > has no attribute 'Initialize'. Is there documentation > somewhere on what > makepy is actually doing. There is some info in "Python Programming on > Win32", but I haven't been able to map what is there to my > case with a DLL > and TLB. > > Is there something I need to do to link the DLL and TLB or is > the issue > related to the fact that just about every method needs > arguments passed by > reference? > > Any assistance would be greatly appreciated. > > Thanks, > > - Chris > > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From mhammond at skippinet.com.au Thu Dec 4 18:12:47 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu Dec 4 18:12:59 2003 Subject: [python-win32] beginner's question on network programming In-Reply-To: Message-ID: <07e301c3babc$22c41680$2c00a8c0@eden> > I should say, I found the documentation of XML-RPC, specifically for > python, to be sketchy and irritating from a new user > perspective. So I > suggest you don't waste your time reading until you've found a good > tutorial. I was barely able to find a good server example of > xml-rpc in > python! If you or others on the list would like, I could > walk you through > my most simple application as a tutorial. As a side note, most of the Python/extensions docs follow this cycle: * Technically smart person writes cool code, and very sketchy docs (generally written for someone just like him/her) * 500 people scratch their head, stumble around, post to mailing lists and manage to put together a vague answer. Many fail. * One of the 500 picks up the ball and contributes real documentation. * The next 500 people trying to use it have a much better life. This is, unfortunately, the current nature of Open Source. As Open Source moves up the food chain, I hope to see that change, but it won't be soon. While it may seem formidable, submitting docs and examples needn't be that hard, and will generally be gratefully accepted. Mark. From fredm at smartypantsco.com Thu Dec 4 18:45:26 2003 From: fredm at smartypantsco.com (Alfred Milgrom) Date: Thu Dec 4 18:46:11 2003 Subject: [python-win32] beginner's question on network programming In-Reply-To: <200312042248.41145.rasjidw@openminddev.net> References: <5.1.0.14.0.20031204113134.03433ec0@192.168.1.1> <5.1.0.14.0.20031204113134.03433ec0@192.168.1.1> Message-ID: <5.1.0.14.0.20031205103431.038b1ec0@192.168.1.1> At 10:48 PM 4/12/03 +1100, Rasjid Wilcox wrote: > > My question is what do I need to make a program network-compatible? >What precisely do you mean by 'network compatible'? Well, I did say I was a beginner here :)) Basically I have an educational program and I was asked to make sure it can run form a server. Since it uses a lot of sound and graphics data files, just running it as a normal form the server is not good enough. >Not quite sure if this is what you are after, but have a look at >http://www.markcarter.me.uk/computing/python/python.html. >The page lists several frameworks (including XML-RPC, Twisted, Pyro and >Corba) >which may be what you are after. Thanks a lot for this pointer. It's exactly what I was looking for. A lot of research and learning to do, but I now have something to get my teeth into. At 08:01 AM 4/12/03 -0800, Tyler Mitchell wrote: >Alfred, >Rasjid already noted XML-RPC. Don't let the complexity of the name fool >you though, I've found it's really nice to use. I'm using it for my first >"networked" application. Well, you're right - it certainly sounds hard :)) A first read of the overview by Mark Carter made me feel that Pyro might be best, but even he prefers XML-RPC. As he said: "My advice is: if you're looking at making your first stab at distributed computing, then consider XML-RPC to see if it has what you want." >So I suggest you don't waste your time reading until you've found a good >tutorial. I was barely able to find a good server example of xml-rpc in >python! If you or others on the list would like, I could walk you through >my most simple application as a tutorial. All of it looks hard! Any better tutorial or a walk-through of a simple example would be great. Thanks to everyone for helping, Alfred Milgrom From cbrandson at triant.com Thu Dec 4 19:28:41 2003 From: cbrandson at triant.com (Chris Brandson) Date: Thu Dec 4 19:28:47 2003 Subject: [python-win32] COM and Makepy when DLL and TLB are separated In-Reply-To: <07e201c3babb$04e0d500$2c00a8c0@eden> Message-ID: I checked and the DLL does have its own typelib, however am told that this is a side effect of the build process and is not needed or used. What I am trying to do is use a COM interface built for VB applications to access a C DLL. We are exploring the possibility of allowing the construction of plug-ins to our system in Python instead of VB, which is how they currently are constructed. First step is to make sure that we can access the "core" C libraries to retrieve and analyse data then step two will be to form this into a plug-in with exports COM interface to VB master application. Today: VB Master Application ->COM-> VB plugin ->COM-> COM wrapper to C DLL Future: VB Master Application ->COM-> Python plugin ->COM-> COM wrapper to C DLL Eventually we can get this to work we will eliminate the COM interface to the C DLL, but we will still need the COM interface back to the master VB application. Given that the wrapper for the DLL is not needed, as a further test, I deleted files in the gen_py directory and rebuilt the file using makepy from the type library only. I can then call create an object from the progid thus: tnt = win32com.client.Dispatch("TntCore5_0.DataFilePreprocessor") However an attempt to invoke the init method produces: tnt.Initialize() Traceback (most recent call last): File "", line 1, in ? File "E:\Programs\Python22\lib\site-packages\win32com\client\dynamic.py", line 454, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: TntCore5_0.DataFilePreprocessor.Initialize If I look in the generated gen_py file there is a vtable entry: IDataFilePreprocessor_vtables_ = [ ('Cancel', 1610678272, (), (3, 0, None), ()), ('Cancelled', 1610678273, ((16395,10,None), ), (3, 0, None), ('pRes',)), ('Initialize', 1610678274, (), (3, 0, None), ()), ...... And VTablesToClassMap = { '{082534F5-5424-11D4-A4E0-005004D6E3AF}' : 'IDataFilePreprocessor', ...... VTablesNamesToIIDMap = { 'IDataFilePreprocessor' : '{082534F5-5424-11D4-A4E0-005004D6E3AF}', ...... } However I notice that the CLSIDToClassMap is empty: CLSIDToClassMap = { } CLSIDToPackageMap = {} win32com.client.CLSIDToClass.RegisterCLSIDsFromDict( CLSIDToClassMap ) VTablesToPackageMap = {} Is there an issue because there is no CLSIDToPackageMap? Also I notice that the Class name is IDataFilePreprocessor. I know that I is for interface but am not sure when COM used I interface and when it uses the method directly. I appreciate your help! Regards, - Chris -----Original Message----- From: Mark Hammond [mailto:mhammond@skippinet.com.au] Sent: Thursday, December 04, 2003 3:05 PM To: 'Chris Brandson'; python-win32@python.org Subject: RE: [python-win32] COM and Makepy when DLL and TLB are separated tlb and the dlls should be able to work when they are discrete, and does for most other objects. Even when they are in the same file, it is quite common that the typelib is just a "blob" in the file anyway. makepy just uses LoadRegTypeLib in most cases, but depending on the params you pass, may open using the .tlb name directly. I'm not completely clear on your environment though. It sounds like your DLL *also* has a typelib - if you try and run makepy over a DLL without a typelib it will fail. If your DLL attempting to extend interfaces in the .tlb? If not, why is there type info available in both the .tlb and the .dll? Mark. > -----Original Message----- > From: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org]On Behalf Of Chris Brandson > Sent: Thursday, 4 December 2003 5:50 AM > To: python-win32@python.org > Subject: [python-win32] COM and Makepy when DLL and TLB are separated > > > I need to access an InProc COM interface which was originally > designed for > VB and has a separate type library (".tlb" file) and DLL. An > additional > problem is that some of the arguments are ByRef and are > modified during > invocation. Makepy can generate source files for both the DLL > and typelib. > The typelib has interfaces defined but CLSIDToClassMap is > empty. The DLL has > a CLSIDToClassMap for the classes but no interfaces defined > (they are in > the tlb). I had hoped that win32com.client would combine TLB > and DLL and > allow access, but when I create the top level object from the > ProgID with > Dispatch, none of the properties or methods seen to be found e.g. > "AttributeError: '. name>' object > has no attribute 'Initialize'. Is there documentation > somewhere on what > makepy is actually doing. There is some info in "Python Programming on > Win32", but I haven't been able to map what is there to my > case with a DLL > and TLB. > > Is there something I need to do to link the DLL and TLB or is > the issue > related to the fact that just about every method needs > arguments passed by > reference? > > Any assistance would be greatly appreciated. > > Thanks, > > - Chris > > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From TMitchell at lignum.com Thu Dec 4 19:51:31 2003 From: TMitchell at lignum.com (Tyler Mitchell) Date: Thu Dec 4 19:51:47 2003 Subject: [python-win32] XML-RPC example - was beginner's question on network programming In-Reply-To: <07e301c3babc$22c41680$2c00a8c0@eden> Message-ID: Mark, what you didn't say was: "Contribute back you silly goose". I should have thought of that a while ago, thanks for the reminder! I was kinda holding out waiting for someone else to point out a better link or say they've already got it figured already ;) So here's an example of what I've done: Pre-requisites include xmlrpclib and SimpleXMLRPCServer libraries. Let me know if you need a hand finding them. ---------- Here's the server-side script, keeping it in an order usual for tutorial purposes: >>>class MyFuncs: >>> def add(self, x, y): >>> return x + y >>>from SimpleXMLRPCServer import SimpleXMLRPCServer >>>server = SimpleXMLRPCServer((localhost,8000)) >>>server.register_instance(MyFuncs()) # The server will run until you hit Control-C or the like --------- Here's the client-side script to access above said function: >>>from xmlrpclib import Server >>>myserver = Server("http://localhost:8000") >>>print myserver.add(5,6) 11 #Printed results here, but could also pass the object (?) back as well... >>>mytotal = myserver.add(5,6) >>>print mytotal 11 "Mark Hammond" To Sent by: "'Tyler Mitchell'" python-win32-boun ces@python.org cc python-win32@python.org Fax to 12/04/2003 03:12 PM Subject RE: [python-win32] beginner's question on network programming > I should say, I found the documentation of XML-RPC, specifically for > python, to be sketchy and irritating from a new user > perspective. So I > suggest you don't waste your time reading until you've found a good > tutorial. I was barely able to find a good server example of > xml-rpc in > python! If you or others on the list would like, I could > walk you through > my most simple application as a tutorial. As a side note, most of the Python/extensions docs follow this cycle: * Technically smart person writes cool code, and very sketchy docs (generally written for someone just like him/her) * 500 people scratch their head, stumble around, post to mailing lists and manage to put together a vague answer. Many fail. * One of the 500 picks up the ball and contributes real documentation. * The next 500 people trying to use it have a much better life. This is, unfortunately, the current nature of Open Source. As Open Source moves up the food chain, I hope to see that change, but it won't be soon. While it may seem formidable, submitting docs and examples needn't be that hard, and will generally be gratefully accepted. Mark. _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From gphst at hotmail.com Thu Dec 4 19:18:18 2003 From: gphst at hotmail.com (Greg Lee) Date: Thu Dec 4 20:04:22 2003 Subject: [python-win32] reliably controlling IE (Dispatch vs DispatchEx) Message-ID: I'm using code like this to display text in IE from within a Tkinter application: # magic argument list generated by makepy.py -i for Microsoft Internet Controls win32com.client.gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}', 0, 1, 1) self.iexplorer = win32com.client.DispatchEx('InternetExplorer.Application.1") self.iexplorer.Visible = 1 self.iexplorer.Navigate(contents) win32gui.ShowWindow(self.iexplorer.HWND, 1) # winuser.h:SW_ I'm using DispatchEx rather than the conventional Dispatch because I've noticed that if I have a Windows Explorer running and use Dispatch, then the contents sometimes appears in the right-hand pane of the Windows Explorer rather than in a new instance of InternetExplorer. Using DispatchEx "seems" to do the right thing, but I'm reluctant to rely on this as a fix for an intermittent problem. Any thoughts from the experts? There is a 4 August posting stating that DispatchEx was necessary when you want two instances of of IE, as in: ie1 = Win32com.client.DispatchEx('InternetExplorer.Application.1') ie2 = Win32com.client.DispatchEx('InternetExplorer.Application.1') _________________________________________________________________ Browse styles for all ages, from the latest looks to cozy weekend wear at MSN Shopping. And check out the beauty products! http://shopping.msn.com From Shu-Chin.Cheeng at Shell.com Thu Dec 4 20:42:36 2003 From: Shu-Chin.Cheeng at Shell.com (Cheeng, Shu-Chin SC SITI-ITDDG12) Date: Thu Dec 4 20:44:01 2003 Subject: [python-win32] RE: Python-win32 Digest, Vol 9, Issue 3 Message-ID: <6F825BFCBC2CDA4CB17564B98AF491FC02171B07@cbj-s-340.asia-pac.shell.com> hi all, Me Too... Python 223+win32all-162 Can't find Gen_py and Import error...once using win32com.client.* Regards, Cheeng Shu Chin SA-Messaging Shell Information Technology International 2340 Century Square, Jalan Usahawan, 63000 Cyberjaya, Selangor D.E., Malaysia Tel: +603-8313 3787 Fax: 3900 Other Tel: +6013 630 1682 Email: shu-chin.cheeng@shell.com Internet: http://www.shell.com -----Original Message----- From: python-win32-request@python.org [mailto:python-win32-request@python.org] Sent: Thursday, December 04, 2003 1:04 AM To: python-win32@python.org Subject: Python-win32 Digest, Vol 9, Issue 3 Send Python-win32 mailing list submissions to python-win32@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@python.org You can reach the person managing the list at python-win32-owner@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. win32com and McMillan Installer do not work together (Thorsten Henninger) ---------------------------------------------------------------------- Message: 1 Date: Tue, 02 Dec 2003 20:22:16 +0100 From: Thorsten Henninger Subject: [python-win32] win32com and McMillan Installer do not work together To: python-win32@python.org Message-ID: <3FCCE668.50108@brainbot.com> Content-Type: text/plain; charset=us-ascii; format=flowed Hi, I do not get the McMillan Installer work together with the latest win32all package. Does anybody have similar problems? regards, Thorsten -- brainbot technologies AG boppstrasse . 64 . 55118 mainz . germany fon +49 6131 211639-1 . fax +49 6131 211639-2 http://brainbot.com/ mailto:henni@brainbot.com ------------------------------ _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 End of Python-win32 Digest, Vol 9, Issue 3 ****************************************** -------------- next part -------------- A non-text attachment was scrubbed... Name: Cheeng, Shu-Chin SC SSI-ISWA2.vcf Type: text/x-vcard Size: 365 bytes Desc: Cheeng, Shu-Chin SC SSI-ISWA2.vcf Url : http://mail.python.org/pipermail/python-win32/attachments/20031205/026523b4/CheengShu-ChinSCSSI-ISWA2-0001.vcf From mhammond at skippinet.com.au Thu Dec 4 22:29:13 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu Dec 4 22:29:25 2003 Subject: [python-win32] COM and Makepy when DLL and TLB are separated In-Reply-To: Message-ID: <082001c3badf$f417ce20$2c00a8c0@eden> > I checked and the DLL does have its own typelib, however am > told that this > is a side effect of the build process and is not needed or > used. Note there are 2 main ways tylelibs are used - they are registered, and an IDispatch object can ask for the type info. Are you sure the internal one isn't used at runtime? It seems strange to bother with the .tlb - I wonder why they don't simply use the one in the DLL, and not bother shipping the .tlb. > What I am > trying to do is use a COM interface built for VB applications > to access a C > DLL. We are exploring the possibility of allowing the construction of > plug-ins to our system in Python instead of VB, which is how > they currently > are constructed. Consider using ActiveScripting. This will give you VB, VBScript, Python, JS, Perl, etc ;) You could even implement this *in* Python, but that is unlikely to fit your app (ie, you would then *require* Python) > First step is to make sure that we can > access the "core" C > libraries to retrieve and analyse data then step two will be > to form this > into a plug-in with exports COM interface to VB master application. > > Today: VB Master Application ->COM-> VB plugin ->COM-> COM > wrapper to C DLL > Future: VB Master Application ->COM-> Python plugin ->COM-> > COM wrapper to C > DLL So from the above, I take it you are currently just trying to do the "Python -> COM -> COM wrapper to C DLL" part? The interfaces you need to define are in the "COM" typelib. From above, it sounds like you are saying that there is also a .tlb that goes with the .DLL implementing this "COM" part. I also assume that the part implementing "COM wrapper to C DLL" is yet another DLL, without any COM typeinfo embedded. So even in this little part, we have Python, the COM dll Python calls, a .tlb that goes with this DLL, and a final DLL which the COM object calls. > Eventually we can get this to work we will eliminate the COM > interface to > the C DLL, but we will still need the COM interface back to > the master VB > application. I'm not exactly sure what you mean by that - but note that if you want Python to directly call a C DLL, without COM, you will need the 'ctypes' module for Python. Ditto for VBScript (as opposed to VB) > Given that the wrapper for the DLL is not needed, as a further test, I > deleted files in the gen_py directory and rebuilt the file > using makepy from > the type library only. I can then call create an object from > the progid > thus: > > tnt = win32com.client.Dispatch("TntCore5_0.DataFilePreprocessor") The code above will also work with an empty gen_py directory - and I suspect, will be exactly the same. If you print repr(tnt), you will find it is a "dymanic" COM object - ie, late bound, and not using gen_py. If you try: tnt = win32com.client.gencache.EnsureDispatch(tnt) You should find that something in the gen_py directory is generated. I suspect you will find this is a *different* typelibrary than the TLB you expect it is. As at the top of this mail, the "EnsureDispatch()" will be asking the object at runtime for the type info. > However an attempt to invoke the init method produces: > > tnt.Initialize() > Traceback (most recent call last): > File "", line 1, in ? > File > "E:\Programs\Python22\lib\site-packages\win32com\client\dynamic.py", > line 454, in __getattr__ > raise AttributeError, "%s.%s" % (self._username_, attr) > AttributeError: TntCore5_0.DataFilePreprocessor.Initialize Note the exception references "dynamic.py" - if gen_py was being used, the traceback would reference the gen_py module. > However I notice that the CLSIDToClassMap is empty: I suspect this type library does not define the objects, but only the interfaces. I suspect the object definitions are in the DLL's typelib, and you will find them if you select this DLL, or use the EnsureDispatch() code above. > Is there an issue because there is no CLSIDToPackageMap? Also > I notice that > the Class name is IDataFilePreprocessor. I know that I is for > interface but > am not sure when COM used I interface and when it uses the > method directly. In general, this is all up to the typelib. It looks like we have the interface definitions, but not the CoClasses. Mark. From jsbenson at bensonsystems.com Thu Dec 4 23:25:46 2003 From: jsbenson at bensonsystems.com (John Benson) Date: Thu Dec 4 23:26:05 2003 Subject: [python-win32] how do I copy a Python text string into the Windows clipboard for use in another application? Message-ID: <017301c3bae7$dc1b6360$8f0a500a@jsbwxp3> Hi, I just want to be able to move plain ASCII text out of a Python application to the Windows clipboard. Any idea how I could accomplish that? Thanks in advance for your help. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20031204/d67a8cec/attachment.html From mhammond at skippinet.com.au Fri Dec 5 00:21:18 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri Dec 5 00:21:30 2003 Subject: [python-win32] how do I copy a Python text string into the Windowsclipboard for use in another application? In-Reply-To: <017301c3bae7$dc1b6360$8f0a500a@jsbwxp3> Message-ID: <084001c3baef$9ed0a5d0$2c00a8c0@eden> Something like: import win32clipboard, win32con win32clipboard.OpenClipboard() win32clipboard.SetClipboardData(win32con.CF_TEXT, "hello") win32clipboard.CloseClipboard() Mark. -----Original Message----- From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org]On Behalf Of John Benson Sent: Friday, 5 December 2003 3:26 PM To: python-win32@python.org Subject: [python-win32] how do I copy a Python text string into the Windowsclipboard for use in another application? Hi, I just want to be able to move plain ASCII text out of a Python application to the Windows clipboard. Any idea how I could accomplish that? Thanks in advance for your help. From mhammond at skippinet.com.au Fri Dec 5 00:23:48 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri Dec 5 00:23:58 2003 Subject: [python-win32] reliably controlling IE (Dispatch vs DispatchEx) In-Reply-To: Message-ID: <084101c3baef$f6efda10$2c00a8c0@eden> Dispatch() attempts to do a GetObject() before creating a new one. DispatchEx() just creates a new one. This is almost certainly the reason for the different behaviour, and this won't change from Python's side of the fence. Mark. > -----Original Message----- > From: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org]On Behalf Of Greg Lee > Sent: Friday, 5 December 2003 11:18 AM > To: python-win32@python.org > Subject: [python-win32] reliably controlling IE (Dispatch vs > DispatchEx) > > > I'm using code like this to display text in IE from within a Tkinter > application: > > # magic argument list generated by makepy.py -i > for Microsoft > Internet Controls > > win32com.client.gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7E > B-0000C05BAE0B}', > 0, 1, 1) > self.iexplorer = > win32com.client.DispatchEx('InternetExplorer.Application.1") > self.iexplorer.Visible = 1 > self.iexplorer.Navigate(contents) > win32gui.ShowWindow(self.iexplorer.HWND, 1) # > winuser.h:SW_ > > I'm using DispatchEx rather than the conventional Dispatch > because I've > noticed that if I have a Windows Explorer running and use > Dispatch, then the > contents sometimes appears in the right-hand pane of the > Windows Explorer > rather than in a new instance of InternetExplorer. Using > DispatchEx "seems" > to do the right thing, but I'm reluctant to rely on this as a > fix for an > intermittent problem. Any thoughts from the experts? > > There is a 4 August posting stating that DispatchEx was > necessary when you > want two instances of of IE, as in: > ie1 = > Win32com.client.DispatchEx('InternetExplorer.Application.1') > ie2 = > Win32com.client.DispatchEx('InternetExplorer.Application.1') > > _________________________________________________________________ > Browse styles for all ages, from the latest looks to cozy > weekend wear at > MSN Shopping. And check out the beauty products! http://shopping.msn.com _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From lbates at syscononline.com Fri Dec 5 08:24:43 2003 From: lbates at syscononline.com (Larry Bates) Date: Fri Dec 5 08:24:53 2003 Subject: [python-win32] RE: COM and Makepy when DLL and TLB are separated In-Reply-To: Message-ID: <00c901c3bb33$25a4a820$5d00a8c0@LABWXP> I may be WAY out of line here, but if the .DLL is a normal C .DLL you can call it directly by using the following: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146847 Hope information helps. Larry Bates I checked and the DLL does have its own typelib, however am told that this is a side effect of the build process and is not needed or used. What I am trying to do is use a COM interface built for VB applications to access a C DLL. We are exploring the possibility of allowing the construction of plug-ins to our system in Python instead of VB, which is how they currently are constructed. First step is to make sure that we can access the "core" C libraries to retrieve and analyse data then step two will be to form this into a plug-in with exports COM interface to VB master application. Today: VB Master Application ->COM-> VB plugin ->COM-> COM wrapper to C DLL Future: VB Master Application ->COM-> Python plugin ->COM-> COM wrapper to C DLL Eventually we can get this to work we will eliminate the COM interface to the C DLL, but we will still need the COM interface back to the master VB application. Given that the wrapper for the DLL is not needed, as a further test, I deleted files in the gen_py directory and rebuilt the file using makepy from the type library only. I can then call create an object from the progid thus: tnt = win32com.client.Dispatch("TntCore5_0.DataFilePreprocessor") However an attempt to invoke the init method produces: tnt.Initialize() Traceback (most recent call last): File "", line 1, in ? File "E:\Programs\Python22\lib\site-packages\win32com\client\dynamic.py", line 454, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: TntCore5_0.DataFilePreprocessor.Initialize If I look in the generated gen_py file there is a vtable entry: IDataFilePreprocessor_vtables_ = [ ('Cancel', 1610678272, (), (3, 0, None), ()), ('Cancelled', 1610678273, ((16395,10,None), ), (3, 0, None), ('pRes',)), ('Initialize', 1610678274, (), (3, 0, None), ()), ...... And VTablesToClassMap = { '{082534F5-5424-11D4-A4E0-005004D6E3AF}' : 'IDataFilePreprocessor', ...... VTablesNamesToIIDMap = { 'IDataFilePreprocessor' : '{082534F5-5424-11D4-A4E0-005004D6E3AF}', ...... } However I notice that the CLSIDToClassMap is empty: CLSIDToClassMap = { } CLSIDToPackageMap = {} win32com.client.CLSIDToClass.RegisterCLSIDsFromDict( CLSIDToClassMap ) VTablesToPackageMap = {} Is there an issue because there is no CLSIDToPackageMap? Also I notice that the Class name is IDataFilePreprocessor. I know that I is for interface but am not sure when COM used I interface and when it uses the method directly. I appreciate your help! Regards, - Chris -----Original Message----- From: Mark Hammond [mailto:mhammond@skippinet.com.au] Sent: Thursday, December 04, 2003 3:05 PM To: 'Chris Brandson'; python-win32@python.org Subject: RE: [python-win32] COM and Makepy when DLL and TLB are separated tlb and the dlls should be able to work when they are discrete, and does for most other objects. Even when they are in the same file, it is quite common that the typelib is just a "blob" in the file anyway. makepy just uses LoadRegTypeLib in most cases, but depending on the params you pass, may open using the .tlb name directly. I'm not completely clear on your environment though. It sounds like your DLL *also* has a typelib - if you try and run makepy over a DLL without a typelib it will fail. If your DLL attempting to extend interfaces in the .tlb? If not, why is there type info available in both the .tlb and the .dll? Mark. > -----Original Message----- > From: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org]On Behalf Of Chris Brandson > Sent: Thursday, 4 December 2003 5:50 AM > To: python-win32@python.org > Subject: [python-win32] COM and Makepy when DLL and TLB are separated > > > I need to access an InProc COM interface which was originally > designed for > VB and has a separate type library (".tlb" file) and DLL. An > additional > problem is that some of the arguments are ByRef and are > modified during > invocation. Makepy can generate source files for both the DLL > and typelib. > The typelib has interfaces defined but CLSIDToClassMap is > empty. The DLL has > a CLSIDToClassMap for the classes but no interfaces defined > (they are in > the tlb). I had hoped that win32com.client would combine TLB > and DLL and > allow access, but when I create the top level object from the > ProgID with > Dispatch, none of the properties or methods seen to be found e.g. > "AttributeError: '. name>' object > has no attribute 'Initialize'. Is there documentation > somewhere on what > makepy is actually doing. There is some info in "Python Programming on > Win32", but I haven't been able to map what is there to my > case with a DLL > and TLB. > > Is there something I need to do to link the DLL and TLB or is > the issue > related to the fact that just about every method needs > arguments passed by > reference? > > Any assistance would be greatly appreciated. > > Thanks, > > - Chris > > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 ------------------------------ Message: 5 Date: Thu, 4 Dec 2003 16:51:31 -0800 From: Tyler Mitchell Subject: [python-win32] XML-RPC example - was beginner's question on network programming To: "Mark Hammond" Cc: python-win32@python.org Message-ID: Content-Type: text/plain; charset=US-ASCII Mark, what you didn't say was: "Contribute back you silly goose". I should have thought of that a while ago, thanks for the reminder! I was kinda holding out waiting for someone else to point out a better link or say they've already got it figured already ;) So here's an example of what I've done: Pre-requisites include xmlrpclib and SimpleXMLRPCServer libraries. Let me know if you need a hand finding them. ---------- Here's the server-side script, keeping it in an order usual for tutorial purposes: >>>class MyFuncs: >>> def add(self, x, y): >>> return x + y >>>from SimpleXMLRPCServer import SimpleXMLRPCServer >>>server = SimpleXMLRPCServer((localhost,8000)) >>>server.register_instance(MyFuncs()) # The server will run until you hit Control-C or the like --------- Here's the client-side script to access above said function: >>>from xmlrpclib import Server >>>myserver = Server("http://localhost:8000") >>>print myserver.add(5,6) 11 #Printed results here, but could also pass the object (?) back as well... >>>mytotal = myserver.add(5,6) >>>print mytotal 11 "Mark Hammond" To Sent by: "'Tyler Mitchell'" python-win32-boun ces@python.org cc python-win32@python.org Fax to 12/04/2003 03:12 PM Subject RE: [python-win32] beginner's question on network programming > I should say, I found the documentation of XML-RPC, specifically for > python, to be sketchy and irritating from a new user > perspective. So I > suggest you don't waste your time reading until you've found a good > tutorial. I was barely able to find a good server example of > xml-rpc in > python! If you or others on the list would like, I could > walk you through > my most simple application as a tutorial. As a side note, most of the Python/extensions docs follow this cycle: * Technically smart person writes cool code, and very sketchy docs (generally written for someone just like him/her) * 500 people scratch their head, stumble around, post to mailing lists and manage to put together a vague answer. Many fail. * One of the 500 picks up the ball and contributes real documentation. * The next 500 people trying to use it have a much better life. This is, unfortunately, the current nature of Open Source. As Open Source moves up the food chain, I hope to see that change, but it won't be soon. While it may seem formidable, submitting docs and examples needn't be that hard, and will generally be gratefully accepted. Mark. _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 ------------------------------ Message: 6 Date: Thu, 04 Dec 2003 16:18:18 -0800 From: "Greg Lee" Subject: [python-win32] reliably controlling IE (Dispatch vs DispatchEx) To: python-win32@python.org Message-ID: Content-Type: text/plain; format=flowed I'm using code like this to display text in IE from within a Tkinter application: # magic argument list generated by makepy.py -i for Microsoft Internet Controls win32com.client.gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}', 0, 1, 1) self.iexplorer = win32com.client.DispatchEx('InternetExplorer.Application.1") self.iexplorer.Visible = 1 self.iexplorer.Navigate(contents) win32gui.ShowWindow(self.iexplorer.HWND, 1) # winuser.h:SW_ I'm using DispatchEx rather than the conventional Dispatch because I've noticed that if I have a Windows Explorer running and use Dispatch, then the contents sometimes appears in the right-hand pane of the Windows Explorer rather than in a new instance of InternetExplorer. Using DispatchEx "seems" to do the right thing, but I'm reluctant to rely on this as a fix for an intermittent problem. Any thoughts from the experts? There is a 4 August posting stating that DispatchEx was necessary when you want two instances of of IE, as in: ie1 = Win32com.client.DispatchEx('InternetExplorer.Application.1') ie2 = Win32com.client.DispatchEx('InternetExplorer.Application.1') _________________________________________________________________ Browse styles for all ages, from the latest looks to cozy weekend wear at MSN Shopping. And check out the beauty products! http://shopping.msn.com ------------------------------ Message: 7 Date: Fri, 5 Dec 2003 09:42:36 +0800 From: "Cheeng, Shu-Chin SC SITI-ITDDG12" Subject: [python-win32] RE: Python-win32 Digest, Vol 9, Issue 3 To: Message-ID: <6F825BFCBC2CDA4CB17564B98AF491FC02171B07@cbj-s-340.asia-pac.shell.com> Content-Type: text/plain; charset="iso-8859-1" hi all, Me Too... Python 223+win32all-162 Can't find Gen_py and Import error...once using win32com.client.* Regards, Cheeng Shu Chin SA-Messaging Shell Information Technology International 2340 Century Square, Jalan Usahawan, 63000 Cyberjaya, Selangor D.E., Malaysia Tel: +603-8313 3787 Fax: 3900 Other Tel: +6013 630 1682 Email: shu-chin.cheeng@shell.com Internet: http://www.shell.com -----Original Message----- From: python-win32-request@python.org [mailto:python-win32-request@python.org] Sent: Thursday, December 04, 2003 1:04 AM To: python-win32@python.org Subject: Python-win32 Digest, Vol 9, Issue 3 Send Python-win32 mailing list submissions to python-win32@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@python.org You can reach the person managing the list at python-win32-owner@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. win32com and McMillan Installer do not work together (Thorsten Henninger) ---------------------------------------------------------------------- Message: 1 Date: Tue, 02 Dec 2003 20:22:16 +0100 From: Thorsten Henninger Subject: [python-win32] win32com and McMillan Installer do not work together To: python-win32@python.org Message-ID: <3FCCE668.50108@brainbot.com> Content-Type: text/plain; charset=us-ascii; format=flowed Hi, I do not get the McMillan Installer work together with the latest win32all package. Does anybody have similar problems? regards, Thorsten -- brainbot technologies AG boppstrasse . 64 . 55118 mainz . germany fon +49 6131 211639-1 . fax +49 6131 211639-2 http://brainbot.com/ mailto:henni@brainbot.com ------------------------------ _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 End of Python-win32 Digest, Vol 9, Issue 3 ****************************************** -------------- next part -------------- A non-text attachment was scrubbed... Name: Cheeng, Shu-Chin SC SSI-ISWA2.vcf Type: text/x-vcard Size: 365 bytes Desc: Cheeng, Shu-Chin SC SSI-ISWA2.vcf Url : http://mail.python.org/pipermail/python-win32/attachments/20031205/026523b4/Chee ngShu-ChinSCSSI-ISWA2.vcf ------------------------------ _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 End of Python-win32 Digest, Vol 9, Issue 5 ****************************************** From troydl at ntsp.nec.co.jp Sun Dec 7 06:58:18 2003 From: troydl at ntsp.nec.co.jp (Troy Z. De Leon) Date: Sun Dec 7 06:57:33 2003 Subject: [python-win32] RE: COM and Makepy when DLL and TLB are separated References: <00c901c3bb33$25a4a820$5d00a8c0@LABWXP> Message-ID: <00d701c3bcb9$6813de10$d364a8c0@mnl.ntsp.nec.co.jp> Hello, i'm a newbie and i was reading up on how to embed python in c++ and the manual states that samples exit in the "embed/demo" directory but the installation doesn't seem to have this directory. or any "demo" directory for that matter. can someone please tell me where i cna find these "demo" files =) thanks, troy From troydl at ntsp.nec.co.jp Sun Dec 7 07:23:21 2003 From: troydl at ntsp.nec.co.jp (Troy Z. De Leon) Date: Sun Dec 7 07:22:34 2003 Subject: [python-win32] embed/demo files Message-ID: <011a01c3bcbc$e815c440$d364a8c0@mnl.ntsp.nec.co.jp> > Hello, i'm a newbie and i was reading up on how to embed python in c++ and > the manual states that samples exit in the "embed/demo" directory but the > installation doesn't seem to have this directory. or any "demo" directory > for that matter. > > can someone please tell me where i can find these "demo" files, or are they just availablefrom sourceforge? =) > > thanks, > troy > From Mark.English at liffe.com Mon Dec 8 07:02:34 2003 From: Mark.English at liffe.com (Mark English) Date: Mon Dec 8 07:13:19 2003 Subject: [python-win32] C extension class wrapping and sequence questions Message-ID: Hi, I'm a bit stumped about how to develop this problem, so I'll overburden you with questions and information, and appreciate any answers you may have. We use a networking "Stream" to send and receive "Messages". I want to wrap streams and messages in Python, so that ultimately I can do the following at a prompt: > msgMine = PyMessages.MsgFoo(args_msg) > streamMine = PyStream.Stream(args_stream) > streamMine.Send(msgMine) There are a lot of messages and associated structures, currently implemented in C++. The C++ is actually auto-generated from a proprietary format. There has been an earlier attempt to wrap the messages in Python which works to some extent, although it requires a fairly high-level interface that runs in an executable with Python embedded in it, and is ultimately pretty difficult to use. It's also hand-coded, and therefore error-prone. I'd like to auto-generate my code, and have some experience of Python, and plenty of experience with C++, mostly under Windows. I have very little experience with writing Python C extensions. So here are the questions: 1) How should I aim to construct my code ? Should the bulk of the intelligence lie in the Python code, ultimately resulting in something I can pass to a C-extension "Stream" type which will know how to create the appropriate C++ "Message" and send it off ? This means no access to the underlying C++ implementation of messages which may not be a great loss seeing as how it is autogenerated anyway. On the other hand, it also means no access to all the associated C++ message handling code which IS useful, and not really easily wrapped in its own set of Python classes. Alternatively, I could make the Python "Message" classes thin-wrappers around the C++ code. Each "Message" class would have its own Python type, and the C module would export constructors for the types. This seems reasonably attractive. I could then override "__setattr__()" so that programmers could either write: > msgMine.SetFoo("Bar") OR > msgMine.strFoo = "Bar" and the underlying implementation would call the same code in C++. Because this is autogenerated, I don't mind going this route. 2) How do I handle "Message" instances which contain sequences (especially sequences of auto-generated structures) ? For example, if the "Message" contains an array of "Record" instances, then this is fine: > msgMine.arrayRec[0].strFoo = "Bar" > strSomething = msgMine.arrayRec[0].strFoo because I can return a sequence of thin wrapper objects for "msgMine.arrayRec" from my C module. Similarly this also is fine: > arrayRec = PyRecords.Record(args_record) msgMine.SetArrayRec(index, > arrayRec) since I am accessing the array through the owner "Message". However, I can't see an easy way around this problem: > arrayRec = PyRecords.Record(args_record) #Construct a new record > object msgMine.arrayRec[0] = arrayRec #Put it in the sequence directly If I simply build a sequence of thin wrappers for "msgMine.arrayRec", then setting one of its members is effectively changing a temporary object. I could write my own sequence wrapping object (like a Python class inheriting from "UserList"), perhaps by providing implementations for the sequence type, so that setting an attribute actually calls a method in the owner C++ "Message" object. This seems like hard work for something that would be easy to do in Python. Alternatively, if I go with a Python-centric implementation then code like that above isn't a problem. The message doesn't get converted to its equivalent C++ object until the stream needs to do so. Trying to frame the questions a bit more generally then, when wrapping an existing C++ class hierarchy, how do you choose between thin Python wrappers (which may not leverage all that Python has to offer), and "more Python less C++" (which may leave out some of the C++ functionality). Also, how do C extension types present instances which contain sequences of other instances ? I suspect if you're any good you do it either way you prefer and don't mess anything up, or leave anything out, but for a first-timer this isn't really an option, and I'd like to get some minimal functionality up and about. I'm looking at following the approach used in win32ui where types are factories, and contain enough mapping intelligence to go back and forth between C and python. I should be able to autogenerate the types. This doesn't solve my owner-of-a-sequence problem though, and I'm worried I'll hit other as yet unforeseen problems down the road. Similarly the SWIG implementation seems to make arrays read-only, and you have to write your own code with typemaps if you want to expand on that implementation. Any thoughts, or pointers to modules which solve similar problems ? Thanks for your time and patience, Cheers, mE ----------------------------------------------------------------------- The information contained in this e-mail is confidential and solely for the intended addressee(s). Unauthorised reproduction, disclosure, modification, and/or distribution of this email may be unlawful. If you have received this email in error, please notify the sender immediately and delete it from your system. The views expressed in this message do not necessarily reflect those of LIFFE Holdings Plc or any of its subsidiary companies. ----------------------------------------------------------------------- From jens.jorgensen at tallan.com Mon Dec 8 10:51:26 2003 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Mon Dec 8 10:54:08 2003 Subject: [python-win32] C extension class wrapping and sequence questions In-Reply-To: References: Message-ID: <3FD49DFE.9040501@tallan.com> Mark English wrote: >Hi, >I'm a bit stumped about how to develop this problem, so I'll overburden >you with questions and information, and appreciate any answers you may >have. > >We use a networking "Stream" to send and receive "Messages". >I want to wrap streams and messages in Python, so that ultimately I can >do the following at a prompt: > > > >>msgMine = PyMessages.MsgFoo(args_msg) >>streamMine = PyStream.Stream(args_stream) >>streamMine.Send(msgMine) >> >> > >There are a lot of messages and associated structures, currently >implemented in C++. The C++ is actually auto-generated from a >proprietary format. There has been an earlier attempt to wrap the >messages in Python which works to some extent, although it requires a >fairly high-level interface that runs in an executable with Python >embedded in it, and is ultimately pretty difficult to use. It's also >hand-coded, and therefore error-prone. > >I'd like to auto-generate my code, and have some experience of Python, >and plenty of experience with C++, mostly under Windows. I have very >little experience with writing Python C extensions. > >So here are the questions: >1) How should I aim to construct my code ? Should the bulk of the >intelligence lie in the Python code, ultimately resulting in something I >can pass to a C-extension "Stream" type which will know how to create >the appropriate C++ "Message" and send it off ? This means no access to >the underlying C++ implementation of messages which may not be a great >loss seeing as how it is autogenerated anyway. On the other hand, it >also means no access to all the associated C++ message handling code >which IS useful, and not really easily wrapped in its own set of Python >classes. > > I don't think there's any easy rule. I look at it more this way: I want to end up with a nice Python interface (nice means object that work like you'd want a Python object to work. This rules out SWIG. By the way even though the extension API is C I write *all* of my extensions in C++ including classes, etc. I say if there's useful code in C++ then use it. But consider what you'd like the Python API to look like. Will doing that require a lot code? A lot of people do write a thin wrapper module that's pretty nearly 1-to-1 to the C/C++ interface they're trying to get in Python and then write some python code around that to make things look nice. If you have some system that auto-generates C++ how hard would it be to get that same code to generate a Python extension written in C++? This might be the best solution of all! >Alternatively, I could make the Python "Message" classes thin-wrappers >around the C++ code. Each "Message" class would have its own Python >type, and the C module would export constructors for the types. This >seems reasonably attractive. I could then override "__setattr__()" so >that programmers could either write: > > >>msgMine.SetFoo("Bar") >> >> >OR > > >>msgMine.strFoo = "Bar" >> >> >and the underlying implementation would call the same code in C++. >Because this is autogenerated, I don't mind going this route. > >2) How do I handle "Message" instances which contain sequences >(especially sequences of auto-generated structures) ? For example, if >the "Message" contains an array of "Record" instances, then this is >fine: > > >>msgMine.arrayRec[0].strFoo = "Bar" >>strSomething = msgMine.arrayRec[0].strFoo >> >> >because I can return a sequence of thin wrapper objects for >"msgMine.arrayRec" from my C module. > >Similarly this also is fine: > > >>arrayRec = PyRecords.Record(args_record) msgMine.SetArrayRec(index, >>arrayRec) >> >> >since I am accessing the array through the owner "Message". > >However, I can't see an easy way around this problem: > > >>arrayRec = PyRecords.Record(args_record) #Construct a new record >>object msgMine.arrayRec[0] = arrayRec #Put it in the sequence directly >> >> > >If I simply build a sequence of thin wrappers for "msgMine.arrayRec", >then setting one of its members is effectively changing a temporary >object. I could write my own sequence wrapping object (like a Python >class inheriting from "UserList"), perhaps by providing implementations >for the sequence type, so that setting an attribute actually calls a >method in the owner C++ "Message" object. This seems like hard work for >something that would be easy to do in Python. > > Although I haven't done it myself to date it seems to be straightforward to implement the sequence "api" in a Python object. In practical terms this means your object type structure contains a non-null PySequenceMethods structure containing function pointers that perform the various sequence operations you support. In your case I would imagine that your python Message object would have an attribute arrayRec that would either be another object that would pretty much just implement the sequence operations. That object could keep a pointer to the real message object to handle the insertion and deletion. >Alternatively, if I go with a Python-centric implementation then code >like that above isn't a problem. The message doesn't get converted to >its equivalent C++ object until the stream needs to do so. > >Trying to frame the questions a bit more generally then, when wrapping >an existing C++ class hierarchy, how do you choose between thin Python >wrappers (which may not leverage all that Python has to offer), and >"more Python less C++" (which may leave out some of the C++ >functionality). Also, how do C extension types present instances which >contain sequences of other instances ? > >I suspect if you're any good you do it either way you prefer and don't >mess anything up, or leave anything out, but for a first-timer this >isn't really an option, and I'd like to get some minimal functionality >up and about. > >I'm looking at following the approach used in win32ui where types are >factories, and contain enough mapping intelligence to go back and forth >between C and python. I should be able to autogenerate the types. This >doesn't solve my owner-of-a-sequence problem though, and I'm worried >I'll hit other as yet unforeseen problems down the road. Similarly the >SWIG implementation seems to make arrays read-only, and you have to >write your own code with typemaps if you want to expand on that >implementation. > >Any thoughts, or pointers to modules which solve similar problems ? > > > What you're trying to do can be difficult. I can imagine if you've got a complex object library where the C++ objects are doing lots of stuff together it's going to be tough to figure out where the Python interface figures in. As an overall approach maybe you think of the Python object interface as more or less a view object graph of C++ objects you are manipulating. You create the python objects as needed to provide that view of the objects but still just let the C++ objects works as normally. I can see how problems like what to do when a Python Record object is created from Python as in your above example as compared to when a Record is created within your C++ code in some spot. One might be built with a Python wrapper that's attached to it while the other does not. In that respect then perhaps this idea of the python objects as a view of the underlying objects may work best. Treat the Python objects as transient artifacts whose lifetime may or may not be coincident with the lifetime of the underlying C++ objects. Create them as needed and destroy them as needed. This still leaves some problems with how to handle c++ objects that are only referenced through the Python objects. How do we know when to delete the C++ object? Well, I think I have an idea what your trying to accomplish and unfortunately I haven't tried to tackle something like this these are the best suggestions I can give. -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions." From Mark.English at liffe.com Mon Dec 8 11:44:49 2003 From: Mark.English at liffe.com (Mark English) Date: Mon Dec 8 11:48:49 2003 Subject: [python-win32] RE: C extension class wrapping and sequence questions [Jens] Message-ID: RE: Jens' message I'll bang on about this a bit more... >> If you have some system that auto-generates C++ how hard would it be to >> get that same code to generate a Python extension written in C++? This >> might be the best solution of all! The data part is autogenerated. I want to be able to build that up in Python, then pass the relatively unintelligent structures built in Python to C++ code that can make use of them. I can only autogenerate the message/record structures, but the good news is that they're relatively unintelligent. Just a series of structs with some C++ on top (get/set methods etc.), some containing instances of others. I agree with your analysis, and I'm currently looking into the thin Python wrapper approach, where the Python instances just bolt on top of a C++ pointer (although typically they will own the lifetime of the C++ pointer - at least for now). Much like the CWnd wrappers in win32ui. I thought about using the sequence methods you mentioned, but I'm also looking into using the new subtyping introduced in 2.2. Need to find a tutorial/example for this... Unfortunately this is a side project and the learning curve is a little steep, but it looks like I can subclass the python sequence type, and possibly add some additional processing to get some of the functionality I want. Ultimately, however, the "owned array" or whatever you want to call it may be a flawed (and therefore floored) idea. For example, if the array sets its members by actually calling set methods in the owning message it solves this problem: > rec = PyRecords.Record() > msg = PyMessages.MessageFoo() > msg.arrayRec[2] = rec # Will actually delegate to "msg.SetRec(2, rec)" I should have explained that some messages contain a fixed size array, and an accompanying integer member saying how many elements of the array are being used. E.g. > msg.nRecs = 3 #Set the number of elements in the array being used by this message In other words, the C-code may restrict the array size to a fixed maximum (e.g. 16), but at runtime the user can say they're only using the first 3 elements of the array. Not pretty, but that's what there is. Even further trickery would be required around the issue of ownership if users wanted to do this: > msg2 = PyMessages.MessageFoo() > msg2.arrayRec = msg.arrayRef #Hmmmm This last line would require a deep (sort of) copy of N elements of the array, where N is the known total possible size of the array, or preferably the run-time established number of array elements actually being used. So I'll have to store the length being used (or at least where to look it up) in the array wrapping class (in some cases). The auto-generating parser knows where to look all this up, but it gets more complex and unwieldy. All I really wanted to show with all this is that the more I try to introduce indirection and issues of ownership into a pseudo-sequence class, the harder things become. The sort of thing that would be more easily solved in Python than C I suspect... Cheers, mE P.S. I do appreciate the feedback though. It's an interesting problem for a newbie like me ----------------------------------------------------------------------- The information contained in this e-mail is confidential and solely for the intended addressee(s). Unauthorised reproduction, disclosure, modification, and/or distribution of this email may be unlawful. If you have received this email in error, please notify the sender immediately and delete it from your system. The views expressed in this message do not necessarily reflect those of LIFFE Holdings Plc or any of its subsidiary companies. ----------------------------------------------------------------------- From Andrew.MacIntyre at aba.gov.au Mon Dec 8 19:32:51 2003 From: Andrew.MacIntyre at aba.gov.au (Andrew MacIntyre) Date: Mon Dec 8 19:37:09 2003 Subject: [python-win32] C extension class wrapping and sequence questi ons Message-ID: > From: Mark English > Sent: Monday, 8 December 2003 11:03 PM > Subject: [python-win32] C extension class wrapping and sequence > questions {...} > There are a lot of messages and associated structures, currently > implemented in C++. The C++ is actually auto-generated from a > proprietary format. There has been an earlier attempt to wrap the > messages in Python which works to some extent, although it requires a > fairly high-level interface that runs in an executable with Python > embedded in it, and is ultimately pretty difficult to use. It's also > hand-coded, and therefore error-prone. > > I'd like to auto-generate my code, and have some experience of Python, > and plenty of experience with C++, mostly under Windows. I have very > little experience with writing Python C extensions. {...} Given the depth of C++ involved, have you looked at Boost.Python? (http://www.boost.org/) ----------------------------------------------------------------------- Andrew MacIntyre \ E-mail: andrew.macintyre@aba.gov.au Planning & Licensing Branch \ Tel: +61 2 6256 2812 Australian Broadcasting Authority \ Fax: +61 2 6253 3277 -> "These thoughts are mine alone!" <---------------------------------- From henni at brainbot.com Tue Dec 9 05:04:19 2003 From: henni at brainbot.com (Thorsten Henninger) Date: Tue Dec 9 05:10:52 2003 Subject: [python-win32] Recipe for using McMillan Installer and win32all.win32com Message-ID: <3FD59E23.8060403@brainbot.com> Hi all, I ran into problems using the McMillan Installer (5b5) together with the latest win32com (win32all package 163). The problem is, that the McMillan Installer overwrites Python's import method. But win32com does some fancy stuff using Python's import to automatically generate Python-modules while accessing COM-Objects such as Outllook. Well, thanks to Ralf Schmitt, who helped me out finding a solution. First, we had to save the "old" import method from Python in McMillan's iu.py module, before the import hook is assigned, for example: __builtins__.__oldimport__ = __builtins__.__import__ To build a working Windows excetutable, one has to include the attached Python-module (comhack) and call set_gen_path(path) at the beginning of the application, where path specifies the Path, where the win32com module generates Python modules for COM-Obejevts. Is it possible, that this solution will be integrated into the next version of the win32com-package? regards, Thorsten -- brainbot technologies AG boppstrasse . 64 . 55118 mainz . germany fon +49 6131 211639-1 . fax +49 6131 211639-2 http://brainbot.com/ mailto:henni@brainbot.com -------------- next part -------------- #! /usr/bin/env python """ [$Id: comhack.py,v 1.2 2003/12/08 19:36:16 henni Exp $] Use this in confuction with McMillan-Installer, if you need COM-Support in your application. McMillan Installer as well as PythonCOM do overwrite the import Method for their needs. _myimport advises the imports to either PythonCOM-Import or McMillan Import. set_gen_path: use this method to specify the gencache-path, where all Python-COMObjects will be automatically generated in. One needs to Patch the McMillan Installer such that the Python-nativ import has to be saved as __oldimport__ Use this hack in your application with import comhack set_gen_path(mypath) Then everything will work ... """ import sys import __builtin__ #save the import-Method (either McMillan's import or Python's) mcimport = __builtin__.__import__ def _myimport(name, globals=None, locals=None, fromlist=None): """ Tell all modules to imported by McMillan's (or Python's) import.method, besides win32com modules automatically genrated by win32com.gencache """ try: #fails with ImportError, if McMillan has overwritten Python's native import #and win32com.gen_py tries to generate a module return mcimport(name, globals, locals, fromlist) except ImportError, err: if name.startswith('win32com.gen_py'): #this is the Python-Native Import Method, if a patched McMillan-Installer exists return __oldimport__(name, globals, locals, fromlist) else: #win32com needs this ImportError raise err def set_gen_path(path): """ Set the gencache Path If not set, all Modules (win32com) will be generated to support/gen_py of your apllication. """ import os import win32com import win32com.gen_py path = os.path.abspath(path) if not os.path.exists(path): os.makedirs(path) #check, if McMillan runs ... frozen = sys.__dict__.get("frozen", 0) #set the gencache path win32com.gen_py.__path__ = [path] win32com.__gen_path__ = path if not frozen: return #setup our import method, if McMillan runs. __builtin__.__import__ = _myimport From vincent.rioux at no-log.org Tue Dec 9 05:40:45 2003 From: vincent.rioux at no-log.org (Vincent Rioux) Date: Tue Dec 9 05:40:41 2003 Subject: [python-win32] help : dnd win32<->Tkinter ? Message-ID: <6.0.1.1.2.20031209113709.01cd0398@pop.no-log.org> Dear all, Is it possible to track down a drag and drop action from windows explorer to a Tkinter window and vice-versa? /vr From hugu at sify.com Tue Dec 9 01:03:52 2003 From: hugu at sify.com (shanmukha) Date: Tue Dec 9 09:57:42 2003 Subject: [python-win32] wrapper for MSAA Message-ID: <1070951632.3fd56cd0c72ac@webmail1.maa.sify.net> hi!! my task is to develop a wrapper to the MSAA using python. for this i'm developing a module. the class design is: class Wrapper: class Application: class Window: class PushButton: class EditBox: in my main module i create an object for the Wrapper class and when i say: wrapper.Application, it should enable me to access the application.. similarly if i say, wrapper.PushButton, it should enable me to access the pushbutton... in other words its a generic class tht gives me the respective handlers. i inherit this class and user for specific purposes. thank u. sha. ------------------------------------------------- Click here to find your dream partner! Know more at http://www.bharatmatrimony.com/partner/sify.html Sify Power mail- a Premium Service from Sify Mail! know more at http://mail.sify.com From paul_rudin at scientia.com Tue Dec 9 12:13:57 2003 From: paul_rudin at scientia.com (Paul Rudin) Date: Tue Dec 9 12:20:50 2003 Subject: [python-win32] com wrapper problem Message-ID: I posted this stuff to comp.lang.python, sombody suggested this was a better forum for this: >>>>> "Paul" == Paul Rudin writes: >> I'm having a problem with the python wrappers generated from a >> type library. >> The symptom is that I get failures to find connections points >> inside the wrappers when called from DispatchWithEvents or >> WithEvents - e.g. "com_error: (-2147220992, >> 'CONNECT_E_NOCONNECTION', None, None)" >> It seems that the coclass_clsid property of some classes is >> incorrect. It seems that when a coclass in the type library has >> multiple "[source] dispinterface" it can happen that this >> coclass can end up as the one referenced by each of the >> corresponding DispatchBaseClass subclasses via the >> coclass_clsid property, whereas probably what should happen is >> that only ones that are default should be so treated. >> But maybe I'm misdiagnosing the problem; has anyone else seen >> this and/or know what the problem is? > To test this I had a quick look at the code that generates the > wrappers. In win32com/client/genpy.py The class Generator has a > method _Build_CoClassChildren. Replacing the line: > dispItem.coclass_clsid = coclass.clsid > with the lines: > if flags & pythoncom.IMPLTYPEFLAG_FDEFAULT: > dispItem.coclass_clsid = coclass.clsid > seems to solve the problem, although perhaps this breaks > something else? From jens.jorgensen at tallan.com Tue Dec 9 15:55:30 2003 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Tue Dec 9 15:58:15 2003 Subject: [python-win32] RE: C extension class wrapping and sequence questions [Jens] In-Reply-To: References: Message-ID: <3FD636C2.60805@tallan.com> Sounds like your approach will make the most sense right now. For a first go at building a python wrapper extension you definitely chose an involved one! The stuff I've done has all followed the model where the Python object owns the underlying struct (and they've all been pretty simple no-logic structs). However when the library your working with already has a model where C++ objects own subordinate objects and control their lifetimes things get significantly more complicated as you've surmised. To make things really work correctly you almost need a kind of bi-directional relationship where the C++ objects can own the objects they contain but when destroy objects they may need to twiddle some Python wrapper construct. class HybridContainer { public: std::vector a_shapes; std::vector b_shapes; void empty() { /* delete each object in a_shapes, b_shapes and empty the collections */ } }; So in the above class when empty() is called it is possible that we've got a Python wrapper object around one of the ShapeAs or ShapeBs that still has a reference. This would be a big problem! There are lots of different solutions some more or less intrusive on the C++ code. Certainly an interesting set of problems. Mark English wrote: >RE: Jens' message >I'll bang on about this a bit more... > > >>>If you have some system that auto-generates C++ how hard would it be >>> >>> >to > > >>>get that same code to generate a Python extension written in C++? >>> >>> >This > > >>>might be the best solution of all! >>> >>> >The data part is autogenerated. I want to be able to build that up in >Python, then pass the relatively unintelligent structures built in >Python to C++ code that can make use of them. I can only autogenerate >the message/record structures, but the good news is that they're >relatively unintelligent. Just a series of structs with some C++ on top >(get/set methods etc.), some containing instances of others. > >I agree with your analysis, and I'm currently looking into the thin >Python wrapper approach, where the Python instances just bolt on top of >a C++ pointer (although typically they will own the lifetime of the C++ >pointer - at least for now). Much like the CWnd wrappers in win32ui. >I thought about using the sequence methods you mentioned, but I'm also >looking into using the new subtyping introduced in 2.2. Need to find a >tutorial/example for this... > >Unfortunately this is a side project and the learning curve is a little >steep, but it looks like I can subclass the python sequence type, and >possibly add some additional processing to get some of the functionality >I want. > >Ultimately, however, the "owned array" or whatever you want to call it >may be a flawed (and therefore floored) idea. For example, if the array >sets its members by actually calling set methods in the owning message >it solves this problem: > > >>rec = PyRecords.Record() >>msg = PyMessages.MessageFoo() >>msg.arrayRec[2] = rec # Will actually delegate to "msg.SetRec(2, rec)" >> >> > >I should have explained that some messages contain a fixed size array, >and an accompanying integer member saying how many elements of the array >are being used. E.g. > > >>msg.nRecs = 3 #Set the number of elements in the array being used by >> >> >this message > >In other words, the C-code may restrict the array size to a fixed >maximum (e.g. 16), but at runtime the user can say they're only using >the first 3 elements of the array. Not pretty, but that's what there is. >Even further trickery would be required around the issue of ownership if >users wanted to do this: > > >>msg2 = PyMessages.MessageFoo() >>msg2.arrayRec = msg.arrayRef #Hmmmm >> >> > >This last line would require a deep (sort of) copy of N elements of the >array, where N is the known total possible size of the array, or >preferably the run-time established number of array elements actually >being used. So I'll have to store the length being used (or at least >where to look it up) in the array wrapping class (in some cases). The >auto-generating parser knows where to look all this up, but it gets more >complex and unwieldy. > >All I really wanted to show with all this is that the more I try to >introduce indirection and issues of ownership into a pseudo-sequence >class, the harder things become. The sort of thing that would be more >easily solved in Python than C I suspect... > >Cheers, >mE > >P.S. I do appreciate the feedback though. It's an interesting problem >for a newbie like me > > >----------------------------------------------------------------------- >The information contained in this e-mail is confidential and solely >for the intended addressee(s). Unauthorised reproduction, disclosure, >modification, and/or distribution of this email may be unlawful. If you >have received this email in error, please notify the sender immediately >and delete it from your system. The views expressed in this message >do not necessarily reflect those of LIFFE Holdings Plc or any of its subsidiary companies. >----------------------------------------------------------------------- > > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions." From a_bogdan_marinescu at yahoo.com Thu Dec 11 03:26:52 2003 From: a_bogdan_marinescu at yahoo.com (Bogdan Marinescu) Date: Thu Dec 11 03:26:57 2003 Subject: [python-win32] Looking for ELF/PE library for Python Message-ID: <20031211082652.14128.qmail@web21205.mail.yahoo.com> Hello, Is there a Python library for working with ELF and/or PE(Portable Executable) formats? By "working" I mean handling file structure, dumping structure information, extracting specific parts of the file and even creating "by hand" new sections/relocations. I already searched some locations for such a library, but I couldn't find anything suitable. Thank you for your time. Bogdan M. __________________________________ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ From keith at kmcomputers.co.uk Thu Dec 11 17:13:15 2003 From: keith at kmcomputers.co.uk (Keith Hickling) Date: Thu Dec 11 17:31:04 2003 Subject: [python-win32] COM Message-ID: <000a01c3c033$f9d3ac90$192aa8c0@Zoo.local> Heeeeeellllp I have created a com server in Python. I can access it via Visual basic and it works. If I make changes to the python server dsepite unregistering and re-registering the server Visual basic cannot see the changes. I have tested the new server via Python and the changes are registered. I have removed the .pyc created by the module and recompiled vut Visual Basic absolutly refuses to see the changes. I have unregistered rebooted and re registered but still can find no way to force Visual basic to accept the changes. Where is the copy or the code that Visual Basic is seeing. How do I implement the changes. Yours desparatley. Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20031211/168a4bf4/attachment.html From forestiero at qwest.net Thu Dec 11 19:10:34 2003 From: forestiero at qwest.net (DogWalker) Date: Thu Dec 11 19:13:20 2003 Subject: [python-win32] COM References: <000a01c3c033$f9d3ac90$192aa8c0@Zoo.local> Message-ID: <00cc01c3c044$62868cc0$b49b0043@presario> When running from the Visual Basic IDE, it is necessary to completely exit Visual Basic in order to get a new version of a COM server. VB does not create a separate process to run your application from the IDE. Windows keeps the version of the COM server that you invoked until all processes which have invoked it are terminated. Therefore you must terminate the instance of VB that was running the COM server. ----- Original Message ----- From: Keith Hickling To: python-win32@python.org Sent: Thursday, December 11, 2003 2:13 PM Subject: [python-win32] COM Heeeeeellllp I have created a com server in Python. I can access it via Visual basic and it works. If I make changes to the python server dsepite unregistering and re-registering the server Visual basic cannot see the changes. I have tested the new server via Python and the changes are registered. I have removed the .pyc created by the module and recompiled vut Visual Basic absolutly refuses to see the changes. I have unregistered rebooted and re registered but still can find no way to force Visual basic to accept the changes. Where is the copy or the code that Visual Basic is seeing. How do I implement the changes. Yours desparatley. Martin ------------------------------------------------------------------------------ _______________________________________________ Python-win32 mailing list Python-win32@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/20031211/aeb6d5c6/attachment.html From martin at datactics.co.uk Fri Dec 12 14:24:29 2003 From: martin at datactics.co.uk (Martin Beckett) Date: Fri Dec 12 14:40:34 2003 Subject: [python-win32] win32pdhutil Processor Time always returns 99 Message-ID: I am trying to get the % CPU load in python on win32 win32pdhutil.GetPerformanceAttributes("Processor(_Total)","% Processor Time") only ever returns 99 whatever the machine load ? Running on Windows XP-pro + ActivePython 2.3.2 Build 231 Any ideas ? From forestiero at qwest.net Fri Dec 12 18:14:24 2003 From: forestiero at qwest.net (Win95 Dog Walker) Date: Fri Dec 12 18:14:30 2003 Subject: [python-win32] COM References: <000a01c3c033$f9d3ac90$192aa8c0@Zoo.local> <00cc01c3c044$62868cc0$b49b0043@presario> <000801c3c0e3$968147f0$192aa8c0@Zoo.local> Message-ID: <000c01c3c105$b0327580$f49b0043@DISDNS> I don't believe it is necessary to either Unregister nor Register your COM server because you've changed its code: only if you move it to a different location or change the GUID or it becomes unsimple (supplies different|new objects). If you don't need the Visual Basic IDE during testing, you could just make an executable and then run that. Or you could run it from VC6. And I believe there is a utility program, in the VC6 Tools, designed for testing COM components (but it may want a type library). HTH ----- Original Message ----- From: Keith Hickling To: DogWalker Sent: Friday, December 12, 2003 11:10 AM Subject: Re: [python-win32] COM Thanks very very much. I had been tearing my hair out for two days trying to figure what was happening. Its a bit of bind having to close VB each time a change is made but I supose most of the testing can be done in the Python scripts. Do I have to unregister each time or can I just re-register the changes over the top. Martin ----- Original Message ----- From: DogWalker To: Keith Hickling ; python-win32@python.org Sent: Friday, December 12, 2003 12:10 AM Subject: Re: [python-win32] COM When running from the Visual Basic IDE, it is necessary to completely exit Visual Basic in order to get a new version of a COM server. VB does not create a separate process to run your application from the IDE. Windows keeps the version of the COM server that you invoked until all processes which have invoked it are terminated. Therefore you must terminate the instance of VB that was running the COM server. ----- Original Message ----- From: Keith Hickling To: python-win32@python.org Sent: Thursday, December 11, 2003 2:13 PM Subject: [python-win32] COM Heeeeeellllp I have created a com server in Python. I can access it via Visual basic and it works. If I make changes to the python server dsepite unregistering and re-registering the server Visual basic cannot see the changes. I have tested the new server via Python and the changes are registered. I have removed the .pyc created by the module and recompiled vut Visual Basic absolutly refuses to see the changes. I have unregistered rebooted and re registered but still can find no way to force Visual basic to accept the changes. Where is the copy or the code that Visual Basic is seeing. How do I implement the changes. Yours desparatley. Martin _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From python-forums at claytonbrown.net Fri Dec 12 20:15:38 2003 From: python-forums at claytonbrown.net (python-forums@claytonbrown.net) Date: Fri Dec 12 22:57:05 2003 Subject: [python-win32] Hello World Problem :: Apache/2.0.48 (Win32) mod_python/3.0.4 Python/2.3 Message-ID: <000001c3c116$9eaaf0b0$3d00000a@ab1tch> Hi I am trying to teach myself a bit of mod_python + apache2.0 as I've not worked with either as yet However the 'hello world' is not exactly what I was hoping for In the example: http://www.modpython.org/live/current/doc-html/inst-testing.html Can anyone point me in the right direction, as far as I can see it all looks good, apache starts without any errors was config and install is all OK, the "Apache/2.0.48 (Win32) mod_python/3.0.4 Python/2.3 Server at localhost Port 8080" footer kinda implies everything is groovy, however it's not really doing the hello world part... Could it be absolute paths need to be specified && perhps in local OS form in the ?? Therefore the request is not being handed to mod_python as not a directory configured for this behaviour? Further detail: httpd.conf: ------------------------------------------------------------------------ ------------ Added: LoadModule python_module modules/mod_python.so Changed: # # Options FollowSymLinks # AllowOverride None # To: #CB :: Test MOD-ython-Directive AddHandler python-program .py PythonHandler mptest PythonDebug On Mptest.py ---------------- from mod_python import apache def handler(req): req.write("Hello World!") return apache.OK OUTPUT: (http://localhost:8080/test/) ------------------------------------------------------------------------ ------------ Index of /test Name Last modified Size Description Parent Directory - mptest.py 13-Dec-2003 00:48 103 Apache/2.0.48 (Win32) mod_python/3.0.4 Python/2.3 Server at localhost Port 8080 From keith at kmcomputers.co.uk Sat Dec 13 19:37:50 2003 From: keith at kmcomputers.co.uk (Keith Hickling) Date: Sun Dec 14 01:00:08 2003 Subject: [python-win32] Com Message-ID: <000a01c3c1da$816be8f0$192aa8c0@Zoo.local> Hi, I am struggling to pass variables to a Python com server. If I call the Python class with say PyList = ComServer.taxcalc(500, 0, 0, 0, 0, "461L", "W", 1) this works fine and ptyhon will send back the answer as a 3 part list which I can read in VB As soon as I try to pass the same list but built from text boxes as in PyList = ComServer.taxcalc(Val(txtWage), Val(txtTotalWage), Val(txtP45Wage), Val(txtTotalTax), Val(txtP45Tax), txtTaxCode, txtTaxPeriod, Val(txtWeekNumber)) Python throws an error 'invalid lieral for int()' I have tried to pass the list as a variant list PyList = ComServer.taxcalc(MyList) but I get the same error If I short circuit the function and return the list I can read all the original values. something is happening with the ptyhon function probably to do with '461L'. I dont understand why I can pass the variables as in the first example but not the second. Any ideas. Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20031214/dba7ff71/attachment.html From forestiero at qwest.net Sun Dec 14 01:22:14 2003 From: forestiero at qwest.net (DogWalker) Date: Sun Dec 14 01:22:52 2003 Subject: [python-win32] Com References: <000a01c3c1da$816be8f0$192aa8c0@Zoo.local> Message-ID: <00d601c3c20a$9f23f060$0b9a0043@presario> You should try CInt(Val(txtWage)), etc. "Val" apparently returns a Double. ----- Original Message ----- From: Keith Hickling To: python-win32@python.org Sent: Saturday, December 13, 2003 4:37 PM Subject: [python-win32] Com Hi, I am struggling to pass variables to a Python com server. If I call the Python class with say PyList = ComServer.taxcalc(500, 0, 0, 0, 0, "461L", "W", 1) this works fine and ptyhon will send back the answer as a 3 part list which I can read in VB As soon as I try to pass the same list but built from text boxes as in PyList = ComServer.taxcalc(Val(txtWage), Val(txtTotalWage), Val(txtP45Wage), Val(txtTotalTax), Val(txtP45Tax), txtTaxCode, txtTaxPeriod, Val(txtWeekNumber)) Python throws an error 'invalid lieral for int()' I have tried to pass the list as a variant list PyList = ComServer.taxcalc(MyList) but I get the same error If I short circuit the function and return the list I can read all the original values. something is happening with the ptyhon function probably to do with '461L'. I dont understand why I can pass the variables as in the first example but not the second. Any ideas. Martin ------------------------------------------------------------------------------ _______________________________________________ Python-win32 mailing list Python-win32@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/20031213/89b01be1/attachment.html From ugly_411 at sympatico.ca Sun Dec 14 11:36:50 2003 From: ugly_411 at sympatico.ca (Wes) Date: Sun Dec 14 11:33:53 2003 Subject: [python-win32] Quickcam access in windows 98+ Message-ID: <001201c3c260$795701a0$b1b3fea9@o0j9l8> Hey guys. I am wishing to write up a package to control the logitech quickcam and other "webcams" via windows python. This job is for some astronomers. We have used the decent VideoCapture module (Thanks Markus), but with minimal success. Basically I need to directly access individual settings via a command ie resolution, colour, exposure and so on. SO my question is this. Does anyone have an idea as to how to do this? I have been interested in the microsoft visual SDK which is supposedly setup for something like this. Does anyone have any experience with that? Thanks! Wes -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20031214/bbd72a7e/attachment.html From tim.golden at viacom-outdoor.co.uk Mon Dec 15 04:39:49 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon Dec 15 04:47:16 2003 Subject: [python-win32] win32pdhutil Processor Time always returns 99 Message-ID: >-----Original Message----- >From: Martin Beckett [mailto:martin@datactics.co.uk] >Sent: 12 December 2003 19:24 >To: python-win32@python.org >Subject: [python-win32] win32pdhutil Processor Time always returns 99 > > >I am trying to get the % CPU load in python on win32 > >win32pdhutil.GetPerformanceAttributes("Processor(_Total)","% Processor >Time") >only ever returns 99 whatever the machine load ? > >Running on Windows XP-pro + ActivePython 2.3.2 Build 231 > > Any ideas ? Nothing that directly answers your question: running the same code on my Win2K machine gives the same result, but I have close to no knowledge on Win32 performance counters. However, can I can offer the following ray of hope? The following code works for me: import wmi import time c = wmi.WMI () while 1: for p in c.Win32_Processor (): print "%s running at %d%% load" % (p.Name, p.LoadPercentage) time.sleep (5) Obviously, I don't know if what else you're doing relies specifically on the Performance Counters, in which case this isn't such a useful example. Some of them are available via WMI, but I don't know if they all are. HTH TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From tim.golden at viacom-outdoor.co.uk Mon Dec 15 11:19:01 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon Dec 15 11:26:23 2003 Subject: [python-win32] win32pdhutil Processor Time always returns 99 Message-ID: >-----Original Message----- >From: Paul Weimer [mailto:Paul.Weimer@harlandfs.com] >Sent: 15 December 2003 16:00 >To: 'Tim Golden'; 'Martin Beckett' >Cc: 'python-win32@python.org' >Subject: RE: [python-win32] win32pdhutil Processor Time always returns >99 > > >Hi >Is there a way to use WMI (or something else) to track memory >use? I can't >see a property that would do it but I could be missing something. > >Thanks >Paul I don't claim to be an expert on all things WMI; in cases like this, I tend to go Googling because -- nearly always -- someone, somewhere's done it before. Depends a bit on what you mean. The Win32_OperatingSystem object has several attributes which might help (FreePhysicalMemory, FreeVirtualMemory, TotalVirtualMemorySize and so on) but they'd probably need interpreting. MSDN has a reference set of all the classes and attributes which is worth perusing: http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_classes.asp TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From theller at python.net Mon Dec 15 11:34:08 2003 From: theller at python.net (Thomas Heller) Date: Mon Dec 15 11:34:15 2003 Subject: [python-win32] Re: win32pdhutil Processor Time always returns 99 References: Message-ID: >>Is there a way to use WMI (or something else) to track memory use? I >>can't see a property that would do it but I could be missing >>something. >> >>Thanks >>Paul Here's a code snippet I cut off a small script I have, it uses ctypes to print the changes in the process memory usage over time: """ from ctypes import * class _PROCESS_MEMORY_COUNTERS(Structure): _fields_ = [("cb", c_long), ("PageFaultCount", c_long), ("PeakWorkingSetSize", c_long), ("WorkingSetSize", c_long), ("QuotaPeakPagedPoolUsage", c_long), ("QuotaPagedPoolUsage", c_long), ("QuotaPeakNonPagedPoolUsage", c_long), ("QuotaNonPagedPoolUsage", c_long), ("PagefileUsage", c_long), ("PeakPagefileUsage", c_long)] def __init__(self, *args, **kw): super(_PROCESS_MEMORY_COUNTERS, self).__init__(*args, **kw) self.cb = sizeof(self) lastPagefileUsage = 0 def mem_counters(): counters = _PROCESS_MEMORY_COUNTERS() handle = windll.kernel32.GetCurrentProcess() if 0 == windll.psapi.GetProcessMemoryInfo(handle, byref(counters), sizeof(counters)): print FormatError() global lastPagefileUsage print "delta mem [kB]", (counters.PagefileUsage - lastPagefileUsage) / 1024. print "delta mem [B]", (counters.PagefileUsage - lastPagefileUsage) lastPagefileUsage = counters.PagefileUsage """ Thomas From Paul.Weimer at harlandfs.com Mon Dec 15 11:00:15 2003 From: Paul.Weimer at harlandfs.com (Paul Weimer) Date: Mon Dec 15 12:33:51 2003 Subject: [python-win32] win32pdhutil Processor Time always returns 99 Message-ID: <342DB6B3FE8BD5119D0F0090273C23649C543A@ex_portland1.harlandfs.com> Hi Is there a way to use WMI (or something else) to track memory use? I can't see a property that would do it but I could be missing something. Thanks Paul -----Original Message----- From: Tim Golden [mailto:tim.golden@viacom-outdoor.co.uk] Sent: Monday, December 15, 2003 1:40 AM To: 'Martin Beckett' Cc: 'python-win32@python.org' Subject: RE: [python-win32] win32pdhutil Processor Time always returns 99 >-----Original Message----- >From: Martin Beckett [mailto:martin@datactics.co.uk] >Sent: 12 December 2003 19:24 >To: python-win32@python.org >Subject: [python-win32] win32pdhutil Processor Time always returns 99 > > >I am trying to get the % CPU load in python on win32 > >win32pdhutil.GetPerformanceAttributes("Processor(_Total)","% Processor >Time") >only ever returns 99 whatever the machine load ? > >Running on Windows XP-pro + ActivePython 2.3.2 Build 231 > > Any ideas ? Nothing that directly answers your question: running the same code on my Win2K machine gives the same result, but I have close to no knowledge on Win32 performance counters. However, can I can offer the following ray of hope? The following code works for me: import wmi import time c = wmi.WMI () while 1: for p in c.Win32_Processor (): print "%s running at %d%% load" % (p.Name, p.LoadPercentage) time.sleep (5) Obviously, I don't know if what else you're doing relies specifically on the Performance Counters, in which case this isn't such a useful example. Some of them are available via WMI, but I don't know if they all are. HTH TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From Richard.Martin at thomson.net Mon Dec 15 13:11:53 2003 From: Richard.Martin at thomson.net (Martin Richard) Date: Mon Dec 15 13:12:34 2003 Subject: [python-win32] win32pdhutil Processor Time always returns 99 Message-ID: <3531F1FE12C5B4489D2014F59B4669130F7C8B@bvtnsmail01.am.thmulti.com> I found a solution by searching the archives. Here some code cut out of some other performance collecting code I put together. Rick import os import time import win32pdh import win32pdhquery import win32pdhutil class HostCPU: # def __init__(self): path = win32pdh.MakeCounterPath((None,"Processor","_Total", None, -1, "% Processor Time")) self.base = win32pdh.OpenQuery() self.counter = win32pdh.AddCounter(self.base, path) self.reset() # def reset(self): ''' Need to do this to initialize first data point. The win32 internals will calculate the CPU usage that occurs between a reset and getUsage or between successive getUsage calls. ''' win32pdh.CollectQueryData(self.base) # def getUsage(self): ''' see HostCPU.reset.__doc_ ''' win32pdh.CollectQueryData(self.base) # Get the formatted value of the counter return win32pdh.GetFormattedCounterValue(self.counter, win32pdh.PDH_FMT_LONG)[1] -----Original Message----- From: Martin Beckett [mailto:martin@datactics.co.uk] Sent: Friday, December 12, 2003 11:24 AM To: python-win32@python.org Subject: [python-win32] win32pdhutil Processor Time always returns 99 I am trying to get the % CPU load in python on win32 win32pdhutil.GetPerformanceAttributes("Processor(_Total)","% Processor Time") only ever returns 99 whatever the machine load ? Running on Windows XP-pro + ActivePython 2.3.2 Build 231 Any ideas ? _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From harry_chillboy at rediffmail.com Tue Dec 16 04:51:06 2003 From: harry_chillboy at rediffmail.com (Harry) Date: Tue Dec 16 10:02:09 2003 Subject: [python-win32] How to access MFC objects CString, CMap in Python Message-ID: <20031216095106.16146.qmail@webmail36.rediffmail.com> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20031216/7cb48e8c/attachment.html -------------- next part -------------- Hi All, In my project I am facing one difficulty while accessing MFC objects in Python. I am working on integrating two dlls which expose their functionalities by set of C APIs. Some of the APIs returns MFC object like CString, CMap. How can I access these objects in python. I tried to use SWIG to generate wrapper for those classes but Swig reports parsing errors. Could you please give me any direction.. Thank you, Harish From TMitchell at lignum.com Tue Dec 16 11:58:54 2003 From: TMitchell at lignum.com (Tyler Mitchell) Date: Tue Dec 16 11:59:05 2003 Subject: [python-win32] Re: XML-RPC example - was beginner's question on network programming In-Reply-To: Message-ID: For those of you who may have tried out my earlier example...sorry. It's ripe with errors! Here's some fixes and a better summary examples without (as many?) problems. I'd love to know if you try it out at all. Tyler --------------- Here's the errors..... > >>>from SimpleXMLRPCServer import SimpleXMLRPCServer > >>>server = SimpleXMLRPCServer((localhost,8000)) Host should be quoted: >>>server = SimpleXMLRPCServer(("localhost",8000)) > >>>server.register_instance(MyFuncs()) > # The server will run until you hit Control-C or the like No it wont, my comment is a lie - in fact the server won't run at all! I didn't issue the final command: >>>server.serve_forever() And on some platforms, Control-C won't kill. I.e. on Windows you must use Control-Pause (aka Break). So to clarify, the following is the full example including above comments/fixes: ------------------------------------- Here's the server-side script, not it makes the functions in a class called MyFuncs available. MyFuncs must already exist. >>>from SimpleXMLRPCServer import SimpleXMLRPCServer >>>server = SimpleXMLRPCServer(("localhost",8000)) >>>server.register_instance(MyFuncs()) >>>server.serve_forever() Here's the client-side script to access above said function: >>>from xmlrpclib import Server >>>myserver = Server("http://localhost:8000") >>>print myserver.add(5,6) 11 #Printed results here, but could also pass the object (?) back as well... >>>mytotal = myserver.add(5,6) >>>print mytotal 11 From tim.golden at viacom-outdoor.co.uk Tue Dec 16 12:15:23 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue Dec 16 12:22:50 2003 Subject: [python-win32] Re: XML-RPC example - was beginner's question on network programming Message-ID: >-----Original Message----- >From: Tyler Mitchell [mailto:TMitchell@lignum.com] >Sent: 16 December 2003 16:59 >To: python-win32@python.org >Subject: [python-win32] Re: XML-RPC example - was beginner's >question on >network programming > > > > > > > >For those of you who may have tried out my earlier >example...sorry. It's >ripe with errors! >Here's some fixes and a better summary examples without (as many?) >problems. I'd love to know if you try it out at all. Works fine for me. Thanks. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From ugly_411 at sympatico.ca Tue Dec 16 17:40:21 2003 From: ugly_411 at sympatico.ca (Wes) Date: Tue Dec 16 17:37:20 2003 Subject: [python-win32] Video for windows Message-ID: <000801c3c425$968c0a60$bc06fea9@o0j9l8> Has anyone come up with an implimentation of video for windows in python? THanks Wes -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20031216/37050a28/attachment.html From myddrin at myddrin.com Tue Dec 16 19:53:15 2003 From: myddrin at myddrin.com (Myddrin) Date: Tue Dec 16 20:00:56 2003 Subject: [python-win32] Efficiency question Message-ID: <200312161953.15644.myddrin@myddrin.com> Hi, I'm using a python Queue object to pass information between threads. Currently, I'm using a blocking Queue.get call and when one thread needs to wait on new information from another thread. This implementation works great, but I'm trying to get my CPU and Memory usage to a minimum. I'm half-way through Skip Montanaro's "Python Peformance Tips," but I got thinking. The performance right now is very good, but when alot of information is passing between two threads, the process can start taking up a goodly chunk of the CPU (up to about 20% on a 1 Ghz machine). Would using win32event module or the python condition class be more efficient, or are the locking classes utilized by Queue about as effiecient as anything else? Cross-platform solutions are preferred, but not required so if I can shave some cycles, I'll happily re-write the same code for the other platforms. [Well, ok...not happily... infact I'll whine and complain, but it would be worth it if I could cut my CPU usage in half or better.] Thanks From andrew-pywin32 at puzzling.org Tue Dec 16 20:56:36 2003 From: andrew-pywin32 at puzzling.org (Andrew Bennetts) Date: Tue Dec 16 20:56:43 2003 Subject: [python-win32] Efficiency question In-Reply-To: <200312161953.15644.myddrin@myddrin.com> References: <200312161953.15644.myddrin@myddrin.com> Message-ID: <20031217015636.GA473@frobozz> On Tue, Dec 16, 2003 at 07:53:15PM -0500, Myddrin wrote: [...using Queue.Queue for inter-thread communication...] > > Would using win32event module or the python condition class be more > efficient, or are the locking classes utilized by Queue about as effiecient > as anything else? Cross-platform solutions are preferred, but not required > so if I can shave some cycles, I'll happily re-write the same code for the > other platforms. [Well, ok...not happily... infact I'll whine and complain, > but it would be worth it if I could cut my CPU usage in half or better.] Have you profiled your code to find out where the time is being spent? It wouldn't expect locking to be bottleneck in most code. Particularly in your case, it sounds like there's very little lock contention at all -- you don't sound like you have many threads all fighting for the same lock. It's conceivable that if you have long queues, that Queue.Queue might be a bottleneck due to all the memmoves. But this is all guesswork. You really need to do some profiling to know that you aren't wasting your time optimising something that only takes 0.1% of the total time. Another option is to just not worry about optimising yourself, and let psyco speed up your code for you. -Andrew. From stefan_holmgren at msn.com Wed Dec 17 17:37:58 2003 From: stefan_holmgren at msn.com (S.Holmgren) Date: Wed Dec 17 17:40:54 2003 Subject: [python-win32] How to get the active process list? Message-ID: Is it possible to get the process list in windows... I want to search for an active process by name and return the pid!! Thanx Holmis From jasimons at online.no Wed Dec 17 20:30:13 2003 From: jasimons at online.no (John A.Simonsen) Date: Thu Dec 18 00:42:55 2003 Subject: [python-win32] XL Worksheet and formulas Message-ID: <000001c3c506$81846900$ad00a8c0@administrator> Hi there. I wondered if you or anybody knows how to make the numbers in a cell to change color. Problem!!! I want the numbers in the cell(s) to change color if the value is zero, or have a negative value. Is there anybody that can help me out here??? I have spent a lot of time trying to find a way, but I still haven?t had any success. Best regards. Phone. +47 51 62 70 98 Cell Phone. +47 913 20 009 John A. Simonsen. Fax. +47 51 97 77 56 jasimons@online.no Fax. +47 51 68 99 05 ? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20031218/f3aada58/attachment.html From kojo at hal-pc.org Thu Dec 18 02:32:47 2003 From: kojo at hal-pc.org (Kojo Idrissa) Date: Thu Dec 18 02:32:52 2003 Subject: [python-win32] XL Worksheet and formulas In-Reply-To: <000001c3c506$81846900$ad00a8c0@administrator> Message-ID: John, If you're just trying to do it in Excel (no Python), you can just use Conditional Formatting. If you're trying to do it in Python, I think you'd have to use Python to alter the value of the FontColorIndex attribute, based on the value in the cell. If you want code (in VB or Python), I may be able to come up with something. The "Excel Only" version needs no code. On Thu, 18 Dec 2003 02:30:13 +0100 "John A.Simonsen" wrote: ]Hi there. ] ]I wondered if you or anybody knows how to make the numbers in a cell ]to change color. ]Problem!!! I want the numbers in the cell(s) to change color if the ]value is zero, or have a negative value. ] ]Is there anybody that can help me out here??? I have spent a lot of ]time trying to find a way, but I still haven?t had any success. ] ]Best regards. Phone. +47 51 62 70 98 ] Cell Phone. +47 913 20 009 ] ]John A. Simonsen. Fax. +47 51 97 77 56 ]jasimons@online.no Fax. +47 51 68 99 05 ]? ] ] **************************** Kojo Idrissa kojo@hal-pc.org http://www.hal-pc.org/~kojo **************************** From Mark.English at liffe.com Thu Dec 18 09:26:19 2003 From: Mark.English at liffe.com (Mark English) Date: Thu Dec 18 09:38:17 2003 Subject: [python-win32] Subtyping in 'C' Message-ID: Hope someone can help because I'm stumped. I'm trying to use the new subtyping mechanism. There is a hierarchy of 3 types: Base - The base type C - Type derived from Base D - Type derived from C Base and C both have tp_new functions of their own. Since D doesn't define one, it ends up with C's. (I actually initialise it this way, but I believe that is what "PyType_Ready()" would do anyway) i.e. Base -> tp_new = Base::New C -> tp_new = C::New D -> tp_new = C::New tp_new has the following signature: PyObject * New (PyTypeObject *ptype, PyObject *args, PyObject *kwds) I've tried to follow the existing code and PEP 0253. Base::New calls ptype->tp_alloc and then does some non-varying data initialisation. C::New calls: "ptype->tp_base->tp_new(ptype, args, kwds)" and then does some non-varying data initialisation of its own. As stated, D doesn't have a tp_new function, so it ends up with C's. When constructing an instance of type "D", the following happens: C::New is called, where ptype=D. This delegates to ptype->tp_base->tp_new, where ptype->tp_base is C. C::New is called, where ptype=D. This carries on in a loop. The obvious solution is to pass ptype->tp_base as the ptype parameter in C::New like this: "ptype->tp_base->tp_new(ptype->tp_base, args, kwds)" The problem here is that when the tp_alloc function is called, "ptype" points to the basemost class of the class instance we're actually trying to initialise (in this case "Base"), and so not enough memory will be allocated. So currently the choice lies between blowing up the stack in an infinite loop, or initialising too small an amount of memory. Could get the functions to call the base type functions explicitly, without going through the tp_new pointer, but that seems kinda dirty. Thinking about hacking the object size in the "Base" type temporarily, so that at least I can allocate the correct amount of memory. Also not pretty but leaves the indirection alone. I'm using ActivePython 2.2.2 and I'd really rather not upgrade or switch yet. Any help, gratefully received. Cheers, mE ----------------------------------------------------------------------- The information contained in this e-mail is confidential and solely for the intended addressee(s). Unauthorised reproduction, disclosure, modification, and/or distribution of this email may be unlawful. If you have received this email in error, please notify the sender immediately and delete it from your system. The views expressed in this message do not necessarily reflect those of LIFFE Holdings Plc or any of its subsidiary companies. ----------------------------------------------------------------------- From Christian.Wyglendowski at greenville.edu Thu Dec 18 16:22:35 2003 From: Christian.Wyglendowski at greenville.edu (Christian Wyglendowski) Date: Thu Dec 18 16:22:39 2003 Subject: [python-win32] How to get the active process list? Message-ID: You could use WMI. >>> from win32com.client import GetObject >>> WMI = GetObject('winmgmts:') Here is how to get the process list: >>> processes = WMI.InstancesOf('Win32_Process') >>> len(processes) 41 >>> [process.Properties_('Name').Value for process in processes] # get the process names [u'System Idle Process', u'System', u'SMSS.EXE', u'CSRSS.EXE', u'WINLOGON.EXE', u'SERVICES.EXE', u'LSASS.EXE', u'SVCHOST.EXE', u'SVCHOST.EXE', u'SVCHOST.EXE', u'SVCHOST.EXE', u'SPOOLSV.EXE', u'ati2evxx.exe', u'BAsfIpM.exe', u'defwatch.exe', u'inetinfo.exe', u'mdm.exe', u'rtvscan.exe', u'SCARDSVR.EXE', u'WLTRYSVC.EXE', u'BCMWLTRY.EXE', u'EXPLORER.EXE', u'Apoint.exe', u'carpserv.exe', u'atiptaxx.exe', u'quickset.exe', u'DSentry.exe', u'Directcd.exe', u'vptray.exe', u'ApntEx.exe', u'FaxCtrl.exe', u'digstream.exe', u'CTFMON.EXE', u'wuauclt.exe', u'IEXPLORE.EXE', u'Pythonwin.exe', u'MMC.EXE', u'OUTLOOK.EXE', u'LineMgr.exe', u'SAPISVR.EXE', u'WMIPRVSE.EXE'] Here is how to get a single process and get its PID. >>> p = WMI.ExecQuery('select * from Win32_Process where Name="Pythonwin.exe"') >>> [prop.Name for prop in p[0].Properties_] # let's look at all the process property names [u'Caption', u'CommandLine', u'CreationClassName', u'CreationDate', u'CSCreationClassName', u'CSName', u'Description', u'ExecutablePath', u'ExecutionState', u'Handle', u'HandleCount', u'InstallDate', u'KernelModeTime', u'MaximumWorkingSetSize', u'MinimumWorkingSetSize', u'Name', u'OSCreationClassName', u'OSName', u'OtherOperationCount', u'OtherTransferCount', u'PageFaults', u'PageFileUsage', u'ParentProcessId', u'PeakPageFileUsage', u'PeakVirtualSize', u'PeakWorkingSetSize', u'Priority', u'PrivatePageCount', u'ProcessId', u'QuotaNonPagedPoolUsage', u'QuotaPagedPoolUsage', u'QuotaPeakNonPagedPoolUsage', u'QuotaPeakPagedPoolUsage', u'ReadOperationCount', u'ReadTransferCount', u'SessionId', u'Status', u'TerminationDate', u'ThreadCount', u'UserModeTime', u'VirtualSize', u'WindowsVersion', u'WorkingSetSize', u'WriteOperationCount', u'WriteTransferCount'] >>> p[0].Properties_('ProcessId').Value # get our ProcessId 928 Note that this is the syntax used after running makepy against WMI. You could also use the module at this site: http://tgolden.sc.sabren.com/python/wmi.html Christian > -----Original Message----- > From: S.Holmgren [mailto:stefan_holmgren@msn.com] > Sent: Wednesday, December 17, 2003 4:38 PM > To: python-win32@python.org > Subject: [python-win32] How to get the active process list? > > > Is it possible to get the process list in windows... > I want to search for an active process by name and return the pid!! > > Thanx > Holmis > > > > From Christian.Wyglendowski at greenville.edu Fri Dec 19 16:18:27 2003 From: Christian.Wyglendowski at greenville.edu (Christian Wyglendowski) Date: Fri Dec 19 16:18:35 2003 Subject: [python-win32] Dynamic method creation and WMI Message-ID: I do most of my Python coding in Pythonwin and really like the code completion feature. Using Python with WMI, I want to be able to call: >>> WMIobj.MethName(args) and have a list of possible attributes/methods pop up in Pythonwin when I type "WMIobj." Since running makepy does not help with this (now must call WMIobj.ExecMethod_(method_name, args)) I thought I'd write a little wrapper class that populates self.__dict__ with valid method names and set the values to a lambda that calls ExecMethod with the proper method name. That way I get code completion and the early binding via makepy. Here is what I have so far (incomplete and buggy as it is): class WMIObject: def __init__(self, object, query, computer='.'): wmi = GetObject('winmgmts://%s' % computer) self._wmiobj = wmi.ExecQuery('select * from %s where %s' % (object, query))[0] for meth in self._wmiobj.Methods_: newmethod = str(meth.Name) self.__dict__[newmethod] = lambda: self._wmiobj.ExecMethod_(meth.Name) Here is some output from a session in the interactive interpreter. >>> x = WMITools.WMIObject('Win32_Process', 'Name="TIWin.exe"') >>> x.GetOwner() Traceback (most recent call last): File "", line 1, in ? File "C:\Python23\Projects\AD Tools\WMITools.py", line 18, in self.__dict__[newmethod] = lambda: self._wmiobj.ExecMethod_(meth.Name) File "win32com\gen_py\565783C6-CB41-11D1-8B02-00600806D9B6x0x1x2.py", line 710, in ExecMethod_ ret = self._oleobj_.InvokeTypes(13, LCID, 1, (9, 0), ((8, 1), (9, 49), (3, 49), (9, 49)),strMethodName, objWbemInParameters, iFlags, objWbemNamedValueSet) com_error: (-2147352567, 'Exception occurred.', (0, 'SWbemObjectEx', 'Generic failure ', None, 0, -2147217407), None) It apparently calls the ExecMethod method but it chokes for some reason. I did some googling on the exception to no avail. Continuing in the interpreter, here is something that is interesting, though: >>> x.GetOwner = lambda: x._wmiobj.ExecMethod_('GetOwner') >>> x.GetOwner() So how come I can do the same thing after the object is created but not in its __init__ method? Christian From tim.golden at viacom-outdoor.co.uk Tue Dec 23 09:30:30 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue Dec 23 09:38:44 2003 Subject: [python-win32] XL Worksheet and formulas Message-ID: >From: Kojo Idrissa [mailto:kojo@hal-pc.org] >John, >If you're just trying to do it in Excel (no Python), you can just use >Conditional Formatting. > >If you're trying to do it in Python, I think you'd have to use Python >to alter the value of the FontColorIndex attribute, based on the value >in the cell. > >If you want code (in VB or Python), I may be able to come up with >something. The "Excel Only" version needs no code. > >On Thu, 18 Dec 2003 02:30:13 +0100 > "John A.Simonsen" wrote: >]Hi there. >] >]I wondered if you or anybody knows how to make the numbers in a cell >]to change color. >]Problem!!! I want the numbers in the cell(s) to change color if the >]value is zero, or have a negative value. >] >]Is there anybody that can help me out here??? I have spent a lot of >]time trying to find a way, but I still haven?t had any success. >] >]Best regards. Phone. +47 51 62 70 98 >] Cell Phone. +47 913 20 009 >] >]John A. Simonsen. Fax. +47 51 97 77 56 >]jasimons@online.no Fax. +47 51 68 99 05 Don't know if this one's been sorted out yet, but I use the code below in my general purpose sql2xl library, which I think is the kind of thing you want. I wrote it a long time ago, but almost certainly it was derived from recording a macro in Excel and then translating the resulting VBA: r = ws.Range (ws.Cells (2, 1 + col), ws.Cells (1 + n_rows, 1 + col)) r.FormatConditions.Add (win32com.client.constants.xlCellValue, win32com.client.constants.xlGreater, 0).Interior.Color = RGB (0, 255, 0) # green => value > 0 r.FormatConditions.Add (win32com.client.constants.xlCellValue, win32com.client.constants.xlLess, 0).Interior.Color = RGB (255, 0, 0) # red => value < 0 r.FormatConditions.Add (win32com.client.constants.xlCellValue, win32com.client.constants.xlEqual, 0).Interior.Color = RGB (255, 255, 255) # white => value == 0 This is only a fragment, and the n_rows and col and so on are not going to mean much to you, but I believe the principle should be clear. The RGB function is imported from win32api. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From alexandre.lemiere at laposte.net Tue Dec 23 19:13:21 2003 From: alexandre.lemiere at laposte.net (=?ISO-8859-15?B?QWxleGFuZHJlIExlbWnocmU=?=) Date: Tue Dec 23 19:09:27 2003 Subject: [python-win32] Printing a Word file silently Message-ID: <3421958254.20031224011321@laposte.net> Hi the list, I'd like to generate Postscript silently from Word. but word still show a dialog box for the filename. Here's the code I try : from win32com.client import constants,Dispatch,DispatchEx WORD = 'Word.Application.8' Faux, Vrai = 0,1 class Word: def __init__(self): self.app = DispatchEx(WORD) #self.app.Visible = 1 def ouvrir(self, doc): self.app.Documents.Open(FileName=doc) def imprimer(self): self.app.Application.ActivePrinter = "PostScript" self.app.Application.PrintOut(OutputFileName=r"c:\temp\testout.ps", PrintToFile=1, Append=Faux) def quitter(self): self.app.Documents(r"c:\temp\test.doc").Close(SaveChanges=Faux) ) if __name__ == '__main__': word = Word() word.ouvrir(r"c:\temp\test.doc") word.imprimer() word.quitter() I've found an old post (On 22 April 2003) about this but the answer doesn't work for me ;( here's a code of a macro that works, if it can helps... Sub Macro1() Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _ wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _ Collate:=True, Background:=True, PrintToFile:=True, PrintZoomColumn:=0, _ PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0, _ OutputFileName:="c:/temp/lulu.ps", Append:=False ActiveDocument.Close End Sub -- Best regards, Alexandre From tim.golden at viacom-outdoor.co.uk Wed Dec 24 04:12:15 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed Dec 24 04:19:58 2003 Subject: [python-win32] Printing a Word file silently Message-ID: >From: Alexandre Lemi?re [mailto:alexandre.lemiere@laposte.net] > >from win32com.client import constants,Dispatch,DispatchEx >WORD = 'Word.Application.8' >Faux, Vrai = 0,1 > >class Word: > def __init__(self): > self.app = DispatchEx(WORD) > #self.app.Visible = 1 > def ouvrir(self, doc): > self.app.Documents.Open(FileName=doc) > def imprimer(self): > self.app.Application.ActivePrinter = "PostScript" > >self.app.Application.PrintOut(OutputFileName=r"c:\temp\testout. >ps", PrintToFile=1, Append=Faux) > def quitter(self): > self.app.Documents(r"c:\temp\test.doc").Close(SaveChanges=Faux) >) > >if __name__ == '__main__': > word = Word() > word.ouvrir(r"c:\temp\test.doc") > word.imprimer() > word.quitter() > This may be of no use to you at all, but running your code (with a stray right bracket removed) on my Win2k box with Word2000 works perfectly. In fact, this is Word.Application.9 masquerading as Word.Application.8, so it may be that Word97 (aka Word 8) doesn't behave exactly the same. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From tim.golden at viacom-outdoor.co.uk Wed Dec 24 04:44:43 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed Dec 24 04:52:19 2003 Subject: [python-win32] Dynamic method creation and WMI Message-ID: >From: Christian Wyglendowski [snip need to autocomplete WMI attributes] >class WMIObject: > def __init__(self, object, query, computer='.'): > wmi = GetObject('winmgmts://%s' % computer) > self._wmiobj = wmi.ExecQuery('select * from %s where %s' % >(object, query))[0] > for meth in self._wmiobj.Methods_: > newmethod = str(meth.Name) > self.__dict__[newmethod] = lambda: >self._wmiobj.ExecMethod_(meth.Name) > >Here is some output from a session in the interactive interpreter. > >>>> x = WMITools.WMIObject('Win32_Process', 'Name="TIWin.exe"') >>>> x.GetOwner() [snip traceback] Well, this is no consolation, but it works for me (I cut-and-pasted your code into WMIUtils.py and adjusted the line-endings as seemed appropriate): C:\temp>python ActivePython 2.2.3 Build 227 (ActiveState Corp.) based on Python 2.2.3 (#42, Nov 13 2003, 09:57:55) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import WMIUtils >>> x = WMIUtils.WMIObject ("Win32_Process", 'Name="notepad.exe"') >>> x.GetOwner () >>> I'm running on Win2k with the builds you see above. I can't see any particular reason why it shouldn't work. As you probably discovered from googling, the error code is gives out (-2147217407 = 0x80041001) is so bland as to be useless. As an aside, while this technique is fine for generating dictionary-level attributes which Pythonwin etc. can pick up, it does (obviously) involve the overhead of creating all the attributes every time you create a WMI object, and will start to get wobbly when you need to pass parameters into the methods called. By this time, you've probably seen that for yourself / got a more robust solution in place, but having gone through all the pain once for myself I thought I might at least warn you. Since I don't use Pythonwin, I simply proxy the attribute calls through __getattr__ on demand. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From moof at metamoof.net Mon Dec 29 14:01:49 2003 From: moof at metamoof.net (Giles A. Radford) Date: Mon Dec 29 14:01:53 2003 Subject: [python-win32] Problems with py2exe and COM Message-ID: <20031229190149.GC20854@horus.kaotix.co.uk> OK, I'm obviously having a bad day, cos I can't seem to get this to work. I feel this is lack of understanding on my part, cos I can't find much documentation on the win32com modules - is there a secret documentation stash that I'm missing? I'm trying to create a DLL with some COM classes that update some websites with certain details. The problem I have is that I manage to get py2exe to compile the program (with a few warnigns about classes refrred to that just don't exist - I don't have Carbon.Folders for instance), but when I try to register the DLL with regsvr32.exe, I get back a message which said (paraphrased from spanish) "Error in DllRegisterServer in webupdate.dll - Returned a code: 0x80040201". I have no idea what this means. I've been fiddling wiht it all day, and I'm tired of it now. The fact that I can seem to find no documentation on the process, and what it's suppsed to do. Also, if I try to compile the py2exe with --debug I end up with a rather abstruse and impossible-to-decypher error: ... creating build\bdist.win32\winexe\collect\webupdater\Scripts.py2exe Traceback (most recent call last): File "C:\Documents and Settings\Moof\Mis documentos\Partner\WebUpdater\setup.p y", line 13, in ? scripts=['webupdater'], File "C:\PYTHON23\lib\distutils\core.py", line 149, in setup dist.run_commands() File "C:\PYTHON23\lib\distutils\dist.py", line 907, in run_commands self.run_command(cmd) File "C:\PYTHON23\lib\distutils\dist.py", line 927, in run_command cmd_obj.run() File "C:\PYTHON23\Lib\site-packages\py2exe\build_exe.py", line 698, in run extra_path + sys.path) File "C:\PYTHON23\Lib\site-packages\py2exe\build_exe.py", line 842, in find_de pendend_dlls alldlls, warnings = bin_depends(loadpath, images) File "C:\PYTHON23\Lib\site-packages\py2exe\build_exe.py", line 1154, in bin_de pends for result in py2exe_util.depends(image, loadpath).items(): py2exe_util.bind_error: C:\PYTHON23\lib\site-packages\py2exe\run_dll_d.dll I really don't know what I'm doing here. I can't work out from the source what's supposed to be happening, so I'm at a bit of a loss. Anyway, can anyone help me work out where I'm goign wrong? or at least shed some light as to where I can find out? Here's some of my code, though I've had to keep the site update stuff out for clarity. I've liberally peppered it with "what does this actually _do_?"-style comments, and any elucidation you could provide would be welcome. __init.py__ ----------- import sys import pythoncom if hasattr(sys, 'importers'): # we are running as py2exe-packed executable pythoncom.frozen = 1 from win32com.server.util import wrap import Site1 #For release, debugging=False debugging = True if debugging: from win32com.server.dispatcher import DefaultDebugDispatcher useDispatcher = DefaultDebugDispatcher else: useDispatcher = None class UpdaterFactory: """Stores a directory of possible instances, and returns instances of the appropriate class when requested to""" # I found this bit in a random python-list post. I have no idea what # it does. _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER _reg_progid_ = 'Foo.UpdaterFactory' _reg_clsid_ = '{3F3AF37A-59BB-XXXX-A2C4-07D5D3B11FE4}' _public_methods_ = ['getUpdater',] _public_attributes_ = ['sites'] #Eventually will have interesting stuff here which lists each #appropriate class in a number of modules directory = {'site1': Site1.Site1Updater, 'site2': Site1.Site2Updater} sites = directory.keys() def getUpdater(self, site): """Will return an instance of a class that will update the desired website @param site the site name as a string. Should be in UpdaterFactory.sites @raises COMException DISP_E_UKNOWNNAME if the site is unknown """ if site in directory: return wrap(diectory[site](), useDispatcher=useDispatcher) else: import winerror from win32com.server.exception import COMException raise COMException("Unknown or Unsupported Site", winerror.DISP_E_UNKNOWNNAME) def register(): print "Registering WebUpdater..." import win32com.server.register win32com.server.register.UseCommandLine(UpdaterFactory, debug=debugging) def unregister(): print "Unregistering WebUpdater..." import win32com.server.register win32com.server.register.UnregisterClasses(UpdaterFactory) if __name__ == '__main__': if hasattr(sys, 'importers'): if '--register' in sys.argv[1:]: register() elif '--unregister' in sys.argv[1:]: unregister() else: #I don't understand what this does, if anything. from win32com.server import localserver localserver.main() else: register() Site1.py -------- import socket socket.setdefaulttimeout(60) import winerror from win32com.server.exception import COMException import urllib, urllib2 from mx import DateTime class Site1Updater: _public_methods_ = ['update'] _readonly_attrs_ = ['name', 'settings'] name = "site1" settings = [('usuario', u'Usuario', 'string'), ('passwd', u'Contrase\xf1a', 'string')] _public_attrs_ = _readonly_attrs_ + [x[0] for x in settings] def __init__(self): self.product = 3 def update(self, from_, to_, num): pass #elided for clarity class Site2Updater(Site1Updater): name="site2" def __init__(self): Site1Updater.__init__(self) self.product=1 Setup.py -------- from distutils.core import setup import py2exe setup(name="WebUpdater", version="0.2", description="WebUpdater", author="Giles Antonio Radford", author_email="moof@metamoof.net", packages=['webupdater'], scripts=['webupdater'], ) From theller at python.net Mon Dec 29 16:30:19 2003 From: theller at python.net (Thomas Heller) Date: Mon Dec 29 15:31:28 2003 Subject: [python-win32] Re: Problems with py2exe and COM References: <20031229190149.GC20854@horus.kaotix.co.uk> Message-ID: "Giles A. Radford" writes: > OK, I'm obviously having a bad day, cos I can't seem to get this to > work. I feel this is lack of understanding on my part, cos I can't find > much documentation on the win32com modules - is there a secret > documentation stash that I'm missing? > > I'm trying to create a DLL with some COM classes that update some websites > with certain details. > > The problem I have is that I manage to get py2exe to compile the > program (with a few warnigns about classes refrred to that just don't > exist - I don't have Carbon.Folders for instance), but when I try to > register the DLL with regsvr32.exe, I get back a message which said > (paraphrased from spanish) "Error in DllRegisterServer in webupdate.dll > - Returned a code: 0x80040201". Are you using py2exe 0.4.x? If so, you should switch to the (soon to be officially released) version 0.5. Prereleases are in the Sourceforge project page, in the downloads section. Note that these currently require win NT, 2k, or XP, and Python 2.3, and, for COM, win32all 163. There's no documentation so far ;-), but some samples (including COM servers) are installed into the lib\site-packages\py2exe\samples subdirectories. You have to rewrite your setup script slightly, look at the samples to see how. > I have no idea what this means. I've been fiddling wiht it all day, and > I'm tired of it now. The fact that I can seem to find no documentation > on the process, and what it's suppsed to do. Also, if I try to compile > the py2exe with --debug I end up with a rather abstruse and > impossible-to-decypher error: --debug build debug versions of the executables, normally you don't want to do this, also you need debug versions of Python, py2exe, win32all, and whatever you use. Thomas From moof at metamoof.net Tue Dec 30 06:34:44 2003 From: moof at metamoof.net (Giles A. Radford) Date: Tue Dec 30 06:34:54 2003 Subject: [python-win32] Re: Problems with py2exe and COM In-Reply-To: References: <20031229190149.GC20854@horus.kaotix.co.uk> Message-ID: <20031230113444.GA3974@www.abyss-uk.com> On Mon, Dec 29, 2003 at 10:30:19PM +0100, Thomas Heller wrote: > Are you using py2exe 0.4.x? If so, you should switch to the (soon to be > officially released) version 0.5. Prereleases are in the Sourceforge > project page, in the downloads section. Note that these currently > require win NT, 2k, or XP, and Python 2.3, and, for COM, win32all 163. It works a dream, apart form the fact that you can't seem to use python 2.3 to be a client for a python 2.3 server inside a DLL. But I read somewhere that's a known problem. Any idea if it's solvable at all? The configuration file was a bit abstruse to understand, but I managed to get the gist fo it in the end. In the advanced sample, you may, for clarity, want to make the com_server line point to the interp object you set up earlier > There's no documentation so far ;-) This seems to be a weakness of PythonCOM generally. If you give me a heads up and are willign to answer questions, I'm quite happy to at least start documenting py2exe for you... > --debug build debug versions of the executables, normally you don't want > to do this, also you need debug versions of Python, py2exe, win32all, > and whatever you use. aah, right. I thoguht it would just register the COM server for debugging. OK: next question- Do I really need everythin in "build", or can I just send webupdater.dll and the library.zip file over? How exactly does this work? If so, what's the best place for this stuff to be installed on a standard windows installation? I have a bunch of dlls, including python23.dll, a bunch of .pyds and a library.zip file Incidentally, My co-programmer is getting rather annoyed that the python objects I've created aren't showing up under VB at all. He's tryign to get things like autocompletion of method names going. Any idea how I could get that going? Or at least get the application showing up on his list of things to include? Moof From theller at python.net Tue Dec 30 09:48:27 2003 From: theller at python.net (Thomas Heller) Date: Tue Dec 30 08:49:40 2003 Subject: [python-win32] Re: Problems with py2exe and COM References: <20031229190149.GC20854@horus.kaotix.co.uk> <20031230113444.GA3974@www.abyss-uk.com> Message-ID: "Giles A. Radford" writes: > On Mon, Dec 29, 2003 at 10:30:19PM +0100, Thomas Heller wrote: >> Are you using py2exe 0.4.x? If so, you should switch to the (soon to be >> officially released) version 0.5. Prereleases are in the Sourceforge >> project page, in the downloads section. Note that these currently >> require win NT, 2k, or XP, and Python 2.3, and, for COM, win32all 163. > > It works a dream, apart form the fact that you can't seem to use python > 2.3 to be a client for a python 2.3 server inside a DLL. But I read > somewhere that's a known problem. Any idea if it's solvable at all? Maybe. Currently the only workaround (if you want to use the 'frozen' com server from a Python script) is to either use the EXE server, not the DLL server, or to use a different Python version. > The configuration file was a bit abstruse to understand, but I managed > to get the gist fo it in the end. In the advanced sample, you may, for > clarity, want to make the com_server line point to the interp object you > set up earlier > >> There's no documentation so far ;-) > > This seems to be a weakness of PythonCOM generally. If you give me a > heads up and are willign to answer questions, I'm quite happy to at > least start documenting py2exe for you... Oh, that would be very cool. To get you started, I append what I currently have - this is a text file, later converted to html, by a StructuredText module I ripped off an old version of zope. Using Rest would definitely be an advantage, OTOH contents is more important than markup. Other possibilities would be to use the py2exe and ctypes wiki at > OK: next question- Do I really need everythin in "build", or can I just > send webupdater.dll and the library.zip file over? How exactly does this > work? If so, what's the best place for this stuff to be installed on a > standard windows installation? I have a bunch of dlls, including > python23.dll, a bunch of .pyds and a library.zip file I assume you mean the "dist" directory - the "build" directory is only needed for the build process. Yes, you have to distribute all what you find there. Python modules are in the library.zip file, the .exe and/or .dll is the executable itself, python23.dll is needed, and since extension modules (.pyd) cannot be loaded from zipfiles, they are also in this directory. Installing them on another machine, the dist directory should probably be installed somewhere below "\Program Files". > Incidentally, My co-programmer is getting rather annoyed that the python > objects I've created aren't showing up under VB at all. He's tryign to > get things like autocompletion of method names going. Any idea how I > could get that going? Or at least get the application showing up on his > list of things to include? I guess you need a typelibrary, but I may be wrong - I never use VB. Thomas -------------- next part -------------- Convert python scripts into standalone windows programs Copyright (c) 2001, 2002, 2003 Thomas Heller, Mark Hammond Abstract 'py2exe' is a Python "distutils":http://www.python.org/doc/current/dist/ extension which converts python scripts into executable windows programs, able to run without requiring a python installation. It has been used to create wxPython, Tkinter, Pmw, PyGTK, pygame, win32com client and server modules and other standalone programs. 'py2exe' is distributed under an open-source "license":LICENSE.TXT. News XXX Using py2exe Assuming you have writtern a python script 'myscript.py' which you want to convert into an executable windows program, able to run on systems without a python installation. If you don't already have written a *distutils* "setup-script":http://www.python.org/doc/current/dist/setup-script.html, write one, and insert the statement 'import py2exe' before the call to the setup function:: # setup.py from distutils.core import setup import py2exe setup(console=["myscript.py"]) Running:: python setup.py py2exe --help will display all available command-line flags to the 'py2exe' command. Now you can call the setup script like in this way:: python setup.py py2exe and a subdirectory 'dist' will be created, containing the files 'myscript.exe', 'python23.dll', and 'library.zip'. If your script uses compiled C extension modules, they will be copied here as well, also all dlls needed at runtime. These files include everything that is needed for your program, and you should distribute the whole directory contents. The above setup script creates a console program, if you want a GUI program without the console window, simply replace 'console=["myscript.py"]' by 'windows=["myscript.py"]'. 'py2exe' can create more than one exe file in one run, this is useful if you have a couple of related scripts. Pass a list of all scripts in the 'console' and/or 'windows' keyword argument. Specifying additional files Some applications need additional files at runtime, like configuration files, fonts, or bitmaps. 'py2exe' can copy these files into subdirectories of 'dist' if they are specified in the setup script with the 'data_files' option. 'data_files' should contain a sequence of '(target-dir, files)' tuples, where files is a sequence of files to be copied. Here's an example:: # setup.py from distutils.core import setup import glob import py2exe setup(console=["myscript.py"], data_files=[("bitmaps", ["bm/large.gif", "bm/small.gif"]), ("fonts", glob.glob("fonts\\*.fnt"))], ) This would create a subdirectory 'dist\bitmaps', containing the two '.gif' files, and a subdirectory 'dist\fonts', containing all the '.fnt' files. How does it work? 'py2exe' uses python's *'modulefinder'* to examine your script and find all python and extension modules needed to run it. Pure python modules are compiled into '.pyc' or '.pyo' files in a temporary directory. Compiled extension modules ('.pyd') are also found and parsed for binary dependencies. A zip-compatible archive is built, containing all python files from this directory. Your main script is inserted as a resource into a custom embedded python interpreter supplied with py2exe, and the zip-archive is installed as the only item on 'sys.path'. In simple cases, only 'pythonxx.dll' is needed in addition to 'myscript.exe'. If, however, your script needs extension modules, unfortunately those cannot be included or imported from the zip-archive, so they are needed as separate files (and are copied into the 'dist' directory). *Attention*: 'py2exe' tries to track down all binary dependencies for all pyd's and dll's copied to the dist directory recursively, and copies all these dependend files into the dist directory. 'py2exe' has a builtin list of some system dlls which are not copied, but this list can never be complete. Installing py2exe Download and run the installer "py2exe-0.5.0a7.win32-py2.3.exe":http://prdownloads.sourceforge.net/py2exe/py2exe-0.5.0a7.win32-py2.3.exe?download. This installs py2exe together with some samples, the samples are in the 'lib\site-packages\py2exe\samples' subdirectory. For Windows 95/98/Me, you additionally need the *Microsoft Layer for Unicode on Windows 95/98/ME Systems (MSLU)* dll from "here":http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdkredist.htm. Run the self-extracting 'unicows.exe' file, and copy the unpacked 'unicows.dll' file in the directory which contains your 'python.exe'. Note that this is only needed on the machine where you want to build executables with 'py2exe', it is not required on the machine where you want to run the created programs. From wb_harris at hotmail.com Tue Dec 30 00:30:57 2003 From: wb_harris at hotmail.com (Bill Harris) Date: Tue Dec 30 09:34:44 2003 Subject: [python-win32] Py2exe problem Message-ID: Hi, I am running into the following problem, and I hope someone here can help me. I am developing a wxPython application using Boa constructor (v 0.2.3) and wxPython 2.4 and Python 2.3.2. I am running Windows XP Pro, Service Pack 1 One of my modules uses strptime in the time module. I have a straight forward import: from time import * The program runs fine under boa, but when I build a Windows executable using py2exe with the -w option, I get the following ImportError - 'no module found _strptime'. Any suggestions? Thanks, Bill Harris {PGP Key ID: 2D10 DD0A} From theller at python.net Tue Dec 30 11:04:25 2003 From: theller at python.net (Thomas Heller) Date: Tue Dec 30 10:05:45 2003 Subject: [python-win32] Re: Py2exe problem References: Message-ID: <65fyjnqu.fsf@python.net> "Bill Harris" writes: > Hi, > I am running into the following problem, and I hope someone here can help > me. > > I am developing a wxPython application using Boa constructor (v 0.2.3) and > wxPython 2.4 and Python 2.3.2. I am running Windows XP Pro, Service Pack 1 > > One of my modules uses strptime in the time module. I have a straight > forward import: > from time import * > > The program runs fine under boa, but when I build a Windows executable using > py2exe with the -w option, I get the following ImportError - 'no module > found _strptime'. Ah, timemodule.c imports '_strptime' from C code, which py2exe cannot track. Adding a '-i _strptime' command line switch when running 'setup.py py2exe' should do the trick. Thomas From unifoam at total.net Tue Dec 30 15:08:19 2003 From: unifoam at total.net (unifoam@total.net) Date: Tue Dec 30 15:09:09 2003 Subject: [python-win32] Re: Problems installing Win32 for Python 2.3.2 Message-ID: <3FF1DB33.EA159B26@total.net> I've encountered an error while trying to install win32all-163 for Python 2.3.2. I have been using Python 2.2 and win32all-148 without any problems ( I was using win32 for Access and CorelDraw applications). I installed Python 2.3.2 without problem: Idle was working, etc., but when I installed win32all-163, the following dialog error message box appeared near the end of the installation: ------------------------------------------------- Completing Installation Error in installer script. Traceback (most recent call last): File "...\Temp\FinishInstall.py", line 101, in ApplyEntryPoint apply(ep, args) File "...\Temp\FinishInstall.py", line 82, in DoCompileAllAndRegisterCom FindDuplicates(mod, dir) File "...\Temp\FinishInstall.py", line 143, in FindDuplicates import win32api Import Error: DLL load failed: A device attached to the system is not functioning. ------------------------------------------------- Installation goes to completion but Double-clicking on Pythonwin.exe produces the following error message: ------------------------------------------------- Python for Win32 The application can not locate win32ui.pyd (or Python)(1157). One of the library files needed to run this application cannot be found. ------------------------------------------------- What I want to know is if I'm missing a DLL somewhere? I have also removed Python 2.2 and win32all-148 and tried to install Python 2.3.2 and win32all-163 but the same error shows up. Once I remove Python 2.3.2 and win32all-163 and re-install Python 2.2 and win32all-148, everything works without problem. I have also tried to install win32all-153 and win32all-155, both causing the same error. I even tried to install ActivePython-2.3.2-232-win32-ix86.msi, but Pythonwin would not work. When installing win32all-163, the following dll's appear in ...\Windows\System\ PythonCOM23.dll version 2.3.0.163 PyWinTypes23.dll version 2.3.0.163 I'm currently using Windows95 and I'm wondering if the latest versions of win32 require an upgraded dll (or operating system?) which I'm not aware of. Any suggestions would be helpful, otherwise, I'll have to stick with Python 2.2 / win32all-148. George Vestergom From Jim.Vickroy at noaa.gov Tue Dec 30 15:18:46 2003 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Dec 30 15:18:52 2003 Subject: [python-win32] Re: Problems installing Win32 for Python 2.3.2 References: <3FF1DB33.EA159B26@total.net> Message-ID: <3FF1DDA6.AD7D1106@noaa.gov> George, I am not able to help with your problem, but I have Python 2.3.2 / win32all-163 installed on both a Windows 2000 machine and a Windows XP machine and it works fine. I do not have access to a Windows 95 machine. -- jv unifoam@total.net wrote: > > I've encountered an error while trying to install win32all-163 for > Python 2.3.2. > > I have been using Python 2.2 and win32all-148 without any problems ( I > was using win32 for Access and CorelDraw applications). > > I installed Python 2.3.2 without problem: Idle was working, etc., but > when I installed win32all-163, the following dialog error message box > appeared near the end of the installation: > > ------------------------------------------------- > Completing Installation > > Error in installer script. > Traceback (most recent call last): > > File "...\Temp\FinishInstall.py", line 101, in ApplyEntryPoint > apply(ep, args) > > File "...\Temp\FinishInstall.py", line 82, in DoCompileAllAndRegisterCom > FindDuplicates(mod, dir) > > File "...\Temp\FinishInstall.py", line 143, in FindDuplicates > import win32api > > Import Error: DLL load failed: A device attached to the system is > not functioning. > ------------------------------------------------- > > Installation goes to completion but Double-clicking on Pythonwin.exe > produces the following error message: > > ------------------------------------------------- > Python for Win32 > The application can not locate win32ui.pyd (or Python)(1157). > One of the library files needed to run this application cannot be > found. > ------------------------------------------------- > > What I want to know is if I'm missing a DLL somewhere? > > I have also removed Python 2.2 and win32all-148 and tried to install > Python 2.3.2 and win32all-163 but the same error shows up. Once I remove > Python 2.3.2 and win32all-163 and re-install Python 2.2 and > win32all-148, everything works without problem. > > I have also tried to install win32all-153 and win32all-155, both causing > the same error. I even tried to install > ActivePython-2.3.2-232-win32-ix86.msi, but Pythonwin would not work. > > When installing win32all-163, the following dll's appear in > ...\Windows\System\ > > PythonCOM23.dll version 2.3.0.163 > PyWinTypes23.dll version 2.3.0.163 > > I'm currently using Windows95 and I'm wondering if the latest versions > of win32 require an upgraded dll (or operating system?) which I'm not > aware of. > > Any suggestions would be helpful, otherwise, I'll have to stick with > Python 2.2 / win32all-148. > > George Vestergom > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From theller at python.net Tue Dec 30 16:28:46 2003 From: theller at python.net (Thomas Heller) Date: Tue Dec 30 15:28:48 2003 Subject: [python-win32] Re: Problems installing Win32 for Python 2.3.2 References: <3FF1DB33.EA159B26@total.net> Message-ID: <65fy2dwx.fsf@python.net> unifoam@total.net writes: > > I've encountered an error while trying to install win32all-163 for > Python 2.3.2. > [...] > > I'm currently using Windows95 and I'm wondering if the latest versions > of win32 require an upgraded dll (or operating system?) which I'm not > aware of. > > Any suggestions would be helpful, otherwise, I'll have to stick with > Python 2.2 / win32all-148. Mark Hammond doesnt support windows 95 anymore (MS does the same, btw). Thomas