From nelson1977 at gmail.com Sat Apr 1 14:16:23 2006 From: nelson1977 at gmail.com (nelson -) Date: Sat, 1 Apr 2006 14:16:23 +0200 Subject: [python-win32] wxPython & COM server Message-ID: Hi all, i'm doing a COM server that have to expose some graphics (panels and configuration controls), that would be embedded in an application through OLE. I was wondering if I can do this using wxPython. Another question is if my COM server would inherits from one of the wxPython class. If it's true, from which? wx.App, wx.Frame, wx.Panel. The important thing is that i would to have the same effect that you have when you the calendar OLE control on a Delphi or VB form (you see the graphics ;) ) thanks, nelson -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060401/089a7be5/attachment.htm From mirco.furlan at visionee.com Mon Apr 3 18:12:00 2006 From: mirco.furlan at visionee.com (Mirco Furlan (Visionee)) Date: Mon, 3 Apr 2006 18:12:00 +0200 Subject: [python-win32] newbie problem with DispatchWithEvents Message-ID: <001101c65739$56db1ab0$3c01a8c0@MFURLAN> I'm new to python and python-win32. Need to use an instance of IE for a little work. I'm trying looking at the examples found, but I'm encountering a big problem to proceed: if I use win32com.client.Dispatch, all works fine, I can manipulate the IE instance without problems. But I need to catch some events from that instance; so I used win32com.client.DispatchWithEvents passing as eventClass a very simple class that handle only the OnVisible event. Every time I use the DispatchWithEvents, the IE instance seems to be locked... I can get it visible and I see that isn't all well draw, I can't Quit it (must kill the process), it doesn't respond to Navigate or any other method. Can someone help me please? From mhammond at skippinet.com.au Tue Apr 4 01:54:16 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 4 Apr 2006 09:54:16 +1000 Subject: [python-win32] newbie problem with DispatchWithEvents In-Reply-To: <001101c65739$56db1ab0$3c01a8c0@MFURLAN> Message-ID: > I'm new to python and python-win32. > Need to use an instance of IE for a little work. > I'm trying looking at the examples found, but I'm encountering a > big problem > to proceed: > if I use win32com.client.Dispatch, all works fine, I can manipulate the IE > instance without problems. But I need to catch some events from that > instance; so I used win32com.client.DispatchWithEvents passing as > eventClass > a very simple class that handle only the OnVisible event. > Every time I use the DispatchWithEvents, the IE instance seems to be > locked... I can get it visible and I see that isn't all well draw, I can't > Quit it (must kill the process), it doesn't respond to Navigate > or any other > method. In most cases, you need to be processing a "message loop" for this to work as you expect. Check out the win32com\demos\eventsApartmentThreaded.py and eventsFreeThreaded.py (they first appeared build 208, so you may need to upgrade) for examples of how to achieve this. Mark From derobins at scs.uiuc.edu Tue Apr 4 21:14:39 2006 From: derobins at scs.uiuc.edu (Dana Robinson) Date: Tue, 4 Apr 2006 14:14:39 -0500 Subject: [python-win32] Importing an array from COM into Python Message-ID: Hello, I am trying to get the arrays out of this function (from the IDL): [id(175), helpstring("method CreateFooBarArray")] HRESULT CreateFooBarArray([out]DOUBLE** FooArray, [out] DOUBLE** BarArray, [out,retval] ULONG* SizeOfFooBarArrays); The two arrays (Foo and Bar) are created with malloc and filled with useful data inside the COM object. I am attempting to access them with the following Python code. size = o.CreateFooBarArray(fooArray, barArray) This does not work. I get an error in \client\__init__.py at line 447 in _ApplyTypes_. It says "float() argument must be a string or number" Other COM functions with simple types work fine. I ran makepy.py over the COM library and I'm using early-bound automation if that makes any difference. So I have two questions: 1) The COM object is brand new and created in-house so I can have it changed to my liking. What's the best way to pass a large array (thousands of elements) of doubles out of a COM object into Python? I have Mark Hammond's book, which is very helpful, but passing arrays between languages doesn't seem to be covered. 2) If the COM object handles the memory allocation, will the arrays be properly garbage collected? Actually, I have a third question. Where can I find a searchable version of the mailing list? The one at python.org doesn't appear to be searchable. Thanks for your help. I just switched from the digest to individual mails, so if you respond this afternoon please cc me so I'll be able to try your suggestions out before I go home. Thanks, Dana Robinson From bwmetz at att.com Tue Apr 4 22:46:32 2006 From: bwmetz at att.com (Metz, Bobby W, WCS) Date: Tue, 4 Apr 2006 15:46:32 -0500 Subject: [python-win32] Importing an array from COM into Python In-Reply-To: Message-ID: <01D5341D04A2E64AB9B34576904733670191991B@OCCLUST01EVS1.ugd.att.com> Not sure about your COM issue, but assuming Google hits all the archive pages like I think it does, just use "site:mail.python.org" on the end of your search string. Bobby -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Dana Robinson Sent: Tuesday, April 04, 2006 12:15 PM To: python-win32 at python.org Subject: [python-win32] Importing an array from COM into Python Hello, I am trying to get the arrays out of this function (from the IDL): [id(175), helpstring("method CreateFooBarArray")] HRESULT CreateFooBarArray([out]DOUBLE** FooArray, [out] DOUBLE** BarArray, [out,retval] ULONG* SizeOfFooBarArrays); The two arrays (Foo and Bar) are created with malloc and filled with useful data inside the COM object. I am attempting to access them with the following Python code. size = o.CreateFooBarArray(fooArray, barArray) This does not work. I get an error in \client\__init__.py at line 447 in _ApplyTypes_. It says "float() argument must be a string or number" Other COM functions with simple types work fine. I ran makepy.py over the COM library and I'm using early-bound automation if that makes any difference. So I have two questions: 1) The COM object is brand new and created in-house so I can have it changed to my liking. What's the best way to pass a large array (thousands of elements) of doubles out of a COM object into Python? I have Mark Hammond's book, which is very helpful, but passing arrays between languages doesn't seem to be covered. 2) If the COM object handles the memory allocation, will the arrays be properly garbage collected? Actually, I have a third question. Where can I find a searchable version of the mailing list? The one at python.org doesn't appear to be searchable. Thanks for your help. I just switched from the digest to individual mails, so if you respond this afternoon please cc me so I'll be able to try your suggestions out before I go home. Thanks, Dana Robinson _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From mhammond at skippinet.com.au Wed Apr 5 02:17:03 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 5 Apr 2006 10:17:03 +1000 Subject: [python-win32] Importing an array from COM into Python In-Reply-To: Message-ID: > I am trying to get the arrays out of this function (from the IDL): > > [id(175), helpstring("method CreateFooBarArray")] HRESULT > CreateFooBarArray([out]DOUBLE** FooArray, [out] DOUBLE** BarArray, > [out,retval] ULONG* SizeOfFooBarArrays); > > The two arrays (Foo and Bar) are created with malloc and filled with > useful data inside the COM object. > > I am attempting to access them with the following Python code. > > size = o.CreateFooBarArray(fooArray, barArray) Note that Python is calling the function via IDispatch, and not natively using the vtable. Hence the arrays are passed as Variants and SAFEARRAYs, not directly. Also note that given the above signature, the Python call should look like: size, fooArray, barArray = CreateFooBarArray() As all params are [out]. > This does not work. I get an error in \client\__init__.py at line 447 in > _ApplyTypes_. It says "float() argument must be a string or number" > Other COM functions with simple types work fine. I ran makepy.py over the > COM library and I'm using early-bound automation if that makes any > difference. That is strange, but would be related to the args you passed. > So I have two questions: > > 1) The COM object is brand new and created in-house so I can have it > changed to my liking. What's the best way to pass a large array > (thousands of elements) of doubles out of a COM object into Python? I > have Mark Hammond's book, which is very helpful, but passing arrays > between languages doesn't seem to be covered. That should work fine. > 2) If the COM object handles the memory allocation, will the arrays be > properly garbage collected? As above, Python will never directly make the call so memory management is handled by the IDispatch implementation your object provides. I'm actually surprised that the IDL allows that as an automation interface! Also check out the com\TestSources directory in the source archive or in CVS - there we have a C++ implemented COM object that exchanges various types of data with Python (and ditto one for VB/Python) Mark From bwmetz at att.com Wed Apr 5 05:04:08 2006 From: bwmetz at att.com (Metz, Bobby W, WCS) Date: Tue, 4 Apr 2006 22:04:08 -0500 Subject: [python-win32] Garbage collection of dispatched classes with dispatched classes In-Reply-To: Message-ID: <01D5341D04A2E64AB9B345769047336701919A7E@OCCLUST01EVS1.ugd.att.com> Hi, I'm hoping someone might provide some COM dispatching insights as I'm relatively new to it in Python. Does using static binding provide for better garbage collection when the dispatched class has dispatched classes of it's own? The nitty gritty... I'm dispatching a registered class, HelpDesk, from python that in turn automates another class, TicketList (has no API that Python can use and there's no support for either class in order to know the full details of the interaction). The ListTicket class provides a portion of the GUI within the HelpDesk GUI the user sees. Basically, I'm automating HelpDesk to pull info from it for my own GUI add-on and don't care about TicketList; however, HelpDesk will always start ListTicket and pass information to it and I can't prevent that. So here's the problem situation... If a user closes the HelpDesk instance I've dispatched, the GUI closes but the actual .exe stays running under task man. This appears to happen because my program hasn't yet detected the close and set the saved instance var to None. Sometimes setting it to None under this condition even causes an error in the hung HelpDesk .exe which doesn't appear as an exception in Python, so I tend to use ProcessTerminate when I detect the hung .exe. The ListTicket program dispatched by HelpDesk no longer appears in task man; however, after I kill the HelpDesk prog and re-dispatch a new instance, the interaction between HelpDesk and ListTicket doesn't work correctly, i.e. ListTicket prompts the user for a piece of info that has already been provided to HelpDesk, one which it never asks for normally. Sometimes it even appears that ListTicket was really still running (according to win32process.EnumProcesses). I'm doing dynamic instead of static binding of the HelpDesk class and I was wondering if anyone thought this might be the root cause, i.e. any ideas if using static binding would provide for better garbage collection when the dispatched class has dispatched classes of it's own? Thanks, B From Byron.Morgan at sfmta.com Wed Apr 5 08:17:39 2006 From: Byron.Morgan at sfmta.com (Morgan, Byron) Date: Tue, 4 Apr 2006 23:17:39 -0700 Subject: [python-win32] Runnin Python app as service with separate console Message-ID: <325A5361CB7EE5439FA9978CBB9D006F01136F00@MUNI-MAIL.muni.sfgov.org> I have a robust, stable Python script that runs 24-7, crunching a telnet feed of real-time data. Problem is, it has to run in a dos console window on the desktop. I would like to run it as a service, and be able connect to it and monitor performance with a separate console (either gui or not) from time to time. I'm hoping for advice on how to proceed. Byron Morgan San Francisco From mirco.furlan at visionee.com Wed Apr 5 09:15:16 2006 From: mirco.furlan at visionee.com (Mirco Furlan (Visionee)) Date: Wed, 5 Apr 2006 09:15:16 +0200 Subject: [python-win32] Acrobat Reader Message-ID: <000601c65880$b0c2c350$3c01a8c0@MFURLAN> I'm trying to use an instance of Adobe Acrobat Reader. I can successfull create an instance with win32com.client.Dispatch, but when I try to load a document, python crashes! I had version 7 of Reader and I tried to install an older version (6.1), but same result. I would use it to print pdf documents with its methods (in particular PrintPages(..) ). Is there some known problem? Any suggestion or alternative solution will appreciate. From fumanchu at amor.org Wed Apr 5 09:43:15 2006 From: fumanchu at amor.org (Robert Brewer) Date: Wed, 5 Apr 2006 00:43:15 -0700 Subject: [python-win32] Runnin Python app as service with separate console References: <325A5361CB7EE5439FA9978CBB9D006F01136F00@MUNI-MAIL.muni.sfgov.org> Message-ID: <435DF58A933BA74397B42CDEB8145A86224B91@ex9.hostedexchange.local> Byron Morgan wrote: > I have a robust, stable Python script that runs 24-7, > crunching a telnet feed of real-time data. Problem is, > it has to run in a dos console window on the desktop. > I would like to run it as a service, and be able > connect to it and monitor performance with a separate > console (either gui or not) from time to time. I'm > hoping for advice on how to proceed. Making the script run as a service is not terribly difficult. Start by Googling for, say, "win32serviceutil.ServiceFramework" to get some sample code. Cut-n-paste should get you there. On the "separate console" front, I've given up on local, desktop-based solutions and now use a web-based terminal I wrote for use with CherryPy: http://projects.amor.org/misc/wiki/HTTPREPL Hope that helps, Robert Brewer System Architect Amor Ministries fumanchu at amor.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060405/99fda8ba/attachment.htm From mhammond at skippinet.com.au Wed Apr 5 09:53:54 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 5 Apr 2006 17:53:54 +1000 Subject: [python-win32] Runnin Python app as service with separate console In-Reply-To: <325A5361CB7EE5439FA9978CBB9D006F01136F00@MUNI-MAIL.muni.sfgov.org> Message-ID: > I have a robust, stable Python script that runs 24-7, crunching a telnet > feed of real-time data. Problem is, it has to run in a dos console > window on the desktop. I would like to run it as a service, If it must run on the desktop of the logged in user, then this is not what services are for. A service can have a console, but it will not be attached to the "WindowStation". Otherwise I'm not sure why it must run in a DOS console - but in general your Python module can run as a service - but no one will be able to *see* any consoles associated with it. Mark From mhammond at skippinet.com.au Wed Apr 5 10:04:08 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 5 Apr 2006 18:04:08 +1000 Subject: [python-win32] Garbage collection of dispatched classes withdispatched classes In-Reply-To: <01D5341D04A2E64AB9B345769047336701919A7E@OCCLUST01EVS1.ugd.att.com> Message-ID: > Hi, I'm hoping someone might provide some COM dispatching > insights as I'm relatively new to it in Python. Does using static > binding provide for better garbage collection when the dispatched class > has dispatched classes of it's own? Nope - it should make no difference. > The nitty gritty... > > I'm dispatching a registered class, HelpDesk, from python that > in turn automates another class, TicketList (has no API that Python can > use and there's no support for either class in order to know the full > details of the interaction). The ListTicket class provides a portion of > the GUI within the HelpDesk GUI the user sees. Basically, I'm > automating HelpDesk to pull info from it for my own GUI add-on and don't > care about TicketList; however, HelpDesk will always start ListTicket > and pass information to it and I can't prevent that. So here's the > problem situation... > If a user closes the HelpDesk instance I've dispatched, the GUI > closes but the actual .exe stays running under task man. This appears > to happen because my program hasn't yet detected the close and set the > saved instance var to None. Sometimes setting it to None under this > condition even causes an error in the hung HelpDesk .exe which doesn't > appear as an exception in Python, so I tend to use ProcessTerminate when > I detect the hung .exe. The ListTicket program dispatched by HelpDesk > no longer appears in task man; however, after I kill the HelpDesk prog > and re-dispatch a new instance, the interaction between HelpDesk and > ListTicket doesn't work correctly, i.e. ListTicket prompts the user for > a piece of info that has already been provided to HelpDesk, one which it > never asks for normally. Sometimes it even appears that ListTicket was > really still running (according to win32process.EnumProcesses). I'm > doing dynamic instead of static binding of the HelpDesk class and I was > wondering if anyone thought this might be the root cause, i.e. any ideas > if using static binding would provide for better garbage collection when > the dispatched class has dispatched classes of it's own? There is no "garbage collection" happening here and it is a tricky problem (that may just be a bug in HelpDesk) - you have a reference to the COM object, and nothing is capable of knowing the app is dead and the reference is "invalid". If you can hook events from HelpDesk, just hook the close event and release your reference that this point - the app should then cleanly shut down - otherwise try setting the app to invisible, so the user can't close it! Using win32com.client.DispatchEx() will often start a second instance of an application where win32com.client.Dispatch() would reuse an existing one - so you may be able to get your own "private" instance running... Mark From mirco.furlan at visionee.com Wed Apr 5 16:44:03 2006 From: mirco.furlan at visionee.com (Mirco Furlan (Visionee)) Date: Wed, 5 Apr 2006 16:44:03 +0200 Subject: [python-win32] R: Acrobat Reader In-Reply-To: <20060405143509.GA10473@slider2.rack66.net> Message-ID: <000001c658bf$620c02f0$3c01a8c0@MFURLAN> here my code: import win32com.client pdf = win32com.client.Dispatch('AcroPDF.PDF') pdf.LoadFile(r'K:\test.pdf') Note that the activeX instance is correctly created, the method LoadFile is recognized and the file 'test.pdf' exists. After the last line of code python crashes. I'm using python 2.4 and Acrobat Reader 7. >Can you provide a code sample for review? >Regards, >Filip From bwmetz at att.com Wed Apr 5 16:51:50 2006 From: bwmetz at att.com (Metz, Bobby W, WCS) Date: Wed, 5 Apr 2006 09:51:50 -0500 Subject: [python-win32] Garbage collection of dispatched classes withdispatched classes In-Reply-To: Message-ID: <01D5341D04A2E64AB9B34576904733670194421D@OCCLUST01EVS1.ugd.att.com> Thanks Mark. I've been using Dispatch which starts new if my user isn't already active in HelpDesk. Unfortunately I have to use the same instance as the user since the add-on I'm writing presents info not available in HelpDesk based on what the user has selected. Fortunately HelpDesk does have a couple of functions that throw a specific COM error when the user has killed the app but it's still running, so I catch that error to detect hung state. Unfortunately, HelpDesk wasn't given a COM close function...crazy I know. I didn't know that DispatchEx worked that way, so thatnks for that. Bobby -----Original Message----- From: Mark Hammond [mailto:mhammond at skippinet.com.au] Sent: Wednesday, April 05, 2006 1:04 AM To: Metz, Bobby W, WCS; python-win32 at python.org Subject: RE: [python-win32] Garbage collection of dispatched classes withdispatched classes > Hi, I'm hoping someone might provide some COM dispatching > insights as I'm relatively new to it in Python. Does using static > binding provide for better garbage collection when the dispatched class > has dispatched classes of it's own? Nope - it should make no difference. > The nitty gritty... > > I'm dispatching a registered class, HelpDesk, from python that > in turn automates another class, TicketList (has no API that Python can > use and there's no support for either class in order to know the full > details of the interaction). The ListTicket class provides a portion of > the GUI within the HelpDesk GUI the user sees. Basically, I'm > automating HelpDesk to pull info from it for my own GUI add-on and don't > care about TicketList; however, HelpDesk will always start ListTicket > and pass information to it and I can't prevent that. So here's the > problem situation... > If a user closes the HelpDesk instance I've dispatched, the GUI > closes but the actual .exe stays running under task man. This appears > to happen because my program hasn't yet detected the close and set the > saved instance var to None. Sometimes setting it to None under this > condition even causes an error in the hung HelpDesk .exe which doesn't > appear as an exception in Python, so I tend to use ProcessTerminate when > I detect the hung .exe. The ListTicket program dispatched by HelpDesk > no longer appears in task man; however, after I kill the HelpDesk prog > and re-dispatch a new instance, the interaction between HelpDesk and > ListTicket doesn't work correctly, i.e. ListTicket prompts the user for > a piece of info that has already been provided to HelpDesk, one which it > never asks for normally. Sometimes it even appears that ListTicket was > really still running (according to win32process.EnumProcesses). I'm > doing dynamic instead of static binding of the HelpDesk class and I was > wondering if anyone thought this might be the root cause, i.e. any ideas > if using static binding would provide for better garbage collection when > the dispatched class has dispatched classes of it's own? There is no "garbage collection" happening here and it is a tricky problem (that may just be a bug in HelpDesk) - you have a reference to the COM object, and nothing is capable of knowing the app is dead and the reference is "invalid". If you can hook events from HelpDesk, just hook the close event and release your reference that this point - the app should then cleanly shut down - otherwise try setting the app to invisible, so the user can't close it! Using win32com.client.DispatchEx() will often start a second instance of an application where win32com.client.Dispatch() would reuse an existing one - so you may be able to get your own "private" instance running... Mark From mechanix at debian.org Wed Apr 5 16:35:09 2006 From: mechanix at debian.org (Filip Van Raemdonck) Date: Wed, 5 Apr 2006 16:35:09 +0200 Subject: [python-win32] Acrobat Reader In-Reply-To: <000601c65880$b0c2c350$3c01a8c0@MFURLAN> References: <000601c65880$b0c2c350$3c01a8c0@MFURLAN> Message-ID: <20060405143509.GA10473@slider2.rack66.net> Hi, On Wed, Apr 05, 2006 at 09:15:16AM +0200, Mirco Furlan (Visionee) wrote: > I'm trying to use an instance of Adobe Acrobat Reader. I can successfull > create an instance with win32com.client.Dispatch, but when I try to load a > document, python crashes! I had version 7 of Reader and I tried to install > an older version (6.1), but same result. I would use it to print pdf > documents with its methods (in particular PrintPages(..) ). Is there some > known problem? Any suggestion or alternative solution will appreciate. Can you provide a code sample for review? Regards, Filip -- "In another study we discover that application development on Windows takes less time (and therefore less money) because it's just a more productive environment. One wonders what Microsoft itself is using, given the production delays to its Longhorn system update." -- comment on Microsofts "Get The Facts" propaganda From bgailer at alum.rpi.edu Wed Apr 5 18:46:44 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Wed, 05 Apr 2006 09:46:44 -0700 Subject: [python-win32] R: Acrobat Reader In-Reply-To: <000001c658bf$620c02f0$3c01a8c0@MFURLAN> References: <000001c658bf$620c02f0$3c01a8c0@MFURLAN> Message-ID: <4433F474.2050201@alum.rpi.edu> Mirco Furlan (Visionee) wrote: > here my code: > > import win32com.client > > pdf = win32com.client.Dispatch('AcroPDF.PDF') > pdf.LoadFile(r'K:\test.pdf') > > Boy Don't Try This At Home. I did and got the BSOD! From bgailer at alum.rpi.edu Wed Apr 5 18:48:25 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Wed, 05 Apr 2006 09:48:25 -0700 Subject: [python-win32] Runnin Python app as service with separate console In-Reply-To: <325A5361CB7EE5439FA9978CBB9D006F01136F00@MUNI-MAIL.muni.sfgov.org> References: <325A5361CB7EE5439FA9978CBB9D006F01136F00@MUNI-MAIL.muni.sfgov.org> Message-ID: <4433F4D9.6020204@alum.rpi.edu> Morgan, Byron wrote: > I have a robust, stable Python script that runs 24-7, crunching a telnet > feed of real-time data. Problem is, it has to run in a dos console > window on the desktop. I would like to run it as a service, and be able > connect to it and monitor performance with a separate console (either > gui or not) from time to time. I'm hoping for advice on how to proceed. You can use the Scheduled Tasks service to run the program. This is a lot easier than building a service. From bwmetz at att.com Wed Apr 5 19:23:10 2006 From: bwmetz at att.com (Metz, Bobby W, WCS) Date: Wed, 5 Apr 2006 12:23:10 -0500 Subject: [python-win32] R: Acrobat Reader In-Reply-To: <4433F474.2050201@alum.rpi.edu> Message-ID: <01D5341D04A2E64AB9B34576904733670194450A@OCCLUST01EVS1.ugd.att.com> Crashes my Python 2.4, but not the box (XP). FYI, AcroPDF.PDF isn't valid pre-7.0 it seems. B -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Bob Gailer Sent: Wednesday, April 05, 2006 10:47 AM To: Mirco Furlan (Visionee) Cc: python-win32 at python.org Subject: Re: [python-win32] R: Acrobat Reader Mirco Furlan (Visionee) wrote: > here my code: > > import win32com.client > > pdf = win32com.client.Dispatch('AcroPDF.PDF') > pdf.LoadFile(r'K:\test.pdf') > > Boy Don't Try This At Home. I did and got the BSOD! _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From timr at probo.com Wed Apr 5 19:39:18 2006 From: timr at probo.com (Tim Roberts) Date: Wed, 05 Apr 2006 10:39:18 -0700 Subject: [python-win32] Acrobat Reader In-Reply-To: References: Message-ID: <443400C6.1050907@probo.com> On Wed, 5 Apr 2006 09:15:16 +0200, "Mirco Furlan (Visionee)" wrote: >I'm trying to use an instance of Adobe Acrobat Reader. I can successfull >create an instance with win32com.client.Dispatch, > How did you do that? To my knowledge, the only way to do that is to use AcroExch.App, which is only exposed by the full Acrobat product, not the Reader. As far as I know, the standalone Reader application simply cannot be controlled via COM. There is an ActiveX control, but that's a bigger deal. >but when I try to load a >document, python crashes! I had version 7 of Reader and I tried to install >an older version (6.1), but same result. I would use it to print pdf >documents with its methods (in particular PrintPages(..) ). Is there some >known problem? Any suggestion or alternative solution will appreciate. > The Acrobat ActiveX wrapper in wxPython explodes with version 7, deep within Acrobat, where it has never done so before. The problem has not been isolated yet. The only reliable and portable way to do what you ask is to fire up the reader from a command line. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From waldemar.osuch at gmail.com Wed Apr 5 19:55:18 2006 From: waldemar.osuch at gmail.com (Waldemar Osuch) Date: Wed, 5 Apr 2006 11:55:18 -0600 Subject: [python-win32] Acrobat Reader In-Reply-To: <443400C6.1050907@probo.com> References: <443400C6.1050907@probo.com> Message-ID: <6fae95540604051055s2552de27kfcad7644775e3060@mail.gmail.com> On 4/5/06, Tim Roberts wrote: > On Wed, 5 Apr 2006 09:15:16 +0200, "Mirco Furlan (Visionee)" > wrote: > > >I'm trying to use an instance of Adobe Acrobat Reader. I can successfull > >create an instance with win32com.client.Dispatch, > > > > How did you do that? To my knowledge, the only way to do that is to use > AcroExch.App, which is only exposed by the full Acrobat product, not the > Reader. As far as I know, the standalone Reader application simply > cannot be controlled via COM. There is an ActiveX control, but that's a > bigger deal. > I know Dispatch used to work with the Reader. Did Adobe broke the Reader to force us to pay for the full version or is it pythoncom at fault here? But then again I have working .Net application that uses Reader to display files. I did not write the .Net one so do not ask me how it does it :-). But I do have source and could try to find out. > The Acrobat ActiveX wrapper in wxPython explodes with version 7, deep > within Acrobat, where it has never done so before. The problem has not > been isolated yet. It is the same issue. I think. > > The only reliable and portable way to do what you ask is to fire up the > reader from a command line. Yes but then you can not control it at all. Waldemar From waldemar.osuch at gmail.com Wed Apr 5 21:20:03 2006 From: waldemar.osuch at gmail.com (Waldemar Osuch) Date: Wed, 5 Apr 2006 13:20:03 -0600 Subject: [python-win32] Runnin Python app as service with separate console In-Reply-To: <4433F4D9.6020204@alum.rpi.edu> References: <325A5361CB7EE5439FA9978CBB9D006F01136F00@MUNI-MAIL.muni.sfgov.org> <4433F4D9.6020204@alum.rpi.edu> Message-ID: <6fae95540604051220m5613d59dw1df0ab784ed0187c@mail.gmail.com> > Morgan, Byron wrote: > > I have a robust, stable Python script that runs 24-7, crunching a telnet > > feed of real-time data. Problem is, it has to run in a dos console > > window on the desktop. I would like to run it as a service, and be able > > connect to it and monitor performance with a separate console (either > > gui or not) from time to time. I'm hoping for advice on how to proceed. Plenty of advice. Here is my 2 cents. For last couple of years I run a windows service based on Twisted framework. One of the almost build in features of the framework is that you can telnet to the live running service, check the status or even tweak it while it runs. The framework handles multitude of protocols as a client and a server and TELNET is included. My service even utilizes built in web server to show the status of the running application. Although it is not obvious from Twisted documentation it is trivial to run an application as a windows service as long as you use *.tac files to build it. Waldemar From bwmetz at att.com Thu Apr 6 03:42:54 2006 From: bwmetz at att.com (Metz, Bobby W, WCS) Date: Wed, 5 Apr 2006 20:42:54 -0500 Subject: [python-win32] Acrobat Reader In-Reply-To: <443400C6.1050907@probo.com> Message-ID: <01D5341D04A2E64AB9B3457690473367019449F4@OCCLUST01EVS1.ugd.att.com> FYI >From the Adobe developer guide... "Use of the ActiveX(r)Control or Netscape plug-in to display a PDF file in an external application besides Internet Explorer or Netscape. The methods used by Acrobat to display a PDF file in Netscape and Internet Explorer are intended only for use with these browsers. Use of the ActiveX Control and Netscape plug-in installed by Adobe Reader is not licensed to other applications. Development with these interfaces is not supported and no documentation is available." This is the AcroPDF.PDF class as best I can tell. There's another dispatchable 7.0 class that doesn't crash Python called AcroExch.Document but I can't find any documentation on it's methods and Open and FileOpen as used by other Acro classes don't respond. Bobby -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Tim Roberts Sent: Wednesday, April 05, 2006 11:39 AM To: python-win32 at python.org Subject: Re: [python-win32] Acrobat Reader On Wed, 5 Apr 2006 09:15:16 +0200, "Mirco Furlan (Visionee)" wrote: >I'm trying to use an instance of Adobe Acrobat Reader. I can successfull >create an instance with win32com.client.Dispatch, > How did you do that? To my knowledge, the only way to do that is to use AcroExch.App, which is only exposed by the full Acrobat product, not the Reader. As far as I know, the standalone Reader application simply cannot be controlled via COM. There is an ActiveX control, but that's a bigger deal. >but when I try to load a >document, python crashes! I had version 7 of Reader and I tried to install >an older version (6.1), but same result. I would use it to print pdf >documents with its methods (in particular PrintPages(..) ). Is there some >known problem? Any suggestion or alternative solution will appreciate. > The Acrobat ActiveX wrapper in wxPython explodes with version 7, deep within Acrobat, where it has never done so before. The problem has not been isolated yet. The only reliable and portable way to do what you ask is to fire up the reader from a command line. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From rwupole at msn.com Thu Apr 6 05:00:07 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 5 Apr 2006 23:00:07 -0400 Subject: [python-win32] Re: Acrobat Reader Message-ID: Tim Roberts wrote: > wrote: > >>I'm trying to use an instance of Adobe Acrobat Reader. I can successfull >>create an instance with win32com.client.Dispatch, >> > > How did you do that? To my knowledge, the only way to do that is to use > AcroExch.App, which is only exposed by the full Acrobat product, not the > Reader. As far as I know, the standalone Reader application simply > cannot be controlled via COM. There is an ActiveX control, but that's a > bigger deal. Acrobat Reader can be used as a COM object thru its Internet Explorer plugin. When you open a PDF directly in IE, the Document object is provided by Acrobat. import win32com.client, time ie = win32com.client.Dispatch('InternetExplorer.Application') ie.Visible=1 ie.Navigate('somedocument.pdf') while ie.Busy: time.sleep(1) ie.Document.printPages(1,3) Roger From mirco.furlan at visionee.com Thu Apr 6 08:45:13 2006 From: mirco.furlan at visionee.com (Mirco Furlan (Visionee)) Date: Thu, 6 Apr 2006 08:45:13 +0200 Subject: [python-win32] R: Acrobat Reader In-Reply-To: <01D5341D04A2E64AB9B3457690473367019449F4@OCCLUST01EVS1.ugd.att.com> Message-ID: <000001c65945$a81790d0$3c01a8c0@MFURLAN> Thank's to all. I think I continue to use an IE instance, load the pdf as url and so with a reference to IE.Document I have my pdf document to manipulate (this time my interest is over all the printPages() function) -----Messaggio originale----- Da: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] Per conto di Metz, Bobby W, WCS Inviato: gioved? 6 aprile 2006 3.43 A: python-win32 at python.org Oggetto: Re: [python-win32] Acrobat Reader FYI >From the Adobe developer guide... "Use of the ActiveX(r)Control or Netscape plug-in to display a PDF file in an external application besides Internet Explorer or Netscape. The methods used by Acrobat to display a PDF file in Netscape and Internet Explorer are intended only for use with these browsers. Use of the ActiveX Control and Netscape plug-in installed by Adobe Reader is not licensed to other applications. Development with these interfaces is not supported and no documentation is available." This is the AcroPDF.PDF class as best I can tell. There's another dispatchable 7.0 class that doesn't crash Python called AcroExch.Document but I can't find any documentation on it's methods and Open and FileOpen as used by other Acro classes don't respond. Bobby -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Tim Roberts Sent: Wednesday, April 05, 2006 11:39 AM To: python-win32 at python.org Subject: Re: [python-win32] Acrobat Reader On Wed, 5 Apr 2006 09:15:16 +0200, "Mirco Furlan (Visionee)" wrote: >I'm trying to use an instance of Adobe Acrobat Reader. I can successfull >create an instance with win32com.client.Dispatch, > How did you do that? To my knowledge, the only way to do that is to use AcroExch.App, which is only exposed by the full Acrobat product, not the Reader. As far as I know, the standalone Reader application simply cannot be controlled via COM. There is an ActiveX control, but that's a bigger deal. >but when I try to load a >document, python crashes! I had version 7 of Reader and I tried to install >an older version (6.1), but same result. I would use it to print pdf >documents with its methods (in particular PrintPages(..) ). Is there some >known problem? Any suggestion or alternative solution will appreciate. > The Acrobat ActiveX wrapper in wxPython explodes with version 7, deep within Acrobat, where it has never done so before. The problem has not been isolated yet. The only reliable and portable way to do what you ask is to fire up the reader from a command line. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From mrmaple at gmail.com Thu Apr 6 09:24:38 2006 From: mrmaple at gmail.com (James Carroll) Date: Thu, 6 Apr 2006 03:24:38 -0400 Subject: [python-win32] Word COM, then paste into word app. Message-ID: I would like to try to do something with wxPython that I've seen a commercial app do... The app was a statistical analysis program, and it would display results in a richly formatted way, then would paste into word perfectly. I'd like to show a read-only, but dynamically generated small word document in wxPython (should be easyish) Next, I'd like to copy the contents of this to the clipboard with all formatting so that the word application can paste it into another document. What do you think? Where can I find documentation on word's com interface so I can look for a wordocument.Copy() method? Thanks, -Jim From amonroe at columbus.rr.com Thu Apr 6 12:45:52 2006 From: amonroe at columbus.rr.com (R. Alan Monroe) Date: Thu, 6 Apr 2006 06:45:52 -0400 Subject: [python-win32] R: Acrobat Reader In-Reply-To: <000001c65945$a81790d0$3c01a8c0@MFURLAN> References: <000001c65945$a81790d0$3c01a8c0@MFURLAN> Message-ID: <197899260368.20060406064552@columbus.rr.com> > Thank's to all. I think I continue to use an IE instance, load the pdf as > url and so with a reference to IE.Document I have my pdf document to > manipulate (this time my interest is over all the printPages() function) Did you look at third party readers like the one from http://www.foxitsoftware.com/pdf/rd_intro.php ? No idea about it's COM abilities, but might be worth a look. Alan From emlynj at gmail.com Thu Apr 6 13:48:17 2006 From: emlynj at gmail.com (Emlyn Jones) Date: Thu, 6 Apr 2006 12:48:17 +0100 Subject: [python-win32] Windows Service Parameters Message-ID: Hello, Does anybody have an example of getting hold of the "start parameters" in a Python windows service? I was half expecting them to be passed to SvcDoRun but I can't see that they are. Cheers, Emlyn. From mc at mclaveau.com Thu Apr 6 14:50:29 2006 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 6 Apr 2006 14:50:29 +0200 Subject: [python-win32] R: Acrobat Reader References: <000001c65945$a81790d0$3c01a8c0@MFURLAN> <197899260368.20060406064552@columbus.rr.com> Message-ID: <00ed01c65978$b2129e30$0701a8c0@PORTABLES> Hi! >>> Foxit-software The free version of FoxIt reader no has COM possibilities. AMHA, the best way is, like Roger Upole said, to use I.E. and navigate on the PDF-document. You can use standalone I.E., ou the ActiveX I.E. componant. @-salutations Michel Claveau From timr at probo.com Thu Apr 6 21:04:40 2006 From: timr at probo.com (Tim Roberts) Date: Thu, 06 Apr 2006 12:04:40 -0700 Subject: [python-win32] Acrobat Reader In-Reply-To: References: Message-ID: <44356648.1050506@probo.com> On Wed, 5 Apr 2006 11:55:18 -0600, "Waldemar Osuch" wrote: >I know Dispatch used to work with the Reader. Did Adobe broke the >Reader to force us to pay for the full version or is it pythoncom at >fault here? The Acrobat 5 Reader exposed an AcroExch.App object, but (according to Google) was an accident. They didn't mean to expose that unless you had purchsed the full product. >But then again I have working .Net application that uses Reader to >display files. >I did not write the .Net one so do not ask me how it does it :-) . >But I do have source and could try to find out. That would be interesting to know. If it is using it as a hosted ActiveX control, rather than a simple COM object, that could be the difference. >>> The Acrobat ActiveX wrapper in wxPython explodes with version 7, deep >>> within Acrobat, where it has never done so before. The problem has not >>> been isolated yet. > >It is the same issue. I think. The failure mode is different. The AcroPDF.PDF / LoadFile thing crashes very early, only about two calls deep into acropdf.dll, dereferencing a null pointer. Is it possible that the LoadFile API requires some other parameter that is defaulting to NULL? >>> >>> The only reliable and portable way to do what you ask is to fire up the >>> reader from a command line. > >Yes but then you can not control it at all. There is a command-line parameter asking it to print the file immediately. For many purposes, that is enough. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From waldemar.osuch at gmail.com Thu Apr 6 21:46:19 2006 From: waldemar.osuch at gmail.com (Waldemar Osuch) Date: Thu, 6 Apr 2006 13:46:19 -0600 Subject: [python-win32] Acrobat Reader In-Reply-To: <44356648.1050506@probo.com> References: <44356648.1050506@probo.com> Message-ID: <6fae95540604061246h13b0f848s765592f179392367@mail.gmail.com> On 4/6/06, Tim Roberts wrote: > On Wed, 5 Apr 2006 11:55:18 -0600, "Waldemar Osuch" > wrote: > > >I know Dispatch used to work with the Reader. Did Adobe broke the > >Reader to force us to pay for the full version or is it pythoncom at > >fault here? > > The Acrobat 5 Reader exposed an AcroExch.App object, but (according to > Google) was an accident. They didn't mean to expose that unless you had > purchsed the full product. > > >But then again I have working .Net application that uses Reader to > >display files. > >I did not write the .Net one so do not ask me how it does it :-) . > >But I do have source and could try to find out. > > That would be interesting to know. If it is using it as a hosted ActiveX > control, rather than a simple COM object, that could be the difference. > I did try but I'm over my head. Nothing beats reading Python code :-) This is what I found out: The .Net solution has two Acrobat related references: - AcroPDFLib with name: Interop.AcroPDFLib - AcAcroPDFLib with name: AxInterop.AcroPDFLib The control is instantiated like this: this.axPdfBrowser = new AxAcroPDFLib.AxAcroPDF(); and initialized like this: this.axPdfBrowser.ContainingControl = this; this.axPdfBrowser.Dock = System.Windows.Forms.DockStyle.Fill; this.axPdfBrowser.Enabled = true; this.axPdfBrowser.Location = new System.Drawing.Point(2, 2); this.axPdfBrowser.Name = "axPdfBrowser"; this.axPdfBrowser.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axPdfBrowser.OcxState"))); this.axPdfBrowser.Size = new System.Drawing.Size(729, 376); this.axPdfBrowser.TabIndex = 12; this.axPdfBrowser.Visible = false; Also I found this article explaining how to use it from MFC. Does it make sense? http://www.codeproject.com/miscctrl/acroview.asp > >>> The Acrobat ActiveX wrapper in wxPython explodes with version 7, deep > >>> within Acrobat, where it has never done so before. The problem has not > >>> been isolated yet. > > > >It is the same issue. I think. > > The failure mode is different. The AcroPDF.PDF / LoadFile thing crashes > very early, only about two calls deep into acropdf.dll, dereferencing a > null pointer. Is it possible that the LoadFile API requires some other > parameter that is defaulting to NULL? > > >>> > >>> The only reliable and portable way to do what you ask is to fire up the > >>> reader from a command line. > > > >Yes but then you can not control it at all. > > > There is a command-line parameter asking it to print the file > immediately. For many purposes, that is enough. > I have tried the suggestion to control the Reader using InternetExplorer and it works nicely. Waldemar From mli at deform.com Fri Apr 7 02:06:21 2006 From: mli at deform.com (Michael Li) Date: Thu, 06 Apr 2006 20:06:21 -0400 Subject: [python-win32] Runnin Python app as service with separate console In-Reply-To: <6fae95540604051220m5613d59dw1df0ab784ed0187c@mail.gmail.com> References: <325A5361CB7EE5439FA9978CBB9D006F01136F00@MUNI-MAIL.muni.sfgov.org> <4433F4D9.6020204@alum.rpi.edu> <6fae95540604051220m5613d59dw1df0ab784ed0187c@mail.gmail.com> Message-ID: <4435ACFD.4040706@deform.com> > Although it is not obvious from Twisted documentation it is trivial to > run an application as a windows service as long as you use *.tac files > to build it. Can you share your code ? I also have an application using Twisted, but I got problems to run as a service. Thank you very much. Waldemar Osuch wrote: >>Morgan, Byron wrote: >> >>>I have a robust, stable Python script that runs 24-7, crunching a telnet >>>feed of real-time data. Problem is, it has to run in a dos console >>>window on the desktop. I would like to run it as a service, and be able >>>connect to it and monitor performance with a separate console (either >>>gui or not) from time to time. I'm hoping for advice on how to proceed. > > > Plenty of advice. > Here is my 2 cents. > For last couple of years I run a windows service based on Twisted framework. > One of the almost build in features of the framework is that you can > telnet to the live running service, check the status or even tweak it > while it runs. > The framework handles multitude of protocols as a client and a server > and TELNET is included. > My service even utilizes built in web server to show the status of the > running application. > Although it is not obvious from Twisted documentation it is trivial to > run an application as a windows service as long as you use *.tac files > to build it. > > Waldemar > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 ========== This email message and any attachments are for the sole use of the intended recipients and may contain proprietary and/or confidential information which may be privileged or otherwise protected from disclosure. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipients, please contact the sender by reply email and destroy the original message and any copies of the message as well as any attachments to the original message. From mhammond at skippinet.com.au Fri Apr 7 03:26:06 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 7 Apr 2006 11:26:06 +1000 Subject: [python-win32] Windows Service Parameters In-Reply-To: Message-ID: > Hello, > Does anybody have an example of getting hold of the "start parameters" > in a Python windows service? > I was half expecting them to be passed to SvcDoRun but I can't see > that they are. Not an example - but they are passed to your service's __init__ function. Most of the examples don't show that - so you need: class MyService(win32serviceutil.ServiceFramework): ... def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) # use args - args[0] is the "service name" Also note that no one persists these service arguments - so entering them into the service manager means they get passed as you start the service that once - they will not be passed in the future as the serivce starts normally. For this reason it is common for your code to write the args to the registry so you can see them next time. win32serviceutil.Set/GetServiceCustomOption may help (but obviously you can persist them any way you choose) Mark From waldemar.osuch at gmail.com Fri Apr 7 04:14:51 2006 From: waldemar.osuch at gmail.com (Waldemar Osuch) Date: Thu, 6 Apr 2006 20:14:51 -0600 Subject: [python-win32] Runnin Python app as service with separate console In-Reply-To: <4435ACFD.4040706@deform.com> References: <325A5361CB7EE5439FA9978CBB9D006F01136F00@MUNI-MAIL.muni.sfgov.org> <4433F4D9.6020204@alum.rpi.edu> <6fae95540604051220m5613d59dw1df0ab784ed0187c@mail.gmail.com> <4435ACFD.4040706@deform.com> Message-ID: <6fae95540604061914m38819159u95247a7b0171554c@mail.gmail.com> On 4/6/06, Michael Li wrote: > > Although it is not obvious from Twisted documentation it is trivial to > > run an application as a windows service as long as you use *.tac files > > to build it. > > Can you share your code ? > > I also have an application using Twisted, but I got problems to run as a > service. I am using py2exe with custom setup.py file. Additionally I have startup.tac and winservice.py - startup.tac - if you know Twisted then you know what goes into startup.tac :-). - winservice.py - is the stub file that gets compiled into winservice.exe. This is the file that you will register with Windows. winservice.exe -h will list all the options. I do not remember them at them moment. - setup.py - is almost standard setup file. You run it with python setup.py py2exe. The trick is to list all required modules explicitly. I list all except the modules that hold my Twisted application logic. The advantage is that I can replace the modules without recompiling. Only restart the service and the bug fix is implemented. Your admin will love you for that :-) The only problem is if you missed a required module the service will die silently when starting. Luckily the Python traceback gets recorded in Windows Application Log. Check it to see what the service is complaining about, add the missing part, rinse and repeat. See the attached files for an example. The original idea comes from: http://twistedmatrix.com/trac/browser/sandbox/moonfallen/ See it for more documentation. -------------- next part -------------- A non-text attachment was scrubbed... Name: winservice.py Type: text/x-python Size: 1580 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20060406/008105d3/attachment-0002.py -------------- next part -------------- A non-text attachment was scrubbed... Name: startup.tac Type: application/octet-stream Size: 1827 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20060406/008105d3/attachment-0001.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: setup.py Type: text/x-python Size: 2025 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20060406/008105d3/attachment-0003.py From emlynj at gmail.com Fri Apr 7 15:56:29 2006 From: emlynj at gmail.com (Emlyn Jones) Date: Fri, 7 Apr 2006 14:56:29 +0100 Subject: [python-win32] Windows Service Parameters In-Reply-To: References: Message-ID: On 4/7/06, Mark Hammond wrote: > > Hello, > > Does anybody have an example of getting hold of the "start parameters" > > in a Python windows service? > > I was half expecting them to be passed to SvcDoRun but I can't see > > that they are. > > Not an example - but they are passed to your service's __init__ function. > Most of the examples don't show that - so you need: > > class MyService(win32serviceutil.ServiceFramework): > ... > def __init__(self, args): > win32serviceutil.ServiceFramework.__init__(self, args) > # use args - args[0] is the "service name" > > Also note that no one persists these service arguments - so entering them > into the service manager means they get passed as you start the service that > once - they will not be passed in the future as the serivce starts normally. > > For this reason it is common for your code to write the args to the registry > so you can see them next time. win32serviceutil.Set/GetServiceCustomOption > may help (but obviously you can persist them any way you choose) > > Mark > > Hello, thanks for the reply. Ok. That makes sense. The non persistance will explain why my testing with args to __init__ didn't show anything. Thanks Mark. Cheers, Emlyn. P.S I mailed to this list a little while ago about some problems with the debugger and Python/ASP; I am still intending to revist the "hacks" I made to get it working, I'll drop you a mail detailing them when I get round to it. From floris.vannee at gmail.com Fri Apr 7 19:34:49 2006 From: floris.vannee at gmail.com (Floris van Nee) Date: Fri, 7 Apr 2006 19:34:49 +0200 Subject: [python-win32] com server Message-ID: <2302ac370604071034x27a0d350od8694e82eee2cfa8@mail.gmail.com> Hi, Is it possible to create a com server in python and then access that server using VB .NET, for example using the following code. A very basic com server i found in a tutorial about win32com: class HelloWorld: _reg_clsid_ = "{7CC9F362-486D-11D1-BB48-0000E838A65F}" _reg_desc_ = "Python Test COM Server" _reg_progid_ = "Python.TestServer" # Next line assumes file is "testcomserver.py" _reg_class_spec_ = "testcomserver.HelloWorld" _public_methods_ = ['Hello'] _public_attrs_ = ['softspace', 'noCalls'] _readonly_attrs_ = ['noCalls'] def __init__(self): self.softspace = 1 self.noCalls = 0 def Hello(self, who): self.noCalls = self.noCalls + 1 # insert "softspace" number of spaces return "Hello" + " " * self.softspace + who if __name__=='__main__': import win32com.server.register win32com.server.register.UseCommandLine(HelloWorld) When I run it it says: '>>> Registered: Python.TestServer ' But how can I access that server now from VB .NET (if it's possible). Or do I need to use very different python code? Thanks in advance, Floris van Nee -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060407/d5632457/attachment.htm From mc at mclaveau.com Fri Apr 7 20:57:22 2006 From: mc at mclaveau.com (Michel Claveau) Date: Fri, 7 Apr 2006 20:57:22 +0200 Subject: [python-win32] com server References: <2302ac370604071034x27a0d350od8694e82eee2cfa8@mail.gmail.com> Message-ID: <003401c65a75$1cf7c070$0701a8c0@PORTABLES> Hi! I don't know for VB.NET; but, with C-Sharp (C#) it's possible. After some research, I found that a technique called had to be used: "Late Binding" @-salutations -- Michel Claveau From alexci at gmx.net Sun Apr 9 11:41:02 2006 From: alexci at gmx.net (Aleksandar Cikota) Date: Sun, 9 Apr 2006 11:41:02 +0200 (Central European Daylight Time) Subject: [python-win32] Code help Message-ID: <4438D6AE.000007.01216@CIKOTA-TM4U7QQ2> Hi all, I started to write a software for our future robotic telescope in Python. We decided that we will use FocusMax for focusing: http://users.bsdwebsolutions.com/~larryweber/ but I have a problem with focusing. FocusMax.FocusControl.Focus starts the auto focus operation and returns when Focus is complete. This Method has the same effect as if the user clicked the Focus button on the Focus tab (in FocusMax), but there is no reaction and I don't get any error message. It works in Visual Basic Script, I have tryed it, but it doesn't work in Python. Why? I'm a beginner in programming and I hope that You can help me. I have send you a part of the code in Python. It should work, but it doesn't I think the problem is here: FM = win32com.client.Dispatch('FocusMax.FocusControl'), but I don't know what is the problem. Python code: import win32com.client FM = win32com.client.Dispatch('FocusMax.FocusControl') FM.Focus VBScript (that works): Set FM = CreateObject("FocusMax.FocusControl") FM.Focus I would be very thankful, if you try to help me! For your prompt reply, I say thank you in advance. Best regards, Aleksandar Cikota (Croatia) ----------------------------------------- Aleksandar Cikota MSN: Aleksandar_Cikota at hotmail.com SkyPe: Aleksandar_Cikota e-mail: alexci at gmx.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060409/c0377025/attachment.html From rwupole at msn.com Sun Apr 9 12:54:32 2006 From: rwupole at msn.com (Roger Upole) Date: Sun, 9 Apr 2006 06:54:32 -0400 Subject: [python-win32] Re: Code help References: <4438D6AE.000007.01216@CIKOTA-TM4U7QQ2> Message-ID: Aleksandar Cikota wrote: > Python code: > import win32com.client > FM = win32com.client.Dispatch('FocusMax.FocusControl') > FM.Focus Use FM.Focus(). You need the parens to actually call the function. In Python, FM.Focus just returns a reference to the Focus method rather than calling the method. hth Roger From justin.mailinglists at gmail.com Mon Apr 10 04:13:08 2006 From: justin.mailinglists at gmail.com (Justin Ezequiel) Date: Mon, 10 Apr 2006 10:13:08 +0800 Subject: [python-win32] Code help (Aleksandar Cikota) Message-ID: <3c6718980604091913y2f35ca35n9d5d7871015e8832@mail.gmail.com> FocusMax.FocusControl.Focus starts the auto focus operation and returns when Focus is complete. This Method has the same effect as if the user clicked the Focus button on the Focus tab (in FocusMax), but there is no reaction and I don't get any error message. Python code: FM.Focus() # you need the parentheses to call the method in VBScript, the parentheses are not required I sometimes forget the parentheses too when porting VB COM code to Python From timr at probo.com Mon Apr 10 06:24:54 2006 From: timr at probo.com (timr at probo.com) Date: Sun, 9 Apr 2006 21:24:54 -0700 Subject: [python-win32] Code help Message-ID: <20060409212454.A21611@probo.com> On Sun, 9 Apr 2006 11:41:02, "Aleksandar Cikota" wrote: > > > FocusMax.FocusControl.Focus starts the auto focus operation and returns when > Focus is complete. This Method has the same effect as if the user clicked > the Focus button on the Focus tab (in FocusMax), but there is no reaction > and I don't get any error message. > > It works in Visual Basic Script, I have tryed it, but it doesn't work in > Python. Why? I'm a beginner in programming and I hope that You can help me. > I have send you a part of the code in Python. It should work, but it doesn't > > Python code: > import win32com.client > FM = win32com.client.Dispatch('FocusMax.FocusControl') > FM.Focus > > VBScript (that works): > Set FM = CreateObject("FocusMax.FocusControl") > FM.Focus VB allows you to use a shortcut to call functions with no parameters, by omitting the parentheses. Python does not. You need to use: FM.Focus() -- - Tim Roberts, timr at probo.com Providenza & Boeklheide, Inc. From bgailer at alum.rpi.edu Mon Apr 10 07:36:45 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Sun, 09 Apr 2006 22:36:45 -0700 Subject: [python-win32] Code help (Aleksandar Cikota) In-Reply-To: <3c6718980604091913y2f35ca35n9d5d7871015e8832@mail.gmail.com> References: <3c6718980604091913y2f35ca35n9d5d7871015e8832@mail.gmail.com> Message-ID: <4439EEED.6050401@alum.rpi.edu> Justin Ezequiel wrote: > FocusMax.FocusControl.Focus starts the auto focus operation and returns when > Focus is complete. This Method has the same effect as if the user clicked > the Focus button on the Focus tab (in FocusMax), but there is no reaction > and I don't get any error message. > > Python code: > FM.Focus() # you need the parentheses to call the method > > in VBScript, the parentheses are not required > This also points out a strength of Python over VB: Python lets one refer to function objects. VB does not. I can for example create a list or dictionary of functions. > I sometimes forget the parentheses too when porting VB COM code to Python > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > From alexci at gmx.net Mon Apr 10 13:18:04 2006 From: alexci at gmx.net (Aleksandar Cikota) Date: Mon, 10 Apr 2006 13:18:04 +0200 (Central European Daylight Time) Subject: [python-win32] Python-win32 Digest, Vol 37, Issue 10 References: Message-ID: <443A3EEC.000001.00524@CIKOTA-TM4U7QQ2> Thank You! I have also found this: Always Use Parentheses to Call a Function You must add parentheses after a function name to call it, whether it takes arguments or not. That is, use function(), not function. Python functions are simply objects that have a special operation, a call, that you trigger with the parentheses. Like all objects, they can also be assigned to variables, and used indirectly: x = function; x(). In Python training, this seems to occur most often with files. It's common to see beginners type file.close to close a file, rather than file.close(); because it's legal to reference a function without calling it, the first version without parenthesis succeeds silently, but does not close the file! Regards, Aleksandar -------Original Message------- From: python-win32-request at python.org Date: 04/10/06 12:03:16 To: python-win32 at python.org Subject: Python-win32 Digest, Vol 37, Issue 10 Send Python-win32 mailing list submissions to python-win32 at python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/python-win32 or, via email, send a message with subject or body 'help' to python-win32-request at python.org You can reach the person managing the list at python-win32-owner at python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Python-win32 digest..." Today's Topics: 1. Re: Code help (Roger Upole) 2. Re: Code help (Aleksandar Cikota) (Justin Ezequiel) 3. Re: Code help (timr at probo.com) 4. Re: Code help (Aleksandar Cikota) (Bob Gailer) ---------------------------------------------------------------------- Message: 1 Date: Sun, 9 Apr 2006 06:54:32 -0400 From: "Roger Upole" Subject: [python-win32] Re: Code help To: Message-ID: Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Aleksandar Cikota wrote: > Python code: > import win32com.client > FM = win32com.client.Dispatch('FocusMax.FocusControl') > FM.Focus Use FM.Focus(). You need the parens to actually call the function. In Python, FM.Focus just returns a reference to the Focus method rather than calling the method. hth Roger ------------------------------ Message: 2 Date: Mon, 10 Apr 2006 10:13:08 +0800 From: "Justin Ezequiel" Subject: Re: [python-win32] Code help (Aleksandar Cikota) To: python-win32 at python.org Message-ID: <3c6718980604091913y2f35ca35n9d5d7871015e8832 at mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 FocusMax.FocusControl.Focus starts the auto focus operation and returns when Focus is complete. This Method has the same effect as if the user clicked the Focus button on the Focus tab (in FocusMax), but there is no reaction and I don't get any error message. Python code: FM.Focus() # you need the parentheses to call the method in VBScript, the parentheses are not required I sometimes forget the parentheses too when porting VB COM code to Python ------------------------------ Message: 3 Date: Sun, 9 Apr 2006 21:24:54 -0700 From: timr at probo.com Subject: Re: [python-win32] Code help To: python-win32 at python.org Cc: Tim Roberts Message-ID: <20060409212454.A21611 at probo.com> Content-Type: text/plain; charset=us-ascii On Sun, 9 Apr 2006 11:41:02, "Aleksandar Cikota" wrote: > > > FocusMax.FocusControl.Focus starts the auto focus operation and returns when > Focus is complete. This Method has the same effect as if the user clicked > the Focus button on the Focus tab (in FocusMax), but there is no reaction > and I don't get any error message. > > It works in Visual Basic Script, I have tryed it, but it doesn't work in > Python. Why? I'm a beginner in programming and I hope that You can help me > I have send you a part of the code in Python. It should work, but it doesn t > > Python code: > import win32com.client > FM = win32com.client.Dispatch('FocusMax.FocusControl') > FM.Focus > > VBScript (that works): > Set FM = CreateObject("FocusMax.FocusControl") > FM.Focus VB allows you to use a shortcut to call functions with no parameters, by omitting the parentheses. Python does not. You need to use: FM.Focus() -- - Tim Roberts, timr at probo.com Providenza & Boeklheide, Inc. ------------------------------ Message: 4 Date: Sun, 09 Apr 2006 22:36:45 -0700 From: Bob Gailer Subject: Re: [python-win32] Code help (Aleksandar Cikota) To: Justin Ezequiel Cc: python-win32 at python.org Message-ID: <4439EEED.6050401 at alum.rpi.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Justin Ezequiel wrote: > FocusMax.FocusControl.Focus starts the auto focus operation and returns when > Focus is complete. This Method has the same effect as if the user clicked > the Focus button on the Focus tab (in FocusMax), but there is no reaction > and I don't get any error message. > > Python code: > FM.Focus() # you need the parentheses to call the method > > in VBScript, the parentheses are not required > This also points out a strength of Python over VB: Python lets one refer to function objects. VB does not. I can for example create a list or dictionary of functions. > I sometimes forget the parentheses too when porting VB COM code to Python > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > ------------------------------ _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 End of Python-win32 Digest, Vol 37, Issue 10 ******************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060410/e773bef2/attachment.htm From bwmetz at att.com Mon Apr 10 18:04:02 2006 From: bwmetz at att.com (Metz, Bobby W, WCS) Date: Mon, 10 Apr 2006 11:04:02 -0500 Subject: [python-win32] Embed PyCWnd in Tkinter Frame? Message-ID: <01D5341D04A2E64AB9B34576904733670199622D@OCCLUST01EVS1.ugd.att.com> I've been searching for this all weekend and can't find what I consider a straight answer. I have an existing Tkinter app which automates IE but I'd really like to embed IE in a Tkinter frame but don't want to have to completely re-write the app. I see it appears fairly easy to activate an ActiveX control using wxPython or Pythonwin. Is it impossible to somehow wrap a Pythonwin PyCWnd into a Tkinter frame so that I can utilize win32ui.CreateControl to initiate an IE control in my app? Thanks, Bobby From edahl at confmon.com Mon Apr 10 22:42:39 2006 From: edahl at confmon.com (Erik Dahl) Date: Mon, 10 Apr 2006 16:42:39 -0400 Subject: [python-win32] WMI Performance API Message-ID: <95B0F427-E577-476A-AEB5-0A28336D832E@confmon.com> I want to use the WMI Performance API to collect performance information from remote boxes. To do this I need to create a WbemScripting. SWbemRefresher object like so: objRefresher = CreateObject("WbemScripting.SWbemRefresher") Is CreateObject something that is available from python (I have looked around but don't see it). Or maybe there is another way to do the same thing? As an aside there are other APIs for getting to the performance info. (I know this is a bit off topic) but does anyone know of the benefits or drawbacks to the different APIs. Clearly if I can't make my refresher object the WMI API is out. The Pdh stuff looks usable but not sure yet how this can be called remotely... -EAD From mhammond at skippinet.com.au Tue Apr 11 00:13:19 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 11 Apr 2006 08:13:19 +1000 Subject: [python-win32] Embed PyCWnd in Tkinter Frame? In-Reply-To: <01D5341D04A2E64AB9B34576904733670199622D@OCCLUST01EVS1.ugd.att.com> Message-ID: > I've been searching for this all weekend and can't find > what I consider a straight answer. I have an existing Tkinter > app which automates IE but I'd really like to embed IE in a > Tkinter frame but don't want to have to completely re-write the > app. I see it appears fairly easy to activate an ActiveX control > using wxPython or Pythonwin. Is it impossible to somehow wrap a > Pythonwin PyCWnd into a Tkinter frame so that I can utilize > win32ui.CreateControl to initiate an IE control in my app? To the best of my knowledge, that has never been done. Pythonwin and Tkinter struggle to coexist in the same process, let alone the same window :( Mark From mhammond at skippinet.com.au Tue Apr 11 00:13:23 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 11 Apr 2006 08:13:23 +1000 Subject: [python-win32] WMI Performance API In-Reply-To: <95B0F427-E577-476A-AEB5-0A28336D832E@confmon.com> Message-ID: > I want to use the WMI Performance API to collect performance > information from remote boxes. To do this I need to create a > WbemScripting. SWbemRefresher object like so: > > objRefresher = CreateObject("WbemScripting.SWbemRefresher") > > Is CreateObject something that is available from python (I have > looked around but don't see it). Or maybe there is another way to do > the same thing? win32com.client.Dispatch() is the equivalent: import win32com.client ob = win32com.client.Dispatch("WbemScripting.SWbemRefresher") However, a quick google should have told you that (searching for 'python wmi' on google shows lots of relevant hits) > As an aside there are other APIs for getting to the performance > info. (I know this is a bit off topic) but does anyone know of the > benefits or drawbacks to the different APIs. Clearly if I can't make > my refresher object the WMI API is out. The Pdh stuff looks usable > but not sure yet how this can be called remotely... Many of the relevant functions have a 'machine' param which is the name of the machine the function should operate on - again 'python pdh' at google lists relevant results. Mark From mli at deform.com Tue Apr 11 01:53:29 2006 From: mli at deform.com (Michael Li) Date: Mon, 10 Apr 2006 19:53:29 -0400 Subject: [python-win32] Runnin Python app as service with separate console In-Reply-To: <6fae95540604061914m38819159u95247a7b0171554c@mail.gmail.com> References: <325A5361CB7EE5439FA9978CBB9D006F01136F00@MUNI-MAIL.muni.sfgov.org> <4433F4D9.6020204@alum.rpi.edu> <6fae95540604051220m5613d59dw1df0ab784ed0187c@mail.gmail.com> <4435ACFD.4040706@deform.com> <6fae95540604061914m38819159u95247a7b0171554c@mail.gmail.com> Message-ID: <443AEFF9.6070805@deform.com> Hi, Waldemar In my previous email, I got -------------------------begin--------------------- Your mail to 'Python-win32' with the subject Re: [python-win32] Runnin Python app as service with separate console Is being held until the list moderator can review it for approval. The reason it is being held: Message body is too big: 119956 bytes with a limit of 30 KB -------------------------end--------------------- So I resend my previous email without big attachments again. --------------------------previous email start------------------- Thank you very much for your code. I still have difficulties to run my python application as a service well. What I am trying to do is something like : C:\python23\python.exe my_server.py -3 --pid=pid.file --slog=log.file >run_log.file When I open a DOS window, run the above command, no problem at all. When I try to put it into a service, I got problem. "install_3d_app_service.cpp" is a program to install sftc3win.exe(sftc_3d_app_service.cpp) into a Windows' service. Inside sftc_3d_app_service.cpp, it will spawn "python". After reboot the machine, no problem, everything works fine, please see attached picture python_running.JPG. The problem is that after I log off, the "python" has gone. Even if I log in as a non-administrative account, I log off, then the "python" has gone, even I am in the session of non-administrative account, I can not terminate(End Process) the "python" process. I am totally confused by this. I also can use Windows' Scheduled Tasks to add a task as "At System startup", I can run it as a service, but after I log in/log off any account, the "python" service has gone. Can you or someone else point me a direction how to solve the problem? Or I am in the wrong direction, I have to use the same way as you described ? One thing I want to mention is that my python scripts work at linux too, and I want to keep it run at the DOS window for easier debugging. I am using python2.3. Best regards. Michael Li Waldemar Osuch wrote: > On 4/6/06, Michael Li wrote: > >> > Although it is not obvious from Twisted documentation it is trivial to >> > run an application as a windows service as long as you use *.tac files >> > to build it. >> >>Can you share your code ? >> >>I also have an application using Twisted, but I got problems to run as a >>service. > > > I am using py2exe with custom setup.py file. > Additionally I have startup.tac and winservice.py > - startup.tac - if you know Twisted then you know what goes into > startup.tac :-). > - winservice.py - is the stub file that gets compiled into > winservice.exe. This is the file that you will register with Windows. > winservice.exe -h will list all the options. I do not remember them > at them moment. > - setup.py - is almost standard setup file. You run it with python > setup.py py2exe. The trick is to list all required modules > explicitly. I list all except the modules that hold my Twisted > application logic. The advantage is that I can replace the modules > without recompiling. Only restart the service and the bug fix is > implemented. Your admin will love you for that :-) > The only problem is if you missed a required module the service will > die silently when starting. Luckily the Python traceback gets > recorded in Windows Application Log. > Check it to see what the service is complaining about, add the missing > part, rinse and repeat. > > See the attached files for an example. > The original idea comes from: > http://twistedmatrix.com/trac/browser/sandbox/moonfallen/ > See it for more documentation. > > > ------------------------------------------------------------------------ > > import sys > import os > > import win32serviceutil, win32service > > basecf = "startup.tac" > cftype = "python" > svcname = "dispatcher" > display = "Twisted Task Dispatcher" > reactortype = "default" > > class ServiceControl(win32serviceutil.ServiceFramework): > > _svc_name_ = svcname > _svc_display_name_ = display > > def SvcDoRun(self): > from twisted.application import app > app.installReactor(reactortype) > > from twisted.internet import reactor > from twisted.application import service > from twisted.python import util, log, logfile > > # look for a readable config file > for cf in (util.sibpath(sys.executable, basecf), > util.sibpath(__file__, basecf), > basecf): > try: > open(cf, 'r').close() > except EnvironmentError: > continue > else: > startdir = os.path.dirname(cf) > os.chdir(startdir) > sys.path.insert(0, startdir) > break > > lf = logfile.LogFile('%s.log' %svcname, 'logs') > log.startLogging(lf) > log.msg("Loading application from %s" % cf) > > service_app = service.loadApplication(cf, cftype) > app.startApplication(service_app , False) > reactor.run(installSignalHandlers=0) > > def SvcStop(self): > self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) > from twisted.internet import reactor > reactor.callFromThread(reactor.stop) > > > if __name__ == '__main__': > win32serviceutil.HandleCommandLine(ServiceControl) > > > ------------------------------------------------------------------------ > > import sys > > # without this section taskscheduler can not be found > import py2exe.mf as modulefinder > import win32com > for p in win32com.__path__[1:]: > modulefinder.AddPackagePath('win32com', p) > for extra in ['win32com.taskscheduler']: > __import__(extra) > m = sys.modules[extra] > for p in m.__path__[1:]: > modulefinder.AddPackagePath(extra, p) > > from distutils.core import setup > import py2exe > > > setup(service = ['winservice'], > zipfile = "lib/library.zip", > data_files = (('', ['startup.tac', > 'config.ini', > 'backend.py', > 'dbloader.py', > 'dispatcher.py', > 'xlsparser.py', > ]), > ('wsdl', ['wsdl/MFISLoader.wsdl',]), > ('logs', []), > ), > options = {'global': {'verbose': '0'}, > 'py2exe': {'optimize': 2, > 'dist_dir': 'dispatcher', > 'excludes': ['perfmon'], > 'dll_excludes': [], > 'packages': ['twisted.application', > 'twisted.python', > 'twisted.web', > 'elementtree', > 'pyExcelerator', > ], > 'includes': ['datetime', > 'pythoncom', > 'cElementTree', > 'cx_Oracle', > 'twisted.mail.smtp', > 'utils.batch', > 'win32com.taskscheduler.taskscheduler', > ], > } > }, > ) ========== This email message and any attachments are for the sole use of the intended recipients and may contain proprietary and/or confidential information which may be privileged or otherwise protected from disclosure. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipients, please contact the sender by reply email and destroy the original message and any copies of the message as well as any attachments to the original message. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: install_3d_app_service.cpp Url: http://mail.python.org/pipermail/python-win32/attachments/20060410/605ef960/attachment-0001.asc -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: sftc_3d_app_service.cpp Url: http://mail.python.org/pipermail/python-win32/attachments/20060410/605ef960/attachment-0001.pot From mhammond at skippinet.com.au Tue Apr 11 02:29:17 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 11 Apr 2006 10:29:17 +1000 Subject: [python-win32] Runnin Python app as service with separateconsole In-Reply-To: <443AEFF9.6070805@deform.com> Message-ID: > "install_3d_app_service.cpp" is a program to install > sftc3win.exe(sftc_3d_app_service.cpp) > into a Windows' service. Inside sftc_3d_app_service.cpp, it will spawn > "python". > After reboot the machine, no problem, everything works fine, please see > attached > picture python_running.JPG. The problem is that after I log off, the > "python" has gone. I'm afraid you don't mention what this spawned Python is supposed to do. Regardless though, it appears that exe is terminating, probably due to an exception. You need to arrange to see the output of this process to see what went wrong. If it is your .cpp implemented service that vanishes, then I've no idea what it could be. > Even if I log in as a non-administrative account, I log off, then the > "python" has gone, > even I am in the session of non-administrative account, I can not > terminate(End Process) > the "python" process. I am totally confused by this. It is normal (but frustrating) you can't kill it as the service is running as LocalSystem. You may have more luck setting it to run as your user. I'm a little confused though, as you seem to say the problem is that the python process has gone - but here you are failing to kill it. > I also can use Windows' Scheduled Tasks to add a task as "At System > startup", I can run > it as a service, but after I log in/log off any account, the "python" > service has gone. The service (implemented in .cpp) has gone, or the child python executable? Same answer as above though... Mark From bwmetz at att.com Tue Apr 11 08:58:35 2006 From: bwmetz at att.com (Metz, Bobby W, WCS) Date: Tue, 11 Apr 2006 01:58:35 -0500 Subject: [python-win32] Embed PyCWnd in Tkinter Frame? In-Reply-To: Message-ID: <01D5341D04A2E64AB9B345769047336701996827@OCCLUST01EVS1.ugd.att.com> Is pythonwin or wxPython the only way to use an ActiveX control then? And for something completely outta left field...is there any way to make the main Tkinter window transparent, i.e. just a window border? If so, a determined individual might be able to intercept move/resize events to literal wrap one's tkinter app around another window. Anyway, guess it looks like I'll have to re-write the app in something else unless someone else has a brilliant suggestion. Thanks, Bobby -----Original Message----- From: Mark Hammond [mailto:mhammond at skippinet.com.au] Sent: Monday, April 10, 2006 3:13 PM To: Metz, Bobby W, WCS; python-win32 at python.org Subject: RE: [python-win32] Embed PyCWnd in Tkinter Frame? > I've been searching for this all weekend and can't find > what I consider a straight answer. I have an existing Tkinter > app which automates IE but I'd really like to embed IE in a > Tkinter frame but don't want to have to completely re-write the > app. I see it appears fairly easy to activate an ActiveX control > using wxPython or Pythonwin. Is it impossible to somehow wrap a > Pythonwin PyCWnd into a Tkinter frame so that I can utilize > win32ui.CreateControl to initiate an IE control in my app? To the best of my knowledge, that has never been done. Pythonwin and Tkinter struggle to coexist in the same process, let alone the same window :( Mark From tim.golden at viacom-outdoor.co.uk Tue Apr 11 09:10:01 2006 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue, 11 Apr 2006 08:10:01 +0100 Subject: [python-win32] WMI Performance API Message-ID: [Erik Dahl] | I want to use the WMI Performance API to collect performance | information from remote boxes. The WMI stuff needs a certain amount of -- imho -- mildly bizarre plumbing work. To save you the trouble, I've put together a WMI module which I know a few people are using. http://timgolden.me.uk/python/wmi.html There isn't actually an example of the performance counters on the cookbook page (have to do something about that) but my usual advice is: find an example from around the net -- there's loads of them -- and then translate that example into Python. I'm happy to help if there are any difficulties there. Possible places to start looking: http://www.activexperts.com/activmonitor/windowsmanagement/wmi/samples/p erformancecounters/ http://groups.google.com/group/microsoft.public.win32.programmer.wmi?lnk =lr I've just found a not-too-complex example I implemented here in the past. Entire code posted below (sorry for the length): import os, sys import operator import time import smtpmail import wmi THRESHOLD = 30.0 BEST_OF = 3 SERVER = "voctx1" try: server = sys.argv[1] except IndexError: server = SERVER print "Looking on", server, "for processes running over", THRESHOLD, "% for more than", BEST_OF, "secs" c = wmi.WMI (wmi=wmi.connect_server (server=server, user=r"username", password="password")) ## c = wmi.WMI () session = smtpmail.smtp_session () process_info = {} while 1: items_shown = False for p in c.Win32_PerfRawData_PerfProc_Process (): id = long (p.IDProcess) n1, d1 = long (p.PercentProcessorTime), long (p.Timestamp_Sys100NS) n0, d0, so_far = process_info.get (id, (0, 0, [])) try: percent_processor_time = (float (n1 - n0) / float (d1 - d0)) * 100 except ZeroDivisionError: percent_processor_time = 0 if len (so_far) > BEST_OF: so_far.pop () so_far.append (percent_processor_time) process_info[id] = (n1, d1, so_far) average_processor_time = reduce (operator.add, so_far) / len (so_far) if (len (so_far) >= BEST_OF) and (average_processor_time > THRESHOLD): for process in c.Win32_Process (Handle=id): domain, return_value, user = process_owner = process.GetOwner () ## print domain, return_value, user alert_text = "%s running at %d on %s (%s)" % (p.Name, average_processor_time, server, user) smtpmail.send ( recipients=["goldent"], subject=alert_text, message_text = alert_text, session=session ) print str (id).ljust (6), p.Name.ljust (20), average_processor_time items_shown = True if items_shown: print time.sleep (1) TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. 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 mc at mclaveau.com Tue Apr 11 10:34:34 2006 From: mc at mclaveau.com (Michel Claveau) Date: Tue, 11 Apr 2006 10:34:34 +0200 Subject: [python-win32] WMI Performance API References: Message-ID: <000201c65d42$c49b3ad0$0701a8c0@PORTABLES> Hi! Just for info : You have many exemples of WMI with Python, on this MS's site : http://www.microsoft.com/technet/scriptcenter/scripts/python @-salutations Michel Claveau From mli at deform.com Wed Apr 12 01:30:38 2006 From: mli at deform.com (Michael Li) Date: Tue, 11 Apr 2006 19:30:38 -0400 Subject: [python-win32] Runnin Python app as service with separateconsole In-Reply-To: References: Message-ID: <443C3C1E.1090107@deform.com> Hi, Mark Thank you very much. See my answers below. Mark Hammond wrote: >> "install_3d_app_service.cpp" is a program to install >> sftc3win.exe(sftc_3d_app_service.cpp) >> into a Windows' service. Inside sftc_3d_app_service.cpp, it will spawn >> "python". >> After reboot the machine, no problem, everything works fine, please see >> attached >> picture python_running.JPG. The problem is that after I log off, the >> "python" has gone. > > > > I'm afraid you don't mention what this spawned Python is supposed to do. The spawned Python(using Twisted framework) runs 24X7 and when receives a request and spawn another command to run. I can my python scripts from DOS window, something like: C:\python23\python.exe my_server.py -3 --pid=pid.file --slog=log.file >run_log.file > Regardless though, it appears that exe is terminating, probably due to an > exception. You need to arrange to see the output of this process to see > what went wrong. The python.exe is terminated only after log off any account. How do I debug/see the output of this process ? > > If it is your .cpp implemented service that vanishes, then I've no idea what > it could be. sftc3win.exe(sftc_3d_app_service.cpp) will spawn "C:\python23\python.exe my_server.py -3 --pid=pid.file --slog=log.file >run_log.file" sftc3win.exe never vanishes. only python.exe vanished after log in/off any account. From attached picture python_running.JPG, you can see python.exe and sftc3win.exe are running as "SYSTEM". > > >> Even if I log in as a non-administrative account, I log off, then the >> "python" has gone, >> even I am in the session of non-administrative account, I can not >> terminate(End Process) >> the "python" process. I am totally confused by this. > > > > It is normal (but frustrating) you can't kill it as the service is running > as LocalSystem. You may have more luck setting it to run as your user. No, I do not want to kill the process. I want to prove that in the session of non-administrative account, you can not kill it, then how could "log off" kill it ? > > I'm a little confused though, as you seem to say the problem is that the > python process has gone - but here you are failing to kill it. > > >> I also can use Windows' Scheduled Tasks to add a task as "At System >> startup", I can run >> it as a service, but after I log in/log off any account, the "python" >> service has gone. > > > > The service (implemented in .cpp) has gone, or the child python executable? The service (implemented in .cpp) stays there always, only child python executable has gone. > Same answer as above though... > > Mark > From attached project file(VC6), you can build ins3apse.exe/sftc3win.exe, this ins3apse.exe will install sftc3win.exe as a service, when a computer reboots, it will start the python.exe, until now, everything works fine. when I log in any account, no problem, everything works fine. Only after I log off any account, "python.exe" has gone. ========== This email message and any attachments are for the sole use of the intended recipients and may contain proprietary and/or confidential information which may be privileged or otherwise protected from disclosure. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipients, please contact the sender by reply email and destroy the original message and any copies of the message as well as any attachments to the original message. From bumble_bee401 at yahoo.com Wed Apr 12 10:23:47 2006 From: bumble_bee401 at yahoo.com (Randall) Date: Wed, 12 Apr 2006 01:23:47 -0700 (PDT) Subject: [python-win32] How can I run python from within Excel ? Message-ID: <20060412082347.98047.qmail@web38008.mail.mud.yahoo.com> Hi, Is it possible to execute Python scripts from within Excel ? For example, I want to place a button which, when run, executes a python script that opens some external files, reads data, and process the info against the current data in the excel spreadsheet. Any help would be cool! Thanks in advance, Randall __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060412/cad58fd4/attachment.htm From floris.vannee at gmail.com Wed Apr 12 18:34:39 2006 From: floris.vannee at gmail.com (Floris van Nee) Date: Wed, 12 Apr 2006 18:34:39 +0200 Subject: [python-win32] com server and py2exe Message-ID: <2302ac370604120934m52e58751hb574114474be17b5@mail.gmail.com> Hi, I'm trying to convert my Python script, which is a COM server, to an exe file. I'm using py2exe 0.6.5. But I ran into a few problems. After a lot of work I was able to run py2exe on my script and create the exe file. I was able to use exectablename.exe --register and --unregister and it returned text that it registered/unregistered the com server, but I wasn't able to connect to it using VB .NET. VB gave me an error saying that it couldn't create the ActiveX component. The normal python file works normally if I try to import the com object from VB, but the exe doesn't work. So I think there's something I do wrong in the setup file or so, or maybe I have to put something else in my Python file, I dont know, I hope some of you do. Here is my Python script and the setup.py (for py2exe) script: setup.py: from distutils.core import setup import py2exe setup(console=['testcomserver.py'], scripts=['testcomserver.py'], name='testcomserver') actual script: from urllib import urlopen import sys import pythoncom class Runescape1: _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER if hasattr(sys, 'importers'): # In the py2exe-packed version, specify the module.class # to use. In the python script version, python is able # to figure it out itself. _reg_class_spec_ = "__main__.Runescape1" _reg_clsid_ = "{6CF99217-4AE8-486A-9858-BE798F8671BC}" _reg_progid_ = "Python.Runescape1" _public_methods_ = ['Lookup', 'ChangeXP', 'ServerStatus', 'MultiplyString'] _public_attrs_ = ['softspace', 'noCalls'] _readonly_attrs_ = ['noCalls'] def __init__(self): self.softspace = 1 self.noCalls = 0 def Lookup(self, nick): url = "http://hiscore.runescape.com/lang/en/aff/runescape/hiscorepersonal.ws?user1=" + nick f = urlopen(url, 'r').read() search_start = '') f = f[:a] + f[b+1:] for a in range(1,122): search = 'World ' + str(a) + ' ' start = f.find(search) servers += [f[start+6:start+len(search)+4]] if ';Type Wo' in servers: del servers[servers.index(';Type Wo')] servers = servers[:115] + ['116 DOWN'] + servers[115:] for a in servers: servers1 += a + ',' return servers1 def MultiplyString(self, string, times): string = times*string return string if hasattr(sys, 'importers'): # we are running as py2exe-packed executable pythoncom.frozen = 1 if __name__=='__main__': if hasattr(sys, 'importers'): # running as packed executable. if '--register' in sys.argv[1:] or '--unregister' in sys.argv[1:]: # --register and --unregister work as usual import win32com.server.register win32com.server.register.UseCommandLine(Runescape1) else: # start the server. from win32com.server import localserver localserver.main() else: import win32com.server.register win32com.server.register.UseCommandLine(Runescape1) That was my whole file, not all of this is probably needed for an answer, but I thought I'd mail the whole py file. You can ignore every function in the Runescape1 class if you want :P. Thanks in advance, Floris From alexci at gmx.net Thu Apr 13 23:21:26 2006 From: alexci at gmx.net (Aleksandar Cikota) Date: Thu, 13 Apr 2006 23:21:26 +0200 (Central European Daylight Time) Subject: [python-win32] BSTR Message-ID: <443EC0D6.000003.02596@CIKOTA-TM4U7QQ2> Hi all, I'm beginner in Python and need help. I'm writing software for a robotic telescope. For CCD camera control we use MaxIm DL (Diffraction Limited). I have a problem with CCDCamera.SaveImage. Here is the code (Python): import win32com.client, time CCDCamera = win32com.client.Dispatch('MaxIm.CCDCamera') CCDCamera.LinkEnabled = True if CCDCamera.LinkEnabled == False: print 'Failed to start camera.' exp = int(raw_input('Exposition[sec]: ')) CCDCamera.Expose(exp, 1, 0) while CCDCamera.ImageReady == False: time.sleep print 'Done' time.sleep(3) CCDCamera.SaveImage('C:/1.fit') Error message: > File "S:MaxImmaxim.py", line 19, in ? > CCDCamera.SaveImage('C:/1.fit') > File "C:ProgrammePython24Libsite- > packageswin32comclientdynamic.py", line 491, in __getattr__ > raise pythoncom.com_error, details > com_error: (-2147352567, 'Ausnahmefehler aufgetreten.', > (65535, 'MaxIm DL 4', 'Invalid Input', None, 0, 0), None) Here is the answer that we recieved from Diffraction Limited: --------- For CCDCamera.SaveImage, 'Invalid Input' is reported only if the argument is not of an acceptable type. As you are probably aware from looking at the type library, the filename argument is declared as a variant. What the type library doesn't tell you is that the variant must be either a BSTR (unicode string with header) or a reference to a BSTR. Specifically, the 'vt' member of the VARIANT must be either VT_BSTR or VT_BSTR|VT_BYREF. Does python provide any way of influencing how arguments for COM methods are created? If so, you may be able to get this to work. It may be as simple as assigning the string to a variable name instead of passing it as a literal, or perhaps there's something equivalent to a C++ cast operator or a VB 'type' function (CInt, CStr, etc.). This problem is likely to affect any MaxIm DL automation method that takes a string as an argument. --------- The question is, how to convert a String in a BSTR (unicodestring with header)? For your prompt reply, I say thank you in advance. Best regards, Aleksandar Cikota ----------------------------------------- Aleksandar Cikota MSN: Aleksandar_Cikota at hotmail.com SkyPe: Aleksandar_Cikota e-mail: alexci at gmx.net Web page: www.neznamadresu.com/astronomija -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060413/5ac13d72/attachment.html From mhammond at skippinet.com.au Fri Apr 14 00:35:08 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 14 Apr 2006 08:35:08 +1000 Subject: [python-win32] BSTR In-Reply-To: <443EC0D6.000003.02596@CIKOTA-TM4U7QQ2> Message-ID: > The question is, how to convert a String in a BSTR (unicodestring with > header)? Python will *always* (unless an object's typelib indicated otherwise) pass a VT_BSTR when a string literal is specified. I'm afraid I can't speculate on what the problem may otherwise be. Mark From timr at probo.com Fri Apr 14 19:41:23 2006 From: timr at probo.com (Tim Roberts) Date: Fri, 14 Apr 2006 10:41:23 -0700 Subject: [python-win32] BSTR In-Reply-To: References: Message-ID: <443FDEC3.70702@probo.com> On Thu, 13 Apr 2006 23:21:26 +0200, "Aleksandar Cikota" wrote: >I'm beginner in Python and need help. I'm writing software for a robotic >telescope. For CCD camera control we use MaxIm DL (Diffraction Limited). I >have a problem with CCDCamera.SaveImage. > >Here is the code (Python): > >import win32com.client, time >CCDCamera = win32com.client.Dispatch('MaxIm.CCDCamera') >CCDCamera.LinkEnabled = True >if CCDCamera.LinkEnabled == False: > print 'Failed to start camera.' >exp = int(raw_input('Exposition[sec]: ')) >CCDCamera.Expose(exp, 1, 0) >while CCDCamera.ImageReady == False: > time.sleep >print 'Done' >time.sleep(3) >CCDCamera.SaveImage('C:/1.fit') > > >Error message: > > >>> File "S:MaxImmaxim.py", line 19, in ? >>> CCDCamera.SaveImage('C:/1.fit') >>> File "C:ProgrammePython24Libsite- >>> packageswin32comclientdynamic.py", line 491, in __getattr__ >>> raise pythoncom.com_error, details >>> com_error: (-2147352567, 'Ausnahmefehler aufgetreten.', >>> (65535, 'MaxIm DL 4', 'Invalid Input', None, 0, 0), None) >> >> Putting on my "wild guess" hat, have you tried backslashes in the file name instead of forward? CCDCamera.SaveImage('C:\\1.fit') or CCDCamera.SaveImage(r'C:\1.fit') It's possible that their file name validation is a bit too strict. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From gabrielg_laburando at yahoo.com.ar Fri Apr 14 21:05:28 2006 From: gabrielg_laburando at yahoo.com.ar (Gabriel Genellina) Date: Fri, 14 Apr 2006 16:05:28 -0300 (ART) Subject: [python-win32] BSTR In-Reply-To: <443FDEC3.70702@probo.com> Message-ID: <20060414190529.29830.qmail@web32814.mail.mud.yahoo.com> Some remarks (altough not directly related to your current problem): > >while CCDCamera.ImageReady == False: > > time.sleep Should be time.sleep(1) or something. Remember that in Python you always need to use () to call a function. >if CCDCamera.LinkEnabled == False: It's not a good idea to compare strictly against True/False; for True just remove the comparison; for False use the "not" operator: >if not CCDCamera.LinkEnabled: >>> def always_true(): ... return 3 # any number!=0 is considered true ... >>> if always_true(): print 'Ok' ... else: print 'Wrong!' ... Ok >>> if always_true()==True: print 'Ok' ... else: print 'Wrong!' ... Wrong! >>> Gabriel Genellina Softlab SRL __________________________________________________ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ?gratis! ?Abr? tu cuenta ya! - http://correo.yahoo.com.ar From mli at deform.com Fri Apr 14 23:23:36 2006 From: mli at deform.com (Michael Li) Date: Fri, 14 Apr 2006 17:23:36 -0400 Subject: [python-win32] Runnin Python app as service with separateconsole In-Reply-To: <443D0CA6.1000706@deform.com> References: <443D0CA6.1000706@deform.com> Message-ID: <444012D8.3070007@deform.com> Hi, Mark Thank you very much. Now my python server works perfectly by adding signal handler to intercept CTRL_LOGOFF_EVENT. Best regards. Michael Li Michael Li wrote: > Hi, Mark > > Thank you very much. > I will try it. > > Best regards. > Michael Li > > Mark Hammond wrote: > >> Your process is probably seeing the CTRL_LOGOFF_EVENT. >> win32api.SetConsoleCtrlHandler will let you write a handler that >> ignores the >> event. >> >> Mark >> >> >>> -----Original Message----- >>> From: Michael Li [mailto:mli at deform.com] >>> Sent: Wednesday, 12 April 2006 9:03 AM >>> To: Mark Hammond >>> Cc: mli >>> Subject: Re: [python-win32] Runnin Python app as service with >>> separateconsole >>> >>> >>> Hi, Mark >>> >>> Thank you very much. >>> >>> >>> See my answers below. >>> >>> Mark Hammond wrote: >>> >>>>> "install_3d_app_service.cpp" is a program to install >>>>> sftc3win.exe(sftc_3d_app_service.cpp) >>>>> into a Windows' service. Inside sftc_3d_app_service.cpp, it will spawn >>>>> "python". >>>>> After reboot the machine, no problem, everything works fine, please >>>>> see >>>>> attached >>>>> picture python_running.JPG. The problem is that after I log off, the >>>>> "python" has gone. >>>> >>>> >>>> >>>> I'm afraid you don't mention what this spawned Python is supposed to >>>> do. >>> >>> >>> The spawned Python(using Twisted framework) runs 24X7 and >>> when receives a request and spawn another command to run. >>> I can my python scripts from DOS window, something like: >>> C:\python23\python.exe my_server.py -3 --pid=pid.file --slog=log.file >>> >run_log.file >>> >>> >>>> Regardless though, it appears that exe is terminating, probably >>> >>> >>> due to an >>> >>>> exception. You need to arrange to see the output of this process to >>>> see >>>> what went wrong. >>> >>> >>> The python.exe is terminated only after log off any account. >>> How do I debug/see the output of this process ? >>> >>> >>>> If it is your .cpp implemented service that vanishes, then I've >>> >>> >>> no idea what >>> >>>> it could be. >>> >>> >>> sftc3win.exe(sftc_3d_app_service.cpp) will spawn >>> "C:\python23\python.exe my_server.py -3 --pid=pid.file --slog=log.file >>> >run_log.file" >>> >>> sftc3win.exe never vanishes. only python.exe vanished after log in/off >>> any account. >>> >>> From attached picture python_running.JPG, >>> you can see python.exe and sftc3win.exe are running as "SYSTEM". >>> >>> >>> >>>> >>>>> Even if I log in as a non-administrative account, I log off, then the >>>>> "python" has gone, >>>>> even I am in the session of non-administrative account, I can not >>>>> terminate(End Process) >>>>> the "python" process. I am totally confused by this. >>>> >>>> >>>> >>>> It is normal (but frustrating) you can't kill it as the service >>> >>> >>> is running >>> >>>> as LocalSystem. You may have more luck setting it to run as your user. >>> >>> >>> No, I do not want to kill the process. I want to prove that >>> in the session of non-administrative account, you can not kill it, >>> then how could "log off" kill it ? >>> >>> >>>> I'm a little confused though, as you seem to say the problem is that >>>> the >>>> python process has gone - but here you are failing to kill it. >>>> >>>> >>>> >>>>> I also can use Windows' Scheduled Tasks to add a task as "At System >>>>> startup", I can run >>>>> it as a service, but after I log in/log off any account, the "python" >>>>> service has gone. >>>> >>>> >>>> >>>> The service (implemented in .cpp) has gone, or the child python >>> >>> >>> executable? >>> The service (implemented in .cpp) stays there always, only child >>> python executable has gone. >>> >>> >>>> Same answer as above though... >>>> >>>> Mark >>>> >>> >>> From attached project file(VC6), you can build >>> ins3apse.exe/sftc3win.exe, >>> this ins3apse.exe will install sftc3win.exe as a service, >>> when a computer reboots, it will start the python.exe, >>> until now, everything works fine. when I log in any account, >>> no problem, everything works fine. Only after I log off any account, >>> "python.exe" has gone. >>> >>> >>> ========== >>> This email message and any attachments are for the sole use of >>> the intended recipients and may contain proprietary and/or >>> confidential information which may be privileged or otherwise >>> protected from disclosure. Any unauthorized review, use, >>> disclosure or distribution is prohibited. If you are not the >>> intended recipients, please contact the sender by reply email and >>> destroy the original message and any copies of the message as >>> well as any attachments to the original message. >>> >> >> > ========== This email message and any attachments are for the sole use of the intended recipients and may contain proprietary and/or confidential information which may be privileged or otherwise protected from disclosure. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipients, please contact the sender by reply email and destroy the original message and any copies of the message as well as any attachments to the original message. From rstoss at hrz1.hrz.tu-darmstadt.de Fri Apr 14 23:57:45 2006 From: rstoss at hrz1.hrz.tu-darmstadt.de (Reiner M. Stoss) Date: Fri, 14 Apr 2006 23:57:45 +0200 Subject: [python-win32] BSTR Message-ID: <444036F9.27841.1408E2D@localhost> Mark et al., > Python will *always* (unless an object's typelib indicated otherwise) pass > a VT_BSTR when a string literal is specified. I'm afraid I can't > speculate on what the problem may otherwise be. As additional information to our problem I want to mention that other methods which need a string (path+filename) do work, e.g. CCDCamera.OpenFile and CCDCamera.SaveFile, only CCDCamera.SaveImage doesn't and raises an exception error (Invalid Input), as mentioned by Aleksandar in a previous post. So I have contacted the author of MaxIm DL and he wrote: "That is quite strange, since CCDCamera.SaveImage and Document.SaveFile declare their filename arguments identically, in (1) the C++ source code, (2) the dispatch table, and (3) the ODL file." Meanwhile he has installed Python 2.4.3 and PythonWin build 208 and with the code I did provided he was able to reproduce the problem. He has then: "set a breakpoint inside MaxIm DL, trapping when CCDCamera.SaveImage was called. Guess what? The variant argument that was supposed to contain the filename was VT_ERROR. Little wonder we were rejecting the call." He continues: "Next, I looked at PythonWin's object browser, per your instructions. But here I see something different. I assume you're opening the "Registered Type Libraries" category, expanding 'MaxIm.Objects', and 'Type Library' within that again. What I see is a long list of entries saying, 'The type info can n... = 'The type info can not be loaded!' I can't say whether this indicates a bug in PythonWin or whether my registry is corrupted somehow." So my question is, do these entries mean anything at all and could they explain why the method SaveImage doesn't work? I see such entries however for other applications too and their methods do work. I also want to add that in PythonWin's COM browser the CCDCamera.SaveImage function lib looks okay. It says, see here: http://www.reinerstoss.de/Python/MaxIm_SaveImage.jpg The entries for the two methods that do work are, see here: http://www.reinerstoss.de/Python/MaxIm_OpenFile_SaveFile.jpg So everything seems okay, right? Still the question is why "The variant argument that was supposed to contain the filename was VT_ERROR". BTW, the code looks like this: --- import win32com.client, time CCDCamera = win32com.client.Dispatch('MaxIm.CCDCamera') CCDCamera.LinkEnabled = True if CCDCamera.LinkEnabled == False: print 'Failed to start camera.' exp = int(raw_input('Exposition[sec]: ')) CCDCamera.Expose(exp, 1, 0) while CCDCamera.ImageReady == False: time.sleep print 'Done' time.sleep(3) CCDCamera.SaveImage('S:/Reiner/MaxIm/1.fit') --- and the raised error message looks like this: --- Traceback (most recent call last): File "S:\Reiner\MaxIm\maxim1.py", line 18, in ? CCDCamera.SaveImage('S:/Reiner/MaxIm/1.fit') File "C:\Programme\Python24\Lib\site-packages\win32com\client\dynamic.py", line 491, in __getattr__ raise pythoncom.com_error, details com_error: (-2147352567, 'Ausnahmefehler aufgetreten.', (65535, 'MaxIm DL 4', 'Invalid Input', None, 0, 0), None) --- Any help much appreciated. Thanks, Reiner From rstoss at hrz1.hrz.tu-darmstadt.de Sat Apr 15 00:19:12 2006 From: rstoss at hrz1.hrz.tu-darmstadt.de (Reiner M. Stoss) Date: Sat, 15 Apr 2006 00:19:12 +0200 Subject: [python-win32] BSTR Message-ID: <44403C00.9399.154310E@localhost> Tim, yes, I had tried all these weird ideas already ;-) Same exception error. As I just wrote in my first reply, the problem seems that the variant argument that should contain the path+filename is a VT_ERROR, whatever that means. I don't have too much experience so far with PythonWin. I just used it for client-side scripting with late-binding and so far everything worked, until I started to script MaxIm DL and this is the first case where I see that calls to some methods do fail. So I am really worried because I need to script this Software from Python. I hope we can solve this issue because I would hate to use something as vbscript to do the job. Cheers, Reiner P.S.: Gabriel, yes, I have put Sleep(1) now, even though it worked without the parenthesis too, even thought it shouldn't, right? From gabrielg_laburando at yahoo.com.ar Sat Apr 15 03:53:03 2006 From: gabrielg_laburando at yahoo.com.ar (Gabriel Genellina) Date: Sat, 15 Apr 2006 01:53:03 +0000 (GMT) Subject: [python-win32] BSTR In-Reply-To: <44403C00.9399.154310E@localhost> Message-ID: <20060415015303.93751.qmail@web32807.mail.mud.yahoo.com> > P.S.: Gabriel, yes, I have put Sleep(1) now, even > though it > worked without the parenthesis too, even thought it > shouldn't, > right? Well, it "worked" in the sense that it gave no errors because time.sleep is a valid Python expression, but it has not the desired effect. It's a common pitfall, specially if you come from VB, that's why I menction it here. Like, in C: if (a=b) {...} which "works" but usually is not the intended behavior. Gabriel Genellina Softlab SRL __________________________________________________ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ?gratis! ?Abr? tu cuenta ya! - http://correo.yahoo.com.ar From rstoss at hrz1.hrz.tu-darmstadt.de Sat Apr 15 12:34:20 2006 From: rstoss at hrz1.hrz.tu-darmstadt.de (Reiner M. Stoss) Date: Sat, 15 Apr 2006 12:34:20 +0200 Subject: [python-win32] BSTR In-Reply-To: <444036F9.27841.1408E2D@localhost> Message-ID: <4440E84C.26375.2EC300@localhost> Mark, > So everything seems okay, right? Still the question is > why "The variant argument that was supposed to contain the > filename was VT_ERROR". I want to share a reply from the developer of MaxIm DL. He installed Python2.4.3 and PythonWin build 208, just to be able to reproduce this error and it looks to me as if the bug could be inside PythonWin. I hadn't scrolled down far enough! Sure enough, the entries for MaxIm DL's object, interfaces, and events are there after all, and the methods and properties look much as I'd expect. It even knows the Dispatch IDs correctly: SaveImage is #39. Of course that had to be true, since it was getting into the right place inside MaxIm DL. It's just not sending the argument string, and I'm no closer to figuring out why. I tried building Python and pywin32 from source, hoping I could debug the client side. I think I was successful for python.exe, but not for the Win32 extensions. The problem is I only have VC6 and they're supposed to be compiled with VC7. Python itself provided old, unsupported .dsp (project) files for VC6 and my result seems to run OK. But I could only create win32com by hacking pieces individually, and I haven't been able to install them so that my debug Python recognizes them. I'm probably missing vital .pyc, .pyo, or other files that are automatically generated by "setup.py install"-- which I can't get to run. Well, it was worth a try. I expect Mark Hammond is far too busy to investigate, but if he shows any interest at all, tell him he can download a 30-day trial of MaxIm DL from http://www.cyanogen.com/downloads/maxim_main.htm. He'll need to know to select the Simulator camera from MaxIm CCD's Setup page once before trying any scripting. FWIW, it works from vbscript and it works from Perl and folks provided me code in these languages and I was able to run it. I'd prefer however to see it work from Python :-) vbscript: --- Dim cam Set cam = CreateObject("MaxIm.CCDCamera") cam.LinkEnabled = True if Not cam.LinkEnabled Then wscript.echo "Failed to start camera." Quit End If wscript.echo "Camera is ready, Exposing." cam.Expose 1, 1, 0 Do While Not cam.ImageReady Loop cam.SaveImage "S:\Reiner\MaxIm\1.fit" wscript.echo "Exposure is done, Image saved as 1.fit" --- Perl: --- #!perl $Cam = $WScript->CreateObject('MaxIm.CCDCamera'); $Cam->{LinkEnabled} = 1; die 'Failed to start camera' unless $Cam->{LinkEnabled}; print "Exposure[sec]: "; $exp = <>; die "Need a number!" unless $exp =~ /^\s*\d+(\.\d*)?\s*$/; $Cam->Expose( $exp, 1, 0 ); $WScript->sleep( 50 ) until $Cam->ImageReady; print "Done\n"; $WScript->sleep( 3000 ); $Cam->SaveImage( 'C:/1.fit' ); --- The Python code and the raised error due to the VT_ERROR is in my previous message. As are the links to the screenshots from PythonWin's COM Browser. If this place is not the right one to report possible bugs in PythonWin, please point me to the proper one ;-) Cheers, Reiner -- MACE - Meeting on Asteroids and Comets in Europe, 2006 May 12-14 (full moon) - Vienna, Austria http://www.minorplanets.org/ From floris.vannee at gmail.com Sun Apr 16 00:28:57 2006 From: floris.vannee at gmail.com (Floris van Nee) Date: Sun, 16 Apr 2006 00:28:57 +0200 Subject: [python-win32] python com and py2exe Message-ID: <2302ac370604151528w166239f9hee91a3508a1c5383@mail.gmail.com> Hi, No-one answered to my previous email, maybe you didn't know the answer or maybe it wasn't received properly. Anyway here is it again, does any of you know the answer? Im still struggling with it.. Previous email: I'm trying to convert my Python script, which is a COM server, to an exe file. I'm using py2exe 0.6.5. But I ran into a few problems. After a lot of work I was able to run py2exe on my script and create the exe file. I was able to use exectablename.exe --register and --unregister and it returned text that it registered/unregistered the com server, but I wasn't able to connect to it using VB .NET. VB gave me an error saying that it couldn't create the ActiveX component. The normal python file works normally if I try to import the com object from VB, but the exe doesn't work. So I think there's something I do wrong in the setup file or so, or maybe I have to put something else in my Python file, I dont know, I hope some of you do. Here is my Python script and the setup.py (for py2exe) script: setup.py: from distutils.core import setup import py2exe setup(console=['testcomserver.py'], scripts=['testcomserver.py'], name='testcomserver') actual script: from urllib import urlopen import sys import pythoncom class Runescape1: _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER if hasattr(sys, 'importers'): # In the py2exe-packed version, specify the module.class # to use. In the python script version, python is able # to figure it out itself. _reg_class_spec_ = "__main__.Runescape1" _reg_clsid_ = "{6CF99217-4AE8-486A-9858-BE798F8671BC}" _reg_progid_ = "Python.Runescape1" _public_methods_ = ['Lookup', 'ChangeXP', 'ServerStatus', 'MultiplyString'] _public_attrs_ = ['softspace', 'noCalls'] _readonly_attrs_ = ['noCalls'] def __init__(self): self.softspace = 1 self.noCalls = 0 def Lookup(self, nick): url = "http://hiscore.runescape.com/lang/en/aff/runescape/hiscorepersonal.ws?user1=" + nick f = urlopen(url, 'r').read() search_start = '') f = f[:a] + f[b+1:] for a in range(1,122): search = 'World ' + str(a) + ' ' start = f.find(search) servers += [f[start+6:start+len(search)+4]] if ';Type Wo' in servers: del servers[servers.index(';Type Wo')] servers = servers[:115] + ['116 DOWN'] + servers[115:] for a in servers: servers1 += a + ',' return servers1 def MultiplyString(self, string, times): string = times*string return string if hasattr(sys, 'importers'): # we are running as py2exe-packed executable pythoncom.frozen = 1 if __name__=='__main__': if hasattr(sys, 'importers'): # running as packed executable. if '--register' in sys.argv[1:] or '--unregister' in sys.argv[1:]: # --register and --unregister work as usual import win32com.server.register win32com.server.register.UseCommandLine(Runescape1) else: # start the server. from win32com.server import localserver localserver.main() else: import win32com.server.register win32com.server.register.UseCommandLine(Runescape1) That was my whole file, not all of this is probably needed for an answer, but I thought I'd mail the whole py file. You can ignore every function in the Runescape1 class if you want :P. Thanks in advance, Floris From p.f.moore at gmail.com Sun Apr 16 15:50:40 2006 From: p.f.moore at gmail.com (Paul Moore) Date: Sun, 16 Apr 2006 14:50:40 +0100 Subject: [python-win32] Problem with installer for pywin32 with Python 2.5 Message-ID: <79990c6b0604160650v23d3bc24oa59ebd7270d2bc2e@mail.gmail.com> There's a problem with Python 2.5 (http://www.python.org/sf/1465834) which means that installers with preinstall scripts don't work. The pywin32 build 208 installer is one such (I reported this as bug 1465566 before I realised this was a Python bug). The preinstall script seems only to be used to detect old Wise-installer versions, which are pretty old by now. Is there any chance of a temporary version of the installer without the preinstall script, just for use with the Python 2.5a1 release? I tried building one for myself, but I'm missing some critical dependencies (dsound.h?) Paul. From mhammond at skippinet.com.au Mon Apr 17 02:58:19 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 17 Apr 2006 10:58:19 +1000 Subject: [python-win32] python com and py2exe In-Reply-To: <2302ac370604151528w166239f9hee91a3508a1c5383@mail.gmail.com> Message-ID: Are you sure you need a COM .exe and not a COM .DLL? When you tested this using a .py implemented server, did you take steps to ensure that was only ever using a .exe COM object too? Otherwise, it would seem to be py2exe related - you will need to use the archives to find explanations I have given for debugging this environment, both to this mailing list and the py2exe-users list. Cheers, Mark > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org]On Behalf Of Floris van Nee > Sent: Sunday, 16 April 2006 8:29 AM > To: python-win32 at python.org > Subject: [python-win32] python com and py2exe > > > Hi, > > No-one answered to my previous email, maybe you didn't know the answer > or maybe it wasn't received properly. Anyway here is it again, does > any of you know the answer? Im still struggling with it.. > > Previous email: > I'm trying to convert my Python script, which is a COM server, to an > exe file. I'm using py2exe 0.6.5. But I ran into a few problems. After > a lot of work I was able to run py2exe on my script and create the exe > file. I was able to use exectablename.exe --register and --unregister > and it returned text that it registered/unregistered the com server, > but I wasn't able to connect to it using VB .NET. VB gave me an error > saying that it couldn't create the ActiveX component. The normal > python file works normally if I try to import the com object from VB, > but the exe doesn't work. So I think there's something I do wrong in > the setup file or so, or maybe I have to put something else in my > Python file, I dont know, I hope some of you do. Here is my Python > script and the setup.py (for py2exe) script: > setup.py: > > from distutils.core import setup > import py2exe > > setup(console=['testcomserver.py'], > scripts=['testcomserver.py'], > name='testcomserver') > > > > > actual script: > > from urllib import urlopen > import sys > import pythoncom > class Runescape1: > _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER > if hasattr(sys, 'importers'): > # In the py2exe-packed version, specify the module.class > # to use. In the python script version, python is able > # to figure it out itself. > _reg_class_spec_ = "__main__.Runescape1" > _reg_clsid_ = "{6CF99217-4AE8-486A-9858-BE798F8671BC}" > _reg_progid_ = "Python.Runescape1" > _public_methods_ = ['Lookup', 'ChangeXP', 'ServerStatus', > 'MultiplyString'] > _public_attrs_ = ['softspace', 'noCalls'] > _readonly_attrs_ = ['noCalls'] > def __init__(self): > self.softspace = 1 > self.noCalls = 0 > def Lookup(self, nick): > url = > "http://hiscore.runescape.com/lang/en/aff/runescape/hiscorepersona > l.ws?user1=" > + nick > f = urlopen(url, 'r').read() > search_start = ' /harrow_down.gif'):] > while '<' in f: > a = f.find('<') > b = f.find('>') > f = f[:a] + f[b+1:] > for a in range(1,122): > search = 'World ' + str(a) + ' ' > start = f.find(search) > servers += [f[start+6:start+len(search)+4]] > if ';Type Wo' in servers: > del servers[servers.index(';Type Wo')] > servers = servers[:115] + ['116 DOWN'] + servers[115:] > for a in servers: > servers1 += a + ',' > return servers1 > def MultiplyString(self, string, times): > string = times*string > return string > if hasattr(sys, 'importers'): > # we are running as py2exe-packed executable > pythoncom.frozen = 1 > > if __name__=='__main__': > if hasattr(sys, 'importers'): > # running as packed executable. > if '--register' in sys.argv[1:] or '--unregister' > in sys.argv[1:]: > # --register and --unregister work as usual > import win32com.server.register > win32com.server.register.UseCommandLine(Runescape1) > else: > # start the server. > from win32com.server import localserver > localserver.main() > else: > import win32com.server.register > win32com.server.register.UseCommandLine(Runescape1) > > > > > That was my whole file, not all of this is probably needed for an > answer, but I thought I'd mail the whole py file. You can ignore every > function in the Runescape1 class if you want :P. > > > Thanks in advance, > > > Floris > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From mhammond at skippinet.com.au Mon Apr 17 03:49:16 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 17 Apr 2006 11:49:16 +1000 Subject: [python-win32] Problem with installer for pywin32 with Python 2.5 In-Reply-To: <79990c6b0604160650v23d3bc24oa59ebd7270d2bc2e@mail.gmail.com> Message-ID: > Wise-installer versions, which are pretty old by now. Is there any > chance of a temporary version of the installer without the preinstall > script, just for use with the Python 2.5a1 release? I tried building > one for myself, but I'm missing some critical dependencies (dsound.h?) Done - see the SF download pages for a 2.5 (only) build of 208.1. As an added bonus, you get whatever has been checked into CVS since, and whatever I have changed but *not* checked in since ;) Mark From davidrushby at yahoo.com Mon Apr 17 05:39:33 2006 From: davidrushby at yahoo.com (David Rushby) Date: Sun, 16 Apr 2006 20:39:33 -0700 (PDT) Subject: [python-win32] Problem with installer for pywin32 with Python 2.5 In-Reply-To: Message-ID: <20060417033933.47731.qmail@web30010.mail.mud.yahoo.com> --- Mark Hammond wrote: > > Wise-installer versions, which are pretty old by now. Is there any > > chance of a temporary version of the installer without the > preinstall > > script, just for use with the Python 2.5a1 release? I tried > building > > one for myself, but I'm missing some critical dependencies > (dsound.h?) > > Done - see the SF download pages for a 2.5 (only) build of 208.1. Thank you for taking the time to do that, Mark. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From p.f.moore at gmail.com Mon Apr 17 11:03:55 2006 From: p.f.moore at gmail.com (Paul Moore) Date: Mon, 17 Apr 2006 10:03:55 +0100 Subject: [python-win32] Problem with installer for pywin32 with Python 2.5 In-Reply-To: <20060417033933.47731.qmail@web30010.mail.mud.yahoo.com> References: <20060417033933.47731.qmail@web30010.mail.mud.yahoo.com> Message-ID: <79990c6b0604170203o46b8836bw972db5483ea17eef@mail.gmail.com> On 4/17/06, David Rushby wrote: > --- Mark Hammond wrote: > > > Wise-installer versions, which are pretty old by now. Is there any > > > chance of a temporary version of the installer without the > > preinstall > > > script, just for use with the Python 2.5a1 release? I tried > > building > > > one for myself, but I'm missing some critical dependencies > > (dsound.h?) > > > > Done - see the SF download pages for a 2.5 (only) build of 208.1. > > Thank you for taking the time to do that, Mark. Agreed. Paul. From mhammond at skippinet.com.au Mon Apr 17 14:13:46 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 17 Apr 2006 22:13:46 +1000 Subject: [python-win32] BSTR In-Reply-To: <4440E84C.26375.2EC300@localhost> Message-ID: > I want to share a reply from the developer of MaxIm DL. > He installed Python2.4.3 and PythonWin build 208, > just to be able to reproduce this error and it looks to me > as if the bug could be inside PythonWin. Please forward this to him. > I expect Mark Hammond is far too busy to investigate, but if he shows any > interest at all, tell him he can download a 30-day trial of MaxIm DL from > http://www.cyanogen.com/downloads/maxim_main.htm. He'll need to know to > select the Simulator camera from MaxIm CCD's Setup page once before trying > any scripting. I did that (mainly due to the effort by him trying to track this down!) The problem turns out to be: pywintypes.com_error: (-2147352567, 'Exception occurred.', (65535, 'MaxIm DL 4', 'Invalid Input', None, 0, 0), None) This exception is being raised by Python calling Invoke with the correct dispid, but with only INVOKE_PROPERTYGET and *not* DISPATCH_METHOD. The "problem" is that Python's syntax does does distinguish between a property and a method - so: ob.foo() is (roughly) equivalent to: func_ob = getattr(ob, "foo") func_ob() so win32com struggles around this, with the short story being that only certain error values are "acceptable" when a 'method' is accessed as a 'property'. Currently, pywin32 only accepts the hresults (DISP_E_MEMBERNOTFOUND, DISP_E_BADPARAMCOUNT, DISP_E_PARAMNOTOPTIONAL, DISP_E_TYPEMISMATCH and E_INVALIDARG). MaxIM returns DISP_E_EXCEPTION, which is not in this list - and actually should not be. DISP_E_EXCEPTION means extra exception info is returned, as reflected in the final part of the above exception. Ideally, pywin32 would indirect into the COM excepinfo structure to find the real error info. Fortunately for me , even if pywin32 did sniff deeper, it would find an error result of -1 (65535) or zero - so would still fail to find one of its 'acceptable' error results to make the distinction between 'property' and 'method'. So - the end result is that MaxIM really needs to return a more sane result when only PROPERTYGET is (or zero args are) requested. If it is more convenient for MaxIM to continue to return DISP_E_EXCEPTION and set the real error in the extended error info, I could agree to make pywin32 handle that case ;) Cheers, Mark From dao at tum.de Mon Apr 17 19:54:14 2006 From: dao at tum.de (Dao Duy Huy) Date: Mon, 17 Apr 2006 19:54:14 +0200 Subject: [python-win32] System wide text selection Message-ID: <4443D646.3000805@tum.de> Hallo, I'm writing a dictionary german <> vietnamese for free use, which should react on the mouse-click like babylon. You click on a german word in any win-program and the dict program will show you the translation in vietnamese and vice versa. But i couldn't find the way how i can select the word with the mouse position... Can you show me how you solve the problem? Thank you very much Dao -------------- next part -------------- A non-text attachment was scrubbed... Name: dao.vcf Type: text/x-vcard Size: 387 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20060417/c34edcda/attachment.vcf From p.f.moore at gmail.com Mon Apr 17 21:53:14 2006 From: p.f.moore at gmail.com (Paul Moore) Date: Mon, 17 Apr 2006 20:53:14 +0100 Subject: [python-win32] Problem with installer for pywin32 with Python 2.5 In-Reply-To: <79990c6b0604160650v23d3bc24oa59ebd7270d2bc2e@mail.gmail.com> References: <79990c6b0604160650v23d3bc24oa59ebd7270d2bc2e@mail.gmail.com> Message-ID: <79990c6b0604171253k7b503319r6cf0f2611f6d14d9@mail.gmail.com> On 4/16/06, Paul Moore wrote: > I tried building one for myself, but I'm missing some critical > dependencies (dsound.h?) I'm assuming this is from the DirectX SDK, which I'm in the process of downloading now to try it out. Are there any other downloads I should get in order to build pywin32? (I have the platform SDK - the setup.py doesn't mention any others as still being needed, but then again, it didn't mention the DirectX one either...) Paul. PS I'm trying to build with the free toolkit compiler, so it's possible I'll have more trouble than usual due to lack of things that are available from Visual Studio by default... From p.f.moore at gmail.com Mon Apr 17 23:54:37 2006 From: p.f.moore at gmail.com (Paul Moore) Date: Mon, 17 Apr 2006 22:54:37 +0100 Subject: [python-win32] Building pywin32 with the free MS toolkit compiler (Was: Problem with installer for pywin32 with Python 2.5) Message-ID: <79990c6b0604171454s77c0bda5qdc11f8f719811c59@mail.gmail.com> On 4/17/06, Paul Moore wrote: > On 4/16/06, Paul Moore wrote: > > I tried building one for myself, but I'm missing some critical > > dependencies (dsound.h?) > > I'm assuming this is from the DirectX SDK, which I'm in the process of > downloading now to try it out. Are there any other downloads I should > get in order to build pywin32? (I have the platform SDK - the setup.py > doesn't mention any others as still being needed, but then again, it > didn't mention the DirectX one either...) Looks like atlbase.h is needed in win32netuse and win32netuser. That's annoying, as it's not freely available, as far as I know. It's possible taht ATL isn't actually needed, though - commenting the includes out results in a successful compile. The link fails with an odd error, though - Creating library build\temp.win32-2.5\Release\win32/src/win32net\win32net.lib and object build\temp.win32-2.5\Release\win32/src/win32net\win32net.exp win32netmodule.obj : error LNK2019: unresolved external symbol __imp__GetSecurityDescriptorLength at 4 referenced in function "int __cdecl PyObject_AsNET_STRUCT(struct _object *,struct PyNET_STRUCT *,unsigned char * *)" (?PyObject_AsNET_STRUCT@@YAHPAU_object@@PAUPyNET_STRUCT@@PAPAE at Z) win32netmodule.obj : error LNK2019: unresolved external symbol __imp__GetLengthSid at 4 referenced in function "int __cdecl PyObject_AsNET_STRUCT(struct _object *, struct PyNET_STRUCT *,unsigned char * *)" (?PyObject_AsNET_STRUCT@@YAHPAU_object@@PAUPyNET_STRUCT@@PAPAE at Z) build\lib.win32-2.5\win32\win32net.pyd : fatal error LNK1120: 2 unresolved externals I'm not sure how this could be related to the ATL include - it looks more like a declaration missing an "extern C" - but that seems improbable. If I comment out win32net from setup.py, I hit a problem in win32wnet\PyNetresource.cpp, which uses ATL for Unicode conversion macros. I took out axdebug, as it's described as "a mess", so let's leave that for now :-) But that uses ATL, as well... mapiutil also failed with ATL dependencies. But then I hit win32ui, which I'd forgotten about completely - that uses MFC, doesn't it, so presumably there's no serious hope of getting it working without the full Visual C product. At this point I gave up. I was impressed by how far things got with just the free stuff, but the lack of MFC and ATL is probably a complete showstopper. Anyway, I'm posting this, not so much in the hope that it's possible, as to have it in the archives for future reference. It was an interesting exercise, in any case :-) Paul. From mhammond at skippinet.com.au Tue Apr 18 14:09:09 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 18 Apr 2006 22:09:09 +1000 Subject: [python-win32] Building pywin32 with the free MS toolkit compiler(Was: Problem with installer for pywin32 with Python 2.5) In-Reply-To: <79990c6b0604171454s77c0bda5qdc11f8f719811c59@mail.gmail.com> Message-ID: > On 4/17/06, Paul Moore wrote: > > On 4/16/06, Paul Moore wrote: > > > I tried building one for myself, but I'm missing some critical > > > dependencies (dsound.h?) > > > > I'm assuming this is from the DirectX SDK, which I'm in the process of > > downloading now to try it out. Are there any other downloads I should > > get in order to build pywin32? (I have the platform SDK - the setup.py > > doesn't mention any others as still being needed, but then again, it > > didn't mention the DirectX one either...) > > Looks like atlbase.h is needed in win32netuse and win32netuser. That's > annoying, as it's not freely available, as far as I know. > > It's possible taht ATL isn't actually needed, though - commenting the > includes out results in a successful compile. The link fails with an > odd error, though - Removing atlbase.h just meant that advapi32.lib needed to be added to the link command-line - presumably the ATL headers automatically caused that to happen. I've just checked in a fix for that and removed that header. > If I comment out win32net from setup.py, I hit a problem in > win32wnet\PyNetresource.cpp, which uses ATL for Unicode conversion > macros. These conversion macros are fairly easy (but not search-replace easy) to change, and I do it as I find it necessary. > mapiutil also failed with ATL dependencies. That seems to build simply by removing the #include. I've checked that in too! > But then I hit win32ui, which I'd forgotten about completely - that > uses MFC, doesn't it, so presumably there's no serious hope of getting > it working without the full Visual C product. It does - although many real projects can live without win32ui (and therefore without Pythonwin). Thus, this may still be a perfectly good solution for people who want to be able to build everything they ship (or just a debug build of what they actually use) - but not necessarily be able to build the entire pywin32 world. > At this point I gave up. I was impressed by how far things got with > just the free stuff, but the lack of MFC and ATL is probably a > complete showstopper. As above - it is probably a showstopper for anyone hoping to recreate a complete pywin32 build - but for many others it may be truly useful. > Anyway, I'm posting this, not so much in the hope that it's possible, > as to have it in the archives for future reference. > > It was an interesting exercise, in any case :-) Thanks! I welcome any other contributions (from anyone at all) towards this end! Cheers, Mark From alexci at gmx.net Tue Apr 18 15:01:10 2006 From: alexci at gmx.net (Aleksandar Cikota) Date: Tue, 18 Apr 2006 15:01:10 +0200 (Central European Daylight Time) Subject: [python-win32] Threading problem Message-ID: <4444E316.000003.03500@CIKOTA-TM4U7QQ2> Hi all, I have a problem with threading. It should work, but it cannot open a file (Document.OpenFile) if "def run (self):" is in the code. Else the programm doesn't work. Code: import win32com.client import time import os import threading Document = win32com.client.Dispatch('MaxIm.Document') Application = win32com.client.Dispatch('MaxIm.Application') p = win32com.client.dynamic.Dispatch('PinPoint.Plate') class TestThread (threading.Thread): def run (self): path_to_watch = "F:/Images/VRT/" before = dict ([(f, None) for f in os.listdir (path_to_watch)]) while 1: time.sleep(2) after2 = dict ([(f, None) for f in os.listdir (path_to_watch)]) added = [f for f in after2 if not f in before] if added: name= ' ,'.join (added) if str(name[-3:])=='fit': print name Document.OpenFile('F:/Images/VRT/'+name) Document.SaveFile('F:/Images/VRT/'+ str(name[0:-4])+'.jpg', 6, 1024,2) Application.CloseAll() before = after2 TestThread().start() Here the error message: >>> Exception in thread Thread-1: Traceback (most recent call last): File "C:\Program Files\Python\lib\threading.py", line 442, in __bootstrap self.run() File "G:\Robot teleskop\VRT\test\test2.py", line 25, in run Document.OpenFile('F:/Images/VRT/'+name) File "C:\Program Files\Python\Lib\site-packages\win32com\client\dynamic.py", line 496, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: MaxIm.Document.OpenFile What does raise AttributeError, "%s.%s" % (self._username_, attr) mean? If I use win32com.client.gencache.EnsureDispatch() in place of Dispatch the error message looks like that: Traceback (most recent call last): File "G:\Robot teleskop\VRT\soft\GUI.py", line 18, in -toplevel- Document = win32com.client.gencache.EnsureDispatch("MaxIm.Document") File "C:\Program Files\Python\Lib\site-packages\win32com\client\gencache py", line 543, in EnsureDispatch raise TypeError, "This COM object can not automate the makepy process - please run makepy manually for this object" TypeError: This COM object can not automate the makepy process - please run makepy manually for this object What should I do? I hope You can help me. For your prompt reply, I say thank you in advance. Best regards, Aleksandar -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060418/5679c6cf/attachment.htm From bwmetz at att.com Tue Apr 18 18:49:30 2006 From: bwmetz at att.com (Metz, Bobby W, WCS) Date: Tue, 18 Apr 2006 11:49:30 -0500 Subject: [python-win32] py2exe & transparent icons In-Reply-To: Message-ID: <01D5341D04A2E64AB9B345769047336701A475B4@OCCLUST01EVS1.ugd.att.com> All, This may not be the right list for this, but I figured there's bound to be some py2exe experts. I'm distributing a Tkinter program using py2exe. The program uses a .ico file to change the default Tk icon. The .ico has a transparent background and looks fine when run as script. When .exe produced by py2exe is run, the transparent areas are now black. I've searched for a knob that might be controlling this but can't find it. I'm currently guessing it's some internal limitation of py2exe that can't display transparent graphics. Any pointers would be greatly appreciated. Thanks, Bobby From timr at probo.com Tue Apr 18 19:13:56 2006 From: timr at probo.com (Tim Roberts) Date: Tue, 18 Apr 2006 10:13:56 -0700 Subject: [python-win32] System wide text selection In-Reply-To: References: Message-ID: <44451E54.5080906@probo.com> On Mon, 17 Apr 2006 19:54:14 +0200, Dao Duy Huy wrote: >I'm writing a dictionary german <> vietnamese for free use, which >should react on the mouse-click like babylon. >You click on a german word in any win-program and the dict program will >show you the translation in vietnamese and vice versa. > >But i couldn't find the way how i can select the word with the mouse >position... > >Can you show me how you solve the problem? > This is a difficult problem to solve, and it may be that Python is not the right language for it. You first have to figure out which window contains the point you want. Then, you have to figure out what KIND of window that is (text box, rich text control, static text, list box, custom control). Then, you use THAT knowledge to decide how to ask the control to translate the X,Y coordinate into a row and column position. Then, you can fetch the whole contents of that window, find the exact character, and work backwards and forwards to find the word boundaries. Note that for some applications (like Word), you will have to use Word APIs to do this. It is complicted. You will want to do a lot of web searching to see if you can find some good sample code. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mark.m.mcmahon at gmail.com Tue Apr 18 19:23:52 2006 From: mark.m.mcmahon at gmail.com (Mark Mc Mahon) Date: Tue, 18 Apr 2006 13:23:52 -0400 Subject: [python-win32] System wide text selection In-Reply-To: <44451E54.5080906@probo.com> References: <44451E54.5080906@probo.com> Message-ID: <71b6302c0604181023yf48bb6cn8b2c3192ea453be0@mail.gmail.com> Hi, You might want to look into pyHook (google for it - I don't have a link right now). Another option that might be much easier is to setup a global hotkey, where the user selects the word, and clicks the hotkey (and you pop up a window at that point with the translation(s). You could probably use WM_COPY to get teh text into teh clipboard and then get it from there using your app (though it would be good manners to save teh existing data first :-) ). Mark On 4/18/06, Tim Roberts wrote: > On Mon, 17 Apr 2006 19:54:14 +0200, Dao Duy Huy wrote: > > >I'm writing a dictionary german <> vietnamese for free use, which > >should react on the mouse-click like babylon. > >You click on a german word in any win-program and the dict program will > >show you the translation in vietnamese and vice versa. > > > >But i couldn't find the way how i can select the word with the mouse > >position... > > > >Can you show me how you solve the problem? > > > > > This is a difficult problem to solve, and it may be that Python is not > the right language for it. > > You first have to figure out which window contains the point you want. > Then, you have to figure out what KIND of window that is (text box, rich > text control, static text, list box, custom control). Then, you use > THAT knowledge to decide how to ask the control to translate the X,Y > coordinate into a row and column position. Then, you can fetch the > whole contents of that window, find the exact character, and work > backwards and forwards to find the word boundaries. Note that for some > applications (like Word), you will have to use Word APIs to do this. > > It is complicted. You will want to do a lot of web searching to see if > you can find some good sample code. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From sjmachin at lexicon.net Tue Apr 18 23:42:29 2006 From: sjmachin at lexicon.net (John Machin) Date: Wed, 19 Apr 2006 07:42:29 +1000 Subject: [python-win32] py2exe & transparent icons In-Reply-To: <01D5341D04A2E64AB9B345769047336701A475B4@OCCLUST01EVS1.ugd.att.com> References: <01D5341D04A2E64AB9B345769047336701A475B4@OCCLUST01EVS1.ugd.att.com> Message-ID: <44455D45.8070607@lexicon.net> On 19/04/2006 2:49 AM, Metz, Bobby W, WCS wrote: > All, > This may not be the right list for this, but I figured there's > bound to be some py2exe experts. [snip] There's bound to be even more py2exe experts on py2exe-users at lists.sourceforge.net :-) > > Thanks, > > Bobby > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From rwupole at msn.com Wed Apr 19 13:39:11 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 19 Apr 2006 07:39:11 -0400 Subject: [python-win32] Building pywin32 with the free MS toolkitcompiler References: <79990c6b0604171454s77c0bda5qdc11f8f719811c59@mail.gmail.com> Message-ID: Mark Hammond wrote: >> On 4/17/06, Paul Moore wrote: >> > On 4/16/06, Paul Moore wrote: >> > > I tried building one for myself, but I'm missing some critical >> > > dependencies (dsound.h?) >> > >> > I'm assuming this is from the DirectX SDK, which I'm in the process of >> > downloading now to try it out. Are there any other downloads I should >> > get in order to build pywin32? (I have the platform SDK - the setup.py >> > doesn't mention any others as still being needed, but then again, it >> > didn't mention the DirectX one either...) >> >> Looks like atlbase.h is needed in win32netuse and win32netuser. That's >> annoying, as it's not freely available, as far as I know. >> >> It's possible taht ATL isn't actually needed, though - commenting the >> includes out results in a successful compile. The link fails with an >> odd error, though - > > Removing atlbase.h just meant that advapi32.lib needed to be added to the > link command-line - presumably the ATL headers automatically caused that to > happen. I've just checked in a fix for that and removed that header. > >> If I comment out win32net from setup.py, I hit a problem in >> win32wnet\PyNetresource.cpp, which uses ATL for Unicode conversion >> macros. > > These conversion macros are fairly easy (but not search-replace easy) to > change, and I do it as I find it necessary. > I've removed the ATL macros from win32wnet. (checkin messages are still bouncing) Roger From p.f.moore at gmail.com Wed Apr 19 15:07:17 2006 From: p.f.moore at gmail.com (Paul Moore) Date: Wed, 19 Apr 2006 14:07:17 +0100 Subject: [python-win32] Building pywin32 with the free MS toolkitcompiler In-Reply-To: References: <79990c6b0604171454s77c0bda5qdc11f8f719811c59@mail.gmail.com> Message-ID: <79990c6b0604190607k5a916eafy4360f37fcb483f2@mail.gmail.com> On 4/19/06, Roger Upole wrote: > I've removed the ATL macros from win32wnet. (checkin messages are still bouncing) Cool, thanks. I was going to look at this, but real life came along... When I get back to it, I'll see how much I can get running, and post a patch on SF. Paul. PS Is SF CVS the right place to get the latest sources? I ask because the log for win32wnet on there (using the viewcvs interface) shows the last change to win32wnet.cpp being by Mark, 5 months ago, saying "Finish the excise of the atl unicode conversion macros." I'm confused - has Guido been letting the time machine keys out of his sight again? :-) From timr at probo.com Wed Apr 19 19:16:34 2006 From: timr at probo.com (Tim Roberts) Date: Wed, 19 Apr 2006 10:16:34 -0700 Subject: [python-win32] Threading problem In-Reply-To: References: Message-ID: <44467072.9090205@probo.com> On Tue, 18 Apr 2006 15:01:10 +0200 (Central European Daylight Time), "Aleksandar Cikota" wrote: >I have a problem with threading. > > Why do you think it is a threading problem? Does this exact program work if you replace TestThread().start() with TestThread().run()? Do you know for certain that the MaxIm objects are thread safe? You're creating the documents in one thread and using them in another. >import win32com.client >import time >import os >import threading >Document = win32com.client.Dispatch('MaxIm.Document') >Application = win32com.client.Dispatch('MaxIm.Application') >p = win32com.client.dynamic.Dispatch('PinPoint.Plate') >class TestThread (threading.Thread): > def run (self): > path_to_watch = "F:/Images/VRT/" > before = dict ([(f, None) for f in os.listdir (path_to_watch)]) > while 1: > time.sleep(2) > after2 = dict ([(f, None) for f in os.listdir (path_to_watch)]) > added = [f for f in after2 if not f in before] > > As a side note, why do you turn these into dicts instead of just leaving them as lists? Given your usage, this seems like unnecessary extra overhead. And this code can't be right. If there are multiple new files in the directory, your "name" string will contain ALL of them, and it's virtually certain that OpenFile won't know how to handle that. > if added: > name= ' ,'.join (added) > if str(name[-3:])=='fit': > > The "str" is unnecessary here. "name" is already a string. > print name > Document.OpenFile('F:/Images/VRT/'+name) > Document.SaveFile('F:/Images/VRT/'+ >str(name[0:-4])+'.jpg', 6, 1024,2) > Application.CloseAll() > > Does CloseAll close the application? If so, doesn't that make the Document objects evaporate? Why don't you create the Document and Application objects in your inner loop? There's no sense in forcing an instance of the application to stick around all the time when it's only going to be asked to operate occasionally. > before = after2 >TestThread().start() > -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From theller at python.net Wed Apr 19 19:30:43 2006 From: theller at python.net (Thomas Heller) Date: Wed, 19 Apr 2006 19:30:43 +0200 Subject: [python-win32] Building pywin32 with the free MS toolkitcompiler In-Reply-To: <79990c6b0604190607k5a916eafy4360f37fcb483f2@mail.gmail.com> References: <79990c6b0604171454s77c0bda5qdc11f8f719811c59@mail.gmail.com> <79990c6b0604190607k5a916eafy4360f37fcb483f2@mail.gmail.com> Message-ID: Paul Moore wrote: > On 4/19/06, Roger Upole wrote: >> I've removed the ATL macros from win32wnet. (checkin messages are still bouncing) > > Cool, thanks. I was going to look at this, but real life came along... > > When I get back to it, I'll see how much I can get running, and post a > patch on SF. > > Paul. > > PS Is SF CVS the right place to get the latest sources? I ask because > the log for win32wnet on there (using the viewcvs interface) shows the > last change to win32wnet.cpp being by Mark, 5 months ago, saying > "Finish the excise of the atl unicode conversion macros." I'm confused > - has Guido been letting the time machine keys out of his sight again? > :-) The anon CVS on SF is not currently synced with the developer CVS servers: http://sourceforge.net/docman/display_doc.php?docid=2352&group_id=1#1145038684 Thomas From rwupole at msn.com Wed Apr 19 19:39:35 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 19 Apr 2006 13:39:35 -0400 Subject: [python-win32] Re: Building pywin32 with the free MS toolkitcompiler References: <79990c6b0604171454s77c0bda5qdc11f8f719811c59@mail.gmail.com> <79990c6b0604190607k5a916eafy4360f37fcb483f2@mail.gmail.com> Message-ID: Paul Moore wrote: > On 4/19/06, Roger Upole wrote: > > I've removed the ATL macros from win32wnet. (checkin messages are still bouncing) > > Cool, thanks. I was going to look at this, but real life came along... > > When I get back to it, I'll see how much I can get running, and post a > patch on SF. > > Paul. > > PS Is SF CVS the right place to get the latest sources? I ask because > the log for win32wnet on there (using the viewcvs interface) shows the > last change to win32wnet.cpp being by Mark, 5 months ago, saying > "Finish the excise of the atl unicode conversion macros." I'm confused > - has Guido been letting the time machine keys out of his sight again? > :-) According to their Site Status page ( http://sourceforge.net/docs/A04/ ), SF is still not completely done fixing the CVS problems they've had, and viewcvs won't be synched up for some time. Roger From aanderson at opentv.com Wed Apr 19 22:47:43 2006 From: aanderson at opentv.com (Anderson, Allan) Date: Wed, 19 Apr 2006 13:47:43 -0700 Subject: [python-win32] MS Exchange address book access within Python Message-ID: Hi, folks. I'm working with the gnatsparse.py script included with Bugzilla to import my company's old GNATS bug database. As this script appears to have been written specifically for the migration of the GCC project, and also as it was written for an older version of Bugzilla, I'm having to make some modifications. One thing I need to do is consolidate the user names. GNATS keeps a list of these in a file called 'responsible' -- they include a username and real name pair like this: 'stanislas.godel:Stanislas Godel:'. However, the bug Reporter field and other similar fields list an email address (say, 'sgodel at mycompany.com'). I know that our email system will accept email addressed in the long form (stanislas.godel at mycompany.com) as well as in the shorter form. It strikes me that it would be very convenient and result in very correct data if I simply looked up the addresses and names in our Exchange address book. I know nothing about how that might work, however. Is there a python module that wraps up this sort of handy functionality? Or should I start looking through the Win32 API, and just call it directly? I don't know much about Windows programming. Thanks! From mli at deform.com Thu Apr 20 00:13:29 2006 From: mli at deform.com (Michael Li) Date: Wed, 19 Apr 2006 18:13:29 -0400 Subject: [python-win32] wrong results in service running mode In-Reply-To: <444012D8.3070007@deform.com> References: <443D0CA6.1000706@deform.com> <444012D8.3070007@deform.com> Message-ID: <4446B609.7090009@deform.com> Hi, I have a python program running 24x7. One piece of the program is to check a file exist or not as follows: szNormPath= os.path.normpath(strFileName) nRetCode = os.access(szNormPath, os.F_OK) # nRetCode = os.path.exists(szNormPath) When the file path is C:\shared\t.txt, no problem. When the path becomes L:\t.txt, then I got problems: nRetCode always is False(0), here L: is a mapped drive L: = C:\shared. So L:\t.txt and C:\shared\t.txt point to the same file. The strange thing is that when I run the python program in a DOS Window, I don't have the above problem, that is, nRetCode always is True(1) for L:\t.txt. The above strange thing happened at one computer, the "L:" can be at another computer, let's say I have two computers, computer 2 maps computer 1 C:\shared as L:, L: = \\computer 1\shared, if the python program runs on computer 1 in service mode, nRetCode always is False(0), if the python program runs on DOS window of computer 1, nRetCode always is True(1). How do I solve the problem ? What else function I should use ? I am using python2.3. best regards. Michael li ========== This email message and any attachments are for the sole use of the intended recipients and may contain proprietary and/or confidential information which may be privileged or otherwise protected from disclosure. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipients, please contact the sender by reply email and destroy the original message and any copies of the message as well as any attachments to the original message. From mhammond at skippinet.com.au Thu Apr 20 01:01:43 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 20 Apr 2006 09:01:43 +1000 Subject: [python-win32] wrong results in service running mode In-Reply-To: <4446B609.7090009@deform.com> Message-ID: > One piece of the program is to check a file exist or not as follows: > > szNormPath= os.path.normpath(strFileName) > nRetCode = os.access(szNormPath, os.F_OK) > # nRetCode = os.path.exists(szNormPath) > > When the file path is C:\shared\t.txt, no problem. > When the path becomes L:\t.txt, then I got problems: > nRetCode always is False(0), here L: is a mapped drive > L: = C:\shared. So L:\t.txt and C:\shared\t.txt > point to the same file. This is almost an FAQ for services and has nothing to do with Python. When running from a DOS box, the service is running as your user, so has all your drive mappings etc. When running as a service it generally runs as a different user, so does not. Worse, the LocalSystem account generally has no network access. The solution is generally just to use the complete UNC name '\\server\share' in your Python program - this generally works fine (but still will generally *not* work for the LocalSystem account - so you will also need to change the username) Cheers, Mark From mark.m.mcmahon at gmail.com Thu Apr 20 01:52:29 2006 From: mark.m.mcmahon at gmail.com (Mark Mc Mahon) Date: Wed, 19 Apr 2006 19:52:29 -0400 Subject: [python-win32] ANN: pywinauto 0.3.3 released - bug fixes, added methods, removed deprecated methods Message-ID: <71b6302c0604191652t22e10ca1k4ccdc228cd660ae5@mail.gmail.com> Hi, 0.3.3 release of pywinauto is now available. pywinauto is a set of open-source (LGPL) modules for using Python as a GUI automation 'driver' for Windows NT based Operating Systems (NT/W2K/XP). SourceForge project page: http://sourceforge.net/projects/pywinauto Download from SourceForge http://sourceforge.net/project/showfiles.php?group_id=157379 Here is the list of changes from 0.3.2: 0.3.3 Added some methods, and fixed some small bugs ------------------------------------------------------------------ 19-Apr-2006 * Added a wait for the control to be active and configurable sleeps after 'modifying' actions (e.g. Select, Deselect, etc) * Fixed Timings.Slow() and Timings.Fast() - they could in certain circumstances do the opposite! If you had already set a timing slower or faster then they would set it then they would blindly ignore that and set their own times. I added functionality that they will take either the slowest or fastest of the new/current setting rather then blindly setting to the new value. * Fixed some hidden bugs with HwndWrapper.CloseClick() * Fixed a bug in setup.py that would raise an error when no argument was specified * Added an argument to HwndWrapper.SendMessageTimeout so that the wait options could be passed in. * Added HwndWrapper.Close(), Maximize(), Minimize(), Restore() and GetShowState(). * Commented out all deprecated methods (will be removed completely in some future release). * Added Application.kill_() method - which closes all windows and kills the application. If the application is asking if you want to save your changes - you will not be able to click yes or no and the application will be killed anyway!. If you want to follow this project then please sign up to the mailing list: https://lists.sourceforge.net/mailman/listinfo/pywinauto-users Thanks From rwupole at msn.com Thu Apr 20 02:39:50 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 19 Apr 2006 20:39:50 -0400 Subject: [python-win32] Re: Building pywin32 with the free MS toolkitcompiler Message-ID: I also removed the ATL headers from win32com. Although with viewcvs, anonymous CVS, and checkin messages broken, it's kind of hard to tell. Roger From dbri.tcc at gmail.com Thu Apr 20 17:13:46 2006 From: dbri.tcc at gmail.com (Don Bright) Date: Thu, 20 Apr 2006 10:13:46 -0500 Subject: [python-win32] Catching Windows Shutdown events. Message-ID: Hello, I need to do something when windows shuts down, as when someone presses the power button. I believe this is a window message, WM_QUERYENDSESSION or WM_ENDSESSION. I can't find any way to trap this in python. atexit() does not work. using the signal module to trap SIGBREAK or SIGTERM does not work either. Any help? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060420/9d82aeaa/attachment.html From tim.golden at viacom-outdoor.co.uk Thu Apr 20 17:56:17 2006 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu, 20 Apr 2006 16:56:17 +0100 Subject: [python-win32] MS Exchange address book access within Python Message-ID: [Anderson, Allan] | Hi, folks. I'm working with the gnatsparse.py script included with | Bugzilla to import my company's old GNATS bug database. As this script | appears to have been written specifically for the migration of the GCC | project, and also as it was written for an older version of Bugzilla, | I'm having to make some modifications. | | ... it would be very convenient and result in very correct | data if I simply looked up the addresses and names in our Exchange | address book. I know nothing about how that might work, however. | | Is there a python module that wraps up this sort of handy | functionality? I'm not sure if this is exactly what you're after (or even roughly what you're after) but I hope it's a starting point: import codecs import tempfile import win32api import win32com.client constants = win32com.client.constants session = win32com.client.Dispatch ("MAPI.Session") session.Logon () filename = tempfile.mktemp (suffix=".csv") print "Writing to", filename f = codecs.open (filename, "w", "latin-1") try: address_lists = session.AddressLists gal = address_lists.Item ("Global Address List") addresses = gal.AddressEntries for i in range (addresses.Count): entry = addresses.Item (i + 1) if entry.DisplayType == constants.CdoUser: name = entry.Name smtp = entry.Fields[0x39FE001E] f.write ('"%s","%s"\n' % (name, smtp)) ## print name finally: f.close () session.Logoff () TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. 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 pydanny at gmail.com Thu Apr 20 21:36:55 2006 From: pydanny at gmail.com (Daniel Greenfeld) Date: Thu, 20 Apr 2006 15:36:55 -0400 Subject: [python-win32] Need help with AutoSummarize feature in Word Message-ID: <7af2eae40604201236o58792604u7c1a04ecabdf6a64@mail.gmail.com> Hello, Last year I made the migration from Java to Python and have been having lots of fun. Just this month I got tasked with a COM programming effort, and since none of us on the team are COM programmers, we decided to do the effort in Python and I was assigned the task. And, of course, in our ignorance of COM programming, we ran into a few snags. The project I am on that requires that we go through 20,000 Word Documents and perform autosummaries on each document. I have something that kind of works, but it has some issues. Basically, the code I wrote does the following: 1. Open the Word Document. 2. Do the AutoSummary 3. Save the results to a flat file for later parsing. 4. Close the Word Document. The problem is that this just seems very inefficent. It sometimes neglects to close the word documents so then my computer gets loaded with tons of open word documents (fortunately I have restricted the number runs it goes through). Also, in the case of yesterday, I actually managed to break the COM server (or whatever it may be called). I'm sure there is a better way of doing things, but actually finding a COM programmer who really understands COM is turning out to be harder than I thought. My hope is that I can get some pointers or even some code fixes so I can progress forward on this effort. If this is not the place to post this sort of request, please direct me to where I should go. For reference, here is the code as it stands: """ This is a test script for playing with various COM word API items using the win32com Python Lib using the Active Python installation. It works in ActivePython, likely nowhere else. Notes: 1. This file need major cleanup 2. This broke Word as a COM server. Need to understand COM better 3. Perhaps run multiple instances of this file? """ import os import datetime # For performance analysis import time from win32com.client import gencache, constants, makepy #basic win32com objects # COM constants that must be established wdSummaryModeCreateNew = 0x3 WORD = 'Word.Application' False, True = 0, -1 #other constants constants breakOut = 10 #How many docs to check before ending. Set to -1 to ensure the entire system is slurped. # seperators used in output docSepB = '\n' + '' + '\n' #Used to break documents inside of the output file docSepE = '\n' + '' + '\n' #Used to break documents inside of the output file sumSepB = '\n' + '' + '\n' #Used to break summary percentage displays inside of a document section in the output file. sumSepE = '\n' + '' + '\n' #Used to break summary percentage displays inside of a document section in the output file. dumpfile = open('test.txt', 'w') class Word: """ I represent all the fun of playing with a MS Word document.""" def __init__(self): """ I initialize the COM object library for word. """ self.app = gencache.EnsureDispatch(WORD) self.summaryPercentages = (5, 10, 18, 25) self.errors = 0 def open(self, doc): """ I open the Word file to be autosummarized. """ self.app.Documents.Open(FileName = doc) def autoSummarize(self, Length = 30, Mode = wdSummaryModeCreateNew, UpdateProperties = True): """ I do the autosummary and return the content. This actually creates a new tmp word file.""" try: self.app.ActiveDocument.AutoSummarize(Length, Mode, UpdateProperties) return word.app.ActiveDocument.Content.Text except: self.errors += 1 return '' def close(self): """ I close the Word document.""" self.app.ActiveDocument.Close(SaveChanges=False) if __name__ == '__main__': print '*'*80 word = Word() startTime = datetime.datetime.now() count = 0 for root, dirs, files in os.walk('C:/wordData/'): for file in files: #in case we get a non-word doc or if it is a word temp file that somehow got saved. if file.lower().endswith('.doc') and not file.startswith('~'): fileName = os.path.join(root, file) else: continue print 'File ' + fileName dumpfile.write(docSepB) dumpfile.write(fileName + '\n') for value in word.summaryPercentages: word.open(fileName) print value dumpfile.write(sumSepB) dumpfile.write('Length: ' + str(value) + '\n') try: data = str(word.autoSummarize(Length=value)) except: data = '' #print data if len(data.strip()): dumpfile.write(data) else: dumpfile.write('No Summary') dumpfile.write(sumSepE) word.close() time.sleep(1) dumpfile.write(docSepE) # closing of the doc dumpfile.write('*' * 80 + '\n') # closing of the doc word.close() time.sleep(3) count += 1 if count == breakOut: break if count == breakOut: break print 'Done: ' + str(datetime.datetime.now() - startTime) From rwupole at msn.com Fri Apr 21 05:25:36 2006 From: rwupole at msn.com (Roger Upole) Date: Thu, 20 Apr 2006 23:25:36 -0400 Subject: [python-win32] Re: Catching Windows Shutdown events. Message-ID: Don Bright wrote: > Hello, > > I need to do something when windows shuts down, as when someone presses the > power button. > > I believe this is a window message, WM_QUERYENDSESSION or WM_ENDSESSION. > > I can't find any way to trap this in python. > > atexit() does not work. > > using the signal module to trap SIGBREAK or SIGTERM does not work either. > > Any help? Thanks. You might be able to use win32api.SetConsoleCtrlHandler and catch the CTRL_SHUTDOWN_EVENT that's sent to the console. Roger From timr at probo.com Fri Apr 21 19:00:33 2006 From: timr at probo.com (Tim Roberts) Date: Fri, 21 Apr 2006 10:00:33 -0700 Subject: [python-win32] Need help with AutoSummarize feature in Word In-Reply-To: References: Message-ID: <44490FB1.1060902@probo.com> On Thu, 20 Apr 2006 15:36:55 -0400, "Daniel Greenfeld" wrote: >Last year I made the migration from Java to Python and have been >having lots of fun. Just this month I got tasked with a COM >programming effort, and since none of us on the team are COM >programmers, we decided to do the effort in Python and I was assigned >the task. And, of course, in our ignorance of COM programming, we ran >into a few snags. > >The project I am on that requires that we go through 20,000 Word >Documents and perform autosummaries on each document. I have >something that kind of works, but it has some issues. Basically, the >code I wrote does the following: > >1. Open the Word Document. >2. Do the AutoSummary >3. Save the results to a flat file for later parsing. >4. Close the Word Document. > >The problem is that this just seems very inefficent. > There is simply no efficient way to do this. What you have is basically the right approach, with some tweaking. >It sometimes >neglects to close the word documents so then my computer gets loaded >with tons of open word documents > Right, because you close the summary, but you never close the original document. >import os >import datetime # For performance analysis >import time >from win32com.client import gencache, constants, makepy #basic win32com objects > ># COM constants that must be established >wdSummaryModeCreateNew = 0x3 > > That constant should be in win32com.client.constants after you do your EnsureDispatch. >WORD = 'Word.Application' >False, True = 0, -1 > > That's an incredibly bad idea. Python has intrinsic constants called False and True with very different values, and you should be able to use them with APIs that expect a Boolean. ># seperators used in output >docSepB = '\n' + '' + '\n' #Used to break documents >inside of the output file >docSepE = '\n' + '' + '\n' #Used to break documents >inside of the output file >sumSepB = '\n' + '' + '\n' #Used to break summary >percentage displays inside of a document section in the output file. >sumSepE = '\n' + '' + '\n' #Used to break summary >percentage displays inside of a document section in the output file. > > Kind of a trivial note -- the + operator on strings is inefficient. It's better just to create the constants as one chunk, but since this is only a one-time thing, it really doesn't matter. >class Word: > """ I represent all the fun of playing with a MS Word document.""" > > def __init__(self): > """ I initialize the COM object library for word. """ > > self.app = gencache.EnsureDispatch(WORD) > self.summaryPercentages = (5, 10, 18, 25) > self.errors = 0 > > def open(self, doc): > """ I open the Word file to be autosummarized. """ > > self.app.Documents.Open(FileName = doc) > > The Open API returns a Document object. You should save that Document object, so that you can close it later. self.original = self.app.Documents.Open( FileName = doc ) > def autoSummarize(self, Length = 30, Mode = >wdSummaryModeCreateNew, UpdateProperties = True): > """ I do the autosummary and return the content. This >actually creates a new tmp word file.""" > try: > self.app.ActiveDocument.AutoSummarize(Length, Mode, >UpdateProperties) > > AutoSummarize returns a Range object. It may be possible to get the text directly from this Range object, instead of relying on the ActiveDocument property. > return word.app.ActiveDocument.Content.Text > > You really want "self" instead of "word" here. You're getting the global variable "word", which happens to be the same thing in this case, but better to do it right. > except: > self.errors += 1 > > return '' > > def close(self): > """ I close the Word document.""" > > self.app.ActiveDocument.Close(SaveChanges=False) > > Here, you're closing the summary. You also need to do: self.original.Close() > for root, dirs, files in os.walk('C:/wordData/'): > for file in files: > #in case we get a non-word doc or if it is a word temp >file that somehow got saved. > if file.lower().endswith('.doc') and not file.startswith('~'): > fileName = os.path.join(root, file) > else: continue > > print 'File ' + fileName > dumpfile.write(docSepB) > dumpfile.write(fileName + '\n') > for value in word.summaryPercentages: > word.open(fileName) > print value > > Since you're running 4 different summaries from the same original, why not do the word.open outside of the loop? You would have to change the Word class to close the autosummary document in the autoSummarize call, instead of in close, but that's easy. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From aanderson at opentv.com Fri Apr 21 22:05:37 2006 From: aanderson at opentv.com (Anderson, Allan) Date: Fri, 21 Apr 2006 13:05:37 -0700 Subject: [python-win32] MS Exchange address book access within Python Message-ID: Thanks for your suggestion and code, Tim. I wound up using the Cookbook recipe here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/475179 -Allan -----Original Message----- From: python-win32-bounces+aanderson=opentv.com at python.org [mailto:python-win32-bounces+aanderson=opentv.com at python.org] On Behalf Of Tim Golden Sent: Thursday, April 20, 2006 8:56 AM To: python-win32 at python.org Subject: Re: [python-win32] MS Exchange address book access within Python [Anderson, Allan] | Hi, folks. I'm working with the gnatsparse.py script included with | Bugzilla to import my company's old GNATS bug database. As this script | appears to have been written specifically for the migration of the GCC | project, and also as it was written for an older version of Bugzilla, | I'm having to make some modifications. | | ... it would be very convenient and result in very correct | data if I simply looked up the addresses and names in our Exchange | address book. I know nothing about how that might work, however. | | Is there a python module that wraps up this sort of handy | functionality? I'm not sure if this is exactly what you're after (or even roughly what you're after) but I hope it's a starting point: import codecs import tempfile import win32api import win32com.client constants = win32com.client.constants session = win32com.client.Dispatch ("MAPI.Session") session.Logon () filename = tempfile.mktemp (suffix=".csv") print "Writing to", filename f = codecs.open (filename, "w", "latin-1") try: address_lists = session.AddressLists gal = address_lists.Item ("Global Address List") addresses = gal.AddressEntries for i in range (addresses.Count): entry = addresses.Item (i + 1) if entry.DisplayType == constants.CdoUser: name = entry.Name smtp = entry.Fields[0x39FE001E] f.write ('"%s","%s"\n' % (name, smtp)) ## print name finally: f.close () session.Logoff () TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. 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 at python.org http://mail.python.org/mailman/listinfo/python-win32 From v_noroozi64 at yahoo.com Sat Apr 22 14:56:50 2006 From: v_noroozi64 at yahoo.com (Vahid Noroozi) Date: Sat, 22 Apr 2006 05:56:50 -0700 (PDT) Subject: [python-win32] select.poll() Message-ID: <20060422125650.56292.qmail@web31609.mail.mud.yahoo.com> hello, in windows python select module doesn't suppport poll() i wanted to know if it is possible to implement poll function by using select.select() function in windows. --------------------------------- Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries for just 2?/min with Yahoo! Messenger with Voice. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060422/dec7c26a/attachment.html From pydanny at gmail.com Sat Apr 22 15:20:07 2006 From: pydanny at gmail.com (Daniel Greenfeld) Date: Sat, 22 Apr 2006 09:20:07 -0400 Subject: [python-win32] Python-win32 Digest, Vol 37, Issue 25 In-Reply-To: References: Message-ID: <7af2eae40604220620g4b1d4d35x91b55ddc8759a74f@mail.gmail.com> > Date: Fri, 21 Apr 2006 10:00:33 -0700 > From: Tim Roberts > Subject: Re: [python-win32] Need help with AutoSummarize feature in > Word > To: python-win32 at python.org > Message-ID: <44490FB1.1060902 at probo.com> > Content-Type: text/plain; charset=ISO-8859-1 First off, thanks very much Tim for the help. Your advice made a big difference! > >It sometimes > >neglects to close the word documents so then my computer gets loaded > >with tons of open word documents > > > > Right, because you close the summary, but you never close the original > document. Gotcha. I think I see what is going on via the issue of documents. > ># COM constants that must be established > >wdSummaryModeCreateNew = 0x3 > > > > > > That constant should be in win32com.client.constants after you do your > EnsureDispatch. Thanks for pointing that out. Now I see how the EnsureDispatch works. > >WORD = 'Word.Application' > >False, True = 0, -1 > > That's an incredibly bad idea. Python has intrinsic constants called > False and True with very different values, and you should be able to use > them with APIs that expect a Boolean. I agree. That was based off the sample I pulled out of the Learning Python book. Now I'ved nixed it and am much happer for it. > Kind of a trivial note -- the + operator on strings is inefficient. > It's better just to create the constants as one chunk, but since this is > only a one-time thing, it really doesn't matter. Don't worry about trivial notes. The more advice I get from people on proper Python practices the better. > The Open API returns a Document object. You should save that Document > object, so that you can close it later. > > self.original = self.app.Documents.Open( FileName = doc ) Thanks. This simple bit of advice is really what has enabled me to finish up the project two weeks ahead of schedule. > > def autoSummarize(self, Length = 30, Mode = > >wdSummaryModeCreateNew, UpdateProperties = True): > > """ I do the autosummary and return the content. This > >actually creates a new tmp word file.""" > > try: > > self.app.ActiveDocument.AutoSummarize(Length, Mode, > >UpdateProperties) > > > AutoSummarize returns a Range object. It may be possible to get the > text directly from this Range object, instead of relying on the > ActiveDocument property. Can you help me with finding documentation or examples of different ways to play with the Range objects? The MSDN docs seem to be assuming I already know what a Range is. > > return word.app.ActiveDocument.Content.Text > > You really want "self" instead of "word" here. You're getting the > global variable "word", which happens to be the same thing in this case, > but better to do it right. Oops! Thanks! > Here, you're closing the summary. You also need to do: > self.original.Close() Yep. That works nicely! > > Since you're running 4 different summaries from the same original, why > not do the word.open outside of the loop? You would have to change the > Word class to close the autosummary document in the autoSummarize call, > instead of in close, but that's easy. It was easy. Like I said, your advice made me jump really far ahead. Thanks so much! -- 'Knowledge is Power' Daniel Greenfeld http://del.icio.us/dgreenfe From le.dahut at laposte.net Mon Apr 24 12:08:14 2006 From: le.dahut at laposte.net (le dahut) Date: Mon, 24 Apr 2006 12:08:14 +0200 Subject: [python-win32] network copy Message-ID: <444CA38E.9030702@laposte.net> Hello, What is the best way to copy files from a windows/samba share without connecting a network drive using python ? K. From tim.golden at viacom-outdoor.co.uk Mon Apr 24 12:18:42 2006 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon, 24 Apr 2006 11:18:42 +0100 Subject: [python-win32] network copy Message-ID: [le dahut] | What is the best way to copy files from a windows/samba share without | connecting a network drive using python ? Well, to answer your question two ways... For general copying-a-file on windows stuff, have a look here: http://timgolden.me.uk/python/win32_how_do_i/copy-a-file.html To refer to a Windows / Samba share, use a UNC: \\server\share\some\path\filename.txt TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. 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 grickert at coldstorage.com Mon Apr 24 17:09:20 2006 From: grickert at coldstorage.com (Gerrat Rickert) Date: Mon, 24 Apr 2006 11:09:20 -0400 Subject: [python-win32] python and WonderWare (automation server) Message-ID: ...on the off chance that anyone here can help me, here goes: I'm trying to communicate with an OPC server (WonderWare's Factory Suite Gateway). I'm using an OPC Client (OPC Web Client from Software ToolBox). I instantiate the client: pythoncom.CoInitialize() win32com.client.Dispatch('OPCLabs.EasyDA3.0') and I can read and write WonderWare tags successfully for a number of hours. Then the communications fail. Generally, I get one of these three Exceptions: ======================== (-2147352567, 'Exception occurred.', (0, 'OPCLabs.EasyDA3.0', 'Write not completed. This error indicates that it could not be verified that the requested write operation was completed during the timeout period. It is possible that the write operation will actually succeed or fail, but later. Increase the timeout period if you want to obtain positive or negative indication of the operation outcome. Other reason for this error may be that under heavy loads, topic request or response queue is overflowing. Check the event log for queue overflow errors. ', None, 0, -1073430512), None) ========================= (-2147352567, 'Exception occurred.', (0, 'OPCLabs.EasyDA3.0', 'Read not completed. This error indicates that it could not be verified that the requested read operation was completed during the timeout period. It is possible that the read operation will actually succeed or fail, but later. Increase the timeout period if you want to obtain positive or negative indication of the operation outcome. Other reason for this error may be that under heavy loads, topic request or response queue is overflowing. Check the event log for queue overflow errors. ', None, 0, -1073430509), None) ========================== (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -1073426430), None) ========================== There is no heavy load on the server, and there are no queue overflow errors. It fails on both tags actually connected to PLC devices and tags just kept in memory in WonderWare. My read timeout for the tag is 10second. It should be able to read that over 1000 times per second (in the case of memory variables). I have event tried re-instantiating the client - sometimes it works and I can read and write tags again for a while, sometimes it just keeps failing, and I have to restart WonderWare (sometimes more than once) for things to work again. The OPC Client vendor mentioned that they have heard of problems when there are multiple connections to FSGateway, so I changed my design from multiple threads connecting to just a single thread. Still flaky. I don't really think this is a python issue, but neither WonderWare or the OPC client vendor seem to have a lot of experience with Python, so I'd thought I'd post here on the off chance that someone else has experience communicating with WonderWare and Python. It would be great to talk to someone who's successfully done this. Thanks for any help anyone can give, Gerrat Rickert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060424/09d9390d/attachment.htm From timr at probo.com Mon Apr 24 19:49:05 2006 From: timr at probo.com (Tim Roberts) Date: Mon, 24 Apr 2006 10:49:05 -0700 Subject: [python-win32] Need help with AutoSummarize feature in Word In-Reply-To: References: Message-ID: <444D0F91.4060204@probo.com> On Sat, 22 Apr 2006 09:20:07 -0400, "Daniel Greenfeld" wrote: >>> Date: Fri, 21 Apr 2006 10:00:33 -0700 >>> From: Tim Roberts >> >First off, thanks very much Tim for the help. Your advice made a big >difference! > > I'm glad to hear it, and I appreciate the feedback. >>>> > def autoSummarize(self, Length = 30, Mode = >>>> >wdSummaryModeCreateNew, UpdateProperties = True): >>>> > """ I do the autosummary and return the content. This >>>> >actually creates a new tmp word file.""" >>>> > try: >>>> > self.app.ActiveDocument.AutoSummarize(Length, Mode, >>>> >UpdateProperties) >>>> > >>> >>> >>> AutoSummarize returns a Range object. It may be possible to get the >>> text directly from this Range object, instead of relying on the >>> ActiveDocument property. >> >> > >Can you help me with finding documentation or examples of different >ways to play with the Range objects? The MSDN docs seem to be >assuming I already know what a Range is. > Yes, the documentation on the Office object model can be a little frustrating. I usually start with Google ("Word object model range") and focus in from there. Here's the MSDN page on the Range object: http://msdn2.microsoft.com/en-us/library/microsoft.office.interop.word.range_members.aspx There is a Text member that should return to you the entire contents. By the way, one of the best ways to explore these object models is to use the command-line interpreter, or something like Pythonwin. That's how I found out that the Open method returned a Document object. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From gagsl-p32 at yahoo.com.ar Tue Apr 25 03:22:37 2006 From: gagsl-p32 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 24 Apr 2006 22:22:37 -0300 Subject: [python-win32] select.poll() In-Reply-To: <20060422125650.56292.qmail@web31609.mail.mud.yahoo.com> References: <20060422125650.56292.qmail@web31609.mail.mud.yahoo.com> Message-ID: <7.0.1.0.0.20060424220846.03812a50@yahoo.com.ar> At Saturday 22/4/2006 09:56, Vahid Noroozi wrote: >in windows python select module doesn't suppport poll() >i wanted to know if it is possible to implement poll function by >using select.select() function in windows. What do you want to do? select.select() only accepts sockets in Windows, not any file. WaitForMultipleEvent might be useful but depends on what you need. Gabriel Genellina Softlab SRL __________________________________________________ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ˇgratis! ˇAbrí tu cuenta ya! - http://correo.yahoo.com.ar From mark.m.mcmahon at gmail.com Tue Apr 25 23:32:23 2006 From: mark.m.mcmahon at gmail.com (Mark Mc Mahon) Date: Tue, 25 Apr 2006 17:32:23 -0400 Subject: [python-win32] ANN: pywinauto 0.3.4 released - Fixed issue with latest ctypes, speed gains, other changes Message-ID: <71b6302c0604251432k14a21817ta3758e2ee2a37f0a@mail.gmail.com> Hi, 0.3.4 release of pywinauto is now available. pywinauto is a set of open-source (LGPL) modules for using Python as a GUI automation 'driver' for Windows NT based Operating Systems (NT/W2K/XP). SourceForge project page: http://sourceforge.net/projects/pywinauto Download from SourceForge http://sourceforge.net/project/showfiles.php?group_id=157379 Here is the list of changes from 0.3.3: 0.3.4 Fixed issue with latest ctypes, speed gains, other changes ------------------------------------------------------------------ 25-Apr-2006 * The latest version of ctypes (0.9.9.6) removed the code generator I was using some generated code in win32functions.py (stdcall). I was not using those functions so I just commented them out. * Started the process of renaming methods of the ``Application`` and ``WindowSpecification`` classes. I will be converting names to ``UppercaseNames_()``. The trailing ``_`` is to disambiguate the method names from potential Window titles. * Updated how print_control_identifiers works so that it now always prints the disambiguated control name. (even for single controls) * Added __hash__ to HwndWrapper so that controls could be dictionary keys. * Caching various information at various points. For example I cache how well two pieces of text match. For short scripts this has little impact - but for larger script it could well have a major impact. Also caching information for controls that cannot change e.g. TopLeveParent, Parent, etc If you want to follow this project then please sign up to the mailing list: https://lists.sourceforge.net/mailman/listinfo/pywinauto-users Thanks Mark From jimpy at oublic.org Wed Apr 26 15:33:23 2006 From: jimpy at oublic.org (Jim Carroll) Date: Wed, 26 Apr 2006 13:33:23 +0000 (UTC) Subject: [python-win32] broken install. win32com has no 'client' Message-ID: Hi, I have somehow broken my installation of pythonwin win32all. I recently uninstalled 207 and installed 208, hoping that would fix it... but no change. The biggest clue something is broken is I have no win32com.client object. import win32com win32com.client Traceback (most recent call last): File "", line 1, in ? AttributeError: 'module' object has no attribute 'client' dir(win32com) ['SetupEnvironment', '__PackageSupportBuildPath__', '__build_path__', '__builtins__', '__doc__', '__file__', '__gen_path__', '__name__', '__path__', '_frozen', 'gen_py', 'win32com'] I also can't use any typelibs in py2exe anymore. What's the best way to uninstall everything that effects pythonwin so that when I re-install I get a working copy? Thanks, -Jim From mli at deform.com Wed Apr 26 16:32:22 2006 From: mli at deform.com (Michael Li) Date: Wed, 26 Apr 2006 10:32:22 -0400 Subject: [python-win32] how to know the native file path of computer A In-Reply-To: References: Message-ID: <444F8476.4080700@deform.com> Hi, Roger Thank you very much for your suggestions. Finally I solved my problems based on your suggestions. Here is what I did: in client side, I use WNetEnumResource to get mapped share name, M:->\\server_computer\shared then I send "shared" to the remote(server) computer. in server(remote) side, I use win32net.NetShareEnum to compare "shared" and get the local path. I still have the same problem in a Windows/Linux mixed environment. Do you have any idea to get local path in linux from Windows' side ? Best regards. Michael Li Roger Upole wrote: > Michael Li wrote: > >>Hi, >>I got bunch of reply, thank you very much. >>But they are not what i want. >>Let me make it more clear, my code looks like: >> >> nRetCode = os.access(szFolder, os.F_OK) >> if nRetCode == 1: >> nRetCode = os.chdir(szFolder) >> szNormPath = os.path.normpath(szCommand) >> szBatchFile = szNormPath >> anArgs = [szBatchFile, 'NDEBUG'] >> nRetCode = os.spawnv(os.P_NOWAIT, szBatchFile, anArgs) >> >>The above code is on the computer A where python server >>is running. The szFolder must be "C:\shared\database", not >>"W:\database", because "W:" does not exist on computer A, >>"W:" is on computer B. >> >>Right now, szFolder comes from computer B as an argument inputed >>on computer B, I want to make szFolder auto-decide if possible. >>Any ideas ? >> > > > You can use win32net.NetUseGetInfo to find what network share > your local drive is mapped to, and then win32net.NetShareGetInfo > to get the local path on the remote machine. > > Roger > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > ========== This email message and any attachments are for the sole use of the intended recipients and may contain proprietary and/or confidential information which may be privileged or otherwise protected from disclosure. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipients, please contact the sender by reply email and destroy the original message and any copies of the message as well as any attachments to the original message. From jimpy at oublic.org Wed Apr 26 18:30:23 2006 From: jimpy at oublic.org (Jim Carroll) Date: Wed, 26 Apr 2006 16:30:23 +0000 (UTC) Subject: [python-win32] broken install. win32com has no 'client' References: Message-ID: > import win32com > win32com.client The answer is: import win32com.client My Bad! -Jim From mli at deform.com Wed Apr 26 18:31:37 2006 From: mli at deform.com (Michael Li) Date: Wed, 26 Apr 2006 12:31:37 -0400 Subject: [python-win32] wrong results in service running mode In-Reply-To: References: Message-ID: <444FA069.1080205@deform.com> Hi, Mark Thank you very much for your reply. Now I understand that Windows' "SYSTEM" account is not the same as Unix's "root" account. Finally I solved my problems based on Roger Upole's suggestions. Here is what I did: in client side, I use WNetEnumResource to get mapped share name, M:->\\server_computer\shared then I send "shared" to the remote(server) computer. in server(remote) side, I use win32net.NetShareEnum to compare "shared" and get the local path. I still have the same problem in a Windows/Linux mixed environment. Do you have any idea to get local path in linux from Windows' side ? Mark, your Win32 extension is very useful and easy to use, you are genius, thank you thank you very very much. Best regards. Michael Li Mark Hammond wrote: >>One piece of the program is to check a file exist or not as follows: >> >> szNormPath= os.path.normpath(strFileName) >> nRetCode = os.access(szNormPath, os.F_OK) >> # nRetCode = os.path.exists(szNormPath) >> >>When the file path is C:\shared\t.txt, no problem. >>When the path becomes L:\t.txt, then I got problems: >>nRetCode always is False(0), here L: is a mapped drive >>L: = C:\shared. So L:\t.txt and C:\shared\t.txt >>point to the same file. > > > This is almost an FAQ for services and has nothing to do with Python. > > When running from a DOS box, the service is running as your user, so has all > your drive mappings etc. When running as a service it generally runs as a > different user, so does not. Worse, the LocalSystem account generally has > no network access. > > The solution is generally just to use the complete UNC name '\\server\share' > in your Python program - this generally works fine (but still will generally > *not* work for the LocalSystem account - so you will also need to change the > username) > > Cheers, > > Mark > ========== This email message and any attachments are for the sole use of the intended recipients and may contain proprietary and/or confidential information which may be privileged or otherwise protected from disclosure. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipients, please contact the sender by reply email and destroy the original message and any copies of the message as well as any attachments to the original message. From tinoloc at gmail.com Thu Apr 27 00:25:27 2006 From: tinoloc at gmail.com (Tino Dai) Date: Wed, 26 Apr 2006 18:25:27 -0400 Subject: [python-win32] Simple questions about win32pdhutil.GetPerformanceAttributes Message-ID: Hi there, Is there a list of performance stats that one can get back from GetPerformanceAttribute. In the Python Programming in Win32, there is an example with Memory and Available bytes, but none of the processor stats seem to work. Thanks! -Tino -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060426/09bbf68c/attachment.htm From mhammond at skippinet.com.au Thu Apr 27 00:37:27 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 27 Apr 2006 08:37:27 +1000 Subject: [python-win32] Simple questions aboutwin32pdhutil.GetPerformanceAttributes In-Reply-To: Message-ID: Please see the comments in win32pdhutil.GetPerformanceAttributes - they explain that many attributes, particularly the processor ones, require 2 samples to give reasonable results. The comment says: # NOTE: Many counters require 2 samples to give accurate results, # including "% Processor Time" (as by definition, at any instant, a # thread's CPU usage is either 0 or 100). To read counters like this, # you should copy this function, but keep the counter open, and call # CollectQueryData() each time you need to know. # See http://support.microsoft.com/default.aspx?scid=kb;EN-US;q262938 # and http://msdn.microsoft.com/library/en-us/dnperfmo/html/perfmonpt2.asp # My older explanation for this was that the "AddCounter" process forced # the CPU to 100%, but the above makes more sense :) Cheers, Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Tino Dai Sent: Thursday, 27 April 2006 8:25 AM To: Python-win32 at python.org Subject: [python-win32] Simple questions aboutwin32pdhutil.GetPerformanceAttributes Hi there, Is there a list of performance stats that one can get back from GetPerformanceAttribute. In the Python Programming in Win32, there is an example with Memory and Available bytes, but none of the processor stats seem to work. Thanks! -Tino -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060427/a8f17b4d/attachment.html From cappy2112 at gmail.com Thu Apr 27 03:25:37 2006 From: cappy2112 at gmail.com (Tony C) Date: Wed, 26 Apr 2006 18:25:37 -0700 Subject: [python-win32] Problems using PythonWin debugger Message-ID: <8249c4ac0604261825w7566d0del98496209ee9918a1@mail.gmail.com> I had stopped using the PyWin debugger, back in 2.3, because of numerous problems, and unexpected things happening. Now, in 2.4.3 I had tried ti again, but still have the same old problems. I have a script which justs iterates through text files, countng lines, and functions, and subs, of another language Pretty basic iteration, no recursion, no generators. The script runs wel, but isn't counting certain lines, so it's a minor logic problem. I want to set some breakpoints to see whats going on. However, when I set breakpoints, the debugger never stops there. The only place it stops is a the breakpoint in main. I can't even step through the program after the breakpoint in main. The debugger jsut exits the program. No exceptions are thrown, and remember the script runs well on the command line. Also the debugging toolbar dissappears from time to time, and I have to re-enable it. This is one of the same problems I have since 2.2 days, as well as the breakpoints not working. I have tried starting the program in "Step Throuhg the debugger', and "Run in the debugger" modes. Has anyone been able to use this debugger effectively? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060426/1844fafb/attachment.html From pydanny at gmail.com Thu Apr 27 13:27:50 2006 From: pydanny at gmail.com (Daniel Greenfeld) Date: Thu, 27 Apr 2006 07:27:50 -0400 Subject: [python-win32] Getting the text of the first slide of a PowerPoint file Message-ID: <7af2eae40604270427y6cf2cd27r2531d63477f9b80c@mail.gmail.com> Hello, On to part 2 of my project. I need to be able to get the text of the first slide out of a lot of Powerpoint files. If anyone can give me some handy hints, that would be appreciated. By the way, thanks to Tim, my script to handle all the word documents is running today in 26 batches. This list has been very helpful. Thanks, Daniel Greenfeld From jferrell at rhsmith.umd.edu Thu Apr 27 16:19:31 2006 From: jferrell at rhsmith.umd.edu (John Ferrell) Date: Thu, 27 Apr 2006 10:19:31 -0400 Subject: [python-win32] SimpleXMLRPCServer Windows service Message-ID: I am trying to create a Windows service using SimpleXMLRPCServer and win32serviceutil. The service itself seems to be working properly (starts, stops, etc) and I can connect using an XMLRPC client from the localhost. However when I connect from a remote client, I either get a socket error or an xmlrpclib.ProtocolError error. If I use serve_forever() rather than handle_request(), the remote clients can connect but it breaks the Windows service functionality (can't stop the service). It would seem that the problem is related to the way the service handles remote connections, but I cannot figure out what the problem is. I have searched around, but can't find any example code. Hopefully someone can point me in the right direction. thanks, John ## XML-RPC Service import win32serviceutil import win32service import win32event import win32evtlogutil import win32file import servicemanager import SimpleXMLRPCServer class OBJECT: def hello(self): return "Hello World" class XMLRPCSERVICE(win32serviceutil.ServiceFramework): _svc_name_ = "XMLRPCSERVICE" _svc_display_name_ = "XMLRPCSERVICE" _svc_description_ = "XMLRPCSERVICE" def __init__(self, args): win32evtlogutil.AddSourceToRegistry(self._svc_display_name_, sys.executable, "Application") win32serviceutil.ServiceFramework.__init__(self, args) self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) self.hSockEvent = win32event.CreateEvent(None, 0, 0, None) def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) win32event.SetEvent(self.hWaitStop) def SvcDoRun(self): ## Write a started event servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, ' (%s)' % self._svc_name_)) server = SimpleXMLRPCServer.SimpleXMLRPCServer(("", 8080)) object = OBJECT() server.register_instance(object) while 1: win32file.WSAEventSelect(server, self.hSockEvent,win32file.FD_ACCEPT) rc = win32event.WaitForMultipleObjects((self.hWaitStop,self.hSockEvent), 0, win32event.INFINITE) if rc == win32event.WAIT_OBJECT_0: break else: win32file.WSAEventSelect(server,self.hSockEvent, 0) server.handle_request() #server.serve_forever() ## Works, but breaks the Windows service functionality ## Write a stopped event win32evtlogutil.ReportEvent(self._svc_name_, servicemanager.PYS_SERVICE_STOPPED,0, servicemanager.EVENTLOG_INFORMATION_TYPE, (self._svc_name_,"")) if __name__ == '__main__': win32serviceutil.HandleCommandLine(XMLRPCSERVICE) ------------------------------------------------------------------------------------------------------ ## XML-RPC Client import xmlrpclib server = xmlrpclib.ServerProxy("http://remoteserver:8080") print server.hello() -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060427/0e57df10/attachment.html From michaelmurdock at gmail.com Fri Apr 28 02:28:15 2006 From: michaelmurdock at gmail.com (Michael Murdock) Date: Thu, 27 Apr 2006 18:28:15 -0600 Subject: [python-win32] Referencing SimpleCOMServer-based COM object from VisStudio C# code? Message-ID: Hello, I am trying to access my python class, implemented as a COM server, from my Visual Studio C# application. The problem is when I try to add a reference with Visual Studio, my COM object isn't listed. When I run PythonWin and use its COM Browser tool, my COM object is in one of the "registered categories", the Python COM server category. I based my Python code on Mark's SimpleCOMServer.py example and registered it, which seemed to work. It's in the registry and, as I said, the COM browser in PythonWin seems to know about it. But Visual Studio's COM browser doesn't list it and I don't know how else to reference it in my C# code. Mark uses SimpleCOMServer.py with a snippet of VB code, which leads me to believe that it is creating a fully-legal COM server. But Visual Studio must need something closer to a type library for me to be able to simply reference it in my C# project. Any ideas? ~Michael. From grickert at coldstorage.com Fri Apr 28 03:04:23 2006 From: grickert at coldstorage.com (Gerrat Rickert) Date: Thu, 27 Apr 2006 21:04:23 -0400 Subject: [python-win32] Python Error - Cannot Initialize OLE Message-ID: I'm writing an application to control some PLC's,and during initialization a little Window pops up with 'Python Error' in the title and the message 'Cannot Initialize OLE'. It doesn't seem to affect my application other than that error message at the start. I've got a GUI running in the main thread, 1 thread doing OPC communications to an OPC server (thanks to some help from Norm Petterson), and two other worker threads implementing business logic. The main thread creates a couple Queues and passes them to the other threads so they can all communicate. In the main thread, I've set sys.coinit_flags = 0 before importing pythoncom. Each of the other threads call pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED). I have Mark Hammond's book on python programming on Win32, but I'm still confused on how exactly to get all my threads communicating well. This setup seems to work, except for that error window that pops up near the start (I can't even tell exactly where it's cropping up). Does anyone know what causes this error window, or what I'm doing wrong? Thanks for any help, Gerrat Rickert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060427/bc11b0e5/attachment.html From grickert at coldstorage.com Fri Apr 28 03:30:11 2006 From: grickert at coldstorage.com (Gerrat Rickert) Date: Thu, 27 Apr 2006 21:30:11 -0400 Subject: [python-win32] Python Error - Cannot Initialize OLE Message-ID: ...ok, I found out that it's generated by wxPython. It looks like someone in the wxWidgets mailing list had the same error message crop up and solved it by marking their thread as a single-threaded apartment. My problem is, my application is using a basic stand-alone OPC client module I wrote that doesn't seem to work unless I mark it as multithreaded, and when I mark it as multithreaded and the rest of the application as single-threaded, they don't work together. Gerrat Rickert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060427/3a5e32f3/attachment.html From p.f.moore at gmail.com Fri Apr 28 09:59:27 2006 From: p.f.moore at gmail.com (Paul Moore) Date: Fri, 28 Apr 2006 08:59:27 +0100 Subject: [python-win32] Problem with installer for pywin32 with Python 2.5 In-Reply-To: <79990c6b0604160650v23d3bc24oa59ebd7270d2bc2e@mail.gmail.com> References: <79990c6b0604160650v23d3bc24oa59ebd7270d2bc2e@mail.gmail.com> Message-ID: <79990c6b0604280059x6a558698y16c06e2121bdc9b9@mail.gmail.com> On 4/16/06, Paul Moore wrote: > There's a problem with Python 2.5 (http://www.python.org/sf/1465834) > which means that installers with preinstall scripts don't work. The > pywin32 build 208 installer is one such (I reported this as bug > 1465566 before I realised this was a Python bug). Just to confirm, this problem has been fixed with 2.5a2. There are a couple of warnings from the postinstall script, but that looks like it's just because the API version number has changed - the install seems to work fine otherwise. Paul. From tim.golden at viacom-outdoor.co.uk Fri Apr 28 10:17:16 2006 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Fri, 28 Apr 2006 09:17:16 +0100 Subject: [python-win32] Getting the text of the first slide of a PowerPointfile Message-ID: [Daniel Greenfeld] | On to part 2 of my project. I need to be able to get the text of the | first slide out of a lot of Powerpoint files. If anyone can give me | some handy hints, that would be appreciated. Daniel, I started to look at this with an eye to helping you out, but since I don't usually use PowerPoint it was taking more time than I had available. So as not to waste my time in looking or yours in reading... if you're still having problems, could you give some indication of whether you're stuck at the first hurdle: how do I get anything out of PowerPoint by any means? Or whether you've gone so far but some particular aspect of the Model or API is proving difficult? Thanks TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. 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 simon.dahlbacka at gmail.com Fri Apr 28 10:50:01 2006 From: simon.dahlbacka at gmail.com (Simon Dahlbacka) Date: Fri, 28 Apr 2006 11:50:01 +0300 Subject: [python-win32] Getting the text of the first slide of a PowerPointfile In-Reply-To: References: Message-ID: <57124720604280150s1bbadf45p432a23cb3ea7c6ee@mail.gmail.com> I've done it the other way around, i.e. created powerpoint files using python, and could probably provide an example, I'll post later tonight if I just remember to do it.. /Simon On 4/28/06, Tim Golden wrote: > > [Daniel Greenfeld] > > | On to part 2 of my project. I need to be able to get the text of the > | first slide out of a lot of Powerpoint files. If anyone can give me > | some handy hints, that would be appreciated. > > Daniel, I started to look at this with an eye to helping > you out, but since I don't usually use PowerPoint it was > taking more time than I had available. So as not to waste > my time in looking or yours in reading... if you're still > having problems, could you give some indication of whether > you're stuck at the first hurdle: how do I get anything out > of PowerPoint by any means? Or whether you've gone so far > but some particular aspect of the Model or API is proving > difficult? > > Thanks > TJG > > ________________________________________________________________________ > This e-mail has been scanned for all viruses by Star. 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 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060428/6ef3f87e/attachment.html From mhammond at skippinet.com.au Fri Apr 28 14:48:05 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 28 Apr 2006 22:48:05 +1000 Subject: [python-win32] Referencing SimpleCOMServer-based COM object fromVisStudio C# code? In-Reply-To: Message-ID: > I am trying to access my python class, implemented as a COM server, > from my Visual Studio C# application. The problem is when I try to add > a reference with Visual Studio, my COM object isn't listed. > > When I run PythonWin and use its COM Browser tool, my COM object is in > one of the "registered categories", the Python COM server category. > > I based my Python code on Mark's SimpleCOMServer.py example and > registered it, which seemed to work. It's in the registry and, as I > said, the COM browser in PythonWin seems to know about it. But Visual > Studio's COM browser doesn't list it and I don't know how else to > reference it in my C# code. > > Mark uses SimpleCOMServer.py with a snippet of VB code, which leads me > to believe that it is creating a fully-legal COM server. But Visual > Studio must need something closer to a > type library for me to be able to simply reference it in my C# project. You need to provide a typelibrary that describes your object. Pywin32 doesn't come with tools to automatically create typelibs from your .py code, but it is capable of tieing your externally created typelib and your .py implementation together. Thus, you need something like the MSVC tools to create it. Check out the 'pippo' samples in the win32com\test directory (but its still not pretty). Check the archives of this list for some discussions about adding better support to pywin32, incase you are interested... Mark From timr at probo.com Fri Apr 28 18:50:38 2006 From: timr at probo.com (Tim Roberts) Date: Fri, 28 Apr 2006 09:50:38 -0700 Subject: [python-win32] Getting the text of the first slide of a PowerPoint file In-Reply-To: References: Message-ID: <445247DE.5010306@probo.com> On Thu, 27 Apr 2006 07:27:50 -0400, "Daniel Greenfeld" wrote: >On to part 2 of my project. I need to be able to get the text of the >first slide out of a lot of Powerpoint files. If anyone can give me >some handy hints, that would be appreciated. > > PowerPoint is one program that I've never tried to automate, but the same techniques you used in Word should work here. Here is the start page in MSDN that describes the PowerPoint object model: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/modcore/html/deovrMicrosoftPowerPoint2000.asp It looks like you should be able to start from the Application object, then use the ActivePresentation property to get a Presentation object, then get the first Slide from the Slides collection. The text is stored as a series of TextFrame objects in the Shapes collection. The rest is easy... >By the way, thanks to Tim, my script to handle all the word documents >is running today in 26 batches. This list has been very helpful. > > I'm glad to hear this. IMHO, this is exactly the kind of task that Python is perfect for. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From simon.dahlbacka at gmail.com Fri Apr 28 18:57:51 2006 From: simon.dahlbacka at gmail.com (Simon Dahlbacka) Date: Fri, 28 Apr 2006 19:57:51 +0300 Subject: [python-win32] Getting the text of the first slide of a PowerPointfile In-Reply-To: <57124720604280150s1bbadf45p432a23cb3ea7c6ee@mail.gmail.com> References: <57124720604280150s1bbadf45p432a23cb3ea7c6ee@mail.gmail.com> Message-ID: <57124720604280957u17617c62o5231b76b7cb8f76a@mail.gmail.com> here's the file I've used for creating PowerPoints, you should be able to use it "backwards" hope it provides some pointers.. /S On 4/28/06, Simon Dahlbacka wrote: > > I've done it the other way around, i.e. created powerpoint files using > python, and could probably provide an example, I'll post later tonight if I > just remember to do it.. > > /Simon > > > On 4/28/06, Tim Golden wrote: > > > > [Daniel Greenfeld] > > > > | On to part 2 of my project. I need to be able to get the text of the > > | first slide out of a lot of Powerpoint files. If anyone can give me > > | some handy hints, that would be appreciated. > > > > Daniel, I started to look at this with an eye to helping > > you out, but since I don't usually use PowerPoint it was > > taking more time than I had available. So as not to waste > > my time in looking or yours in reading... if you're still > > having problems, could you give some indication of whether > > you're stuck at the first hurdle: how do I get anything out > > of PowerPoint by any means? Or whether you've gone so far > > but some particular aspect of the Model or API is proving > > difficult? > > > > Thanks > > TJG > > > > ________________________________________________________________________ > > This e-mail has been scanned for all viruses by Star. 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 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060428/9e15741e/attachment.htm -------------- next part -------------- A non-text attachment was scrubbed... Name: ppt.py Type: application/x-python Size: 3704 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20060428/9e15741e/attachment.bin From mc at mclaveau.com Fri Apr 28 19:49:09 2006 From: mc at mclaveau.com (Michel Claveau) Date: Fri, 28 Apr 2006 19:49:09 +0200 Subject: [python-win32] Referencing SimpleCOMServer-based COM object fromVisStudio C# code? References: Message-ID: <001701c66aec$0f026880$0701a8c0@PORTABLES> Hi! You can access to your Python-COM-server, from C#, with a tech named "Late Binding". "Late Binding" can access to dymanic COM server, without type library. After many search, I had can write this code (at bottom of this message), who run with my Python-COM-server. This code run, if compiled with Visual-studio-C#-express-2005 (free). Perhaps this exemple can help you. @-salutations, and **Sorry for my bad english** -- Michel Claveau using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Reflection; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, System.EventArgs e) { object objApp_Late; object pver; try { Type objClassType; objClassType = Type.GetTypeFromProgID("ponx.Mci"); objApp_Late = Activator.CreateInstance(objClassType); pver = objApp_Late.GetType().InvokeMember("version", BindingFlags.GetProperty, null, objApp_Late, null); MessageBox.Show(pver.ToString(), "Version de Ponx : "); pver = objApp_Late.GetType().InvokeMember("PVersion", BindingFlags.InvokeMethod, null, objApp_Late, null); MessageBox.Show(pver.ToString(), "Version de Ponx : "); } catch( Exception theException ) { String errorMessage; errorMessage = "Erreur: "; errorMessage = String.Concat(errorMessage, theException.Message); errorMessage = String.Concat(errorMessage, " Line: "); errorMessage = String.Concat(errorMessage, theException.Source); MessageBox.Show(errorMessage, "Erreur en appelant Ponx"); } } } } From billburns at pennswoods.net Sat Apr 29 22:54:09 2006 From: billburns at pennswoods.net (Bill Burns) Date: Sat, 29 Apr 2006 16:54:09 -0400 Subject: [python-win32] Python Programming on Win32 Book Message-ID: <4453D271.5070704@pennswoods.net> Mark, Is there going to be a 2nd Edition of your Python Programming on Win32 book? If so, when do you think it will be released? Regardless of a second book, do you recommend I purchase the book directly from O'Reilly? I've not checked other vendors (Amazon, Barnes & Noble, etc). I just want to make sure that the most amount for my purchase gets diverted to you :-) Maybe it doesn't matter who I buy from - but I thought I ask anyway! Thanks, Bill From mhammond at skippinet.com.au Sun Apr 30 01:56:31 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 30 Apr 2006 09:56:31 +1000 Subject: [python-win32] Python Programming on Win32 Book In-Reply-To: <4453D271.5070704@pennswoods.net> Message-ID: > Mark, > > Is there going to be a 2nd Edition of your Python Programming on Win32 > book? If so, when do you think it will be released? I hope to have this complete this year, so released some time next year. Of course, that means I need to *start* it this year. I've one or two people lined up to help too (sadly I believe Andy will be too busy to contribute second time around, but I'm yet to confirm that with him) > Regardless of a second book, do you recommend I purchase the book > directly from O'Reilly? I've not checked other vendors (Amazon, Barnes & > Noble, etc). I just want to make sure that the most amount for my > purchase gets diverted to you :-) Maybe it doesn't matter who I buy from > - but I thought I ask anyway! Thanks for your consideration, but I've no idea how any of that works. AFAIK I just get a few cents per copy sold regardless of who the retailer is. Cheers, Mark. From billburns at pennswoods.net Sun Apr 30 17:16:56 2006 From: billburns at pennswoods.net (Bill Burns) Date: Sun, 30 Apr 2006 11:16:56 -0400 Subject: [python-win32] Python Programming on Win32 Book In-Reply-To: References: Message-ID: <4454D4E8.5010303@pennswoods.net> >>Is there going to be a 2nd Edition of your Python Programming on Win32 >>book? If so, when do you think it will be released? > > > I hope to have this complete this year, so released some time next year. Of > course, that means I need to *start* it this year. I've one or two people > lined up to help too (sadly I believe Andy will be too busy to contribute > second time around, but I'm yet to confirm that with him) Thanks for the info and good luck with the new book! I'm sure there's a lot of people eager to get it! I've just ordered the 1st edition from O'Reilly (it's on back-order). I can't wait a whole year for the new book :-) I guess I'll have two of your books in the future ;-) >>Regardless of a second book, do you recommend I purchase the book >>directly from O'Reilly? I've not checked other vendors (Amazon, Barnes & >>Noble, etc). I just want to make sure that the most amount for my >>purchase gets diverted to you :-) Maybe it doesn't matter who I buy from >>- but I thought I ask anyway! > > > Thanks for your consideration, but I've no idea how any of that works. > AFAIK I just get a few cents per copy sold regardless of who the retailer > is. A few cents, that blows! I'll have to help you out some other way :-) Thanks again - Mark! Bill