From sam_spam_cat at verizon.net Tue May 1 03:43:02 2007 From: sam_spam_cat at verizon.net (Sam The Cat) Date: Mon, 30 Apr 2007 21:43:02 -0400 Subject: [python-win32] Python COM and Photoshop Message-ID: <006001c78b92$0eeb82b0$0201a8c0@neo> Help ! I am writing some COM code in Python to control photoshop. Several functions of PS require an "Array" argument. In the examples of VBscript or javascript the Array type is used. I have tried what would appear to be the equivalent in Python -- Lists and Tuples -- but to no avail. Anyone have any insight on what via the COM interface is equivalent to an Array in javascript ? Here is the Javascript example code ..... selRegion = Array(Array(1,1),Array(1,2),Array(2,2),Array(2,1)) Doc.Selection.Select(selRegion,1,0,0) ..... Here is my interpretation in Python ....... selregion = [(1,1),(1,2),(2,2),(2,1)] print selregion doc.Selection.Select(selregion,1,0,0) ...... Here is the error code generated .......... F:\automation>test2.py [(1, 1), (1, 2), (2, 2), (2, 1)] Traceback (most recent call last): File "F:\automation\test2.py", line 19, in ? doc.Selection.Select(selregion,1,0,0) File ">", line 3, in Select pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Adobe Photoshop', 'Illegal argument - argument 1\n- Only arrays with dimension 1 are supported', None, 0, -2147220262), None) ............ I have tried many differnet permutations of structure for the selregion variable. Any scalar or single dimension array returns an "Illegal Argument" response with no further details -- any thing that resembles a two dimensional array returns the result above. Any help / thoughts would be appreciated From Amit.Arora at infogain.com Tue May 1 07:45:39 2007 From: Amit.Arora at infogain.com (Amit Arora) Date: Tue, 1 May 2007 11:15:39 +0530 Subject: [python-win32] Python Help needed - VerInstallFile API Message-ID: HI All, I need to install a package and check the return value using the VerInstallFile() API : The function declaration which I get on MSDN is : DWORD VerInstallFile( DWORD uFlags, LPCTSTR szSrcFileName, LPCTSTR szDestFileName, LPCTSTR szSrcDir, LPCTSTR szDestDir, LPCTSTR szCurDir, LPTSTR szTmpFile, PUINT lpuTmpFileLen ) Anybody has used this API and could share an example using a standard msi package will be of great help ......... MSI packages can be any package , you make take installation of an ActivePerl package for instance .... (ActivePerl.msi) Regards, ~Amit Arora From f.guerrieri at gmail.com Tue May 1 12:43:31 2007 From: f.guerrieri at gmail.com (Francesco Guerrieri) Date: Tue, 1 May 2007 12:43:31 +0200 Subject: [python-win32] Python COM and Photoshop In-Reply-To: <006001c78b92$0eeb82b0$0201a8c0@neo> References: <006001c78b92$0eeb82b0$0201a8c0@neo> Message-ID: <79b79e730705010343g440fd931kdabbbec457d18c9c@mail.gmail.com> I am a complete beginner myself with python and win so surely there are better ways of doing this. In any case, here's my try. You could try to go in the reverse manner: instead of trying to guess the right way from python to VB, define an Array object in VB and pass it to python, dispatch it if needed, and look at how it is formed. In this way you will find out precisely how the array object is formed. francesco On 5/1/07, Sam The Cat wrote: > > Help ! > > I am writing some COM code in Python to control photoshop. Several > functions of PS require an "Array" argument. In the examples of VBscript > or javascript the Array type is used. I have tried what would appear > to be > the equivalent in Python -- Lists and Tuples -- but to no avail. Anyone > have > any insight on what via the COM interface is equivalent to an Array in > javascript ? > > Here is the Javascript example code > > ..... > selRegion = Array(Array(1,1),Array(1,2),Array(2,2),Array(2,1)) > Doc.Selection.Select(selRegion,1,0,0) > ..... > > Here is my interpretation in Python > > ....... > selregion = [(1,1),(1,2),(2,2),(2,1)] > print selregion > doc.Selection.Select(selregion,1,0,0) > ...... > > Here is the error code generated > > .......... > F:\automation>test2.py > [(1, 1), (1, 2), (2, 2), (2, 1)] > Traceback (most recent call last): > File "F:\automation\test2.py", line 19, in ? > doc.Selection.Select(selregion,1,0,0) > File ">", line 3, in Select > pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Adobe > Photoshop', 'Illegal argument - argument 1\n- Only arrays > with dimension 1 > are supported', None, 0, -2147220262), None) > > > ............ > > I have tried many differnet permutations of structure for the selregion > variable. Any scalar or single dimension array returns an "Illegal > Argument" response with no further details -- any thing that resembles a > two > dimensional array returns the result above. > > Any help / thoughts would be appreciated > > > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- "Voil?! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of fate. This visage, no mere veneer of vanity, is a vestige of the vox populi, now vacant, vanished. However, this valorous visitation of a bygone vexation stands vivified, and has vowed to vanquish these venal and virulent vermin vanguarding vice and vouchsafing the violently vicious and voracious violation of volition. The only verdict is vengeance; a vendetta held as a votive, not in vain, for the value and veracity of such shall one day vindicate the vigilant and the virtuous. Verily, this vichyssoise of verbiage veers most verbose vis-?-vis an introduction, so let me simply add that it's my very good honor to meet you and you may call me V." -- V's introduction to Evey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070501/4eab76d8/attachment.html From paj at pajhome.org.uk Tue May 1 18:07:59 2007 From: paj at pajhome.org.uk (Paul Johnston) Date: Tue, 1 May 2007 17:07:59 +0100 Subject: [python-win32] Running CherryPy inside IIS Message-ID: Hi, I am trying to run a CherryPy (Python web server) application inside IIS, and having some problems. I'm using wsgiref and this ASP/WSGI script: http://www.aminus.org/blogs/index.php/fumanchu/2005/05/26/wsgi_gateway_for_asp_microsoft_iis For now I'll skip over the details of exactly how I installed that, although I'm happy to provide more info if required. I'm using IIS 6.0 on Windows Server 2003, with Python 2.4. Now, I can get a single request to work - "Hello World". However, the second request produces a stacktrace: File "<Script Block >", line 3, in ? handler(Application, Request, Response).run(wsgiApp) File "C:\Python24\lib\site-packages\wsgiref\asp_gateway.py& quot;, line 85, in __init__ Response.Buffer = buffering File & quot;C:\Python24\lib\site-packages\win32comext\axscript\client\pyscript.py", line 152, in __setattr__ return setattr(self._scriptItem_.dispatchContainer,attr, value) File & quot;C:\Python24\lib\site-packages\win32com\client\dynamic.py", line 521, in __setattr__ self._oleobj_.Invoke(entry.dispid, 0, invoke_type, 0, value) COM Error: Member not found. If I restart the "World Wide Web Publishing" service, it works again (for one request). If I modify handler.asp or global.asa, it works for one request. I tried commenting out the "Response.Buffer =" line, and I get another "COM Error: Member not found", seemingly at the next point COM is used. I've tried refreshing loads of times (in case this is some kind of pooling issue) but I never get a second successful request. Any suggestions will be much appreciated! Does anyone here have CherryPy working on Windows? Paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070501/7e41bb8a/attachment.html From mail at timgolden.me.uk Tue May 1 18:15:54 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 01 May 2007 17:15:54 +0100 Subject: [python-win32] Running CherryPy inside IIS In-Reply-To: References: Message-ID: <463767BA.2000709@timgolden.me.uk> Paul Johnston wrote: [... snip loads of IIS stuff about which I'm blissfully ignorant ...] > Any suggestions will be much appreciated! Does anyone here have CherryPy > working on Windows? Yup. I have it working standalone and (just today) behind mod_python - and with mod_auth_sspi to boot. But that obviously won't help if you're tied to IIS. TJG From mc at mclaveau.com Tue May 1 18:26:21 2007 From: mc at mclaveau.com (Michel Claveau) Date: Tue, 1 May 2007 18:26:21 +0200 Subject: [python-win32] SilverLight, a substitute for Python-Active-Scripting in IE? References: Message-ID: <000f01c78c0d$75ee6650$0701a8c0@PORTABLES> Hi! SilverLight ("MS flash killer"), is a plug-in for InternetExplorer (Win), FireFox (Win), and Safari (Mac). SilverLight is scriptable with Python (& Jscript, and, soon, with Ruby) The release 1.1-Alpha come with JScript & Python (or ironPython?) See : http://www.microsoft.com/silverlight/default.aspx http://www.microsoft.com/silverlight/why-compelling.aspx http://silverlight.net/Default.aspx http://www.microsoft.com/silverlight/install.aspx But, I don't had try SilverLight... Who had try it? @-salutations -- Michel Claveau From Jim.Vickroy at noaa.gov Tue May 1 17:43:41 2007 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue, 01 May 2007 09:43:41 -0600 Subject: [python-win32] Python COM and Photoshop In-Reply-To: <006001c78b92$0eeb82b0$0201a8c0@neo> References: <006001c78b92$0eeb82b0$0201a8c0@neo> Message-ID: <4637602D.6030602@noaa.gov> Sam The Cat wrote: > Help ! > > I am writing some COM code in Python to control photoshop. Several > functions of PS require an "Array" argument. In the examples of VBscript > or javascript the Array type is used. I have tried what would appear to be > the equivalent in Python -- Lists and Tuples -- but to no avail. Anyone have > any insight on what via the COM interface is equivalent to an Array in > javascript ? > > Here is the Javascript example code > > ..... > selRegion = Array(Array(1,1),Array(1,2),Array(2,2),Array(2,1)) > Doc.Selection.Select(selRegion,1,0,0) > ..... > > Here is my interpretation in Python > > ....... > selregion = [(1,1),(1,2),(2,2),(2,1)] > print selregion > doc.Selection.Select(selregion,1,0,0) > ...... > > Here is the error code generated > > .......... > F:\automation>test2.py > [(1, 1), (1, 2), (2, 2), (2, 1)] > Traceback (most recent call last): > File "F:\automation\test2.py", line 19, in ? > doc.Selection.Select(selregion,1,0,0) > File ">", line 3, in Select > pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Adobe > Photoshop', 'Illegal argument - argument 1\n- Only arrays > with dimension 1 > are supported', None, 0, -2147220262), None) > > > ............ > > I have tried many differnet permutations of structure for the selregion > variable. Any scalar or single dimension array returns an "Illegal > Argument" response with no further details -- any thing that resembles a two > dimensional array returns the result above. > I assume this means you have tried a list of lists as follows: selregion = [[1,1],[1,2],[2,2],[2,1]] > Any help / thoughts would be appreciated > > > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From primmer at google.com Tue May 1 19:13:42 2007 From: primmer at google.com (David Primmer) Date: Tue, 1 May 2007 10:13:42 -0700 Subject: [python-win32] Running CherryPy inside IIS In-Reply-To: References: Message-ID: <428eca980705011013g5dee9561m4796744553f36c9b@mail.gmail.com> try some bourbon. http://chichen-itza.compmed.ucdavis.edu/trac/bourbontrac it uses cherrypy and servies wsgi apps on windows. davep On 5/1/07, Paul Johnston wrote: > Hi, > > I am trying to run a CherryPy (Python web server) application inside IIS, > and having some problems. > > I'm using wsgiref and this ASP/WSGI script: > http://www.aminus.org/blogs/index.php/fumanchu/2005/05/26/wsgi_gateway_for_asp_microsoft_iis > > For now I'll skip over the details of exactly how I installed that, although > I'm happy to provide more info if required. > I'm using IIS 6.0 on Windows Server 2003, with Python 2.4. > > Now, I can get a single request to work - "Hello World". However, the second > request produces a stacktrace: > File " > <Script Block >", line 3, in ? > handler(Application, Request, Response).run(wsgiApp) > > File > "C:\Python24\lib\site-packages\wsgiref\asp_gateway.py& > > quot;, line 85, in __init__ > Response.Buffer = buffering > File & > quot;C:\Python24\lib\site-packages\win32comext\axscript\client\pyscript.py", > line 152, in __setattr__ > > return setattr(self._scriptItem_.dispatchContainer,attr, > value) > File & > > quot;C:\Python24\lib\site-packages\win32com\client\dynamic.py", > line 521, in __setattr__ > > self._oleobj_.Invoke(entry.dispid, 0, invoke_type, 0, value) > > COM Error: Member not found. > > > If I restart the "World Wide Web Publishing" service, it works again (for > one request). If I modify handler.asp or global.asa, it works for one > request. > > I tried commenting out the "Response.Buffer =" line, and I get another "COM > Error: Member not found", seemingly at the next point COM is used. > > I've tried refreshing loads of times (in case this is some kind of pooling > issue) but I never get a second successful request. > > Any suggestions will be much appreciated! Does anyone here have CherryPy > working on Windows? > > Paul > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From fumanchu at amor.org Tue May 1 19:16:02 2007 From: fumanchu at amor.org (Robert Brewer) Date: Tue, 1 May 2007 10:16:02 -0700 Subject: [python-win32] Running CherryPy inside IIS In-Reply-To: <463767BA.2000709@timgolden.me.uk> Message-ID: <435DF58A933BA74397B42CDEB8145A860B745E53@ex9.hostedexchange.local> Tim Golden wrote: > Paul Johnston wrote: > > [... snip loads of IIS stuff about which I'm > blissfully ignorant ...] > > > Any suggestions will be much appreciated! Does anyone here > > have CherryPy working on Windows? > > Yup. I have it working standalone and (just today) > behind mod_python - and with mod_auth_sspi to boot. > But that obviously won't help if you're tied to IIS. That's my production setup, too (Apache 2, mod_python, and mod_auth_sspi), and is therefore a fundamental test case for CherryPy. IIS/ASP doesn't have nearly that level of testing (even though I wrote asp_gateway). I don't recommend it unless you have the time to debug the interaction between various versions of IIS, ASP, pywin32, and Python. Robert Brewer System Architect Amor Ministries fumanchu at amor.org From sam_spam_cat at verizon.net Wed May 2 00:28:57 2007 From: sam_spam_cat at verizon.net (Sam The Cat) Date: Tue, 01 May 2007 18:28:57 -0400 Subject: [python-win32] Python COM and Photoshop References: <006001c78b92$0eeb82b0$0201a8c0@neo> <4637602D.6030602@noaa.gov> Message-ID: <004701c78c40$1c1a26e0$0201a8c0@neo> Jim, Yes -- Each permutation has the same issue -- If I try anything that looks two dimensional I get the error below, if I try a scalar or single dimension array I get an "illegal" argument error ----- Original Message ----- From: "Jim Vickroy" To: "Sam The Cat" Cc: Sent: Tuesday, May 01, 2007 11:43 AM Subject: Re: [python-win32] Python COM and Photoshop > Sam The Cat wrote: >> Help ! >> >> I am writing some COM code in Python to control photoshop. Several >> functions of PS require an "Array" argument. In the examples of >> VBscript >> or javascript the Array type is used. I have tried what would appear to >> be >> the equivalent in Python -- Lists and Tuples -- but to no avail. Anyone >> have >> any insight on what via the COM interface is equivalent to an Array in >> javascript ? >> >> Here is the Javascript example code >> >> ..... >> selRegion = Array(Array(1,1),Array(1,2),Array(2,2),Array(2,1)) >> Doc.Selection.Select(selRegion,1,0,0) >> ..... >> >> Here is my interpretation in Python >> >> ....... >> selregion = [(1,1),(1,2),(2,2),(2,1)] >> print selregion >> doc.Selection.Select(selregion,1,0,0) >> ...... >> >> Here is the error code generated >> >> .......... >> F:\automation>test2.py >> [(1, 1), (1, 2), (2, 2), (2, 1)] >> Traceback (most recent call last): >> File "F:\automation\test2.py", line 19, in ? >> doc.Selection.Select(selregion,1,0,0) >> File ">", line 3, in Select >> pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Adobe >> Photoshop', 'Illegal argument - argument 1\n- Only arrays >> with dimension 1 >> are supported', None, 0, -2147220262), None) >> >> >> ............ >> >> I have tried many differnet permutations of structure for the selregion >> variable. Any scalar or single dimension array returns an "Illegal >> Argument" response with no further details -- any thing that resembles a >> two >> dimensional array returns the result above. >> > > I assume this means you have tried a list of lists as follows: > > selregion = [[1,1],[1,2],[2,2],[2,1]] > > >> Any help / thoughts would be appreciated >> >> >> >> _______________________________________________ >> Python-win32 mailing list >> Python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 >> > > From mhammond at skippinet.com.au Wed May 2 01:39:39 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 2 May 2007 09:39:39 +1000 Subject: [python-win32] Running CherryPy inside IIS In-Reply-To: Message-ID: <01cd01c78c49$fd067ab0$090a0a0a@enfoldsystems.local> You almost certainly do not want to do this via ASP. Look at the isapi module that comes with pywin32 for a much lower-level interface into IIS. Cheers, Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Paul Johnston Sent: Wednesday, 2 May 2007 2:08 AM To: python-win32 at python.org Subject: [python-win32] Running CherryPy inside IIS Hi, I am trying to run a CherryPy (Python web server) application inside IIS, and having some problems. I'm using wsgiref and this ASP/WSGI script: http://www.aminus.org/blogs/index.php/fumanchu/2005/05/26/wsgi_gateway_for _asp_microsoft_iis For now I'll skip over the details of exactly how I installed that, although I'm happy to provide more info if required. I'm using IIS 6.0 on Windows Server 2003, with Python 2.4. Now, I can get a single request to work - "Hello World". However, the second request produces a stacktrace: File " <Script Block >", line 3, in ? handler(Application, Request, Response).run(wsgiApp) File "C:\Python24\lib\site-packages\wsgiref\asp_gateway.py& quot;, line 85, in __init__ Response.Buffer = buffering File "C:\Python24\lib\site-packages\win32comext\axscript\client\pyscript.py& quot;, line 152, in __setattr__ return setattr(self._scriptItem_.dispatchContainer,attr, value) File "C:\Python24\lib\site-packages\win32com\client\dynamic.py", line 521, in __setattr__ self._oleobj_.Invoke(entry.dispid, 0, invoke_type, 0, value)COM Error: Member not found. If I restart the "World Wide Web Publishing" service, it works again (for one request). If I modify handler.asp or global.asa, it works for one request. I tried commenting out the "Response.Buffer =" line, and I get another "COM Error: Member not found", seemingly at the next point COM is used. I've tried refreshing loads of times (in case this is some kind of pooling issue) but I never get a second successful request. Any suggestions will be much appreciated! Does anyone here have CherryPy working on Windows? Paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070502/092e62ae/attachment.html From fuzzyman at voidspace.org.uk Wed May 2 01:45:02 2007 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 02 May 2007 00:45:02 +0100 Subject: [python-win32] SilverLight, a substitute for Python-Active-Scripting in IE? In-Reply-To: <000f01c78c0d$75ee6650$0701a8c0@PORTABLES> References: <000f01c78c0d$75ee6650$0701a8c0@PORTABLES> Message-ID: <4637D0FE.1030103@voidspace.org.uk> Michel Claveau wrote: > Hi! > > SilverLight ("MS flash killer"), is a plug-in for InternetExplorer (Win), > FireFox (Win), and Safari (Mac). > SilverLight is scriptable with Python (& Jscript, and, soon, with Ruby) > > The release 1.1-Alpha come with JScript & Python (or ironPython?) > > See : > http://www.microsoft.com/silverlight/default.aspx > http://www.microsoft.com/silverlight/why-compelling.aspx > http://silverlight.net/Default.aspx > http://www.microsoft.com/silverlight/install.aspx > > > But, I don't had try SilverLight... > > Who had try it? > > I'm trying to try it now. :-) Not easy to get it to work... Fuzzyman http://www.voidspace.org.uk/ironpython/index.shtml > > > @-salutations > From Amit.Arora at infogain.com Wed May 2 14:08:38 2007 From: Amit.Arora at infogain.com (Amit Arora) Date: Wed, 2 May 2007 17:38:38 +0530 Subject: [python-win32] Help needed : FindWindowEx Message-ID: Hi, I am a Amateur in python and an doing some work on Python and Win32 APIs . One of my task includes finding the active window , during any installation proces and proceed ...... Take an instance : I connect a USB device say a USB printer to the USB port , as soon as it connects we get a pop-up saying "New Hardware Found " I need to detect that popup , and then proceed with the other installation steps if that popup occurs : Trying to check its appearance with the following command : #!/usr/local/bin/python Import os , win32gui, win32ui hWnd = win32ui.FindWindowEx(win32gui.GetDesktopWindow(), None, "wndclass_desked_gsk",None) Getting the following message : Traceback (most recent call last): File "", line 1, in win32ui: No window can be found. Please provide inputs on this , will be of great help for me to start with ....... Regards, ~Amit Arora, Senior Software Engineer, Infogain India (P) Ltd. A-16, Sector-60, NOIDA - U.P. - 201301, India. Phone: +91-120-2445144, Extn.: 4210. Fax: +91-120-2580406. www.infogain.com e-mail: amit.arora at infogain.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070502/f8d0ec6c/attachment.htm From rwupole at msn.com Thu May 3 06:25:37 2007 From: rwupole at msn.com (Roger Upole) Date: Thu, 3 May 2007 00:25:37 -0400 Subject: [python-win32] Re: Help needed : FindWindowEx Message-ID: <002901c78d3b$1bed9390$0100a8c0@rupole> > Amit Arora wrote: > Hi, > > I am a Amateur in python and an doing some work on Python and Win32 APIs. > > One of my task includes finding the active window , during any > installation proces and proceed ...... > Take an instance : I connect a USB device say a USB printer to the USB > port , as soon as it connects we get a pop-up saying "New Hardware Found" > > I need to detect that popup , and then proceed with the other > installation steps if that popup occurs : > > Trying to check its appearance with the following command : > > #!/usr/local/bin/python > Import os , win32gui, win32ui > > hWnd = win32ui.FindWindowEx(win32gui.GetDesktopWindow(), None, > "wndclass_desked_gsk",None) > > Getting the following message : > Traceback (most recent call last): > File "", line 1, in > win32ui: No window can be found. A couple things to check: Are you sure the window class name is correct ? Is the desktop window actually its parent ? hth Roger From rwupole at msn.com Thu May 3 06:37:43 2007 From: rwupole at msn.com (Roger Upole) Date: Thu, 3 May 2007 00:37:43 -0400 Subject: [python-win32] Re: Python Help needed - VerInstallFile API Message-ID: <003701c78d3c$cc429be0$0100a8c0@rupole> Amit Arora wrote: > > HI All, > > I need to install a package and check the return value using the > VerInstallFile() API : > > The function declaration which I get on MSDN is : > > DWORD VerInstallFile( DWORD uFlags, > LPCTSTR szSrcFileName, > LPCTSTR szDestFileName, > LPCTSTR szSrcDir, > LPCTSTR szDestDir, > LPCTSTR szCurDir, > LPTSTR szTmpFile, > PUINT lpuTmpFileLen > ) > > Anybody has used this API and could share an example using a standard > msi package will be of great help ......... > MSI packages can be any package , you make take installation of an > ActivePerl package for instance .... > (ActivePerl.msi) > > Regards, > ~Amit Arora VerInstallFile isn't really what you need for msi packages. Try the msiexec command line utility, or you can use WMI to install one. hth Roger From Amit.Arora at infogain.com Thu May 3 06:58:52 2007 From: Amit.Arora at infogain.com (Amit Arora) Date: Thu, 3 May 2007 10:28:52 +0530 Subject: [python-win32] Help needed : FindWindowEx In-Reply-To: <002901c78d3b$1bed9390$0100a8c0@rupole> Message-ID: This helps a lot, there was actually a confusion in window names as you mentioned . I tried this now for notepad while opening notepad on desktop , it worked :) Import win32gui hWnd = win32ui.FindWindowEx(win32gui.GetDesktopWindow(), None,"Notepad",None) Value of hWnd I get : object 'PyCWnd' - assoc is 00B4E620, vi=, notify=0,ch/u=0/0, mh=0, kh=0 Should this be applicable to locate popups on desktop (may be during an application installation, as we get like - while connecting a new hardware on USB - "New Hardware found" ) , guess there's an API AnyPopup() for this, any imputs on this will be of great help too ..... Regards, ~Amit Arora -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Roger Upole Sent: Thursday, May 03, 2007 9:56 AM To: python-win32 at python.org Subject: [python-win32] Re: Help needed : FindWindowEx > Amit Arora wrote: > Hi, > > I am a Amateur in python and an doing some work on Python and Win32 APIs. > > One of my task includes finding the active window , during any > installation proces and proceed ...... > Take an instance : I connect a USB device say a USB printer to the USB > port , as soon as it connects we get a pop-up saying "New Hardware Found" > > I need to detect that popup , and then proceed with the other > installation steps if that popup occurs : > > Trying to check its appearance with the following command : > > #!/usr/local/bin/python > Import os , win32gui, win32ui > > hWnd = win32ui.FindWindowEx(win32gui.GetDesktopWindow(), None, > "wndclass_desked_gsk",None) > > Getting the following message : > Traceback (most recent call last): > File "", line 1, in > win32ui: No window can be found. A couple things to check: Are you sure the window class name is correct ? Is the desktop window actually its parent ? hth Roger _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From simon.dahlbacka at gmail.com Thu May 3 07:24:57 2007 From: simon.dahlbacka at gmail.com (Simon Dahlbacka) Date: Thu, 3 May 2007 08:24:57 +0300 Subject: [python-win32] Help needed : FindWindowEx In-Reply-To: References: <002901c78d3b$1bed9390$0100a8c0@rupole> Message-ID: <57124720705022224g7cc5d539n8af9a37c5f936826@mail.gmail.com> Random thought.. there *has* to be a better way of finding out when a usb device is plugged in... (not that I know how, but I haven't needed to find out either..) On 5/3/07, Amit Arora wrote: > > > > This helps a lot, there was actually a confusion in window names as you > mentioned . I tried this now for notepad while opening notepad on > desktop , it worked :) > > Import win32gui > hWnd = win32ui.FindWindowEx(win32gui.GetDesktopWindow(), > None,"Notepad",None) > > Value of hWnd I get : > object 'PyCWnd' - assoc is 00B4E620, vi=, notify=0,ch/u=0/0, mh=0, > kh=0 > > Should this be applicable to locate popups on desktop (may be during an > application installation, as we get like - while connecting a new > hardware on USB - "New Hardware found" ) , guess there's an API > AnyPopup() for this, any imputs on this will be of great help too ..... > > Regards, > ~Amit Arora > > > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org] On Behalf Of Roger Upole > Sent: Thursday, May 03, 2007 9:56 AM > To: python-win32 at python.org > Subject: [python-win32] Re: Help needed : FindWindowEx > > > Amit Arora wrote: > > Hi, > > > > I am a Amateur in python and an doing some work on Python and Win32 > APIs. > > > > One of my task includes finding the active window , during any > > installation proces and proceed ...... > > Take an instance : I connect a USB device say a USB printer to the USB > > > port , as soon as it connects we get a pop-up saying "New Hardware > Found" > > > > I need to detect that popup , and then proceed with the other > > installation steps if that popup occurs : > > > > Trying to check its appearance with the following command : > > > > #!/usr/local/bin/python > > Import os , win32gui, win32ui > > > > hWnd = win32ui.FindWindowEx(win32gui.GetDesktopWindow(), None, > > "wndclass_desked_gsk",None) > > > > Getting the following message : > > Traceback (most recent call last): > > File "", line 1, in > > win32ui: No window can be found. > > A couple things to check: > Are you sure the window class name is correct ? > Is the desktop window actually its parent ? > > hth > Roger > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070503/1fceac76/attachment.html From Amit.Arora at infogain.com Thu May 3 07:30:05 2007 From: Amit.Arora at infogain.com (Amit Arora) Date: Thu, 3 May 2007 11:00:05 +0530 Subject: [python-win32] Help needed : FindWindowEx In-Reply-To: <57124720705022224g7cc5d539n8af9a37c5f936826@mail.gmail.com> Message-ID: Exact Requirement : Need to write a Python script that keeps on running and when a USB device is plugged in , it detects the device and flashes a message on the propt or logs it to a file do suggest your ideas on this ........ ________________________________ From: Simon Dahlbacka [mailto:simon.dahlbacka at gmail.com] Sent: Thursday, May 03, 2007 10:55 AM To: Amit Arora Cc: Roger Upole; python-win32 at python.org Subject: Re: [python-win32] Help needed : FindWindowEx Random thought.. there *has* to be a better way of finding out when a usb device is plugged in... (not that I know how, but I haven't needed to find out either..) On 5/3/07, Amit Arora wrote: This helps a lot, there was actually a confusion in window names as you mentioned . I tried this now for notepad while opening notepad on desktop , it worked :) Import win32gui hWnd = win32ui.FindWindowEx (win32gui.GetDesktopWindow(), None,"Notepad",None) Value of hWnd I get : object 'PyCWnd' - assoc is 00B4E620, vi=, notify=0,ch/u=0/0, mh=0, kh=0 Should this be applicable to locate popups on desktop (may be during an application installation, as we get like - while connecting a new hardware on USB - "New Hardware found" ) , guess there's an API AnyPopup() for this, any imputs on this will be of great help too ..... Regards, ~Amit Arora -----Original Message----- From: python-win32-bounces at python.org [mailto: python-win32-bounces at python.org ] On Behalf Of Roger Upole Sent: Thursday, May 03, 2007 9:56 AM To: python-win32 at python.org Subject: [python-win32] Re: Help needed : FindWindowEx > Amit Arora wrote: > Hi, > > I am a Amateur in python and an doing some work on Python and Win32 APIs. > > One of my task includes finding the active window , during any > installation proces and proceed ...... > Take an instance : I connect a USB device say a USB printer to the USB > port , as soon as it connects we get a pop-up saying "New Hardware Found" > > I need to detect that popup , and then proceed with the other > installation steps if that popup occurs : > > Trying to check its appearance with the following command : > > #!/usr/local/bin/python > Import os , win32gui, win32ui > > hWnd = win32ui.FindWindowEx(win32gui.GetDesktopWindow(), None, > "wndclass_desked_gsk",None) > > Getting the following message : > Traceback (most recent call last): > File "", line 1, in > win32ui: No window can be found. A couple things to check: Are you sure the window class name is correct ? Is the desktop window actually its parent ? hth Roger _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070503/73cd9414/attachment.htm From simon.dahlbacka at gmail.com Thu May 3 07:56:04 2007 From: simon.dahlbacka at gmail.com (Simon Dahlbacka) Date: Thu, 3 May 2007 08:56:04 +0300 Subject: [python-win32] Help needed : FindWindowEx In-Reply-To: References: <57124720705022224g7cc5d539n8af9a37c5f936826@mail.gmail.com> Message-ID: <57124720705022256y11a8d72fja136ab85070d38b9@mail.gmail.com> This http://msdn2.microsoft.com/en-us/library/aa363243.aspx might be a starting point... On 5/3/07, Amit Arora wrote: > > Exact Requirement : > Need to write a Python script that keeps on running and when a USB device > is plugged in , it detects the device and flashes a message on the propt or > logs it to a file > do suggest your ideas on this ........ > > ------------------------------ > *From:* Simon Dahlbacka [mailto:simon.dahlbacka at gmail.com] > *Sent:* Thursday, May 03, 2007 10:55 AM > *To:* Amit Arora > *Cc:* Roger Upole; python-win32 at python.org > *Subject:* Re: [python-win32] Help needed : FindWindowEx > > Random thought.. there *has* to be a better way of finding out when a usb > device is plugged in... > > (not that I know how, but I haven't needed to find out either..) > > On 5/3/07, Amit Arora wrote: > > > > > > > > This helps a lot, there was actually a confusion in window names as you > > mentioned . I tried this now for notepad while opening notepad on > > desktop , it worked :) > > > > Import win32gui > > hWnd = win32ui.FindWindowEx (win32gui.GetDesktopWindow(), > > None,"Notepad",None) > > > > Value of hWnd I get : > > object 'PyCWnd' - assoc is 00B4E620, vi=, notify=0,ch/u=0/0, mh=0, > > kh=0 > > > > Should this be applicable to locate popups on desktop (may be during an > > application installation, as we get like - while connecting a new > > hardware on USB - "New Hardware found" ) , guess there's an API > > AnyPopup() for this, any imputs on this will be of great help too ..... > > > > > > Regards, > > ~Amit Arora > > > > > > -----Original Message----- > > From: python-win32-bounces at python.org > > [mailto: python-win32-bounces at python.org] On Behalf Of Roger Upole > > Sent: Thursday, May 03, 2007 9:56 AM > > To: python-win32 at python.org > > Subject: [python-win32] Re: Help needed : FindWindowEx > > > > > Amit Arora wrote: > > > Hi, > > > > > > I am a Amateur in python and an doing some work on Python and Win32 > > APIs. > > > > > > One of my task includes finding the active window , during any > > > installation proces and proceed ...... > > > Take an instance : I connect a USB device say a USB printer to the USB > > > > > port , as soon as it connects we get a pop-up saying "New Hardware > > Found" > > > > > > I need to detect that popup , and then proceed with the other > > > installation steps if that popup occurs : > > > > > > Trying to check its appearance with the following command : > > > > > > #!/usr/local/bin/python > > > Import os , win32gui, win32ui > > > > > > hWnd = win32ui.FindWindowEx(win32gui.GetDesktopWindow(), None, > > > "wndclass_desked_gsk",None) > > > > > > Getting the following message : > > > Traceback (most recent call last): > > > File "", line 1, in > > > win32ui: No window can be found. > > > > A couple things to check: > > Are you sure the window class name is correct ? > > Is the desktop window actually its parent ? > > > > hth > > Roger > > > > _______________________________________________ > > Python-win32 mailing list > > Python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > _______________________________________________ > > Python-win32 mailing list > > Python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070503/6826df79/attachment.html From cappy2112 at gmail.com Thu May 3 19:26:02 2007 From: cappy2112 at gmail.com (Tony Cappellini) Date: Thu, 3 May 2007 10:26:02 -0700 Subject: [python-win32] Python-win32 Digest, Vol 50, Issue 5 In-Reply-To: References: Message-ID: <8249c4ac0705031026r7a9e075ep194ef7a224d466f8@mail.gmail.com> When your program starts, take a snapshot of all the storage devices. You can do this with a timer, every few seconds or so. If the new snapshot changes from the original, you can call an API to see if the new device is removable or not. This won't tell you if it's a USB drive specifically, but for your situation, it may be highly unlikely people would be connecting additionally floppy drives or other removable devices. You could also parse the output of a program called PCI32.exe and check for new USB devices. PCI32 is free, produces text output only, and can be called every few seconds (or whatever interval you feel is appropriate) Message: 1 Date: Thu, 3 May 2007 08:56:04 +0300 From: "Simon Dahlbacka" Subject: Re: [python-win32] Help needed : FindWindowEx To: "Amit Arora" Cc: Roger Upole , python-win32 at python.org Message-ID: <57124720705022256y11a8d72fja136ab85070d38b9 at mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" On 5/3/07, Amit Arora wrote: > > Exact Requirement : > Need to write a Python script that keeps on running and when a USB device > is plugged in , it detects the device and flashes a message on the propt or > logs it to a file > do suggest your ideas on this ........ From timr at probo.com Thu May 3 19:46:06 2007 From: timr at probo.com (Tim Roberts) Date: Thu, 03 May 2007 10:46:06 -0700 Subject: [python-win32] Help needed : FindWindowEx In-Reply-To: <57124720705022224g7cc5d539n8af9a37c5f936826@mail.gmail.com> References: <002901c78d3b$1bed9390$0100a8c0@rupole> <57124720705022224g7cc5d539n8af9a37c5f936826@mail.gmail.com> Message-ID: <463A1FDE.7080704@probo.com> Simon Dahlbacka wrote: > Random thought.. there *has* to be a better way of finding out when a > usb device is plugged in... > > (not that I know how, but I haven't needed to find out either..) Oh, there is. You can watch for the WM_DEVICECHANGE message, which fires every time there is a plug-and-play event. Once you get that message, you can go enumerate the devices in your device class using the SetupDi APIs to see if you are present. Now, how does all that map to Python? With difficulty, I imagine. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From malaclypse2 at gmail.com Thu May 3 20:35:55 2007 From: malaclypse2 at gmail.com (Jerry Hill) Date: Thu, 3 May 2007 14:35:55 -0400 Subject: [python-win32] Help needed : FindWindowEx In-Reply-To: <463A1FDE.7080704@probo.com> References: <002901c78d3b$1bed9390$0100a8c0@rupole> <57124720705022224g7cc5d539n8af9a37c5f936826@mail.gmail.com> <463A1FDE.7080704@probo.com> Message-ID: <16651e80705031135hd62a3fav61f20abdb2160a0b@mail.gmail.com> On 5/3/07, Tim Roberts wrote: > Oh, there is. You can watch for the WM_DEVICECHANGE message, which > fires every time there is a plug-and-play event. Once you get that > message, you can go enumerate the devices in your device class using the > SetupDi APIs to see if you are present. Googling for the words WM_DEVICECHANGE and Python leads to the following bit of code posted by Tim Golden to c.l.py back in 2004: http://mail.python.org/pipermail/python-list/2004-January/245358.html I don't have a USB device to test with, but it does properly detect the insertion of a CDROM. At the very least it should serve as an example of how to get WM_DEVICECHANGE notifications in python on win32. -- Jerry From mail at timgolden.me.uk Thu May 3 20:53:45 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 03 May 2007 19:53:45 +0100 Subject: [python-win32] Help needed : FindWindowEx In-Reply-To: <463A1FDE.7080704@probo.com> References: <002901c78d3b$1bed9390$0100a8c0@rupole> <57124720705022224g7cc5d539n8af9a37c5f936826@mail.gmail.com> <463A1FDE.7080704@probo.com> Message-ID: <463A2FB9.9010504@timgolden.me.uk> Tim Roberts wrote: > Simon Dahlbacka wrote: >> Random thought.. there *has* to be a better way of finding out when a >> usb device is plugged in... >> >> (not that I know how, but I haven't needed to find out either..) > > Oh, there is. You can watch for the WM_DEVICECHANGE message, which > fires every time there is a plug-and-play event. Once you get that > message, you can go enumerate the devices in your device class using the > SetupDi APIs to see if you are present. > > Now, how does all that map to Python? With difficulty, I imagine. It's actually made a bit easier by using the Win32_DeviceChange event under WMI (you will not be surprised to hear me say!) But once you've got the fact that the device has changed, I'm not sure where you go from there... TJG From timr at probo.com Thu May 3 21:25:13 2007 From: timr at probo.com (Tim Roberts) Date: Thu, 03 May 2007 12:25:13 -0700 Subject: [python-win32] Help needed : FindWindowEx In-Reply-To: <463A2FB9.9010504@timgolden.me.uk> References: <002901c78d3b$1bed9390$0100a8c0@rupole> <57124720705022224g7cc5d539n8af9a37c5f936826@mail.gmail.com> <463A1FDE.7080704@probo.com> <463A2FB9.9010504@timgolden.me.uk> Message-ID: <463A3719.2060602@probo.com> Tim Golden wrote: > > It's actually made a bit easier by using > the Win32_DeviceChange event under WMI > (you will not be surprised to hear me say!) > > But once you've got the fact that the device has > changed, I'm not sure where you go from there... I admit that WMI is not my strong suit, but using the WMI object browser on my machine, I find that Win32_SystemDevices contains a key called Win32_USBHub which contains DeviceID entries for all of the USB devices on my computer. I have never attempted it, but I suspect that's all the OP would need. And actually, since I *think* he said he was working with a printer, he may be able to look at the Win32_Printer collection instead. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mail at timgolden.me.uk Thu May 3 21:36:27 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 03 May 2007 20:36:27 +0100 Subject: [python-win32] Help needed : FindWindowEx In-Reply-To: <463A3719.2060602@probo.com> References: <002901c78d3b$1bed9390$0100a8c0@rupole> <57124720705022224g7cc5d539n8af9a37c5f936826@mail.gmail.com> <463A1FDE.7080704@probo.com> <463A2FB9.9010504@timgolden.me.uk> <463A3719.2060602@probo.com> Message-ID: <463A39BB.7060202@timgolden.me.uk> Tim Roberts wrote: > Tim Golden wrote: >> It's actually made a bit easier by using >> the Win32_DeviceChange event under WMI >> (you will not be surprised to hear me say!) >> >> But once you've got the fact that the device has >> changed, I'm not sure where you go from there... > > I admit that WMI is not my strong suit, but using the WMI object browser > on my machine, I find that Win32_SystemDevices contains a key called > Win32_USBHub which contains DeviceID entries for all of the USB devices > on my computer. I have never attempted it, but I suspect that's all the > OP would need. > > And actually, since I *think* he said he was working with a printer, he > may be able to look at the Win32_Printer collection instead. (I spend most of my WMI time doing detective work like that!) I think what I meant was that the OP wanted to step through some kind installation process when the device was initiated. At least, I think that's what he wanted to do. And I'm not sure how much closer the WMI device objects take you to that dialog, which presumably just pops up. TJG From timr at probo.com Thu May 3 21:45:18 2007 From: timr at probo.com (Tim Roberts) Date: Thu, 03 May 2007 12:45:18 -0700 Subject: [python-win32] Help needed : FindWindowEx In-Reply-To: <463A39BB.7060202@timgolden.me.uk> References: <002901c78d3b$1bed9390$0100a8c0@rupole> <57124720705022224g7cc5d539n8af9a37c5f936826@mail.gmail.com> <463A1FDE.7080704@probo.com> <463A2FB9.9010504@timgolden.me.uk> <463A3719.2060602@probo.com> <463A39BB.7060202@timgolden.me.uk> Message-ID: <463A3BCE.6080404@probo.com> Tim Golden wrote: > > (I spend most of my WMI time doing detective work like that!) > > I think what I meant was that the OP wanted to step through > some kind installation process when the device was initiated. > At least, I think that's what he wanted to do. And I'm not > sure how much closer the WMI device objects take you to that > dialog, which presumably just pops up. Could be. My interpretation was that he was writing a device installer, where the installer at some point puts up a dialog that says "Now, plug in the device", and then the installer finishes its work after that. Such a thing is extremely delicate, because users rarely behave in the predicted fashion. We'll see when he responds. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From python at ertis.net Fri May 4 00:39:53 2007 From: python at ertis.net (Carlos Izquierdo) Date: Fri, 4 May 2007 00:39:53 +0200 Subject: [python-win32] Excel calls failing Message-ID: <200705040039.53324.python@ertis.net> Hi, I'm fairly new to Python COM development and I'm having trouble automating Microsoft Excel. I have the following piece of code: d = win32com.client.Dispatch('Excel.Application') d.Visible = 1 dw = d.Workbooks.Open('c:\\datos.xls') dw.Sheets(1).Select() Normally it runs great, and after these four lines I can begin crunching lots of numbers. There are many times, however, that the code fails in the last line or other lines throughout the code such as: dw.Activate() The error is almost always on the lines of: "bool object is not callable". The randomness of this kind of failure, coupled with the fact that if I add a call to time.sleep() before the line that triggers the error prevents it from happening (prevents better the bigger the sleep, but I can't just wait half a minute for each row of data that I want to read, there are too many of them...) led me to think that it was some sort of race condition, but my program is single-threaded at the moment :-( Is there something that I'm missing? Thank you. BTW, I'm using Python 2.5 with PyWin 210 and MS Office XP/2003, if that helps. From mail at timgolden.me.uk Fri May 4 09:53:28 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 04 May 2007 08:53:28 +0100 Subject: [python-win32] Excel calls failing In-Reply-To: <200705040039.53324.python@ertis.net> References: <200705040039.53324.python@ertis.net> Message-ID: <463AE678.5070204@timgolden.me.uk> Carlos Izquierdo wrote: > The error is almost always on the lines of: "bool object is not callable". Feel free to knock this suggestion on the head straightaway, but an error of this type will often come down to the fact that -- somewhere in the code -- you've bound a name which is originally a callable (function, method, etc) to something which is not callable. eg, def found (text, s): return s in text # # .. some time later # d = {} key = 1 found = key in d # # ... later still # if found ("mary had a little lamb", "lamb"): print "Found it!" Obviously this has nothing to do with Excel (and may have nothing to do with your problem :) but it certainly exhibits the same symptoms. TJG From A.Holtz at gmx.net Mon May 7 16:09:25 2007 From: A.Holtz at gmx.net (Andreas Holtz) Date: Mon, 07 May 2007 16:09:25 +0200 Subject: [python-win32] Array and CATIA Message-ID: <20070507140925.249630@gmx.net> Hello, we have a problem to pass an array to the GetComponents()-Method of CATIA-COM-Object. The method expects an array as method-parameter. The result will be written in the given array. The array must be initialized with 12 elements. You can't pass an empty array/dictionary to the method. For unknown reason, this does not work. The array is not changed. Does anybody has a solution for this? Not working source: # ---- snip ---- CATIA = win32com.client.dynamic.Dispatch("CATIA.Application") selection = CATIA.ActiveDocument.selection # error checking if selection.Count == 0: CATIA.Statusbar = "exit1" return if selection.Item2(1).Type <> "Product": CATIA.Statusbar = "exit2" return rootProduct = selection.Item2(1).Value positionArray = [0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0] result = rootProduct.Products.Item(1).Position.GetComponents(positionArray) print result # print result gives defaultvalues of positionArray, # but should give other values # ---- snip ---- Thanks in advance Andreas -- "Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ... Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail From sam_spam_cat at verizon.net Tue May 8 03:48:21 2007 From: sam_spam_cat at verizon.net (Sam The Cat) Date: Mon, 07 May 2007 21:48:21 -0400 Subject: [python-win32] Fw: Python COM and Photoshop Message-ID: <004801c79112$f5d081f0$0201a8c0@neo> I thought I'd try this again -- still no progress on my debugging. From using Visual Basic it seems that the interface is expecting an array of type varint where each element of the array is another array. The inner arrays are two elements long (an x and y data point) I have also tried using the array module but I still get the same errors -- basically anything that I try in Python results in a error indicating that only a 1-dimensional arrays are supported -- which seems weird since the vbasic code is not making a single dimensional array. Any thoughts are appreciated > Help ! > > I am writing some COM code in Python to control photoshop. Several > functions of PS require an "Array" argument. In the examples of VBscript > or javascript the Array type is used. I have tried what would appear to > be > the equivalent in Python -- Lists and Tuples -- but to no avail. Anyone > have > any insight on what via the COM interface is equivalent to an Array in > javascript ? > > Here is the Javascript example code > > ..... > selRegion = Array(Array(1,1),Array(1,2),Array(2,2),Array(2,1)) > Doc.Selection.Select(selRegion,1,0,0) > ..... > > Here is my interpretation in Python > > ....... > selregion = [(1,1),(1,2),(2,2),(2,1)] > print selregion > doc.Selection.Select(selregion,1,0,0) > ...... > > Here is the error code generated > > .......... > F:\automation>test2.py > [(1, 1), (1, 2), (2, 2), (2, 1)] > Traceback (most recent call last): > File "F:\automation\test2.py", line 19, in ? > doc.Selection.Select(selregion,1,0,0) > File ">", line 3, in Select > pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Adobe > Photoshop', 'Illegal argument - argument 1\n- Only arrays > with dimension 1 > are supported', None, 0, -2147220262), None) > > > ............ > > I have tried many differnet permutations of structure for the selregion > variable. Any scalar or single dimension array returns an "Illegal > Argument" response with no further details -- any thing that resembles a > two > dimensional array returns the result above. > > Any help / thoughts would be appreciated > > From sam_spam_cat at verizon.net Tue May 8 03:53:23 2007 From: sam_spam_cat at verizon.net (Sam The Cat) Date: Mon, 07 May 2007 21:53:23 -0400 Subject: [python-win32] Python COM and Photoshop Message-ID: <005401c79113$a9ddf3d0$0201a8c0@neo> One more thought -- I have tried both Early and Late binding COM calls and I get the same error message either way. >I thought I'd try this again -- still no progress on my debugging. From >using Visual Basic it seems that the interface is expecting an array of >type varint where each element of the array is another array. The inner >arrays are two elements long (an x and y data point) > > I have also tried using the array module but I still get the same > errors -- basically anything that I try in Python results in a error > indicating that only a 1-dimensional arrays are supported -- which seems > weird since the vbasic code is not making a single dimensional array. > > Any thoughts are appreciated > > > >> Help ! >> >> I am writing some COM code in Python to control photoshop. Several >> functions of PS require an "Array" argument. In the examples of >> VBscript >> or javascript the Array type is used. I have tried what would appear to >> be >> the equivalent in Python -- Lists and Tuples -- but to no avail. Anyone >> have >> any insight on what via the COM interface is equivalent to an Array in >> javascript ? >> >> Here is the Javascript example code >> >> ..... >> selRegion = Array(Array(1,1),Array(1,2),Array(2,2),Array(2,1)) >> Doc.Selection.Select(selRegion,1,0,0) >> ..... >> >> Here is my interpretation in Python >> >> ....... >> selregion = [(1,1),(1,2),(2,2),(2,1)] >> print selregion >> doc.Selection.Select(selregion,1,0,0) >> ...... >> >> Here is the error code generated >> >> .......... >> F:\automation>test2.py >> [(1, 1), (1, 2), (2, 2), (2, 1)] >> Traceback (most recent call last): >> File "F:\automation\test2.py", line 19, in ? >> doc.Selection.Select(selregion,1,0,0) >> File ">", line 3, in Select >> pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Adobe >> Photoshop', 'Illegal argument - argument 1\n- Only arrays >> with dimension 1 >> are supported', None, 0, -2147220262), None) >> >> >> ............ >> >> I have tried many differnet permutations of structure for the selregion >> variable. Any scalar or single dimension array returns an "Illegal >> Argument" response with no further details -- any thing that resembles a >> two >> dimensional array returns the result above. >> >> Any help / thoughts would be appreciated >> >> > From mhammond at skippinet.com.au Tue May 8 04:09:40 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 8 May 2007 12:09:40 +1000 Subject: [python-win32] Fw: Python COM and Photoshop In-Reply-To: <004801c79112$f5d081f0$0201a8c0@neo> Message-ID: <00c401c79115$f0643bf0$170a0a0a@enfoldsystems.local> > > F:\automation>test2.py > > [(1, 1), (1, 2), (2, 2), (2, 1)] > > Traceback (most recent call last): > > File "F:\automation\test2.py", line 19, in ? > > doc.Selection.Select(selregion,1,0,0) > > File ">", line 3, in Select > > pywintypes.com_error: (-2147352567, 'Exception occurred.', > (0, 'Adobe > > Photoshop', 'Illegal argument - argument 1\n- Only arrays > > with dimension 1 > > are supported', None, 0, -2147220262), None) >From the line: > > File ">", line 3, in Select It appears you are not using 'makepy' for the object (maybe as makepy is not support for that object). If possible, you should try and use a makepy based object. The easiest way is something like: from win32com.client.gencache import EnsureDispatch select = EnsureDispatch(select) # try and convert into makepy based object. If you can get that to work, you might have more luck, as python can determine the exact type of the variant from the type-library. Good luck, Mark From f.guerrieri at gmail.com Tue May 8 12:29:47 2007 From: f.guerrieri at gmail.com (Francesco Guerrieri) Date: Tue, 8 May 2007 12:29:47 +0200 Subject: [python-win32] PyTime Message-ID: <79b79e730705080329j793497b8if6fa1f38adf461a4@mail.gmail.com> hello, I have another newbie question. I have googled around but didn't find an answer. I have an Excel file with many dates beyond 2038, which arrive to me as a list of PyTime objects. From the doc I have found ( http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/pywin32/PyTime.html ) it appears that an int conversion is needed to handle them. There is even a reference to an __int__ method which I cannot use >>> import pywintypes >>> testTime = pywintypes.Time >>> testTime.__int__ Traceback (most recent call last): File "", line 1, in AttributeError: 'builtin_function_or_method' object has no attribute '__int__' >>> In any case, int is not enough to go beyond 2038. Since I only need the day, month and year, and surely not the seconds :-) I would be more than happy to use some date object. I still haven't found how to initialize them with my pytime objects... can you tell me where to look for? thanks in advance, Francesco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070508/b79111f8/attachment.html From mark.m.mcmahon at gmail.com Tue May 8 14:03:01 2007 From: mark.m.mcmahon at gmail.com (Mark Mc Mahon) Date: Tue, 8 May 2007 08:03:01 -0400 Subject: [python-win32] PyTime In-Reply-To: <79b79e730705080329j793497b8if6fa1f38adf461a4@mail.gmail.com> References: <79b79e730705080329j793497b8if6fa1f38adf461a4@mail.gmail.com> Message-ID: <71b6302c0705080503r162fc962r6b3dfb70f72749b0@mail.gmail.com> Hi, Maybe there is a better way then this suggestion... from datetime import datetime date = day = int(xl.activecell.value.Format("%d")) month = int(xl.activecell.value.Format("%m")) year = int(xl.activecell.value.Format("%Y")) date_as_datetime = datetime(year, month, day) PyTime is starting to look like a wart :-) Is it a hold over from when datetime didn't exist? Thanks Mark On 5/8/07, Francesco Guerrieri wrote: > hello, > I have another newbie question. I have googled around but didn't find an > answer. > > I have an Excel file with many dates beyond 2038, which arrive to me as a > list of PyTime objects. From the doc I have found ( > http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/pywin32/PyTime.html > ) it appears that an int conversion is needed to handle them. There is even > a reference to an __int__ method which I cannot use > > >>> import pywintypes > >>> testTime = pywintypes.Time > >>> testTime.__int__ > Traceback (most recent call last): > File "", line 1, in > AttributeError: 'builtin_function_or_method' object has no attribute > '__int__' > >>> > > In any case, int is not enough to go beyond 2038. Since I only need the day, > month and year, and surely not the seconds :-) I would be more than happy to > use some date object. I still haven't found how to initialize them with my > pytime objects... can you tell me where to look for? > > thanks in advance, > Francesco > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From mail at timgolden.me.uk Tue May 8 14:49:23 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 08 May 2007 13:49:23 +0100 Subject: [python-win32] PyTime In-Reply-To: <71b6302c0705080503r162fc962r6b3dfb70f72749b0@mail.gmail.com> References: <79b79e730705080329j793497b8if6fa1f38adf461a4@mail.gmail.com> <71b6302c0705080503r162fc962r6b3dfb70f72749b0@mail.gmail.com> Message-ID: <464071D3.9070507@timgolden.me.uk> Mark Mc Mahon wrote: > Hi, > > Maybe there is a better way then this suggestion... > > from datetime import datetime > > date = > > day = int(xl.activecell.value.Format("%d")) > month = int(xl.activecell.value.Format("%m")) > year = int(xl.activecell.value.Format("%Y")) > > date_as_datetime = datetime(year, month, day) Frankly, I can't think of anything better. You might combine PyTime.Format and datetime.strptime, or do some kind of integer combination thing with the three values, but nothing's too compelling. Maybe the OP might be interested in xlrd or PyExcelerator (assuming they handle dates a little better). > PyTime is starting to look like a wart :-) > Is it a hold over from when > datetime didn't exist? Think so; guess Mark's had no incentive to change things, and I imagine it would be non-trivial to rework all the PyTimes into datetimes. Maybe, though a new method might be added? (Sadly, though, I'm in no position to offer, and I don't really have an itch to scratch, either). TJG From f.guerrieri at gmail.com Tue May 8 14:59:50 2007 From: f.guerrieri at gmail.com (Francesco Guerrieri) Date: Tue, 8 May 2007 14:59:50 +0200 Subject: [python-win32] PyTime In-Reply-To: <464071D3.9070507@timgolden.me.uk> References: <79b79e730705080329j793497b8if6fa1f38adf461a4@mail.gmail.com> <71b6302c0705080503r162fc962r6b3dfb70f72749b0@mail.gmail.com> <464071D3.9070507@timgolden.me.uk> Message-ID: <79b79e730705080559m666a21c2q2e61ca4d7ba3ee61@mail.gmail.com> thanks :) I resorted to your solution: for i in DataList: OutputList.append(datetime.date(int(i.Format("%Y")), int(i.Format("%m")), int(i.Format("%d")))) return OutputList and it works. I am considering dates up to 50 years from now so 2038 is definitely too early :-) Francesco On 5/8/07, Tim Golden wrote: > > Mark Mc Mahon wrote: > > Hi, > > > > Maybe there is a better way then this suggestion... > > > > from datetime import datetime > > > > date = > > > > day = int(xl.activecell.value.Format("%d")) > > month = int(xl.activecell.value.Format("%m")) > > year = int(xl.activecell.value.Format("%Y")) > > > > date_as_datetime = datetime(year, month, day) > > Frankly, I can't think of anything better. You > might combine PyTime.Format and datetime.strptime, > or do some kind of integer combination thing > with the three values, but nothing's too > compelling. > > Maybe the OP might be interested in xlrd or > PyExcelerator (assuming they handle dates > a little better). > > > PyTime is starting to look like a wart :-) > > Is it a hold over from when > > datetime didn't exist? > > Think so; guess Mark's had no incentive to change > things, and I imagine it would be non-trivial to > rework all the PyTimes into datetimes. Maybe, though > a new method might be added? (Sadly, though, I'm > in no position to offer, and I don't really have > an itch to scratch, either). > > TJG > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070508/402517b5/attachment.html From mhammond at skippinet.com.au Tue May 8 16:36:41 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 9 May 2007 00:36:41 +1000 Subject: [python-win32] PyTime In-Reply-To: <79b79e730705080329j793497b8if6fa1f38adf461a4@mail.gmail.com> Message-ID: <012b01c7917e$4bf7db30$170a0a0a@enfoldsystems.local> > I have an Excel file with many dates beyond 2038, which arrive to me as a list of PyTime objects. > From the doc I have found ( http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/pywin32/PyTime.html ) > it appears that an int conversion is needed to handle them. To answer Mark's question first, the PyTime objects predate the datetime module by a number of years. These objects support int conversion for use with the (effectively deprecated) time module - which does indeed suffer the same limitations. Your solution seems to be to simply construct a datetime object from the pywintypes time object by way of attributes - eg: >>> from win32com.client import Dispatch >>> import datetime >>> xl=Dispatch("Excel.Application") >>> d=xl.Range("A1").Value >>> datetime.datetime(d.year, d.month, d.day, d.hour, d.minute, d.second, d.msec) datetime.datetime(2065, 2, 3, 0, 0) Cheers, Mark From f.guerrieri at gmail.com Tue May 8 16:52:37 2007 From: f.guerrieri at gmail.com (Francesco Guerrieri) Date: Tue, 8 May 2007 16:52:37 +0200 Subject: [python-win32] PyTime In-Reply-To: <012b01c7917e$4bf7db30$170a0a0a@enfoldsystems.local> References: <79b79e730705080329j793497b8if6fa1f38adf461a4@mail.gmail.com> <012b01c7917e$4bf7db30$170a0a0a@enfoldsystems.local> Message-ID: <79b79e730705080752h4a7b0ef9yc771675f498cbcd5@mail.gmail.com> On 5/8/07, Mark Hammond wrote: > Your solution seems to be to simply construct a datetime object from the > pywintypes time object by way of attributes - eg: > > >>> from win32com.client import Dispatch > >>> import datetime > >>> xl=Dispatch("Excel.Application") > >>> d=xl.Range("A1").Value > >>> datetime.datetime(d.year, d.month, d.day, d.hour, d.minute, d.second, > d.msec) > datetime.datetime(2065, 2, 3, 0, 0) thanks, the docs didn't explicitly cite the existance of those attributes... However I (mistakenly) thought of having tried to use them. It's evident that I hadn't tried correctly :-) Now the code is much more readable :-) Francesco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070508/a34ecd18/attachment.htm From mail at timgolden.me.uk Tue May 8 16:57:09 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 08 May 2007 15:57:09 +0100 Subject: [python-win32] PyTime In-Reply-To: <79b79e730705080752h4a7b0ef9yc771675f498cbcd5@mail.gmail.com> References: <79b79e730705080329j793497b8if6fa1f38adf461a4@mail.gmail.com> <012b01c7917e$4bf7db30$170a0a0a@enfoldsystems.local> <79b79e730705080752h4a7b0ef9yc771675f498cbcd5@mail.gmail.com> Message-ID: <46408FC5.70701@timgolden.me.uk> > the docs didn't explicitly cite the existance of those attributes... Well in fact they do (at least my version of the .chm does) and to my shame I hadn't looked there, relying on a quick dir (), which only shows the .Format method. > Now the code is much more readable :-) Indeed. TJG From InNomine at gmx.net Tue May 8 17:37:07 2007 From: InNomine at gmx.net (InNomine at gmx.net) Date: Tue, 08 May 2007 17:37:07 +0200 Subject: [python-win32] py2exe - ms vista - CreateProcess/ShellExecute/etc... Message-ID: <20070508153707.155640@gmx.net> Hi, after hours of searching, testing and hoping to code for vista never again ;) i tried to call an application with everything i found... sometimes py2exe couldn't load the needed modules. but every time the app stuck. it seems that ShellExecuteEx doesnt word with py2exe... maybe i'm wrong. i read about some 'magic' to load the necessary win32 modules... doesnt work... so... how do i call an application in vista? thanks in advance ps: Non-Elevated Application Runs an Elevated Application. A non-elevated application may need to spawn an elevated application to perform a download, an install, register a COM server etc. The Shell API calls ShellExecute() and ShellExecuteEx() do this just fine. Often programmers launch applications using CreateProcess(), which is useful to wait on a process to terminate. Unfortunately CreateProcess() will fail under Vista when running an elevated application from a non-elevated application. You will need to use ShellExecute() or ShellExecuteEx() which BTW can also return a process ID, then use WaitForSingleObject(ExecInfo.hProcess, INFINITE). From fumanchu at amor.org Tue May 8 18:52:12 2007 From: fumanchu at amor.org (Robert Brewer) Date: Tue, 8 May 2007 09:52:12 -0700 Subject: [python-win32] PyTime In-Reply-To: <012b01c7917e$4bf7db30$170a0a0a@enfoldsystems.local> Message-ID: <435DF58A933BA74397B42CDEB8145A860BAFB987@ex9.hostedexchange.local> Mark Hammond wrote: > Your solution seems to be to simply construct a datetime > object from the > pywintypes time object by way of attributes - eg: > > >>> from win32com.client import Dispatch > >>> import datetime > >>> xl=Dispatch("Excel.Application") > >>> d=xl.Range("A1").Value > >>> datetime.datetime(d.year, d.month, d.day, d.hour, > d.minute, d.second, > d.msec) > datetime.datetime(2065, 2, 3, 0, 0) Argle bargle...#$%^&* Wish I'd known about those attributes before I spent far too many hours trying to extract them back from float(d) [1]. Yet another lesson in the dangers of multiple documentation locations. Ah well, at least I learned something about Jet and SQL server internals. Robert Brewer System Architect Amor Ministries fumanchu at amor.org [1] http://projects.amor.org/geniusql/changeset/84 From sam_spam_cat at verizon.net Wed May 9 02:14:37 2007 From: sam_spam_cat at verizon.net (Sam The Cat) Date: Tue, 08 May 2007 20:14:37 -0400 Subject: [python-win32] Fw: Python COM and Photoshop Message-ID: <007e01c791cf$0837a230$0201a8c0@neo> Mark, My apologies -- I tried to relay that I have tried both ways -- "early and late dispatch" Here is the output after running the makepy routine on the type and object libraries for Photoshop --------------------------------------------------------------------------- 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] Traceback (most recent call last): File "F:\automation\test3.py", line 16, in doc.Selection.Select([[1,1],[1,2],[2,1],[2,2]]) File "C:\Python25\lib\site-packages\win32com\gen_py\E891EE9A-D0AE-4CB4-8871-F92C0109F18Ex0x9x0.py", line 2606, in Select , Type, Feather, AntiAlias) pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Adobe Photoshop', 'Illegal argument - argument 1\n- Only arrays with dimension 1 are supported', None, 0, -2147220262), None) ----------------------------------------------------------------------------- I really think that Python knows what to do and that I do not know how to tell Python to do it. What I need to end up with is a an array of VARINTs where each VARINT is an array of length two. Maybe I should ask -- if the PythonCOM interface knows this will it turn a list of lists (ex. [[1,1],[1,2],[2,1],[2,2]]) into what I need ? Cheers>>> > F:\automation>test2.py>>> > [(1, 1), (1, 2), (2, 2), (2, 1)]>>> > Traceback (most recent call last):>>> > File "F:\automation\test2.py", line 19, in ?>>> > doc.Selection.Select(selregion,1,0,0)>>> > File ">", line 3, in Select>>> > pywintypes.com_error: (-2147352567, 'Exception occurred.',>>> (0, 'Adobe>>> > Photoshop', 'Illegal argument - argument 1\n- Only arrays>>> > with dimension 1>>> > are supported', None, 0, -2147220262), None)>>>>>From the line:>>>>> > File ">", line 3, in Select>>>> It appears you are not using 'makepy' for the object (maybe as makepy isnot>> support for that object). If possible, you should try and use a makepy>> based object. The easiest way is something like:>>>> from win32com.client.gencache import EnsureDispatch>> select = EnsureDispatch(select) # try and convert into makepy basedobject.>>>> If you can get that to work, you might have more luck, as python can>> determine the exact type of the variant from the type-library.>>>> Good luck,>>>> Mark>>>> _______________________________________________>> Python-win32 mailing list>> Python-win32 at python.org>> http://mail.python.org/mailman/listinfo/python-win32>>>>> From sam_spam_cat at verizon.net Wed May 9 02:20:30 2007 From: sam_spam_cat at verizon.net (Sam The Cat) Date: Tue, 08 May 2007 20:20:30 -0400 Subject: [python-win32] Fw: Python COM and Photoshop Message-ID: <008301c791cf$da71d720$0201a8c0@neo> As a follow-up question is there a way to see what python thinks the variable should be ? In looking at the file created by makepy I see the function call for select but nothing that looks to me like information relating to the type of variable that needs to be generated here is the method in question found in the Selection Class def Select(self, Region=defaultNamedNotOptArg, Type=defaultNamedOptArg, Feather=defaultNamedOptArg, AntiAlias=defaultNamedOptArg): return self._oleobj_.InvokeTypes(1936483188, LCID, 1, (24, 0), ((12, 1), (12, 17), (12, 17), (12, 17)),Region , Type, Feather, AntiAlias) Is there magic in the arguments ? > Mark, > My apologies -- I tried to relay that I have tried both ways -- "early > and late dispatch" > > Here is the output after running the makepy routine on the type and object > libraries for Photoshop > > --------------------------------------------------------------------------- > 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] > Traceback (most recent call last): > File "F:\automation\test3.py", line 16, in > doc.Selection.Select([[1,1],[1,2],[2,1],[2,2]]) > File > "C:\Python25\lib\site-packages\win32com\gen_py\E891EE9A-D0AE-4CB4-8871-F92C0109F18Ex0x9x0.py", > line 2606, in Select , Type, Feather, AntiAlias) pywintypes.com_error: > (-2147352567, 'Exception occurred.', (0, 'Adobe Photoshop', 'Illegal > argument - argument 1\n- Only arrays with dimension 1 are supported', > None, 0, -2147220262), > None) ----------------------------------------------------------------------------- > I really think that Python knows what to do and that I do not know how to > tell Python to do it. What I need to end up with is a an array of VARINTs > where each VARINT is an array of length two. Maybe I should ask -- if the > PythonCOM interface knows this will it turn a list of lists (ex. > [[1,1],[1,2],[2,1],[2,2]]) into what I need ? Cheers>>> > > F:\automation>test2.py>>> > [(1, 1), (1, 2), (2, 2), (2, 1)]>>> > > Traceback (most recent call last):>>> > File "F:\automation\test2.py", > line 19, in ?>>> > doc.Selection.Select(selregion,1,0,0)>>> > File > ">", line 3, in Select>>> > pywintypes.com_error: > (-2147352567, 'Exception occurred.',>>> (0, 'Adobe>>> > Photoshop', > 'Illegal argument - argument 1\n- Only arrays>>> > with dimension 1>>> > > are supported', None, 0, -2147220262), None)>>>>>From the line:>>>>> > > File ">", line 3, in Select>>>> It appears you are not > using 'makepy' for the object (maybe as makepy isnot>> support for that > object). If possible, you should try and use a makepy>> based object. > The easiest way is something like:>>>> from win32com.client.gencache > import EnsureDispatch>> select = EnsureDispatch(select) # try and convert > into makepy basedobject.>>>> If you can get that to work, you might have > more luck, as python can>> determine the exact type of the variant from > the type-library.>>>> Good luck,>>>> Mark>>>> > _______________________________________________>> Python-win32 mailing > list>> Python-win32 at python.org>> > http://mail.python.org/mailman/listinfo/python-win32>>>>> From ckkart at hoc.net Wed May 9 08:51:52 2007 From: ckkart at hoc.net (Christian K.) Date: Wed, 09 May 2007 15:51:52 +0900 Subject: [python-win32] how to create a valid Sink Message-ID: Hi, I'd like to ask for help on how to create a valid event Sink which I can pass to the Advise() method of a message stores table. Any class I made up so far gives the same error: File "", line 333, in notify TypeError: The Python instance can not be converted to a COM object So what attributes does an object need to be convertable to a COM object? Thanks in advance, Christian From patter001 at gmail.com Wed May 9 15:16:56 2007 From: patter001 at gmail.com (Kevin Patterson) Date: Wed, 9 May 2007 09:16:56 -0400 Subject: [python-win32] VT_UI1 ByRef behavior In-Reply-To: <000e01c78aca$5ce755c0$090a0a0a@enfoldsystems.local> References: <000e01c78aca$5ce755c0$090a0a0a@enfoldsystems.local> Message-ID: Alrighty, I'll keep looking in to it. I think it is easy to make the buffers get returned as a python list. Almost all the code exists to help with that. The tough part is telling the COM that the array being passed IN needs to become a Safe Array where the size of each element is only VT_UI1. The buffer is a great thing for that and at first glance the only thing I can think of would be to modify PyCom_VariantFromPyObject to check the size of the number to see if it will fit in VT_UI1 (it is already doing this for ints and longs)...but i think that would be way to dangerous... I might still look into a proposal for changing the output, but for the input, I can't think of how to do it any other way than what you already have. Perhaps I will just have to write a script that searches my generated file from makepy and creates a layer in the python code...instead of on the C side...oh well... -Kevin On 4/29/07, Mark Hammond wrote: > > > I was curious is there a way to prevent an array of VT_UI1's from being > > converted to a buffer? Or perhaps a way to modify the file generated > > from "makepy" to prevent the conversion? > > Nope, no such facility exists. Feel free to propose a patch though. > > Cheers, > > Mark > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070509/b09ad07b/attachment.html From larry.bates at websafe.com Wed May 9 15:41:56 2007 From: larry.bates at websafe.com (Larry Bates) Date: Wed, 09 May 2007 08:41:56 -0500 Subject: [python-win32] Win32 service with tray icon In-Reply-To: <07f801c7764c$7309c280$0200a8c0@enfoldsystems.local> References: <200704031717.40946.tchough@tchough.com> <07f801c7764c$7309c280$0200a8c0@enfoldsystems.local> Message-ID: Mark Hammond wrote: >> I'm writing a win32 service in Python. I'd like to add a >> tray icon displayed >> whenever the service is running. I have played around with >> SysTrayIcon.py >> [1], but if a user logs off and logs back on, the tray icon >> disappears even >> though the service is still running. I think the answer is >> probably getting >> my service to recreate the icon whenever a logon event >> happens. I don't >> really know much about win32 programming, though. Can >> someone point me in >> the right direction to solve this problem? > > Services have trouble interacting with the desktop. The general approach is > to have a dedicated taskbar application that communicates with the dedicated > service using some kind of IPC. > > Mark Mark, Please accept my apology for hijacking this thread, but it is exactly what I want to implement. I have a COM object that is doing an upload. I want a system tray icon that: 1) Shows a heartbeat (upload progress indicator) 2) Provides the user with a way to cancel the upload I found systrayicon.py and it almost does what I want. I thought about using socket server/client to have the two apps communicate but I'm at a complete loss as to how to implement socket client in the systrayicon.py program since it uses PumpMessages. I just don't see how to connect to my com server (which would also be a socket server) inside some loop mechanism. Thanks in advance for any assistance. Regards, Larry Bates From mail at timgolden.me.uk Wed May 9 15:53:10 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 09 May 2007 14:53:10 +0100 Subject: [python-win32] Win32 service with tray icon In-Reply-To: References: <200704031717.40946.tchough@tchough.com> <07f801c7764c$7309c280$0200a8c0@enfoldsystems.local> Message-ID: <4641D246.2030807@timgolden.me.uk> Larry Bates wrote: > Please accept my apology for hijacking this thread, but it is exactly > what I want to implement. I have a COM object that is doing an upload. > I want a system tray icon that: > > 1) Shows a heartbeat (upload progress indicator) > 2) Provides the user with a way to cancel the upload > > I found systrayicon.py and it almost does what I want. I thought > about using socket server/client to have the two apps communicate > but I'm at a complete loss as to how to implement socket client > in the systrayicon.py program since it uses PumpMessages. I just > don't see how to connect to my com server (which would also be > a socket server) inside some loop mechanism. Since I assume you're not looking for cross-platform portability here, I'd be inclined to use one of Windows' built-in mechanisms: Events, Pipes, Messages etc. They should mesh with a suitable message loop, eg: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82236 TJG From theller at ctypes.org Wed May 9 17:04:55 2007 From: theller at ctypes.org (Thomas Heller) Date: Wed, 09 May 2007 17:04:55 +0200 Subject: [python-win32] Win32 service with tray icon In-Reply-To: References: <200704031717.40946.tchough@tchough.com> <07f801c7764c$7309c280$0200a8c0@enfoldsystems.local> Message-ID: Larry Bates schrieb: > Mark Hammond wrote: >>> I'm writing a win32 service in Python. I'd like to add a >>> tray icon displayed >>> whenever the service is running. I have played around with >>> SysTrayIcon.py >>> [1], but if a user logs off and logs back on, the tray icon >>> disappears even >>> though the service is still running. I think the answer is >>> probably getting >>> my service to recreate the icon whenever a logon event >>> happens. I don't >>> really know much about win32 programming, though. Can >>> someone point me in >>> the right direction to solve this problem? >> >> Services have trouble interacting with the desktop. The general approach is >> to have a dedicated taskbar application that communicates with the dedicated >> service using some kind of IPC. >> >> Mark > > Mark, > > Please accept my apology for hijacking this thread, but it is exactly > what I want to implement. I have a COM object that is doing an upload. > I want a system tray icon that: > > 1) Shows a heartbeat (upload progress indicator) > 2) Provides the user with a way to cancel the upload > > I found systrayicon.py and it almost does what I want. I thought > about using socket server/client to have the two apps communicate > but I'm at a complete loss as to how to implement socket client > in the systrayicon.py program since it uses PumpMessages. I just > don't see how to connect to my com server (which would also be > a socket server) inside some loop mechanism. You set the sockets to non-blocking, and use WSAAsyncSelect to get messages posted to the messageloop when something interesting happens to the socket. I do not know if pywin32 exposes WSAAsyncSelect, otherwise you can use ctypes to call it. Thomas From mc at mclaveau.com Wed May 9 20:33:41 2007 From: mc at mclaveau.com (Michel Claveau) Date: Wed, 9 May 2007 20:33:41 +0200 Subject: [python-win32] GetOpenFileNameW & InitialDir References: <200704031717.40946.tchough@tchough.com> <07f801c7764c$7309c280$0200a8c0@enfoldsystems.local> Message-ID: <000001c79268$93f17f00$0701a8c0@PORTABLES> Hi! I'have a problem with this code : import win32gui fname=win32gui.GetOpenFileNameW(InitialDir="C:\\dev")[0] print fname The InitialDir is not set. It's already the last dir opened, and not my request. Any idea ? Thanks by advance. Michel Claveau From p.f.moore at gmail.com Wed May 9 23:42:36 2007 From: p.f.moore at gmail.com (Paul Moore) Date: Wed, 9 May 2007 22:42:36 +0100 Subject: [python-win32] GetOpenFileNameW & InitialDir In-Reply-To: <000001c79268$93f17f00$0701a8c0@PORTABLES> References: <200704031717.40946.tchough@tchough.com> <07f801c7764c$7309c280$0200a8c0@enfoldsystems.local> <000001c79268$93f17f00$0701a8c0@PORTABLES> Message-ID: <79990c6b0705091442i720e6947q3bcc5ae40cee7ebf@mail.gmail.com> On 09/05/07, Michel Claveau wrote: > I'have a problem with this code : > > import win32gui > fname=win32gui.GetOpenFileNameW(InitialDir="C:\\dev")[0] > print fname > > The InitialDir is not set. It's already the last dir opened, and not my > request. > > Any idea ? Thanks by advance. You're using the ...W form. Shouldn't you therefore be using a unicode string for InitialDir? Paul. From mhammond at skippinet.com.au Thu May 10 01:14:35 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 10 May 2007 09:14:35 +1000 Subject: [python-win32] how to create a valid Sink In-Reply-To: Message-ID: <024701c7928f$cff58060$170a0a0a@enfoldsystems.local> > I'd like to ask for help on how to create a valid event Sink > which I can > pass to the Advise() method of a message stores table. This might be tricky unless pywin32 already has support for the specific interface you need. > Any class I made up so far gives the same error: > > File "", line 333, in notify > TypeError: The Python instance can not be converted to a COM object > > So what attributes does an object need to be convertable to a > COM object? It would need to be like any other pywin32 COM object; you should be able to find info about that on the web. Cheers, Mark From ckkart at hoc.net Thu May 10 01:54:30 2007 From: ckkart at hoc.net (Christian K.) Date: Thu, 10 May 2007 08:54:30 +0900 Subject: [python-win32] how to create a valid Sink In-Reply-To: <024701c7928f$cff58060$170a0a0a@enfoldsystems.local> References: <024701c7928f$cff58060$170a0a0a@enfoldsystems.local> Message-ID: Mark Hammond wrote: >> I'd like to ask for help on how to create a valid event Sink >> which I can >> pass to the Advise() method of a message stores table. > > This might be tricky unless pywin32 already has support for the specific > interface you need. I want to receive 'new mail' notifications from Outlook. >> Any class I made up so far gives the same error: >> >> File "", line 333, in notify >> TypeError: The Python instance can not be converted to a COM object >> >> So what attributes does an object need to be convertable to a >> COM object? > > It would need to be like any other pywin32 COM object; you should be able to > find info about that on the web. Forgive my ignorance but those are my first steps with com. Does that mean I should create and register a COM server? Basically I'm trying to reimplement the following code in python: http://www.codeproject.com/internet/CMapiEx.asp Up to now this was straightforward, but at this point I'm stuck. Thanks for any help, Christian From mhammond at skippinet.com.au Thu May 10 02:17:43 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 10 May 2007 10:17:43 +1000 Subject: [python-win32] how to create a valid Sink In-Reply-To: Message-ID: <024e01c79298$a17608a0$170a0a0a@enfoldsystems.local> > Forgive my ignorance but those are my first steps with com. Does that > mean I should create and register a COM server? You should create one - you probably don't need to register it. > Basically I'm trying to reimplement the following code in python: > > http://www.codeproject.com/internet/CMapiEx.asp > > Up to now this was straightforward, but at this point I'm stuck. I can't see anything related to a "sink" on that page - but as a start, consider looking at the spambayes package at spambayes.org - there is code there that deals with MAPI in various ways. Good luck, Mark From ckkart at hoc.net Thu May 10 02:46:41 2007 From: ckkart at hoc.net (Christian K.) Date: Thu, 10 May 2007 09:46:41 +0900 Subject: [python-win32] how to create a valid Sink In-Reply-To: <024e01c79298$a17608a0$170a0a0a@enfoldsystems.local> References: <024e01c79298$a17608a0$170a0a0a@enfoldsystems.local> Message-ID: Mark Hammond wrote: >> Forgive my ignorance but those are my first steps with com. Does that >> mean I should create and register a COM server? > > You should create one - you probably don't need to register it. > >> Basically I'm trying to reimplement the following code in python: >> >> http://www.codeproject.com/internet/CMapiEx.asp >> >> Up to now this was straightforward, but at this point I'm stuck. > > I can't see anything related to a "sink" on that page - but as a start, True, I was refering to the code in the zip file on that page. I'll attach MAPISink.h below. > consider looking at the spambayes package at spambayes.org - there is code > there that deals with MAPI in various ways. > Thank you. I'll have a look at it. Christian -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: MAPISink.h Url: http://mail.python.org/pipermail/python-win32/attachments/20070510/2dc62f9c/attachment.pot From rwupole at msn.com Thu May 10 02:58:31 2007 From: rwupole at msn.com (Roger Upole) Date: Wed, 9 May 2007 20:58:31 -0400 Subject: [python-win32] Re: GetOpenFileNameW & InitialDir Message-ID: <21C78FAF76534065BCD368415C279B7C@rwuvista> > Hi! > > I'have a problem with this code : > > import win32gui > fname=win32gui.GetOpenFileNameW(InitialDir="C:\\dev")[0] > print fname > > The InitialDir is not set. It's already the last dir opened, and not my > request. > > Any idea ? Thanks by advance. > > Michel Claveau I can't reproduce the behaviour you describe. What OS and versions of Python/Pywin32 are you using ? Roger From patter001 at gmail.com Thu May 10 14:40:01 2007 From: patter001 at gmail.com (Kevin Patterson) Date: Thu, 10 May 2007 08:40:01 -0400 Subject: [python-win32] VT_UI1 ByRef behavior In-Reply-To: References: <000e01c78aca$5ce755c0$090a0a0a@enfoldsystems.local> Message-ID: In case anyone else is interested, below is the code I ended up using to filter buffers from the input and output of the com. It makes use of the Python2.4 decorators that are added to all the functions in th py file generated by makepy. I never thought I would find a reason for the decorator, but now I'm really glad that feature is there!! :) The code was figured out by looking at the argument/return type check that is shown in the decorator PEP and making tweaks. Hope this helps! http://www.python.org/dev/peps/pep-0318/ def list2buffer(list): if type(list) == types.ListType: val = buffer(array.array('B', list)) else: val = list return val def buffer2list(abuffer,width=1): """handles buffers or lists of buffers if you actually want the buffer broken down differently than a single byte, then specify the width """ newlist = [] if type(abuffer) == types.ListType: for l in abuffer: newlist.append( buffer2list(l) ) elif type(abuffer) == types.BufferType: if width is 4: typecode = 'L' elif width is 2: typecode = 'H' elif width is 1: typecode = 'B' else: raise ValueError("Unsupported width: %d"%width) return array.array(typecode, str(abuffer)).tolist() else: return abuffer def filterin(f): def new_f(*args, **kwds): newargs = [] for i in range(len(args)): newargs.append( list2buffer(args[i]) ) for k in kwds.keys(): kwds[k] = list2buffer(args[i]) return f(*newargs, **kwds) new_f.func_name = f.func_name return new_f def filterout(f): def new_f(*args, **kwds): result = f(*args, **kwds) return buffer2list( result ) new_f.func_name = f.func_name return new_f @filterin @filterout def myfunction(somearg1,somarg2): pass On 5/9/07, Kevin Patterson wrote: > > Alrighty, I'll keep looking in to it. I think it is easy to make the > buffers get returned as a python list. Almost all the code exists to help > with that. The tough part is telling the COM that the array being passed IN > needs to become a Safe Array where the size of each element is only VT_UI1. > The buffer is a great thing for that and at first glance the only thing I > can think of would be to modify PyCom_VariantFromPyObject to check the size > of the number to see if it will fit in VT_UI1 (it is already doing this for > ints and longs)...but i think that would be way to dangerous... > > I might still look into a proposal for changing the output, but for the > input, I can't think of how to do it any other way than what you already > have. Perhaps I will just have to write a script that searches my generated > file from makepy and creates a layer in the python code...instead of on the > C side...oh well... > > -Kevin > > On 4/29/07, Mark Hammond wrote: > > > > > I was curious is there a way to prevent an array of VT_UI1's from > > being > > > converted to a buffer? Or perhaps a way to modify the file generated > > > from "makepy" to prevent the conversion? > > > > Nope, no such facility exists. Feel free to propose a patch though. > > > > Cheers, > > > > Mark > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070510/b1a0769c/attachment.htm From rbell01824 at earthlink.net Thu May 10 16:40:52 2007 From: rbell01824 at earthlink.net (Richard Bell) Date: Thu, 10 May 2007 10:40:52 -0400 Subject: [python-win32] win32com.client.DispatchWithEvents free threading re-entrancy Message-ID: <000901c79311$35811e90$6801a8c0@homeoffice.benchmarkinternational.com> I'm working on an application that does some IE automation via the COM interface. I'm running in a free thread model, sys.coint_flags = 0, and starting IE with win32.com.client.DispatchWIthEvents("InternetExplorer.Application", event_handler_class). Events are arriving as revealed by print statements in the event handling routines. Unfortunately, testing suggest that the event handling routines are being reentered (a win32 mutex can not be got because the event routines were reentered BEFORE it was released). Does anyone know if it is or is not possible for the event handlers to be re-entered under this interface? Thanks. Richard -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070510/4ebb279a/attachment.html From mail at timgolden.me.uk Thu May 10 18:19:45 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 10 May 2007 17:19:45 +0100 Subject: [python-win32] Couple of new How Do I entries Message-ID: <46434621.3080709@timgolden.me.uk> I've added a few new How Do I entries to my site[*], hopefully the first of a few more which I have meant to write up. Since these are COM-related, and since my COM knowledge is not deep, I would appreciate a few eyeballs looking at them to see if I've dropped any real clangers. AFAICT I've not got anything majorly wrong: the stuff I'm talking about is pretty simple, and the examples all work. But it's possible I'm giving misleading info, or going round the houses. Thanks for any criticisms you may be able to offer. TJG [*] http://timgolden.me.uk/python/win32_how_do_i/start-a-new-com-instance.html http://timgolden.me.uk/python/win32_how_do_i/attach-to-a-com-instance.html From deboute at gmail.com Thu May 10 18:34:53 2007 From: deboute at gmail.com (benjamin deboute) Date: Thu, 10 May 2007 18:34:53 +0200 Subject: [python-win32] terminateprocess, getprocessid and compiling trunk on win32 Message-ID: Hi Pythonistas, i'm currently building a multi-platform renderfarm application, and would need to use GetProcessId to circumvant problems i encounter when i try to kill processes on win32 IE: i can't kill with TerminateProcess a process i spawned with CreateProcess (getting a Acess Denied error), but i can kill it using this chunk of aspn'd code PROCESS_TERMINATE = 1 handle = win32api.OpenProcess(PROCESS_TERMINATE, False, pid) win32api.TerminateProcess(handle, -1) win32api.CloseHandle(handle) As i haven't found any way to get the pid except searching for the process name (but as we'll get several instances of maya.exe running on a renderslave, it won't get me far), i browsed the cvs source and found a function that was recently added: GetProcessId I then tried to compile the cvs trunk using python setup.py build, but got this error Building pywin32 2.4.210.1 running build running build_py running build_ext Warning - can't find an installed platform SDK error: The .NET Framework SDK needs to be installed before building extensions for Python. After several .net installs, i still got this error : \ i also tried (and failed) compiling it on visual studio, cygwin+mingw, but as i'm quite the noob on the subject of compiling for windows, i'm afraid i'm quite lost at the moment (my skills are limited to loading the project, clicking on build and watching the build fail with wide-eyed horror) Has someone got any pointers on compiling the cvs trunk ? A link to a quick howto or just a small paste of working compiling commands would be very appreciated Alternatively, if anyone knew how to effectively kill a process without the 'access denied' error (excepting running the service as administrator), i'll be very happy with it have a nice day and thanks in advance, ben From theller at ctypes.org Thu May 10 19:52:14 2007 From: theller at ctypes.org (Thomas Heller) Date: Thu, 10 May 2007 19:52:14 +0200 Subject: [python-win32] win32com.client.DispatchWithEvents free threading re-entrancy In-Reply-To: <000901c79311$35811e90$6801a8c0@homeoffice.benchmarkinternational.com> References: <000901c79311$35811e90$6801a8c0@homeoffice.benchmarkinternational.com> Message-ID: Richard Bell schrieb: > I'm working on an application that does some IE automation via the COM > interface. I'm running in a free thread model, sys.coint_flags = 0, and > starting IE with > win32.com.client.DispatchWIthEvents("InternetExplorer.Application", > event_handler_class). Events are arriving as revealed by print statements > in the event handling routines. Unfortunately, testing suggest that the > event handling routines are being reentered (a win32 mutex can not be got > because the event routines were reentered BEFORE it was released). > In a free-threaded apartment you must be prepared to receive events in different threads. So I think it is not forbidden that event handlers are reentered. IMO this is most easily fixed by using an STA instead, if you can live with that. Thomas From mhammond at skippinet.com.au Fri May 11 01:08:08 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 11 May 2007 09:08:08 +1000 Subject: [python-win32] terminateprocess, getprocessid and compiling trunk on win32 In-Reply-To: Message-ID: <037001c79358$1376daf0$170a0a0a@enfoldsystems.local> > i'm currently building a multi-platform renderfarm application, and > would need to use GetProcessId to circumvant problems i encounter when > i try to kill processes on win32 > > IE: i can't kill with TerminateProcess a process i spawned with > CreateProcess (getting a Acess Denied error), but i can kill it using > this chunk of aspn'd code > > PROCESS_TERMINATE = 1 > handle = win32api.OpenProcess(PROCESS_TERMINATE, False, pid) > win32api.TerminateProcess(handle, -1) > win32api.CloseHandle(handle) But doesn't CreateProcess also return the PID to you, meaning you can safely use the code above? If the 2 processes are running as the same user, I'm surprised it fails. > I then tried to compile the cvs trunk using python setup.py build, but > got this error > > Building pywin32 2.4.210.1 > running build > running build_py > running build_ext > Warning - can't find an installed platform SDK > error: The .NET Framework SDK needs to be installed before building > extensions for Python. > > After several .net installs, i still got this error : \ After installing the Platform SDK (or .NET SDK), you still got the exact error above? It might be worth looking at the source code to see why it fails to be detected. > i also tried (and failed) compiling it on visual studio, cygwin+mingw, These day, setup.py is the only way that is known to work (well - sometimes :) Mark From mmarch at gmail.com Fri May 11 03:08:16 2007 From: mmarch at gmail.com (Michael March) Date: Thu, 10 May 2007 18:08:16 -0700 Subject: [python-win32] translating VB into Python... Message-ID: <48bc40670705101808j26d9c857heb1f49034c17619d@mail.gmail.com> I have some sample code with this: object.Field("UserDefined_01") = "Open" Python barfs on that.. what would be the equivalent of that in Python? thanks! -- Michael F. March ----- mmarch at gmail dot com From timr at probo.com Fri May 11 03:18:33 2007 From: timr at probo.com (Tim Roberts) Date: Thu, 10 May 2007 18:18:33 -0700 Subject: [python-win32] translating VB into Python... In-Reply-To: <48bc40670705101808j26d9c857heb1f49034c17619d@mail.gmail.com> References: <48bc40670705101808j26d9c857heb1f49034c17619d@mail.gmail.com> Message-ID: <4643C469.60407@probo.com> Michael March wrote: > I have some sample code with this: > > object.Field("UserDefined_01") = "Open" > > Python barfs on that.. what would be the equivalent of that in Python? > Usually: object.Field("UserDefined_01").Value = "Open" VB has the concept of a "default property" for a collection like this. Python's COM doesn't. Unfortunately, every object has it's own "default property", so you sometimes have to refer to documentation to figure out what it is. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mmarch at gmail.com Fri May 11 03:23:31 2007 From: mmarch at gmail.com (Michael March) Date: Thu, 10 May 2007 18:23:31 -0700 Subject: [python-win32] translating VB into Python... In-Reply-To: <4643C469.60407@probo.com> References: <48bc40670705101808j26d9c857heb1f49034c17619d@mail.gmail.com> <4643C469.60407@probo.com> Message-ID: <48bc40670705101823i2568a984p9e5e6e6806fdc6ff@mail.gmail.com> Cool.. The docs have this: Public Property Field( _ ByVal FieldName As String _ ) As Variant Can we infer the default property from this? On 5/10/07, Tim Roberts wrote: > Michael March wrote: > > I have some sample code with this: > > > > object.Field("UserDefined_01") = "Open" > > > > Python barfs on that.. what would be the equivalent of that in Python? > > > > Usually: > object.Field("UserDefined_01").Value = "Open" > > VB has the concept of a "default property" for a collection like this. > Python's COM doesn't. Unfortunately, every object has it's own "default > property", so you sometimes have to refer to documentation to figure out > what it is. > > -- > 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 > -- Michael F. March ----- mmarch at gmail.com Ph: (415)462-1910 ---- Fax: (602)296-0400 P.O. Box 2254 ---- Phoenix, AZ 85002-2254 "Seriously" - HSR From mc at mclaveau.com Fri May 11 06:47:35 2007 From: mc at mclaveau.com (Michel Claveau) Date: Fri, 11 May 2007 06:47:35 +0200 Subject: [python-win32] GetOpenFileNameW & InitialDir References: <21C78FAF76534065BCD368415C279B7C@rwuvista> Message-ID: <000201c79387$f1f14f20$0701a8c0@PORTABLES> Hi! >>> fname=win32gui.GetOpenFileNameW(InitialDir="C:\\dev")[0] >>> The InitialDir is not set > I can't reproduce the behaviour you describe. Sorry. I found that the problem come from the software Stardock/windows_blinds/Enhanced_file_dialog (a skin manager). Yesterday, I try on anothers CPUs, without the problem. On my computer, I had sp?cified Python.exe in exclusion mode, and ... no longer problem. Apologies for trouble, and thanks for ta have try my code. Michel Claveau From ghankiewicz at rastertech.es Fri May 11 11:58:15 2007 From: ghankiewicz at rastertech.es (Grzegorz Adam Hankiewicz) Date: Fri, 11 May 2007 11:58:15 +0200 Subject: [python-win32] How to convert an OLE image from ODBC? Message-ID: <46443E37.7010102@rastertech.es> I have an access database I can access through python. A query for the image column returns binary data, but this data is in OLE image/bitmap format. Is it possible to convert this into something PIL understands? -- Rastertech Espa?a S.A. Grzegorz Adam Hankiewicz /Jefe de Producto TeraVial/ C/ Perfumer?a 21. Nave I. Pol?gono industrial La Mina 28770 Colmenar Viejo. Madrid (Espa?a) Tel. +34 918 467 390 (Ext.17) *?* Fax +34 918 457 889 ghankiewicz at rastertech.es *?* www.rastertech.es From steven.james at gmail.com Fri May 11 12:12:12 2007 From: steven.james at gmail.com (Steven James) Date: Fri, 11 May 2007 06:12:12 -0400 Subject: [python-win32] How to convert an OLE image from ODBC? In-Reply-To: <46443E37.7010102@rastertech.es> References: <46443E37.7010102@rastertech.es> Message-ID: Have you tried writing the binary data to a file, then reading it from that file with PIL? Also, you could try Image.frombuffer() if you can coerce the binary data into a python string. I just finished a win32 project that read thumbnails from COM using IExtractImage and the data came in with B,G,R byte order instead of R,G,B, so that took some finagling as well. Steven James On 5/11/07, Grzegorz Adam Hankiewicz wrote: > > I have an access database I can access through python. A query for the > image column returns binary data, but this data is in OLE image/bitmap > format. Is it possible to convert this into something PIL understands? > > -- > Rastertech Espa?a S.A. > Grzegorz Adam Hankiewicz > /Jefe de Producto TeraVial/ > > C/ Perfumer?a 21. Nave I. Pol?gono industrial La Mina > 28770 Colmenar Viejo. Madrid (Espa?a) > Tel. +34 918 467 390 (Ext.17) *?* Fax +34 918 457 889 > ghankiewicz at rastertech.es *?* www.rastertech.es > > > _______________________________________________ > 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/20070511/b08b3011/attachment.htm From ghankiewicz at rastertech.es Fri May 11 12:49:42 2007 From: ghankiewicz at rastertech.es (Grzegorz Adam Hankiewicz) Date: Fri, 11 May 2007 12:49:42 +0200 Subject: [python-win32] How to convert an OLE image from ODBC? In-Reply-To: References: <46443E37.7010102@rastertech.es> Message-ID: <46444A46.9020605@rastertech.es> Steven James wrote: > Have you tried writing the binary data to a file, then reading it from > that file with PIL? > > Also, you could try Image.frombuffer() if you can coerce the binary > data into a python string. I just finished a win32 project that read > thumbnails from COM using IExtractImage and the data came in with > B,G,R byte order instead of R,G,B, so that took some finagling as well. I dump the data to a temporary file and no matter how I rename the extension GIMP can't handle it. Opening the file with Vim shows the following header string: "Imagen de mapa de bits...Paint.Picture". -- Rastertech Espa?a S.A. Grzegorz Adam Hankiewicz /Jefe de Producto TeraVial/ C/ Perfumer?a 21. Nave I. Pol?gono industrial La Mina 28770 Colmenar Viejo. Madrid (Espa?a) Tel. +34 918 467 390 (Ext.17) *?* Fax +34 918 457 889 ghankiewicz at rastertech.es *?* www.rastertech.es From steven.james at gmail.com Fri May 11 13:52:11 2007 From: steven.james at gmail.com (Steven James) Date: Fri, 11 May 2007 07:52:11 -0400 Subject: [python-win32] How to convert an OLE image from ODBC? In-Reply-To: <46444A46.9020605@rastertech.es> References: <46443E37.7010102@rastertech.es> <46444A46.9020605@rastertech.es> Message-ID: Can you post one of those tempfiles somewhere? On 5/11/07, Grzegorz Adam Hankiewicz wrote: > > Steven James wrote: > > Have you tried writing the binary data to a file, then reading it from > > that file with PIL? > > > > Also, you could try Image.frombuffer() if you can coerce the binary > > data into a python string. I just finished a win32 project that read > > thumbnails from COM using IExtractImage and the data came in with > > B,G,R byte order instead of R,G,B, so that took some finagling as well. > I dump the data to a temporary file and no matter how I rename the > extension GIMP can't handle it. Opening the file with Vim shows the > following header string: "Imagen de mapa de bits...Paint.Picture". > > -- > Rastertech Espa?a S.A. > Grzegorz Adam Hankiewicz > /Jefe de Producto TeraVial/ > > C/ Perfumer?a 21. Nave I. Pol?gono industrial La Mina > 28770 Colmenar Viejo. Madrid (Espa?a) > Tel. +34 918 467 390 (Ext.17) *?* Fax +34 918 457 889 > ghankiewicz at rastertech.es *?* www.rastertech.es > > > _______________________________________________ > 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/20070511/8024de44/attachment.htm From ghankiewicz at rastertech.es Fri May 11 14:10:55 2007 From: ghankiewicz at rastertech.es (Grzegorz Adam Hankiewicz) Date: Fri, 11 May 2007 14:10:55 +0200 Subject: [python-win32] How to convert an OLE image from ODBC? In-Reply-To: References: <46443E37.7010102@rastertech.es> <46444A46.9020605@rastertech.es> Message-ID: <46445D4F.5050209@rastertech.es> Steven James wrote: > Can you post one of those tempfiles somewhere? Yes, you can grab them from http://gradha.no-ip.org/temp/, a .bmp and .dump version. From the sizes and the stringisation of the files looks like the .dump version is just the same with a header, but I wouldn't like to try stripping these bytes in case the header can change size. -- Rastertech Espa?a S.A. Grzegorz Adam Hankiewicz /Jefe de Producto TeraVial/ C/ Perfumer?a 21. Nave I. Pol?gono industrial La Mina 28770 Colmenar Viejo. Madrid (Espa?a) Tel. +34 918 467 390 (Ext.17) *?* Fax +34 918 457 889 ghankiewicz at rastertech.es *?* www.rastertech.es From steven.james at gmail.com Fri May 11 14:51:42 2007 From: steven.james at gmail.com (Steven James) Date: Fri, 11 May 2007 08:51:42 -0400 Subject: [python-win32] How to convert an OLE image from ODBC? In-Reply-To: References: <46443E37.7010102@rastertech.es> <46444A46.9020605@rastertech.es> <46445D4F.5050209@rastertech.es> Message-ID: It appears that your database is adding a header of its own on the image file (or maybe this is part of it being an OLE object, not sure). If you strip off the first 88 bytes, this is a standard windows bitmap file. The following code works on your file, but for your code you should just start dumping the data at the 89th byte. dump_file = file('show.dump', 'rb') out_file = file('show.bmp', 'wb') dump_file.seek(88) out_file.write(dump_file.read()) dump_file.close() out_file.close() Steven James On 5/11/07, Grzegorz Adam Hankiewicz wrote: > > Steven James wrote: > > Can you post one of those tempfiles somewhere? > > Yes, you can grab them from http://gradha.no-ip.org/temp/, a .bmp and > .dump version. From the sizes and the stringisation of the files looks > like the .dump version is just the same with a header, but I wouldn't > like to try stripping these bytes in case the header can change size. > > -- > Rastertech Espa?a S.A. > Grzegorz Adam Hankiewicz > /Jefe de Producto TeraVial/ > > C/ Perfumer?a 21. Nave I. Pol?gono industrial La Mina > 28770 Colmenar Viejo. Madrid (Espa?a) > Tel. +34 918 467 390 (Ext.17) *?* Fax +34 918 457 889 > ghankiewicz at rastertech.es *?* www.rastertech.es > > > _______________________________________________ > 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/20070511/9256e95d/attachment.htm From mail at timgolden.me.uk Fri May 11 14:54:08 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 11 May 2007 13:54:08 +0100 Subject: [python-win32] How to convert an OLE image from ODBC? In-Reply-To: References: <46443E37.7010102@rastertech.es> <46444A46.9020605@rastertech.es> <46445D4F.5050209@rastertech.es> Message-ID: <46446770.1070902@timgolden.me.uk> Steven James wrote: > It appears that your database is adding a header of its own on the image > file (or maybe this is part of it being an OLE object, not sure). > > If you strip off the first 88 bytes, this is a standard windows bitmap > file. > The following code works on your file, but for your code you should just > start dumping the data at the 89th byte. I think that's what the OP meant when he said that they were basically the same, but that he didn't know if the size of the header would be constant. TJG From mail at timgolden.me.uk Fri May 11 14:56:44 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 11 May 2007 13:56:44 +0100 Subject: [python-win32] How to convert an OLE image from ODBC? In-Reply-To: <46444A46.9020605@rastertech.es> References: <46443E37.7010102@rastertech.es> <46444A46.9020605@rastertech.es> Message-ID: <4644680C.9010307@timgolden.me.uk> Grzegorz Adam Hankiewicz wrote: > Steven James wrote: >> Have you tried writing the binary data to a file, then reading it from >> that file with PIL? >> >> Also, you could try Image.frombuffer() if you can coerce the binary >> data into a python string. I just finished a win32 project that read >> thumbnails from COM using IExtractImage and the data came in with >> B,G,R byte order instead of R,G,B, so that took some finagling as well. > I dump the data to a temporary file and no matter how I rename the > extension GIMP can't handle it. Opening the file with Vim shows the > following header string: "Imagen de mapa de bits...Paint.Picture". *Very* sketchy knowledge follows: I think that Access stores BLOBs (including, presumably, images) as a special data format which you have to read in chunks using some specific ADO code. I just threw "Access blob ado chunk" at Google and it threw up: http://support.microsoft.com/kb/258038 and http://support.microsoft.com/kb/103257 which might be useful. I'm just winging it, never done it myself. TJG From timr at probo.com Fri May 11 18:05:52 2007 From: timr at probo.com (Tim Roberts) Date: Fri, 11 May 2007 09:05:52 -0700 Subject: [python-win32] translating VB into Python... In-Reply-To: <48bc40670705101823i2568a984p9e5e6e6806fdc6ff@mail.gmail.com> References: <48bc40670705101808j26d9c857heb1f49034c17619d@mail.gmail.com> <4643C469.60407@probo.com> <48bc40670705101823i2568a984p9e5e6e6806fdc6ff@mail.gmail.com> Message-ID: <46449460.1060002@probo.com> Michael March wrote: > Cool.. > > The docs have this: > > Public Property Field( _ > ByVal FieldName As String _ > ) As Variant > > Can we infer the default property from this? No, all this tells you is that you feed a string as a parameter. You have to know more about the Variant that will be returned. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rbell01824 at earthlink.net Sat May 12 01:04:28 2007 From: rbell01824 at earthlink.net (Richard Bell) Date: Fri, 11 May 2007 19:04:28 -0400 Subject: [python-win32] win32com.client.DispatchWithEvents free threading reentrancy Message-ID: <003301c79420$ba16f700$6801a8c0@homeoffice.benchmarkinternational.com> Thanks for the response. The symptom I was seeing suggested that while a thread was processing one event, it was being re-entered. Some additional Investigation revealed that the apparent problem was caused by the event handler terminating before it was finished when it tried to reference the IE.Document.ReadyState attribute. At the time, the document was still in the process of arriving and the COM Document object did not exist. This in turn caused event processing in Python to terminate without releasing the Mutex. I've removed the reference to the Document.ReadyState and the problem is corrected. Richard Bell schrieb: > I'm working on an application that does some IE automation via the COM > interface. I'm running in a free thread model, sys.coint_flags = 0, > and starting IE with > win32.com.client.DispatchWIthEvents("InternetExplorer.Application", > event_handler_class). Events are arriving as revealed by print > statements in the event handling routines. Unfortunately, testing > suggest that the event handling routines are being reentered (a win32 > mutex can not be got because the event routines were reentered BEFORE it was released). > In a free-threaded apartment you must be prepared to receive events in different threads. So I think it is not forbidden that event handlers are reentered. IMO this is most easily fixed by using an STA instead, if you can live with that. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070511/c5d310ae/attachment.htm From rbell01824 at earthlink.net Sat May 12 01:40:15 2007 From: rbell01824 at earthlink.net (Richard Bell) Date: Fri, 11 May 2007 19:40:15 -0400 Subject: [python-win32] Referencing IE's DOM when using free thread win32com.client.DispatchWithEvents Message-ID: <003f01c79425$ba4567c0$6801a8c0@homeoffice.benchmarkinternational.com> My adventures in IE automation continue. I'm now able to start IE, navigate to a page, and process events as they occur. Unfortunately, when I try to reference the document after it is loaded and displayed I encounter a number of problems. The relevant code is as follows: self.ie = win32com.client.DispatchWithEvents( "InternetExplorer.Application", ieEvents) (snip) ie.Navigate(url) # navigate to page (snip) try: frames = yie.ie.Document.frames print "Frames length", frames.length except: print "No frames error" print sys.exc_info() This last bit of code prints No frames error (, com_error(-2147467262, 'No such interface supported', None, None), ) In an effort to correct the problem, I ran MakePY against several interfaces that looked like they might be appropriate. Subsequently, the code print "Ready State", ie.Document.ReadyState which had been working also started to generate a 'No such interface supported' error. I've modeled my access to the DOM after cPamie and run it's certification routines to verify that Python is generally sound. Does anyone know how to address this issue? Thanks, Richard From ghankiewicz at rastertech.es Sat May 12 19:49:53 2007 From: ghankiewicz at rastertech.es (Grzegorz Adam Hankiewicz) Date: Sat, 12 May 2007 19:49:53 +0200 Subject: [python-win32] How to convert an OLE image from ODBC? In-Reply-To: <46446770.1070902@timgolden.me.uk> References: <46443E37.7010102@rastertech.es> <46444A46.9020605@rastertech.es> <46445D4F.5050209@rastertech.es> <46446770.1070902@timgolden.me.uk> Message-ID: <4645FE41.3050104@rastertech.es> Tim Golden wrote: > Steven James wrote: >> It appears that your database is adding a header of its own on the >> image file (or maybe this is part of it being an OLE object, not >> sure). >> >> If you strip off the first 88 bytes, this is a standard windows >> bitmap file. The following code works on your file, but for your >> code you should just start dumping the data at the 89th byte. > > I think that's what the OP meant when he said that they were > basically the same, but that he didn't know if the size of the header > would be constant. What the hell. I'll go with the 88 skip trick for the while wrapping everything into a big try/except with error logging to a file and see how it goes. Thanks for the help. -- Rastertech Espa?a S.A. Grzegorz Adam Hankiewicz /Jefe de Producto TeraVial/ C/ Perfumer?a 21. Nave I. Pol?gono industrial La Mina 28770 Colmenar Viejo. Madrid (Espa?a) Tel. +34 918 467 390 (Ext.17) *?* Fax +34 918 457 889 ghankiewicz at rastertech.es *?* www.rastertech.es From rex555 at hotmail.com Mon May 14 21:26:20 2007 From: rex555 at hotmail.com (Rex Corrovan) Date: Mon, 14 May 2007 12:26:20 -0700 Subject: [python-win32] Referencing IE's DOM when using free threadwin32com.client.DispatchWithEvents In-Reply-To: <003f01c79425$ba4567c0$6801a8c0@homeoffice.benchmarkinternational.com> Message-ID: So I am not sure what research you have done, or if this is inherited, or how much refactoring you would need to do, but out of curiousity, have you thought about using PAMIE? I have used it with quite a lot of success. It may not be the answer you are looking for, but you might want to have a look at it. http://pamie.sourceforge.net/ -Rex From: "Richard Bell" To: Subject: [python-win32] Referencing IE's DOM when using free threadwin32com.client.DispatchWithEvents Date: Fri, 11 May 2007 19:40:15 -0400 My adventures in IE automation continue. I'm now able to start IE, navigate to a page, and process events as they occur. Unfortunately, when I try to reference the document after it is loaded and displayed I encounter a number of problems. The relevant code is as follows: self.ie = win32com.client.DispatchWithEvents( "InternetExplorer.Application", ieEvents) (snip) ie.Navigate(url) # navigate to page (snip) try: frames = yie.ie.Document.frames print "Frames length", frames.length except: print "No frames error" print sys.exc_info() This last bit of code prints No frames error (, com_error(-2147467262, 'No such interface supported', None, None), ) In an effort to correct the problem, I ran MakePY against several interfaces that looked like they might be appropriate. Subsequently, the code print "Ready State", ie.Document.ReadyState which had been working also started to generate a 'No such interface supported' error. I've modeled my access to the DOM after cPamie and run it's certification routines to verify that Python is generally sound. Does anyone know how to address this issue? Thanks, Richard _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 _________________________________________________________________ PC Magazine?s 2007 editors? choice for best Web mail?award-winning Windows Live Hotmail. http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HM_mini_pcmag_0507 From mmarch at gmail.com Tue May 15 01:22:24 2007 From: mmarch at gmail.com (Michael March) Date: Mon, 14 May 2007 16:22:24 -0700 Subject: [python-win32] translating VB into Python... In-Reply-To: <4643C469.60407@probo.com> References: <48bc40670705101808j26d9c857heb1f49034c17619d@mail.gmail.com> <4643C469.60407@probo.com> Message-ID: <48bc40670705141622t614906e4k897e847e3a98ae90@mail.gmail.com> > Michael March wrote: > > I have some sample code with this: > > > > object.Field("UserDefined_01") = "Open" > > > > Python barfs on that.. what would be the equivalent of that in Python? > > > > Usually: > object.Field("UserDefined_01").Value = "Open" > > VB has the concept of a "default property" for a collection like this. > Python's COM doesn't. Unfortunately, every object has it's own "default > property", so you sometimes have to refer to documentation to figure out > what it is. When you do: object.Field("UserDefined_01") ... the output is a unicode object.. So putting: object.Field("UserDefined_01").Value .. barfs.. I'm obviously missing something here.. Thanks! From rbell01824 at earthlink.net Tue May 15 01:23:57 2007 From: rbell01824 at earthlink.net (Richard Bell) Date: Mon, 14 May 2007 19:23:57 -0400 Subject: [python-win32] Referencing IE's DOM when using free threadwin32com.client.DispatchWithEvents In-Reply-To: Message-ID: <003601c7967e$f2715db0$6501a8c0@homeoffice.benchmarkinternational.com> Rex, I have looked at PAMIE rather carefully. Indeed, about a year ago I exchanged a number of emails with one of the authors. There are a couple of underlying problems with PAMIE's approach to IE automation. The most serious is that it doesn't do a very good job of detecting page completion. Indeed, the source notes the problem. There is also a hack to get around what is essentially a bug when referencing the DOM before it is ready. Beyond that, it doesn't effectively handle popups, something that some web applications use heavily. Additionally, although less seriously, there is no support for tabs. Last, but certainly not least, I'm a hacker at heart and it's an interesting problem. I've learned a bit more about the problem since the previous post. It appears that if calls are made to pump messages, never mind that it is a free thread model, the DOM can be referenced. I'm not sure what the issue is and will let Mark Hammond know what I've found. If anyone knows a work around, I'd appreciate some guidance. Regards, Richard Rex Wrote | |So I am not sure what research you have done, or if this is inherited, or |how much refactoring you would need to do, but out of curiousity, have you |thought about using PAMIE? I have used it with quite a lot of success. It |may not be the answer you are looking for, but you might want to have a |look |at it. | |http://pamie.sourceforge.net/ | |-Rex | | |From: "Richard Bell" |To: |Subject: [python-win32] Referencing IE's DOM when using free |threadwin32com.client.DispatchWithEvents |Date: Fri, 11 May 2007 19:40:15 -0400 | |My adventures in IE automation continue. I'm now able to start IE, |navigate |to a page, and process events as they occur. Unfortunately, when I try to |reference the document after it is loaded and displayed I encounter a |number |of problems. | |The relevant code is as follows: | | self.ie = win32com.client.DispatchWithEvents( | "InternetExplorer.Application", | ieEvents) | | (snip) | | ie.Navigate(url) # navigate to page | | (snip) | | try: | frames = yie.ie.Document.frames | print "Frames length", frames.length | except: | print "No frames error" | print sys.exc_info() | |This last bit of code prints | | No frames error | (, com_error(-2147467262, 'No such |interface supported', None, None), ) | |In an effort to correct the problem, I ran MakePY against several |interfaces |that looked like they might be appropriate. Subsequently, the code | | print "Ready State", ie.Document.ReadyState | |which had been working also started to generate a 'No such interface |supported' error. | |I've modeled my access to the DOM after cPamie and run it's certification |routines to verify that Python is generally sound. | |Does anyone know how to address this issue? | |Thanks, |Richard | From teekaysoh at gmail.com Tue May 15 03:31:07 2007 From: teekaysoh at gmail.com (TK Soh) Date: Mon, 14 May 2007 20:31:07 -0500 Subject: [python-win32] HookMessage fails Message-ID: <58b84f8e0705141831q5f8017a6yba864bf2f262c9e0@mail.gmail.com> Greeting. I built a custom dialog which would be resized by a handler connected with HookMessage() to win32con.WM_SIZE. The dialogs are actually called from the shell extension's context menu. Every seemed to work well at first. The I noticed the resize handler is only called on the dialogs that are called from the explorer window that made the first call. The same dialogs that are called from other explorer windows seemed to have the handler ignored. In fact I did some experiment indicating that the problem is not unique to WM_SIZE, but any handlers that are hooked by HookMessage. Appreciate if anyone can help shed some light on this. Thanks. From niki at vintech.bg Tue May 15 09:32:17 2007 From: niki at vintech.bg (Niki Spahiev) Date: Tue, 15 May 2007 10:32:17 +0300 Subject: [python-win32] HookMessage fails In-Reply-To: <58b84f8e0705141831q5f8017a6yba864bf2f262c9e0@mail.gmail.com> References: <58b84f8e0705141831q5f8017a6yba864bf2f262c9e0@mail.gmail.com> Message-ID: <46496201.2070106@vintech.bg> TK Soh wrote: > Greeting. > > I built a custom dialog which would be resized by a handler connected > with HookMessage() to win32con.WM_SIZE. The dialogs are actually > called from the shell extension's context menu. Every seemed to work > well at first. > > The I noticed the resize handler is only called on the dialogs that > are called from the explorer window that made the first call. The same > dialogs that are called from other explorer windows seemed to have the > handler ignored. In fact I did some experiment indicating that the > problem is not unique to WM_SIZE, but any handlers that are hooked by > HookMessage. > > Appreciate if anyone can help shed some light on this. Thanks. In order to hook more messages (e.g. WM_SIZE) you must recompile pywin32 with PYWIN_WITH_WINDOWPROC defined HTH Niki Spahiev From mail at timgolden.me.uk Tue May 15 10:26:43 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 15 May 2007 09:26:43 +0100 Subject: [python-win32] translating VB into Python... In-Reply-To: <48bc40670705141622t614906e4k897e847e3a98ae90@mail.gmail.com> References: <48bc40670705101808j26d9c857heb1f49034c17619d@mail.gmail.com> <4643C469.60407@probo.com> <48bc40670705141622t614906e4k897e847e3a98ae90@mail.gmail.com> Message-ID: <46496EC3.9040303@timgolden.me.uk> Michael March wrote: > When you do: > > object.Field("UserDefined_01") > > ... the output is a unicode object.. So putting: > > object.Field("UserDefined_01").Value > > .. barfs.. > > I'm obviously missing something here.. Not seeing the exact code you're using, so I could be wrong, but I would expect the result of the expression: object.Field ("blah") to be an instance of some class x.y.Field (or whatever). Since you wouldn't be able to use such a term on the LHS of a Python name-binding (object.Field("UserDefined_01") = "Open") then the first error you noted is unsurprising. I would then not be surprised if the pywin32 proxy for that field handled things like __unicode__, __str__, __repr__ in such a way as to return the ms-defined default property, typically the one called .Value which could well be a Unicode string. But obviously, if what you say above is strictly true - that object.Field ("blah").Value "barfs" (and I'm going to guess that this means: "raises an AttributeError because the builtin Unicode object has no .Value attribute) then what I'm describing above isn't happening. But am I understanding correctly? Could you provide a small code fragment which might help clarify things? Here's a toy example using Excel: from win32com.client.gencache import EnsureDispatch xl = EnsureDispatch ("Excel.Application") ws = xl.Workbooks.Add ().ActiveSheet cell_11 = ws.Cells (1, 1) print cell_11.__class__ # win32com...Range cell_11 = "blah" # has now bound cell_11 to the string "blah". # It works, but isn't what we want. Rebind. cell_11 = ws.Cells (1, 1) cell_11.Value = "blah" # OK print cell_11 # "blah" because of the default property print cell_11.Value # "blah" x = cell_11 print x.__class__ # win32com...Range y = cell_11.Value print y.__class__ # type "str" TJG From teekaysoh at gmail.com Tue May 15 15:15:11 2007 From: teekaysoh at gmail.com (TK Soh) Date: Tue, 15 May 2007 08:15:11 -0500 Subject: [python-win32] HookMessage fails In-Reply-To: <46496201.2070106@vintech.bg> References: <58b84f8e0705141831q5f8017a6yba864bf2f262c9e0@mail.gmail.com> <46496201.2070106@vintech.bg> Message-ID: <58b84f8e0705150615v63054fa9h57185de130a3c99d@mail.gmail.com> On 5/15/07, Niki Spahiev wrote: > TK Soh wrote: > > Greeting. > > > > I built a custom dialog which would be resized by a handler connected > > with HookMessage() to win32con.WM_SIZE. The dialogs are actually > > called from the shell extension's context menu. Every seemed to work > > well at first. > > > > The I noticed the resize handler is only called on the dialogs that > > are called from the explorer window that made the first call. The same > > dialogs that are called from other explorer windows seemed to have the > > handler ignored. In fact I did some experiment indicating that the > > problem is not unique to WM_SIZE, but any handlers that are hooked by > > HookMessage. > > > > Appreciate if anyone can help shed some light on this. Thanks. > > In order to hook more messages (e.g. WM_SIZE) you must recompile pywin32 > with PYWIN_WITH_WINDOWPROC defined I'm confused. The hooks appeared to work fine, though only in the dialog opened from the specific explorer window as I described earlier. I've tried WM_SIZE, WM_ACTIVATE, etc. BTW, I'm using ActivePython 2.4, which comes with pywin32 bundled. I'm not sure if PYWIN_WITH_WINDOWPROC is defined in ActivePython. From niki at vintech.bg Tue May 15 16:09:42 2007 From: niki at vintech.bg (Niki Spahiev) Date: Tue, 15 May 2007 17:09:42 +0300 Subject: [python-win32] HookMessage fails In-Reply-To: <58b84f8e0705150615v63054fa9h57185de130a3c99d@mail.gmail.com> References: <58b84f8e0705141831q5f8017a6yba864bf2f262c9e0@mail.gmail.com> <46496201.2070106@vintech.bg> <58b84f8e0705150615v63054fa9h57185de130a3c99d@mail.gmail.com> Message-ID: <4649BF26.1030409@vintech.bg> >> In order to hook more messages (e.g. WM_SIZE) you must recompile pywin32 >> with PYWIN_WITH_WINDOWPROC defined > > I'm confused. The hooks appeared to work fine, though only in the > dialog opened from the specific explorer window as I described > earlier. I've tried WM_SIZE, WM_ACTIVATE, etc. > > BTW, I'm using ActivePython 2.4, which comes with pywin32 bundled. I'm > not sure if PYWIN_WITH_WINDOWPROC is defined in ActivePython. Hooks are based on special MFC glue code. When this glue code is not active some messages are handled only by PYWIN_WITH_WINDOWPROC build. Niki Spahiev From teekaysoh at gmail.com Tue May 15 18:47:46 2007 From: teekaysoh at gmail.com (TK Soh) Date: Tue, 15 May 2007 11:47:46 -0500 Subject: [python-win32] HookMessage fails In-Reply-To: <4649BF26.1030409@vintech.bg> References: <58b84f8e0705141831q5f8017a6yba864bf2f262c9e0@mail.gmail.com> <46496201.2070106@vintech.bg> <58b84f8e0705150615v63054fa9h57185de130a3c99d@mail.gmail.com> <4649BF26.1030409@vintech.bg> Message-ID: <58b84f8e0705150947l520ebcf9t2bc0aa0fbeff12ea@mail.gmail.com> On 5/15/07, Niki Spahiev wrote: > >> In order to hook more messages (e.g. WM_SIZE) you must recompile pywin32 > >> with PYWIN_WITH_WINDOWPROC defined > > > > I'm confused. The hooks appeared to work fine, though only in the > > dialog opened from the specific explorer window as I described > > earlier. I've tried WM_SIZE, WM_ACTIVATE, etc. > > > > BTW, I'm using ActivePython 2.4, which comes with pywin32 bundled. I'm > > not sure if PYWIN_WITH_WINDOWPROC is defined in ActivePython. > > Hooks are based on special MFC glue code. When this glue code is not > active some messages are handled only by PYWIN_WITH_WINDOWPROC build. The hooks are working, so I guess PYWIN_WITH_WINDOWPROC support has indeed been compiled into ActivePython. The only problem now is the strange behavior when sometime the hooks don't get triggered. Any suggestion on workaround? Thanks. From timr at probo.com Tue May 15 19:09:41 2007 From: timr at probo.com (Tim Roberts) Date: Tue, 15 May 2007 10:09:41 -0700 Subject: [python-win32] HookMessage fails In-Reply-To: <58b84f8e0705150947l520ebcf9t2bc0aa0fbeff12ea@mail.gmail.com> References: <58b84f8e0705141831q5f8017a6yba864bf2f262c9e0@mail.gmail.com> <46496201.2070106@vintech.bg> <58b84f8e0705150615v63054fa9h57185de130a3c99d@mail.gmail.com> <4649BF26.1030409@vintech.bg> <58b84f8e0705150947l520ebcf9t2bc0aa0fbeff12ea@mail.gmail.com> Message-ID: <4649E955.5070004@probo.com> TK Soh wrote: > The hooks are working, so I guess PYWIN_WITH_WINDOWPROC support has > indeed been compiled into ActivePython. The only problem now is the > strange behavior when sometime the hooks don't get triggered. Any > suggestion on workaround? > Where do you call HookWindow? Are you calling it every time you create a new dialog window? Do you have access to the Platform SDK? It might be worth using spyxx to monitor the message traffic to your dialogs, and see if anything changes from one invocation to the next. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From teekaysoh at gmail.com Tue May 15 19:27:08 2007 From: teekaysoh at gmail.com (TK Soh) Date: Tue, 15 May 2007 12:27:08 -0500 Subject: [python-win32] HookMessage fails In-Reply-To: <4649E955.5070004@probo.com> References: <58b84f8e0705141831q5f8017a6yba864bf2f262c9e0@mail.gmail.com> <46496201.2070106@vintech.bg> <58b84f8e0705150615v63054fa9h57185de130a3c99d@mail.gmail.com> <4649BF26.1030409@vintech.bg> <58b84f8e0705150947l520ebcf9t2bc0aa0fbeff12ea@mail.gmail.com> <4649E955.5070004@probo.com> Message-ID: <58b84f8e0705151027p3743b3bcv2e88c1295553d609@mail.gmail.com> On 5/15/07, Tim Roberts wrote: > TK Soh wrote: > > The hooks are working, so I guess PYWIN_WITH_WINDOWPROC support has > > indeed been compiled into ActivePython. The only problem now is the > > strange behavior when sometime the hooks don't get triggered. Any > > suggestion on workaround? > > > > Where do you call HookWindow? Are you calling it every time you create > a new dialog window? > > Do you have access to the Platform SDK? It might be worth using spyxx > to monitor the message traffic to your dialogs, and see if anything > changes from one invocation to the next. Thanks for the info, but I'm not sure about Platform SDK. I started doing this windows thing directly with python32. The HookMessage is called in OnInitDialog(), so I presumed is called every time a new dialog is created (I'm very new to windows programming): def OnInitDialog(self): rc = Dialog.OnInitDialog(self) oldhanler = self.HookMessage(self.OnSize, win32con.WM_SIZE) I just noticed yet another strange thing: the dialogs opened from the 'first' explorer window will always stay on top with respect to their parent explorer window, while other dialogs maybe freely reordered. Windowx (XP) also does not create taskbar menus (not sure this is what they are called) for the custom dialogs that are opened from the 'first' explorer window. From timr at probo.com Tue May 15 19:36:23 2007 From: timr at probo.com (Tim Roberts) Date: Tue, 15 May 2007 10:36:23 -0700 Subject: [python-win32] HookMessage fails In-Reply-To: <58b84f8e0705151027p3743b3bcv2e88c1295553d609@mail.gmail.com> References: <58b84f8e0705141831q5f8017a6yba864bf2f262c9e0@mail.gmail.com> <46496201.2070106@vintech.bg> <58b84f8e0705150615v63054fa9h57185de130a3c99d@mail.gmail.com> <4649BF26.1030409@vintech.bg> <58b84f8e0705150947l520ebcf9t2bc0aa0fbeff12ea@mail.gmail.com> <4649E955.5070004@probo.com> <58b84f8e0705151027p3743b3bcv2e88c1295553d609@mail.gmail.com> Message-ID: <4649EF97.2030609@probo.com> TK Soh wrote: > > Thanks for the info, but I'm not sure about Platform SDK. I started > doing this windows thing directly with python32. > > The HookMessage is called in OnInitDialog(), so I presumed is called > every time a new dialog is created (I'm very new to windows > programming): Yes, it is. WM_INITDIALOG is called after all the child controls are created but before the dialog is made visible. It was designed specifically for things like your subclassing. > def OnInitDialog(self): > rc = Dialog.OnInitDialog(self) > oldhanler = self.HookMessage(self.OnSize, win32con.WM_SIZE) > > I just noticed yet another strange thing: the dialogs opened from the > 'first' explorer window will always stay on top with respect to their > parent explorer window, while other dialogs maybe freely reordered. > > Windowx (XP) also does not create taskbar menus (not sure this is what > they are called) for the custom dialogs that are opened from the > 'first' explorer window. Interesting that they behave so differently. That begins to suggest they have different parents. What do you specify as the parent when you create the dialog? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From teekaysoh at gmail.com Tue May 15 19:49:51 2007 From: teekaysoh at gmail.com (TK Soh) Date: Tue, 15 May 2007 12:49:51 -0500 Subject: [python-win32] HookMessage fails In-Reply-To: <4649EF97.2030609@probo.com> References: <58b84f8e0705141831q5f8017a6yba864bf2f262c9e0@mail.gmail.com> <46496201.2070106@vintech.bg> <58b84f8e0705150615v63054fa9h57185de130a3c99d@mail.gmail.com> <4649BF26.1030409@vintech.bg> <58b84f8e0705150947l520ebcf9t2bc0aa0fbeff12ea@mail.gmail.com> <4649E955.5070004@probo.com> <58b84f8e0705151027p3743b3bcv2e88c1295553d609@mail.gmail.com> <4649EF97.2030609@probo.com> Message-ID: <58b84f8e0705151049p41b5457j7e0aa44eaf9f21c7@mail.gmail.com> On 5/15/07, Tim Roberts wrote: > TK Soh wrote: > > > > Thanks for the info, but I'm not sure about Platform SDK. I started > > doing this windows thing directly with python32. > > > > The HookMessage is called in OnInitDialog(), so I presumed is called > > every time a new dialog is created (I'm very new to windows > > programming): > > Yes, it is. WM_INITDIALOG is called after all the child controls are > created but before the dialog is made visible. It was designed > specifically for things like your subclassing. > > > > def OnInitDialog(self): > > rc = Dialog.OnInitDialog(self) > > oldhanler = self.HookMessage(self.OnSize, win32con.WM_SIZE) > > > > I just noticed yet another strange thing: the dialogs opened from the > > 'first' explorer window will always stay on top with respect to their > > parent explorer window, while other dialogs maybe freely reordered. > > > > Windowx (XP) also does not create taskbar menus (not sure this is what > > they are called) for the custom dialogs that are opened from the > > 'first' explorer window. > > Interesting that they behave so differently. That begins to suggest > they have different parents. What do you specify as the parent when you > create the dialog? Actually I didn't specify any parent at all: class MyDialog(Dialog): def __init__(self, title=None, tmpl=None): self.title = title if tmpl is None: tmpl = dlg_template() Dialog.__init__(self, tmpl) I don't see the parent being passed into the dialogs in pywin32's sample code. Is this going to be a problem? From timr at probo.com Tue May 15 20:03:08 2007 From: timr at probo.com (Tim Roberts) Date: Tue, 15 May 2007 11:03:08 -0700 Subject: [python-win32] HookMessage fails In-Reply-To: <58b84f8e0705151049p41b5457j7e0aa44eaf9f21c7@mail.gmail.com> References: <58b84f8e0705141831q5f8017a6yba864bf2f262c9e0@mail.gmail.com> <46496201.2070106@vintech.bg> <58b84f8e0705150615v63054fa9h57185de130a3c99d@mail.gmail.com> <4649BF26.1030409@vintech.bg> <58b84f8e0705150947l520ebcf9t2bc0aa0fbeff12ea@mail.gmail.com> <4649E955.5070004@probo.com> <58b84f8e0705151027p3743b3bcv2e88c1295553d609@mail.gmail.com> <4649EF97.2030609@probo.com> <58b84f8e0705151049p41b5457j7e0aa44eaf9f21c7@mail.gmail.com> Message-ID: <4649F5DC.3090404@probo.com> TK Soh wrote: > > Actually I didn't specify any parent at all: > > class MyDialog(Dialog): > def __init__(self, title=None, tmpl=None): > self.title = title > if tmpl is None: > tmpl = dlg_template() > Dialog.__init__(self, tmpl) > > I don't see the parent being passed into the dialogs in pywin32's > sample code. Is this going to be a problem? Well, in looking at the code, I don't even see a way to specify one, so this seems to have been a rat hole. I'm mildly surprised by that. The CreateDialog APIs all take a "parent" window, and the parentage plays a part in determining window stacking and taskbar presence. I wonder what the win32ui code uses for that... -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mmarch at gmail.com Tue May 15 20:46:14 2007 From: mmarch at gmail.com (Michael March) Date: Tue, 15 May 2007 11:46:14 -0700 Subject: [python-win32] translating VB into Python... In-Reply-To: <46496EC3.9040303@timgolden.me.uk> References: <48bc40670705101808j26d9c857heb1f49034c17619d@mail.gmail.com> <4643C469.60407@probo.com> <48bc40670705141622t614906e4k897e847e3a98ae90@mail.gmail.com> <46496EC3.9040303@timgolden.me.uk> Message-ID: <48bc40670705151146w44d04575t3f1069a1c1bcfab8@mail.gmail.com> Ok.. here is the VB example .. (this is for / provided by HP's Quality Center help file..) Sub LinkDefects() 'This example creates two defects and links them Dim BugF As BugFactory Dim Bug1 As Bug ' tdc is a TDConnection. The user is authenticated and ' connected to the project before this routine runs. Set BugF = tdc.BugFactory 'Create new defects Set Bug1 = BugF.AddItem(Null) Bug1.Summary = "Lydia Bennet is 15 years old." Bug1.Status = "New" Bug1.Priority = "3-High" Bug1.Field("BG_SEVERITY") = "3-High" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Bug1.DetectedBy = c_qcUser Bug1.Field("BG_DETECTION_DATE") = Date ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Bug1.Post I'm able to translate all that code, no prob, except for the lines highlighted. If you do: print Bug1.Field ..you get the current value of the field. On 5/15/07, Tim Golden wrote: > Michael March wrote: > > When you do: > > > > object.Field("UserDefined_01") > > > > ... the output is a unicode object.. So putting: > > > > object.Field("UserDefined_01").Value > > > > .. barfs.. > > > > I'm obviously missing something here.. > > Not seeing the exact code you're using, so I > could be wrong, but I would expect the result > of the expression: object.Field ("blah") to > be an instance of some class x.y.Field > (or whatever). Since you wouldn't be able to > use such a term on the LHS of a Python name-binding > (object.Field("UserDefined_01") = "Open") then > the first error you noted is unsurprising. > > I would then not be surprised if the pywin32 > proxy for that field handled things like > __unicode__, __str__, __repr__ in such a way > as to return the ms-defined default property, > typically the one called .Value which could > well be a Unicode string. > > But obviously, if what you say above is strictly > true - that object.Field ("blah").Value "barfs" > (and I'm going to guess that this means: "raises > an AttributeError because the builtin Unicode > object has no .Value attribute) then what I'm > describing above isn't happening. > > But am I understanding correctly? Could you provide a > small code fragment which might help clarify things? > > Here's a toy example using Excel: > > > from win32com.client.gencache import EnsureDispatch > xl = EnsureDispatch ("Excel.Application") > ws = xl.Workbooks.Add ().ActiveSheet > > cell_11 = ws.Cells (1, 1) > print cell_11.__class__ > # win32com...Range > > cell_11 = "blah" > # has now bound cell_11 to the string "blah". > # It works, but isn't what we want. Rebind. > > cell_11 = ws.Cells (1, 1) > cell_11.Value = "blah" > # OK > > print cell_11 > # "blah" because of the default property > print cell_11.Value > # "blah" > > x = cell_11 > print x.__class__ > # win32com...Range > > y = cell_11.Value > print y.__class__ > # type "str" > > > > TJG > From benjamin.d at sparx.com Wed May 9 12:48:01 2007 From: benjamin.d at sparx.com (Benjamin Deboute) Date: Wed, 09 May 2007 12:48:01 +0200 Subject: [python-win32] terminateprocess, getprocessid and compiling trunk on win32 Message-ID: <4641A6E1.4040603@sparx.com> Hi Pythonistas, i'm currently building a multi-platform renderfarm application, and would need to use GetProcessId to circumvant problems i encounter when i try to kill processes on win32 IE: i can't kill with TerminateProcess a process i spawned with CreateProcess (getting a Acess Denied error), but i can kill it using this chunk of aspn'd code PROCESS_TERMINATE = 1 handle = win32api.OpenProcess(PROCESS_TERMINATE, False, pid) win32api.TerminateProcess(handle, -1) win32api.CloseHandle(handle) As i haven't found any way to get the pid except searching for the process name (but as we'll get several instances of maya.exe running on a renderslave, it won't get me far), i browsed the cvs source and found a function that was recently added: GetProcessId I then tried to compile the cvs trunk using python setup.py build, but got this error Building pywin32 2.4.210.1 running build running build_py running build_ext Warning - can't find an installed platform SDK error: The .NET Framework SDK needs to be installed before building extensions for Python. After several .net installs, i still got this error : \ i also tried (and failed) compiling it on visual studio, cygwin+mingw, but as i'm quite the noob on the subject of compiling for windows, i'm afraid i'm quite lost at the moment (my skills are limited to loading the project, clicking on build and watching the build fail with wide-eyed horror) Has someone got any pointers on compiling the cvs trunk ? A link to a quick howto or just a small paste of working compiling commands would be very appreciated Alternatively, if anyone knew how to effectively kill a process without the 'access denied' error (excepting running the service as administrator), i'll be very happy with it have a nice day and thanks in advance, ben From mmarch at gmail.com Tue May 15 23:19:24 2007 From: mmarch at gmail.com (Michael March) Date: Tue, 15 May 2007 14:19:24 -0700 Subject: [python-win32] translating VB into Python... In-Reply-To: <48bc40670705151146w44d04575t3f1069a1c1bcfab8@mail.gmail.com> References: <48bc40670705101808j26d9c857heb1f49034c17619d@mail.gmail.com> <4643C469.60407@probo.com> <48bc40670705141622t614906e4k897e847e3a98ae90@mail.gmail.com> <46496EC3.9040303@timgolden.me.uk> <48bc40670705151146w44d04575t3f1069a1c1bcfab8@mail.gmail.com> Message-ID: <48bc40670705151419l6e130b59ve3181a32d176b3d6@mail.gmail.com> Here is another example in context: >>> import win32com.client >>> td = win32com.client.Dispatch("TDApiOle80.TDConnection.1") >>> td.InitConnectionEx( "http://myserver.com:8080/qcbin/" ) >>> td.ConnectProjectEx("TM_PLAY_AREA", "TM_PlayArea", "user", "passwd") >>> bfact = td.BugFactory >>> mybug=bfact.Item(22) >>> fields = mybug.Field("BG_DESCRIPTION") >>> print fields Test Set: Mercury Tours UI Test: [1]Welcome Page Run: Run_9-11_11-43-36 Step: Forms Description: Check the forms on the page: - Input fields - Lists - Radio buttons - Checkboxes Expected result: 1. The input fields should be left aligned. >>> mybug.Field("BG_DESCRIPTION") u'Test Set: Mercury Tours UI\nTest: [1]Welcome Page\nRun: Run_9-11_11-43-36\nSte p: Forms\n\nDescription:\nCheck the forms on the page:\n - Input fields\n - Lists\n - Radio buttons\n - Checkboxes\n\nExpected result:\n1. The input fields should be left aligned.\n2.' >>> mybug.Field("BG_DESCRIPTION").Value = "123" Traceback (most recent call last): File "", line 1, in ? AttributeError: 'unicode' object has no attribute 'Value' On 5/15/07, Michael March wrote: > Ok.. here is the VB example .. (this is for / provided by HP's > Quality Center help file..) > > Sub LinkDefects() > > 'This example creates two defects and links them > > Dim BugF As BugFactory > > Dim Bug1 As Bug > > ' tdc is a TDConnection. The user is authenticated and > > ' connected to the project before this routine runs. > > Set BugF = tdc.BugFactory > > > 'Create new defects > > Set Bug1 = BugF.AddItem(Null) > > Bug1.Summary = "Lydia Bennet is 15 years old." > > Bug1.Status = "New" > > Bug1.Priority = "3-High" > > Bug1.Field("BG_SEVERITY") = "3-High" > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Bug1.DetectedBy = c_qcUser > > Bug1.Field("BG_DETECTION_DATE") = Date > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Bug1.Post > > I'm able to translate all that code, no prob, except for the lines highlighted. > > If you do: > > print Bug1.Field > > ..you get the current value of the field. > > On 5/15/07, Tim Golden wrote: > > Michael March wrote: > > > When you do: > > > > > > object.Field("UserDefined_01") > > > > > > ... the output is a unicode object.. So putting: > > > > > > object.Field("UserDefined_01").Value > > > > > > .. barfs.. > > > > > > I'm obviously missing something here.. > > > > Not seeing the exact code you're using, so I > > could be wrong, but I would expect the result > > of the expression: object.Field ("blah") to > > be an instance of some class x.y.Field > > (or whatever). Since you wouldn't be able to > > use such a term on the LHS of a Python name-binding > > (object.Field("UserDefined_01") = "Open") then > > the first error you noted is unsurprising. > > > > I would then not be surprised if the pywin32 > > proxy for that field handled things like > > __unicode__, __str__, __repr__ in such a way > > as to return the ms-defined default property, > > typically the one called .Value which could > > well be a Unicode string. > > > > But obviously, if what you say above is strictly > > true - that object.Field ("blah").Value "barfs" > > (and I'm going to guess that this means: "raises > > an AttributeError because the builtin Unicode > > object has no .Value attribute) then what I'm > > describing above isn't happening. > > > > But am I understanding correctly? Could you provide a > > small code fragment which might help clarify things? > > > > Here's a toy example using Excel: > > > > > > from win32com.client.gencache import EnsureDispatch > > xl = EnsureDispatch ("Excel.Application") > > ws = xl.Workbooks.Add ().ActiveSheet > > > > cell_11 = ws.Cells (1, 1) > > print cell_11.__class__ > > # win32com...Range > > > > cell_11 = "blah" > > # has now bound cell_11 to the string "blah". > > # It works, but isn't what we want. Rebind. > > > > cell_11 = ws.Cells (1, 1) > > cell_11.Value = "blah" > > # OK > > > > print cell_11 > > # "blah" because of the default property > > print cell_11.Value > > # "blah" > > > > x = cell_11 > > print x.__class__ > > # win32com...Range > > > > y = cell_11.Value > > print y.__class__ > > # type "str" > > > > > > > > TJG > > > -- Michael F. March ----- mmarch at gmail.com Ph: (415)462-1910 ---- Fax: (602)296-0400 P.O. Box 2254 ---- Phoenix, AZ 85002-2254 "Seriously" - HSR From timr at probo.com Tue May 15 23:41:10 2007 From: timr at probo.com (Tim Roberts) Date: Tue, 15 May 2007 14:41:10 -0700 Subject: [python-win32] translating VB into Python... In-Reply-To: <48bc40670705151419l6e130b59ve3181a32d176b3d6@mail.gmail.com> References: <48bc40670705101808j26d9c857heb1f49034c17619d@mail.gmail.com> <4643C469.60407@probo.com> <48bc40670705141622t614906e4k897e847e3a98ae90@mail.gmail.com> <46496EC3.9040303@timgolden.me.uk> <48bc40670705151146w44d04575t3f1069a1c1bcfab8@mail.gmail.com> <48bc40670705151419l6e130b59ve3181a32d176b3d6@mail.gmail.com> Message-ID: <464A28F6.1070100@probo.com> Michael March wrote: > Here is another example in context: > >>>> mybug.Field("BG_DESCRIPTION") >>>> > u'Test Set: Mercury Tours UI\nTest: [1]Welcome Page\nRun: Run_9-11_11-43-36\nSte > p: Forms\n\nDescription:\nCheck the forms on the page:\n - Input fields\n > - Lists\n - Radio buttons\n - Checkboxes\n\nExpected result:\n1. The input > fields should be left aligned.\n2.' > > >>>> mybug.Field("BG_DESCRIPTION").Value = "123" >>>> > Traceback (most recent call last): > File "", line 1, in ? > AttributeError: 'unicode' object has no attribute 'Value' > The "Value" suggestion was clearly bad advice on my part. What do you get if you just do this: mybug.Field("BG_DESCRIPTION") = "123' -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mmarch at gmail.com Tue May 15 23:47:01 2007 From: mmarch at gmail.com (Michael March) Date: Tue, 15 May 2007 14:47:01 -0700 Subject: [python-win32] translating VB into Python... In-Reply-To: <464A28F6.1070100@probo.com> References: <48bc40670705101808j26d9c857heb1f49034c17619d@mail.gmail.com> <4643C469.60407@probo.com> <48bc40670705141622t614906e4k897e847e3a98ae90@mail.gmail.com> <46496EC3.9040303@timgolden.me.uk> <48bc40670705151146w44d04575t3f1069a1c1bcfab8@mail.gmail.com> <48bc40670705151419l6e130b59ve3181a32d176b3d6@mail.gmail.com> <464A28F6.1070100@probo.com> Message-ID: <48bc40670705151447w78433d01o5cb96e2557bedf8c@mail.gmail.com> >>> mybug.Field("BG_DESCRIPTION")= "123" SyntaxError: can't assign to function call On 5/15/07, Tim Roberts wrote: > Michael March wrote: > > Here is another example in context: > > > >>>> mybug.Field("BG_DESCRIPTION") > >>>> > > u'Test Set: Mercury Tours UI\nTest: [1]Welcome Page\nRun: Run_9-11_11-43-36\nSte > > p: Forms\n\nDescription:\nCheck the forms on the page:\n - Input fields\n > > - Lists\n - Radio buttons\n - Checkboxes\n\nExpected result:\n1. The input > > fields should be left aligned.\n2.' > > > > > >>>> mybug.Field("BG_DESCRIPTION").Value = "123" > >>>> > > Traceback (most recent call last): > > File "", line 1, in ? > > AttributeError: 'unicode' object has no attribute 'Value' > > > > The "Value" suggestion was clearly bad advice on my part. What do you > get if you just do this: > mybug.Field("BG_DESCRIPTION") = "123' > > -- > 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 > -- Michael F. March ----- mmarch at gmail.com Ph: (415)462-1910 ---- Fax: (602)296-0400 P.O. Box 2254 ---- Phoenix, AZ 85002-2254 "Seriously" - HSR From mhammond at skippinet.com.au Wed May 16 01:21:21 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 16 May 2007 09:21:21 +1000 Subject: [python-win32] HookMessage fails In-Reply-To: <4649F5DC.3090404@probo.com> Message-ID: <018601c79747$bfed9880$1d0a0a0a@enfoldsystems.local> > > I don't see the parent being passed into the dialogs in pywin32's > > sample code. Is this going to be a problem? > > Well, in looking at the code, I don't even see a way to > specify one, so > this seems to have been a rat hole. > > I'm mildly surprised by that. The CreateDialog APIs all take > a "parent" > window, and the parentage plays a part in determining window stacking > and taskbar presence. I wonder what the win32ui code uses for that... This is the magic of MFC - if no parent is specified, the "main window" for the application is automatically used. Mark From timr at probo.com Wed May 16 01:27:18 2007 From: timr at probo.com (Tim Roberts) Date: Tue, 15 May 2007 16:27:18 -0700 Subject: [python-win32] HookMessage fails In-Reply-To: <018601c79747$bfed9880$1d0a0a0a@enfoldsystems.local> References: <018601c79747$bfed9880$1d0a0a0a@enfoldsystems.local> Message-ID: <464A41D6.2070906@probo.com> Mark Hammond wrote: >>> I don't see the parent being passed into the dialogs in pywin32's >>> sample code. Is this going to be a problem? >>> >> Well, in looking at the code, I don't even see a way to >> specify one, so >> this seems to have been a rat hole. >> >> I'm mildly surprised by that. The CreateDialog APIs all take >> a "parent" >> window, and the parentage plays a part in determining window stacking >> and taskbar presence. I wonder what the win32ui code uses for that... >> > > This is the magic of MFC - if no parent is specified, the "main window" for > the application is automatically used. > Isn't that the issue, then? He's writing a dialog to plug in to Explorer, and every time he runs, there's a different "main window". MFC gets its concept of a "main window" from its global state, so unless something in the process tells MFC to refresh its global state, it will have stale information. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From benjamin.d at sparx.com Thu May 10 09:56:27 2007 From: benjamin.d at sparx.com (Benjamin Deboute) Date: Thu, 10 May 2007 09:56:27 +0200 Subject: [python-win32] terminateprocess, getprocessid and compiling trunk on win32 Message-ID: <4642D02B.1020601@sparx.com> Hi Pythonistas, i'm currently building a multi-platform renderfarm application, and would need to use GetProcessId to circumvant problems i encounter when i try to kill processes on win32 IE: i can't kill with TerminateProcess a process i spawned with CreateProcess (getting a Acess Denied error), but i can kill it using this chunk of aspn'd code PROCESS_TERMINATE = 1 handle = win32api.OpenProcess(PROCESS_TERMINATE, False, pid) win32api.TerminateProcess(handle, -1) win32api.CloseHandle(handle) As i haven't found any way to get the pid except searching for the process name (but as we'll get several instances of maya.exe running on a renderslave, it won't get me far), i browsed the cvs source and found a function that was recently added: GetProcessId I then tried to compile the cvs trunk using python setup.py build, but got this error Building pywin32 2.4.210.1 running build running build_py running build_ext Warning - can't find an installed platform SDK error: The .NET Framework SDK needs to be installed before building extensions for Python. After several .net installs, i still got this error : \ i also tried (and failed) compiling it on visual studio, cygwin+mingw, but as i'm quite the noob on the subject of compiling for windows, i'm afraid i'm quite lost at the moment (my skills are limited to loading the project, clicking on build and watching the build fail with wide-eyed horror) Has someone got any pointers on compiling the cvs trunk ? A link to a quick howto or just a small paste of working compiling commands would be very appreciated Alternatively, if anyone knew how to effectively kill a process without the 'access denied' error (excepting running the service as administrator), i'll be very happy with it have a nice day and thanks in advance, ben From mhammond at skippinet.com.au Wed May 16 03:13:54 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 16 May 2007 11:13:54 +1000 Subject: [python-win32] HookMessage fails In-Reply-To: <464A41D6.2070906@probo.com> Message-ID: <018d01c79757$796c5440$1d0a0a0a@enfoldsystems.local> > > This is the magic of MFC - if no parent is specified, the > "main window" for > > the application is automatically used. > > > > Isn't that the issue, then? He's writing a dialog to plug in to > Explorer, and every time he runs, there's a different "main window". > MFC gets its concept of a "main window" from its global > state, so unless > something in the process tells MFC to refresh its global > state, it will > have stale information. Quite possibly - I'm afraid I can't recall the exact semantics for dialog based apps, but I suspect that a number of things in MFC will end up getting upset if the nominated main window dies but the application does not - but win32ui.GetApp().SetMainFrame() can be used to change this value dynamically. I'm afraid I haven't found the time to read the other messages in enough detail to offer more concrete suggestions (other than to possibly consider using win32gui to avoid future MFCisms from biting) Cheers, Mark From mhammond at skippinet.com.au Wed May 16 03:15:42 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 16 May 2007 11:15:42 +1000 Subject: [python-win32] terminateprocess, getprocessid and compiling trunk on win32 In-Reply-To: <4642D02B.1020601@sparx.com> Message-ID: <018e01c79757$b9e12f00$1d0a0a0a@enfoldsystems.local> These appear to be a reposts of the message you sent on May 11, which I also answered on that same day (notwithstanding time zones!) Mark > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org]On Behalf Of Benjamin Deboute > Sent: Thursday, 10 May 2007 5:56 PM > To: python-win32 at python.org > Subject: [python-win32] terminateprocess,getprocessid and compiling > trunk on win32 > > > Hi Pythonistas, > > i'm currently building a multi-platform renderfarm application, and > would need to use GetProcessId to circumvant problems i > encounter when i > try to kill processes on win32 > > IE: i can't kill with TerminateProcess a process i spawned with > CreateProcess (getting a Acess Denied error), but i can kill it using > this chunk of aspn'd code > > PROCESS_TERMINATE = 1 > handle = win32api.OpenProcess(PROCESS_TERMINATE, False, pid) > win32api.TerminateProcess(handle, -1) > win32api.CloseHandle(handle) > > As i haven't found any way to get the pid except searching for the > process name (but as we'll get several instances of maya.exe > running on > a renderslave, it won't get me far), i browsed the cvs source > and found > a function that was recently added: GetProcessId > > I then tried to compile the cvs trunk using python setup.py > build, but > got this error > > Building pywin32 2.4.210.1 > running build > running build_py > running build_ext > Warning - can't find an installed platform SDK > error: The .NET Framework SDK needs to be installed before building > extensions for Python. > > After several .net installs, i still got this error : \ > i also tried (and failed) compiling it on visual studio, > cygwin+mingw, > but as i'm quite the noob on the subject of compiling for > windows, i'm > afraid i'm quite lost at the moment (my skills are limited to loading > the project, clicking on build and watching the build fail with > wide-eyed horror) > Has someone got any pointers on compiling the cvs trunk ? A link to a > quick howto or just a small paste of working compiling > commands would be > very appreciated > > Alternatively, if anyone knew how to effectively kill a > process without > the 'access denied' error (excepting running the service as > administrator), i'll be very happy with it > > > have a nice day and thanks in advance, > ben > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From mail at timgolden.me.uk Wed May 16 09:12:43 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 16 May 2007 08:12:43 +0100 Subject: [python-win32] translating VB into Python... In-Reply-To: <48bc40670705151419l6e130b59ve3181a32d176b3d6@mail.gmail.com> References: <48bc40670705101808j26d9c857heb1f49034c17619d@mail.gmail.com> <4643C469.60407@probo.com> <48bc40670705141622t614906e4k897e847e3a98ae90@mail.gmail.com> <46496EC3.9040303@timgolden.me.uk> <48bc40670705151146w44d04575t3f1069a1c1bcfab8@mail.gmail.com> <48bc40670705151419l6e130b59ve3181a32d176b3d6@mail.gmail.com> Message-ID: <464AAEEB.50502@timgolden.me.uk> I'm hoping that Mark Hammond will catch sight of this thread and chip in. I'm guessing that you're seeing some odd interaction between the generated class/module and the COM object properties. There's a sort of funniness where properties can be methods... or not. Have you generated a proxy module for this? If you haven't use makepy or EnsureDispatch to generate and then look for the definition of the result of the .Field method or property or whatever. I'm groping in the dark a little, but I suspect that the __str__ and __unicode__ magic methods of whatever type that is are actually invoking the default method/property of the underlying object. To be concrete then: 1) Can you generate and post (probably to some webspace somwhere) the proxy module? If you don't have easy access to space, send it to me off-list and I can post it up. from win32com.client import gencache td = gencache.EnsureDispatch ("TDApiOle80.TDConnection.1") print td.__module__ 2) What is the *type* of the value returned from mybug.Field ("blah") ? import win32com.client td = win32com.client.Dispatch("TDApiOle80.TDConnection.1") td.InitConnectionEx( "http://myserver.com:8080/qcbin/" ) td.ConnectProjectEx( "TM_PLAY_AREA", "TM_PlayArea", "user", "passwd" ) bfact = td.BugFactory mybug=bfact.Item(22) fields = mybug.Field("BG_DESCRIPTION") print fields.__class__ print type (fields) From le.dahut at laposte.net Wed May 16 10:34:03 2007 From: le.dahut at laposte.net (le dahut) Date: Wed, 16 May 2007 10:34:03 +0200 Subject: [python-win32] Error FindPerformanceAttributesByName Message-ID: <464AC1FB.6010405@laposte.net> Hi, I'm using win32pdhutil.FindPerformanceAttributesByName in order to know if 'explorer.exe' is running or not. Sometimes I get this error : """ File "win32pdhutil.pyc", line 97, in FindPerformanceAttributesByName File "win32pdhutil.pyc", line 60, in GetPerformanceAttributes pywintypes.error: (-2147481643, 'CollectQueryData', 'No error message is available') """ I've googled for "2147481643" but didn't find interesting pages. Can someone explain me what's happening ? I'm using the latest py-win32 for python 2.5. K. From mhammond at skippinet.com.au Wed May 16 14:06:47 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 16 May 2007 22:06:47 +1000 Subject: [python-win32] translating VB into Python... In-Reply-To: <464AAEEB.50502@timgolden.me.uk> Message-ID: <021301c797b2$ada96080$1d0a0a0a@enfoldsystems.local> > I'm hoping that Mark Hammond will catch sight > of this thread and chip in. I'm guessing that > you're seeing some odd interaction between > the generated class/module and the COM object > properties. There's a sort of funniness where > properties can be methods... or not. I'm stumped too. > > Have you generated a proxy module for this? > If you haven't use makepy or EnsureDispatch > to generate and then look for the definition > of the result of the .Field method or > property or whatever. > > I'm groping in the dark a little, but I suspect > that the __str__ and __unicode__ magic methods > of whatever type that is are actually invoking > the default method/property of the underlying > object. This is 1/2 correct - 'print' or 'str' of a COM object will try a default method, but this isn't the problem here best I can tell: >From before: >>> mybug.Field("BG_DESCRIPTION").Value = "123" > > Traceback (most recent call last): > > File "", line 1, in ? > > AttributeError: 'unicode' object has no attribute 'Value' printing repr(mybug) before the above line would be interesting tho, just to make sure it is a makepy object - if it wasn't I could see it happening in edge cases (ie, the code around ERRORS_BAD_CONTEXT in win32com.client.dynamic) Mark From mail at timgolden.me.uk Wed May 16 14:27:47 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 16 May 2007 13:27:47 +0100 Subject: [python-win32] Error FindPerformanceAttributesByName In-Reply-To: <464AC1FB.6010405@laposte.net> References: <464AC1FB.6010405@laposte.net> Message-ID: <464AF8C3.9030406@timgolden.me.uk> le dahut wrote: > Hi, > > I'm using win32pdhutil.FindPerformanceAttributesByName in order to know > if 'explorer.exe' is running or not. Sometimes I get this error : > """ > File "win32pdhutil.pyc", line 97, in FindPerformanceAttributesByName > > File "win32pdhutil.pyc", line 60, in GetPerformanceAttributes > > pywintypes.error: (-2147481643, 'CollectQueryData', 'No error message is > available') > """ > > I've googled for "2147481643" but didn't find interesting pages. Can > someone explain me what's happening ? Notice that the number is actually negative: -2147481643 which equates to hex 800007d5. Might be worth searching on that. Meanwhile... ... I can't easily think of a situation under Windows when explorer.exe *isn't* running, since it powers thing like your desktop. This code snippet, for example, shows the explorer processes running on my machine with nothing running in the foreground except the Python process itself: import wmi for i in wmi.WMI ().Win32_Process (Name="explorer.exe"): print i.CommandLine # => c:/windows/explorer/exe What are you trying to do with the explorer.exe once you find it? TJG From deboute at gmail.com Wed May 16 15:09:49 2007 From: deboute at gmail.com (benjamin deboute) Date: Wed, 16 May 2007 15:09:49 +0200 Subject: [python-win32] terminateprocess, getprocessid and compiling trunk on win32 In-Reply-To: <018e01c79757$b9e12f00$1d0a0a0a@enfoldsystems.local> References: <4642D02B.1020601@sparx.com> <018e01c79757$b9e12f00$1d0a0a0a@enfoldsystems.local> Message-ID: Hi Mark, On 5/16/07, Mark Hammond wrote: > These appear to be a reposts of the message you sent on May 11, which I also > answered on that same day (notwithstanding time zones!) > Sorry about that, but actually they were sent before and never managed to appear on the list until now :\ I encountered a strange problem when trying to post this message the other week, from another email address than the one i'm using right now. Those two emails where sent 09/05 and 10/05 and never appeared before just now, but as a matter of fact i did saw two posts from other people on the list which had as enveloppe-from "python-win32-bounces+benjamin.d=sparx.com at python.org". I alerted python.org mailing list admin on this really strange postfix behaviour and reposted my mail using another email addy and this time it actually went through. Quite voodoo story, and as everything voodoo, it now has its own zombies with those mails that have been raised from the dead Anyway, sorry for not having answered before but i was slightly overworked :\ >>i'm currently building a multi-platform renderfarm application, and >> would need to use GetProcessId to circumvant problems i encounter when >> i try to kill processes on win32 >> >> IE: i can't kill with TerminateProcess a process i spawned with >> CreateProcess (getting a Acess Denied error), but i can kill it using >> this chunk of aspn'd code >> >> PROCESS_TERMINATE = 1 >> handle = win32api.OpenProcess(PROCESS_TERMINATE, False, pid) >> win32api.TerminateProcess(handle, -1) >> win32api.CloseHandle(handle) >But doesn't CreateProcess also return the PID to you, meaning you can safely >use the code above? If the 2 processes are running as the same user, I'm >surprised it fails. So, as i was telling, when i use createprocess i can't find the PID In [1]: import win32process In [2]: s = 'd:\\APPLIS\\cygwin\\bin\\ping.exe -t embrun' In [3]: win32process.CreateProcess(None, s,None, None, 1, 0, None,None, win32process.STARTUPINFO()) Out[3]: (, , 1316, 1528) and the ping.exe process is listed with a PID of 1402 in windows' tasks manager I have checked msdn and have seen the function that is called via win32.process.CreateProcess is stated to return a ProcessInformation structure, that contains the process ProcessId as its 3rd entry http://msdn2.microsoft.com/en-us/library/ms684873.aspx So in my case, the process id returned would be 1316 In order to be sure i invoked PROCESS_TERMINATE = 1 handle = win32api.OpenProcess(PROCESS_TERMINATE, False, 1316) win32api.TerminateProcess(handle, -1) win32api.CloseHandle(handle) A quick glance in my task manager window showed me that the ping process was still running I then tried the same chuck of code with a PID of 1402, and the ping process this time disapeared from the task manager For your info, i'm on win2k For the compilation problems >> Warning - can't find an installed platform SDK >> > error: The .NET Framework SDK needs to be installed before building >> > extensions for Python. >> > >> > After several .net installs, i still got this error : \ > After installing the Platform SDK (or .NET SDK), you still got the exact > error above? It might be worth looking at the source code to see why it > fails to be detected. > > i also tried (and failed) compiling it on visual studio, cygwin+mingw, > These day, setup.py is the only way that is known to work (well - sometimes :) The .NET error message has been resolved by reading more carefully and realizing that i needed a computer with visual platform sdk installed. Don't know why it incorrectly states .NET as being seeked, as the string *NET* does not exist in setup.py so i suppose it's windows internals that are at fault As i progressed, this error has been raised 'Can't find a version in Windows.h' Been crudely taken care of with finding the hexa value in windows.h and assigning it to a variable in setup.py Then i got a linking problem with pywintypes, Link reported that it couldn't find pywintypes.lib i searched around and found that pywintypes is a lib included in pywin32, i found it strange that pywin32 couldn't be build if pywin32 wasn't installed in the system, but i shrugged the shrug of HeWhoIsCompilingOnWindows and copied pywintypes.lib shamelessly at the root of my source directory Then pywin32 compiled some more and crashed on this C:\APPLIS\Microsoft Visual Studio .NET 2003\Vc7\bin\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\Python24\libs /LIBPATH:C:\Python24\PCBuild /LIBPATH:build\temp.win32-2.4\Release /EXPORT:initwin32pdh build\temp.win32-2.4\Release\win32\src\win32pdhmodule.obj /OUT:build\lib.win32-2.4\win32\win32pdh.pyd /IMPLIB:build\temp.win32-2.4\Release\win32\src\win32pdh.lib /MACHINE:ix86 /BASE:0x1eb30000 /DEBUG /PDB:build\temp.win32-2.4\Release\win32pdh.pdb Creating library build\temp.win32-2.4\Release\win32\src\win32pdh.lib and object build\temp.win32-2.4\Release\win32\src\win32pdh.exp win32pdhmodule.obj : error LNK2019: external symbol unresolved "__declspec(dllimport) struct _object * __cdecl PyWinLong_FromHANDLE(void *)" (__imp_?PyWinLong_FromHANDLE@@YAPAU_object@@PAX at Z) referenced in function "struct _object * __cdecl PyAddCounter(struct _object *,struct _object *)" (?PyAddCounter@@YAPAU_object@@PAU1 at 0@Z) build\lib.win32-2.4\win32\win32pdh.pyd : fatal error LNK1120: 1 external unresolved As it states that PyWinLong_FromHandle is not declared in pywintypes i verified that i had the latest relased version of pywin32 (it was) and grepped the lib for PywinLong No match was found for it This is where i stopped yesterday, i hope the gritty details will help you understand the issue. If you need specific info that i did not include, please ask Regards, ben From graham.bloice at trihedral.com Wed May 16 14:41:24 2007 From: graham.bloice at trihedral.com (Graham Bloice) Date: Wed, 16 May 2007 13:41:24 +0100 Subject: [python-win32] Error FindPerformanceAttributesByName In-Reply-To: <464AF8C3.9030406@timgolden.me.uk> References: <464AC1FB.6010405@laposte.net> <464AF8C3.9030406@timgolden.me.uk> Message-ID: <464AFBF4.8030203@trihedral.com> Tim Golden wrote: > le dahut wrote: >> Hi, >> >> I'm using win32pdhutil.FindPerformanceAttributesByName in order to know >> if 'explorer.exe' is running or not. Sometimes I get this error : >> """ >> File "win32pdhutil.pyc", line 97, in FindPerformanceAttributesByName >> >> File "win32pdhutil.pyc", line 60, in GetPerformanceAttributes >> >> pywintypes.error: (-2147481643, 'CollectQueryData', 'No error message is >> available') >> """ >> >> I've googled for "2147481643" but didn't find interesting pages. Can >> someone explain me what's happening ? > > Notice that the number is actually negative: -2147481643 > which equates to hex 800007d5. Might be worth searching on > that. Meanwhile... > FYI, the error "PDH_NO_DATA" is defined as 0x800007D5 in the SDK header files. The comment beside it states "No data to return". -- Regards, Graham Bloice From le.dahut at laposte.net Wed May 16 15:33:09 2007 From: le.dahut at laposte.net (le dahut) Date: Wed, 16 May 2007 15:33:09 +0200 Subject: [python-win32] Error FindPerformanceAttributesByName In-Reply-To: <464AF8C3.9030406@timgolden.me.uk> References: <464AC1FB.6010405@laposte.net> <464AF8C3.9030406@timgolden.me.uk> Message-ID: <464B0815.5070707@laposte.net> Tim Golden wrote : > le dahut wrote: >> Hi, >> >> I'm using win32pdhutil.FindPerformanceAttributesByName in order to know >> if 'explorer.exe' is running or not. Sometimes I get this error : >> """ >> File "win32pdhutil.pyc", line 97, in FindPerformanceAttributesByName >> >> File "win32pdhutil.pyc", line 60, in GetPerformanceAttributes >> >> pywintypes.error: (-2147481643, 'CollectQueryData', 'No error message is >> available') >> """ >> >> I've googled for "2147481643" but didn't find interesting pages. Can >> someone explain me what's happening ? > > Notice that the number is actually negative: -2147481643 > which equates to hex 800007d5. Might be worth searching on > that. Meanwhile... > > ... I can't easily think of a situation under Windows when > explorer.exe *isn't* running, since it powers thing like > your desktop. This code snippet, for example, shows > the explorer processes running on my machine with > nothing running in the foreground except the Python > process itself: > > > import wmi > for i in wmi.WMI ().Win32_Process (Name="explorer.exe"): > print i.CommandLine > > # => c:/windows/explorer/exe > > > What are you trying to do with the explorer.exe > once you find it? > > TJG Kill it ;-) this code is part of an winlogon notification package that setup users' environment like hide drives which require explorer to be restarted. If you're interested in how to make that, here's the subversion's url - for the .dll that runs the python script http://eole.orion.education.fr/depot/listing.php?repname=Eole&path=%2FEole2%2Fscribe%2Fcontrole-vnc%2Ftrunk%2Fsources%2Fcliscribe_dll%2F&rev=0&sc=0 - for the python script itself (look for logon.py) http://eole.orion.education.fr/depot/listing.php?repname=Eole&path=%2FEole2%2Fscribe%2Fcontrole-vnc%2Ftrunk%2Fsources%2Fservscribe%2F&rev=0&sc=0 I've re-written my "isrunning" and the killProcName functions with ctypes which runs very faster than the python version (look for process.py in subversion). From mmarch at gmail.com Wed May 16 15:49:27 2007 From: mmarch at gmail.com (Michael March) Date: Wed, 16 May 2007 06:49:27 -0700 Subject: [python-win32] translating VB into Python... In-Reply-To: <464AAEEB.50502@timgolden.me.uk> References: <48bc40670705101808j26d9c857heb1f49034c17619d@mail.gmail.com> <4643C469.60407@probo.com> <48bc40670705141622t614906e4k897e847e3a98ae90@mail.gmail.com> <46496EC3.9040303@timgolden.me.uk> <48bc40670705151146w44d04575t3f1069a1c1bcfab8@mail.gmail.com> <48bc40670705151419l6e130b59ve3181a32d176b3d6@mail.gmail.com> <464AAEEB.50502@timgolden.me.uk> Message-ID: <48bc40670705160649g12064e4eiefb8d70b6d77d364@mail.gmail.com> See below.. On 5/16/07, Tim Golden wrote: > I'm hoping that Mark Hammond will catch sight > of this thread and chip in. I'm guessing that > you're seeing some odd interaction between > the generated class/module and the COM object > properties. There's a sort of funniness where > properties can be methods... or not. > > Have you generated a proxy module for this? > If you haven't use makepy or EnsureDispatch > to generate and then look for the definition > of the result of the .Field method or > property or whatever. > > I'm groping in the dark a little, but I suspect > that the __str__ and __unicode__ magic methods > of whatever type that is are actually invoking > the default method/property of the underlying > object. > > To be concrete then: > > 1) Can you generate and post (probably to some webspace > somwhere) the proxy module? If you don't have easy > access to space, send it to me off-list and I can post > it up. Oops.. I sent it to Mark in the most COMPRESSED form I could muster up. > > from win32com.client import gencache > td = gencache.EnsureDispatch ("TDApiOle80.TDConnection.1") > print td.__module__ > >>> from win32com.client import gencache >>> td = gencache.EnsureDispatch ("TDApiOle80.TDConnection.1") >>> print td.__module__ win32com.gen_py.F645BD06-E1B4-4E6A-82FB-E97D027FD456x0x1x0 > 2) What is the *type* of the value returned from > mybug.Field ("blah") ? > > > import win32com.client > td = win32com.client.Dispatch("TDApiOle80.TDConnection.1") > td.InitConnectionEx( "http://myserver.com:8080/qcbin/" ) > td.ConnectProjectEx( > "TM_PLAY_AREA", > "TM_PlayArea", > "user", > "passwd" > ) > bfact = td.BugFactory > mybug=bfact.Item(22) > fields = mybug.Field("BG_DESCRIPTION") > print fields.__class__ > print type (fields) > > >>> bfact = td.BugFactory >>> mybug=bfact.Item(22) >>> fields = mybug.Field("BG_DESCRIPTION") >>> print fields.__class__ >>> print type (fields) From mmarch at gmail.com Wed May 16 15:58:15 2007 From: mmarch at gmail.com (Michael March) Date: Wed, 16 May 2007 06:58:15 -0700 Subject: [python-win32] translating VB into Python... In-Reply-To: <48bc40670705160629x127d0897lcafd9eceff9b5df9@mail.gmail.com> References: <464AAEEB.50502@timgolden.me.uk> <021301c797b2$ada96080$1d0a0a0a@enfoldsystems.local> <48bc40670705160629x127d0897lcafd9eceff9b5df9@mail.gmail.com> Message-ID: <48bc40670705160658r563f8ba5j6b6b29e929ccd818@mail.gmail.com> [resend - I think the mailing list ate my last post..] See comments below... On 5/16/07, Mark Hammond wrote: > > I'm hoping that Mark Hammond will catch sight > > of this thread and chip in. I'm guessing that > > you're seeing some odd interaction between > > the generated class/module and the COM object > > properties. There's a sort of funniness where > > properties can be methods... or not. > > I'm stumped too. > > > > > Have you generated a proxy module for this? > > If you haven't use makepy or EnsureDispatch > > to generate and then look for the definition > > of the result of the .Field method or > > property or whatever. > > > > I'm groping in the dark a little, but I suspect > > that the __str__ and __unicode__ magic methods > > of whatever type that is are actually invoking > > the default method/property of the underlying > > object. > > This is 1/2 correct - 'print' or 'str' of a COM object will try a default > method, but this isn't the problem here best I can tell: > > From before: > > >>> mybug.Field("BG_DESCRIPTION").Value = "123" > > > Traceback (most recent call last): > > > File "", line 1, in ? > > > AttributeError: 'unicode' object has no attribute 'Value' > > printing repr(mybug) before the above line would be interesting tho, just to > make sure it is a makepy object - if it wasn't I could see it happening in > edge cases (ie, the code around ERRORS_BAD_CONTEXT in > win32com.client.dynamic) >>> repr(mybug) '' And here is the generated stub code (in 7zip or uncompressed form.) http://music.cowmix.com/PythonWin32/ From mail at timgolden.me.uk Wed May 16 16:01:51 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 16 May 2007 15:01:51 +0100 Subject: [python-win32] translating VB into Python... In-Reply-To: <48bc40670705160658r563f8ba5j6b6b29e929ccd818@mail.gmail.com> References: <464AAEEB.50502@timgolden.me.uk> <021301c797b2$ada96080$1d0a0a0a@enfoldsystems.local> <48bc40670705160629x127d0897lcafd9eceff9b5df9@mail.gmail.com> <48bc40670705160658r563f8ba5j6b6b29e929ccd818@mail.gmail.com> Message-ID: <464B0ECF.2020702@timgolden.me.uk> Michael March wrote: > [resend - I think the mailing list ate my last post..] I saw it! But no matter, the web link's useful. I imagine Mark's hitting the sack about now (assuming he's in Australia). It's 3pm here in the UK so I'll try to see if I can spot what's happening, but from a glance at the generated code, it looks like one of those awkward cases where a method is also a property and *also* the default value. I'll try and have a go at it. TJG From mhammond at skippinet.com.au Wed May 16 16:48:46 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 17 May 2007 00:48:46 +1000 Subject: [python-win32] translating VB into Python... In-Reply-To: <48bc40670705160629x127d0897lcafd9eceff9b5df9@mail.gmail.com> Message-ID: <023c01c797c9$4f42ff80$1d0a0a0a@enfoldsystems.local> > > printing repr(mybug) before the above line would be > interesting tho, just to > > make sure it is a makepy object - if it wasn't I could see > it happening in > > edge cases (ie, the code around ERRORS_BAD_CONTEXT in > > win32com.client.dynamic) > > >>> repr(mybug) > ' 0x18853976>' Yeah - so sadly it *is* a makepy based object, so I remain stumped :( Mark From graham.bloice at trihedral.com Wed May 16 16:53:17 2007 From: graham.bloice at trihedral.com (Graham Bloice) Date: Wed, 16 May 2007 15:53:17 +0100 Subject: [python-win32] translating VB into Python... In-Reply-To: <464B0ECF.2020702@timgolden.me.uk> References: <464AAEEB.50502@timgolden.me.uk> <021301c797b2$ada96080$1d0a0a0a@enfoldsystems.local> <48bc40670705160629x127d0897lcafd9eceff9b5df9@mail.gmail.com> <48bc40670705160658r563f8ba5j6b6b29e929ccd818@mail.gmail.com> <464B0ECF.2020702@timgolden.me.uk> Message-ID: <464B1ADD.8070003@trihedral.com> Tim Golden wrote: > Michael March wrote: >> [resend - I think the mailing list ate my last post..] > > I saw it! But no matter, the web link's useful. I imagine > Mark's hitting the sack about now (assuming he's in > Australia). It's 3pm here in the UK so I'll try to see > if I can spot what's happening, but from a glance at > the generated code, it looks like one of those awkward > cases where a method is also a property and *also* the > default value. I'll try and have a go at it. > Looking at the makepy output isn't this a case where pywin32 has to use a method to access an indexed property using a "SetXXX" call. >From the makepy: class IBug(DispatchBaseClass): """Represents a defect.""" CLSID = IID('{2AF970F7-6CCC-4DFB-AA78-08F689481F94}') coclass_clsid = IID('{AF9180F9-8C16-4824-9EA1-A9010B072B2C}') # The method Field is actually a property, but must be used as a method to correctly pass the arguments def Field(self, FieldName=defaultNamedNotOptArg): """The value of the specified field.""" return self._ApplyTypes_(0, 2, (12, 0), ((8, 0),), 'Field', None,FieldName) ... # The method SetField is actually a property, but must be used as a method to correctly pass the arguments def SetField(self, FieldName=defaultNamedNotOptArg, arg1=defaultUnnamedArg): """The value of the specified field.""" return self._oleobj_.InvokeTypes(0, LCID, 4, (24, 0), ((8, 0), (12, 1)),FieldName, arg1) So try using: mybug.SetField("BG_DESCRIPTION", "123") -- Regards, Graham Bloice From mmarch at gmail.com Wed May 16 17:01:08 2007 From: mmarch at gmail.com (Michael March) Date: Wed, 16 May 2007 08:01:08 -0700 Subject: [python-win32] translating VB into Python... In-Reply-To: <464B1ADD.8070003@trihedral.com> References: <464AAEEB.50502@timgolden.me.uk> <021301c797b2$ada96080$1d0a0a0a@enfoldsystems.local> <48bc40670705160629x127d0897lcafd9eceff9b5df9@mail.gmail.com> <48bc40670705160658r563f8ba5j6b6b29e929ccd818@mail.gmail.com> <464B0ECF.2020702@timgolden.me.uk> <464B1ADD.8070003@trihedral.com> Message-ID: <48bc40670705160801j4644ff65q5c5c39dc5a3bbc08@mail.gmail.com> Hurray!!!!!!!! >>> mybug=bfact.Item(24) >>> mybug.Field("BG_DESCRIPTION") u'Test Set: Mercury Tours UI\nTest: [1]Welcome Page\nRun: Run_9-11_11-43-36\nSte p: Verify Tag Properties\n\nDescription:\n1. Click the "Find Next" button.\n2. V erify properties for the tag.\n\nExpected result:\n\n\nActual Result:\nIMG tags have no these attributes on all HTML pages of the Mercury Tours site.' >>> mybug.SetField("BG_DESCRIPTION", "123") >>> mybug.Field("BG_DESCRIPTION") u'123' >>> mybug.Post() On 5/16/07, Graham Bloice wrote: > Tim Golden wrote: > > Michael March wrote: > >> [resend - I think the mailing list ate my last post..] > > > > I saw it! But no matter, the web link's useful. I imagine > > Mark's hitting the sack about now (assuming he's in > > Australia). It's 3pm here in the UK so I'll try to see > > if I can spot what's happening, but from a glance at > > the generated code, it looks like one of those awkward > > cases where a method is also a property and *also* the > > default value. I'll try and have a go at it. > > > > Looking at the makepy output isn't this a case where pywin32 has to use > a method to access an indexed property using a "SetXXX" call. > > From the makepy: > > class IBug(DispatchBaseClass): > """Represents a defect.""" > CLSID = IID('{2AF970F7-6CCC-4DFB-AA78-08F689481F94}') > coclass_clsid = IID('{AF9180F9-8C16-4824-9EA1-A9010B072B2C}') > > # The method Field is actually a property, but must be used as a method > to correctly pass the arguments > def Field(self, FieldName=defaultNamedNotOptArg): > """The value of the specified field.""" > return self._ApplyTypes_(0, 2, (12, 0), ((8, 0),), 'Field', > None,FieldName) > > ... > > # The method SetField is actually a property, but must be used as a > method to correctly pass the arguments > def SetField(self, FieldName=defaultNamedNotOptArg, > arg1=defaultUnnamedArg): > """The value of the specified field.""" > return self._oleobj_.InvokeTypes(0, LCID, 4, (24, 0), ((8, 0), > (12, 1)),FieldName, arg1) > > > So try using: > > mybug.SetField("BG_DESCRIPTION", "123") > > -- > Regards, > > Graham Bloice > -- Michael F. March ----- mmarch at gmail.com Ph: (415)462-1910 ---- Fax: (602)296-0400 P.O. Box 2254 ---- Phoenix, AZ 85002-2254 "Seriously" - HSR From steve_geo at optusnet.com.au Thu May 17 03:32:11 2007 From: steve_geo at optusnet.com.au (Stephen George) Date: Thu, 17 May 2007 11:32:11 +1000 Subject: [python-win32] Cannot get COM early bound Message-ID: <464BB09B.1040201@optusnet.com.au> Greetings, I have been a COM expert for all of two days ;-) I did get a Type Mismatch error on an argument, .. the more I dug and researched this error, the more I found out and now have a question about early binding. I am trying to get access to two COM objects/interfaces <=(don't know what word to use here, so bear with me if I get it wrong) The COM objects I'm interested in are ClearCase Automation Library (CAL) & ClearQuestOLEServer I ran makepy on both of these. selected info from each of the generated files is =============================== # From type library 'ccauto.dll' # On Wed May 16 16:38:12 2007 """ClearCase Automation Library 6.0""" makepy_version = '0.4.95' python_version = 0x20500f0 :: :: # This CoClass is known by the name 'ClearCase.Application.1' class Application(CoClassBaseClass): # A CoClass =============================== # From type library 'cqole.dll' # On Wed May 16 16:37:15 2007 """""" makepy_version = '0.4.95' python_version = 0x20500f0 :: :: # This CoClass is known by the name 'CLEARQUEST.SESSION' class Session(CoClassBaseClass): # A CoClass =============================== Chapter 12 of Marks book, indicates case sensitivity can be a problem for late bound Also VARIANT translations may not work so well under late bound. I wanted to use early bound to ensure my VARIANTS are correct. But I cannot get the CLEARQUEST.SESSION early bound. I successfully got ClearCase.Application early bound The output of my program indicates that the ClearCase.Application object was early bound, but I could do nothing to get CLEARQUEST.SESSION early bound ==========My Program============= import win32com.client as w32c import pythoncom from win32com.client import constants try: cc = w32c.Dispatch(r"ClearCase.Application") print "CC:",cc except TypeError, detail: print "ClearCase exception: TypeError", detail print '--------------------------------------------------------' #---------------ClearQuest ---------------- try: from win32com.client import gencache gencache.EnsureModule('{B805FDF6-BEA8-11D1-B36D-00A0C9851B52}', 0, 1, 0) cq_session = w32c.Dispatch(r"CLEARQUEST.SESSION") # cq_session = w32c.Dispatch(r"Clearquest.Session") # cq_session = w32c.Dispatch(r"ClearQuest.Session") # cq_session = w32c.Dispatch(r"clearquest.session") # cq_session = w32c.Dispatch('{B805FDF6-BEA8-11D1-B36D-00A0C9851B52}') print "CQ:",cq_session cq_session.UserLogon( 'sgeorge', 'sgeorge', "OSI", "" ); except pythoncom.com_error ,(hr, msg, exc, arg): print 'HRESULT\t%d: %s' % (hr, msg) if exc: wcode, source, text, helpFile, helpId, scode = exc print 'The source of the error is', source print 'The error message is', text print "More info can be found in %s (id=%d)" % (helpFile, helpId) ========= Output =============================== D:\tempSVNPyFiles\clearcase>testcom.py CC: -------------------------------------------------------- CQ: HRESULT -2147352571: Type mismatch. ================================================= According to Chp. 12, the 'win32com.gen_py' bit indicates early binding and 'COMObject ' indicates late binding To ensure early binding as per the book , I force the makepy process from the source using info from running makepy.py -i D:\tempSVNPyFiles\clearcase>c:\python24\Lib\site-packages\win32com\client\makepy.py -i ClearQuestOleServer {B805FDF6-BEA8-11D1-B36D-00A0C9851B52}, lcid=0, major=1, minor=0 >>> # Use these commands in Python code to auto generate .py support >>> from win32com.client import gencache >>> gencache.EnsureModule('{B805FDF6-BEA8-11D1-B36D-00A0C9851B52}', 0, 1, 0) I also experimented with the case of the object name CLEARQUEST.SESSION, as can been seen in the source. All resulted in late binding. The final test is passing in the CLSID (hope this is the right format) cq_session = w32c.Dispatch('{B805FDF6-BEA8-11D1-B36D-00A0C9851B52}') Which resulted in D:\tempSVNPyFiles\clearcase>testcom.py CC: -------------------------------------------------------- HRESULT -2147221164: Class not registered Making me wonder whats going on? I'm unsure were to go from here. ====================== Possibly separate but related, I have notice something funny. I deleted the cache of generated py files by deleting the directory C:\Python25\Lib\site-packages\win32com\gen_py (not Python\win32com\gen_py as the book suggests) And re-run the application, and ClearCase.Application was still early bound (although it should not be as I was not forcing it) CC: I had noticed on some occasions (not all) when I run makepy.py (from command line), it sticks stuff into a temp directory instead of win32com\gen.py ??? D:\tempSVNPyFiles\clearcase> D:\tempSVNPyFiles\clearcase>c:\python25\Lib\site-packages\win32com\client\makepy.py Generating to C:\DOCUME~1\SGEORG~1.OSI\LOCALS~1\Temp\gen_py\2.5\B22C7EFA-5A5E-11D3-B1CD-00C04F8ECE2Fx0x6x0.py Building definitions from type library... Generating... Importing module If I then run makepy from PythonWin It correctly puts things into \win32com\gen_py Subsequent runs from the command line then correctly put into win32com\gen_py So out of curiosity after deleting gen_py from the python directory, checking that the app was still early bound, I went to the temp directory and deleted the gen_py directory from there. finally ClearCase was late bound. CC: Why would my application be picking up the generated com interface file from a temp directory?? I could not work out the trigger for getting makepy.py into this mode. I suspected running with -i argument or running makepy from python24 which I also have co-installed, but I couldn't reproduce on demand. However once I re-assured myself that the ONLY gen_py directory on my hard disk was in C:\Python25\Lib\site-packages\win32com\ and the two COM interface I was interested in had both been generated into this directory, I still had one late bound and one early bound. A further test showed that if no gen_py directory exists on my hard disk, both under python24 and python25 the following code >> from win32com.client import gencache >> gencache.EnsureModule('{B805FDF6-BEA8-11D1-B36D-00A0C9851B52}', 0, 1, 0) created the gen_py directory in the temp directory - Maybe this is the correct behavior for users without permissions? After this a subsequent run of make_py from the command line put the resultant gen_py files also into the gen_py directory of the temp directory instead of under python? I'm confused if I'm observing correct behavior?, and as to why I cannot get CLEARQUEST.SESSION early bound. Any comments appreciated Thanks Steve From mhammond at skippinet.com.au Thu May 17 04:51:38 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 17 May 2007 12:51:38 +1000 Subject: [python-win32] Cannot get COM early bound In-Reply-To: <464BB09B.1040201@optusnet.com.au> Message-ID: <02ae01c7982e$4acf36c0$1d0a0a0a@enfoldsystems.local> > Greetings, > > I have been a COM expert for all of two days ;-) > > I did get a Type Mismatch error on an argument, .. the more I dug and > researched this error, the more I found out and now have a question > about early binding. > > I am trying to get access to two COM objects/interfaces <=(don't know > what word to use here, so bear with me if I get it wrong) > > The COM objects I'm interested in are ClearCase Automation > Library (CAL) > & ClearQuestOLEServer > > I ran makepy on both of these. > selected info from each of the generated files is > =============================== > # From type library 'ccauto.dll' > # On Wed May 16 16:38:12 2007 > """ClearCase Automation Library 6.0""" > makepy_version = '0.4.95' > python_version = 0x20500f0 > :: :: > # This CoClass is known by the name 'ClearCase.Application.1' > class Application(CoClassBaseClass): # A CoClass > =============================== > # From type library 'cqole.dll' > # On Wed May 16 16:37:15 2007 > """""" > makepy_version = '0.4.95' > python_version = 0x20500f0 > :: :: > # This CoClass is known by the name 'CLEARQUEST.SESSION' > class Session(CoClassBaseClass): # A CoClass > =============================== > > Chapter 12 of Marks book, indicates case sensitivity can be a problem > for late bound > Also VARIANT translations may not work so well under late bound. > > I wanted to use early bound to ensure my VARIANTS are correct. But I > cannot get the > CLEARQUEST.SESSION early bound. I successfully got > ClearCase.Application > early bound > > The output of my program indicates that the > ClearCase.Application object > was early bound, but I > could do nothing to get CLEARQUEST.SESSION early bound Sadly some objects behave like this - they provide a typelib, but when you ask the object itself about the type info, it says it has none! win32com is therefore unable to associate the object with the makepy module. The "standard" answer here is to force things. Something like: mod = gencache.EnsureModule('{B805FDF6-BEA8-11D1-B36D-00A0C9851B52}' , 0, 1, 0) cq_session = w32c.Dispatch(r"CLEARQUEST.SESSION") cq_session = mod.Session(cq_session) This should force cq_session to use the makepy generated info. You may even find: mod = gencache.EnsureModule('{B805FDF6-BEA8-11D1-B36D-00A0C9851B52}' , 0, 1, 0) cq_session = mod.Session() works, but I can't recall... Hope this helps, Mark From steve_geo at optusnet.com.au Thu May 17 08:03:22 2007 From: steve_geo at optusnet.com.au (Stephen George) Date: Thu, 17 May 2007 16:03:22 +1000 Subject: [python-win32] Cannot get COM early bound In-Reply-To: <02bb01c7983c$97a8f2c0$1d0a0a0a@enfoldsystems.local> References: <02bb01c7983c$97a8f2c0$1d0a0a0a@enfoldsystems.local> Message-ID: <464BF02A.5080301@optusnet.com.au> Hi Mark, Thanks for the info, I had only just inserted the error handling from the example from your book, and although it was staring me in the face I was not concentrating on that message, I was looking at the late/early binding info. I had missed supplying one argument in that method call, (my fault for not being careful enough) so the string had moved into the int place. This has now highlighted to me, since the arguments to the functions all have default values, being short an argument is not flagged as an error by python, and why I missed it. Lesson learnt: is to be more careful with arguments and types. Thanks again Steve Mark Hammond wrote: >> Hi Mark, >> >> Thanks for the response. >> >> Both those methods you highlighted resulted in the following output >> >> D:\tempSVNPyFiles\clearcase>testcom.py >> CC: > instance at 0x16083224> >> -------------------------------------------------------- >> CQ: >> Traceback (most recent call last): >> File "D:\tempSVNPyFiles\clearcase\testcom.py", line 28, in >> cq_session.UserLogon( 'sgeorge', 'sgeorge', "OSI", "" ); >> File >> "C:\DOCUME~1\SGEORG~1.OSI\LOCALS~1\Temp\gen_py\2.5\B805FDF6-BE >> A8-11D1-B36D-00A0C9851B52x0x1x0.py", >> line 2816, in UserL >> ogon >> , password, database_name, session_type, database_set) >> ValueError: invalid literal for int() with base 10: '' >> > > The function appears to want an int, but you are passing a string. Even > with type info, python does not cooerce string to ints, just like it doesnt > with: > > print "Num is %d" % ('foo',) > > >> The ValueError is the initial problem I had before I got sidetracked >> with EarlyBinding >> >> However I just check with you that >> >> Is correct when getting binding by this method? >> > > Although it looks strange, it is correct, yes. > > Mark > > > From mmarch at gmail.com Thu May 17 15:15:41 2007 From: mmarch at gmail.com (Michael March) Date: Thu, 17 May 2007 06:15:41 -0700 Subject: [python-win32] translating VB into Python... In-Reply-To: <48bc40670705160801j4644ff65q5c5c39dc5a3bbc08@mail.gmail.com> References: <464AAEEB.50502@timgolden.me.uk> <021301c797b2$ada96080$1d0a0a0a@enfoldsystems.local> <48bc40670705160629x127d0897lcafd9eceff9b5df9@mail.gmail.com> <48bc40670705160658r563f8ba5j6b6b29e929ccd818@mail.gmail.com> <464B0ECF.2020702@timgolden.me.uk> <464B1ADD.8070003@trihedral.com> <48bc40670705160801j4644ff65q5c5c39dc5a3bbc08@mail.gmail.com> Message-ID: <48bc40670705170615x5fef04c3o3b7d6d7b106b49a2@mail.gmail.com> I just wanted to follow up and say I completed my app today. Everything worked wonderfully. Thanks to everyone. If anyone needs assistance automating Quality Center with Python, let me know. On 5/16/07, Michael March wrote: > Hurray!!!!!!!! > > >>> mybug=bfact.Item(24) > > >>> mybug.Field("BG_DESCRIPTION") > u'Test Set: Mercury Tours UI\nTest: [1]Welcome Page\nRun: > Run_9-11_11-43-36\nSte > p: Verify Tag Properties\n\nDescription:\n1. Click the "Find Next" > button.\n2. V > erify properties for the tag.\n\nExpected > result:\n WIDTH and HEIGHT properties should be set to numeric values. The ALT > property sh > ould define a text alternative to the graphic.>\n\nActual Result:\nIMG tags > have > no these attributes on all HTML pages of the Mercury Tours site.' > > >>> mybug.SetField("BG_DESCRIPTION", "123") > > >>> mybug.Field("BG_DESCRIPTION") > u'123' > > >>> mybug.Post() > > > On 5/16/07, Graham Bloice wrote: > > Tim Golden wrote: > > > Michael March wrote: > > >> [resend - I think the mailing list ate my last post..] > > > > > > I saw it! But no matter, the web link's useful. I imagine > > > Mark's hitting the sack about now (assuming he's in > > > Australia). It's 3pm here in the UK so I'll try to see > > > if I can spot what's happening, but from a glance at > > > the generated code, it looks like one of those awkward > > > cases where a method is also a property and *also* the > > > default value. I'll try and have a go at it. > > > > > > > Looking at the makepy output isn't this a case where pywin32 has to use > > a method to access an indexed property using a "SetXXX" call. > > > > From the makepy: > > > > class IBug(DispatchBaseClass): > > """Represents a defect.""" > > CLSID = IID('{2AF970F7-6CCC-4DFB-AA78-08F689481F94}') > > coclass_clsid = IID('{AF9180F9-8C16-4824-9EA1-A9010B072B2C}') > > > > # The method Field is actually a property, but must be used as a > method > > to correctly pass the arguments > > def Field(self, FieldName=defaultNamedNotOptArg): > > """The value of the specified field.""" > > return self._ApplyTypes_(0, 2, (12, 0), ((8, 0),), > 'Field', > > None,FieldName) > > > > ... > > > > # The method SetField is actually a property, but must be used as > a > > method to correctly pass the arguments > > def SetField(self, FieldName=defaultNamedNotOptArg, > > arg1=defaultUnnamedArg): > > """The value of the specified field.""" > > return self._oleobj_.InvokeTypes(0, LCID, 4, (24, 0), > ((8, 0), > > (12, 1)),FieldName, arg1) > > > > > > So try using: > > > > mybug.SetField("BG_DESCRIPTION", "123") > > > > -- > > Regards, > > > > Graham Bloice > > > > > -- > > > Michael F. March ----- mmarch at gmail.com > Ph: (415)462-1910 ---- Fax: (602)296-0400 > P.O. Box 2254 ---- Phoenix, AZ 85002-2254 > "Seriously" - HSR > -- Michael F. March ----- mmarch at gmail.com Ph: (415)462-1910 ---- Fax: (602)296-0400 P.O. Box 2254 ---- Phoenix, AZ 85002-2254 "Seriously" - HSR From erich.nakasone at gmail.com Fri May 18 02:44:17 2007 From: erich.nakasone at gmail.com (Erich Nakasone) Date: Thu, 17 May 2007 19:44:17 -0500 Subject: [python-win32] plz help Message-ID: <936fae1a0705171744w5c6b9762g193e55990d4d85ea@mail.gmail.com> hi, i'm from Peru, so my english is really bad, but anyway. I got this code import win32com.client, sys, os gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1") #Configura el directorio de trabajo gp.workspace = "E:/PRACTICANTES/erich/python/NameMatching.mdb" #Lista de features listaFC = gp.ListFeatureClasses("*") #Loop para listar los features listaFC.Reset() fc = listaFC.Next() while fc: if fc == "cp06wFC": print "Trabajamos con " + fc ruta = gp.workspace + "/" + fc #Loop para listar los campos fCampos = gp.ListFields(ruta) fCampo = fCampos.next() fNomField = "MATCHING" fExiste = 0 while fCampo: print fCampo.name + " es tipo " + fCampo.type if fCampo.name == fNomField: print "El campo " + fNomField + " ya fue creado" fExiste = 1 fCampo = fCampos.next() if fExiste == 0: print fExiste gp.AddField(fc, fNomField, "text", "30") #Crea un Search Cursor para este Feature # fFilas = gp.SearchCursor(ruta) fFilas = gp.UpdateCursor(ruta) #Loop para listar los registros fFilas.Reset() fFila = fFilas.Next() while fFila: fUBIGEO = fFila.getvalue("UBIGEO") fNomCP = fFila.getvalue("NOMCP") fVlen = len(fFila.getvalue("NOMCP")) n = 0 m = 0 vNewCode = fNomCP[n] print fVlen while n < fVlen: if fVlen >= 2: if fNomCP[n] == " ": if fNomCP[n+1] == "/": break else: vNewCode = vNewCode + str(m) + fNomCP[n+1] m = -1 n = n + 1 m = m + 1 vNewCode = fUBIGEO + str(n) + vNewCode + str(m) print fNomCP.encode('latin-1') + " = " + vNewCode.encode ('latin-1') fFila.setvalue(fNomField, vNewCode) fFilas.UpdateRow(fFila) fFila = fFilas.Next() else: print "Paso de " + fc fc = listaFC.Next() print "FIN" that run wihtout problems. but when I change of computer the same code apear this Traceback (most recent call last): File "E:\PRACTICANTES\erich\python\python\namematchingV3.py", line 2, in ? gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1") File "C:\Python21\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\Python21\win32com\client\dynamic.py", line 84, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python21\win32com\client\dynamic.py", line 72, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147024770, 'The specified module could not be found.', None, None) I don't know what to do. I apreciate the help that can bring me =) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070517/0677a535/attachment.htm From timr at probo.com Fri May 18 03:14:53 2007 From: timr at probo.com (Tim Roberts) Date: Thu, 17 May 2007 18:14:53 -0700 Subject: [python-win32] plz help In-Reply-To: <936fae1a0705171744w5c6b9762g193e55990d4d85ea@mail.gmail.com> References: <936fae1a0705171744w5c6b9762g193e55990d4d85ea@mail.gmail.com> Message-ID: <464CFE0D.40808@probo.com> Erich Nakasone wrote: > > hi, i'm from Peru, so my english is really bad, but anyway. > > I got this code > > import win32com.client, sys, os > gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1") > > ... > > that run wihtout problems. > > but when I change of computer the same code > > apear this > > Traceback (most recent call last): > File "E:\PRACTICANTES\erich\python\python\namematchingV3.py", line > 2, in ? > gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1") > File "C:\Python21\win32com\client\__init__.py", line 95, in Dispatch > dispatch, userName = > dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) > File "C:\Python21\win32com\client\dynamic.py", line 84, in > _GetGoodDispatchAndUserName > return (_GetGoodDispatch(IDispatch, clsctx), userName) > File "C:\Python21\win32com\client\dynamic.py", line 72, in > _GetGoodDispatch > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, > pythoncom.IID_IDispatch) > com_error: (-2147024770, 'The specified module could not be found.', > None, None) > > I don't know what to do. > This just says that you don't have the ESRI application installed on the other computer. Or, if it is installed, it isn't properly registered. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From jhawk at innovativerobotics.com Fri May 18 08:14:13 2007 From: jhawk at innovativerobotics.com (jhawk at innovativerobotics.com) Date: Fri, 18 May 2007 02:14:13 -0400 Subject: [python-win32] Word Document manipulation (newbie) Message-ID: <18309535.180511179468853857.JavaMail.servlet@perfora> I am trying to manipulate a word doc and realize that there are modules available but to date have been unable to get my paws on them. I have installed python 2.4.4 with pywin32-210.win32-py2.4. I have bought Mark Hammonds book which references such modules wdclass.py and the use of easyword. Could some one point a newbie in the right direction. It would be much appreciated. Thanks From mail at timgolden.me.uk Fri May 18 10:23:22 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 18 May 2007 09:23:22 +0100 Subject: [python-win32] Word Document manipulation (newbie) In-Reply-To: <18309535.180511179468853857.JavaMail.servlet@perfora> References: <18309535.180511179468853857.JavaMail.servlet@perfora> Message-ID: <464D627A.9070100@timgolden.me.uk> jhawk at innovativerobotics.com wrote: > I am trying to manipulate a word doc and realize that there are modules available > but to date have been unable to get my paws on them. I have installed > python 2.4.4 with pywin32-210.win32-py2.4. I have bought Mark Hammonds > book which references such modules wdclass.py and the use of easyword. > Could some one point a newbie in the right direction. > It would be much appreciated. Thanks I'm not aware of any publicly-available modules to ease working with Word. It may be that the modules the book refers to are available from the publisher's site as downloads. It's probably not beyond the wit of man in any case to roll one's own. If you can't lay your hands on useful modules then perhaps come back here with specific questions, and maybe someone can help. TJG From iladyko at odesk.com Fri May 18 10:56:21 2007 From: iladyko at odesk.com (Irene Ladyko) Date: Fri, 18 May 2007 15:56:21 +0700 Subject: [python-win32] embedded python and winsound module Message-ID: <1947791765.20070518155621@odesk.com> Hello, python-win32. I use Python version 2.4.4 under win32. I built python using pcbuild.sln. There is winsound module project in it, so I built it too. After that I can run python.exe interpeter directly and load winsound module in it. All be OK. D:\....>python.exe Python 2.4.4 (#71, May 17 2007, 16:53:33) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> >>>import winsound >>>winsound.PlaySound("SystemExit", winsound.SND_ALIAS) But I am interested in embeded python. I use this interpreter in C++ code (MSVC7.1). And when I load winsound programmatically, the following error appears: "No module named winsound". But such module as 'array' is imported correctly: import array What is wrong. Please, point me on my error. Code: #include #include "Python.h" int main(int /*argc*/, char** /*argv*/) { PyThreadState *m_threadState; // Initialize python Py_NoSiteFlag = 1; Py_Initialize(); // Enable thread support. PyEval_InitThreads(); // Delete default thread state. PyThreadState *l_default = PyThreadState_Get(); Py_EndInterpreter(l_default); // Release global interpreter lock. PyEval_ReleaseLock(); //start python PyEval_AcquireLock(); m_threadState = Py_NewInterpreter(); PyEval_ReleaseThread(m_threadState); //-------Load winsound module----------!!!!!!!!!!!!!!!!!!!!!!!! PyEval_AcquireThread(m_threadState); PyObject *l_module; PyObject *l_dict; PyObject *l_retValue; // we will use __main__ module as our global and local namespace. l_module = PyImport_AddModule("__main__"); if (!l_module) { PyEval_ReleaseThread(m_threadState); return -1; } std::string l_str = "import winsound"; l_dict = PyModule_GetDict(l_module); l_retValue = PyRun_StringFlags( (char *)l_str.c_str(), Py_file_input, l_dict, l_dict, NULL); if (!l_retValue) { //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // Enter into this block!!!!!!!!!!!!!!!!!!! PyEval_ReleaseThread(m_threadState); return -1; } Py_DECREF(l_retValue); PyEval_ReleaseThread(m_threadState); //End PyEval_AcquireThread(m_threadState); Py_EndInterpreter(m_threadState); PyEval_ReleaseLock(); PyEval_AcquireLock(); // Create default interpreter back. Py_NewInterpreter(); Py_Finalize(); return 0; } -- Best Regards, Irene Ladyko, C++ Developer of ISS Art, Ltd., Omsk, Russia. http://issart.com http://issart.com/index/Portfolio/cpp&lang=eng mailto:your at address.com From pc88mxer at gmail.com Fri May 18 18:11:44 2007 From: pc88mxer at gmail.com (E R) Date: Fri, 18 May 2007 11:11:44 -0500 Subject: [python-win32] interacting with Windows Media Player Message-ID: <3a69fa7c0705180911p76d9ed23m6b56da0df0024ff4@mail.gmail.com> Hello, I am trying to write a simple video bookmarking tool with python. It would allow you to keep track of and annotate locations in video files so you can quickly find and jump to them. To do this I just need to solve two technical problems. The first is to instantiate a visible instance of Windows Media Player. The code listed in this posting works: http://mail.python.org/pipermail/python-win32/2005-August/003626.html but WMP doesn't show a user interface. I think I need to put the WMP COM object into a GUI object, but I'm very new to Win32 programming, so any help would be greatly appreciated! The second technical problem is to be able to ask WMP where in the video stream it currently is. And then I need to be able to tell WMP to start playing a file from a certain offset. Does anyone know how to do this? Also, I don't have to use WMP if this can be done easier with another media player. All I need to play are MPEG2 video files. Thanks, ER From niki at vintech.bg Fri May 18 19:14:33 2007 From: niki at vintech.bg (Niki Spahiev) Date: Fri, 18 May 2007 20:14:33 +0300 Subject: [python-win32] interacting with Windows Media Player In-Reply-To: <3a69fa7c0705180911p76d9ed23m6b56da0df0024ff4@mail.gmail.com> References: <3a69fa7c0705180911p76d9ed23m6b56da0df0024ff4@mail.gmail.com> Message-ID: <464DDEF9.6080107@vintech.bg> E R wrote: > Hello, > > I am trying to write a simple video bookmarking tool with python. It > would allow you to keep track of and annotate locations in video files > so you can quickly find and jump to them. > > To do this I just need to solve two technical problems. The first is > to instantiate a visible instance of Windows Media Player. The code > listed in this posting works: > > http://mail.python.org/pipermail/python-win32/2005-August/003626.html > > but WMP doesn't show a user interface. I think I need to put the WMP > COM object into a GUI object, but I'm very new to Win32 programming, > so any help would be greatly appreciated! > > The second technical problem is to be able to ask WMP where in the > video stream it currently is. And then I need to be able to tell WMP > to start playing a file from a certain offset. Does anyone know how to > do this? > > Also, I don't have to use WMP if this can be done easier with another > media player. All I need to play are MPEG2 video files. IIRC there is wxPython based project with same goals. And IIRC its open source. Niki Spahiev From mail at timgolden.me.uk Fri May 18 21:27:31 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 18 May 2007 20:27:31 +0100 Subject: [python-win32] interacting with Windows Media Player In-Reply-To: <3a69fa7c0705180911p76d9ed23m6b56da0df0024ff4@mail.gmail.com> References: <3a69fa7c0705180911p76d9ed23m6b56da0df0024ff4@mail.gmail.com> Message-ID: <464DFE23.2040302@timgolden.me.uk> > Also, I don't have to use WMP if this can be done easier with another > media player. All I need to play are MPEG2 video files. Would have thought it's worth checking out mplayer. TJG From mhammond at skippinet.com.au Sat May 19 01:39:14 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 19 May 2007 09:39:14 +1000 Subject: [python-win32] Word Document manipulation (newbie) In-Reply-To: <18309535.180511179468853857.JavaMail.servlet@perfora> Message-ID: <043101c799a5$bf0c0cc0$1d0a0a0a@enfoldsystems.local> > I am trying to manipulate a word doc and realize that there > are modules available but to date have been unable to get my > paws on them. I have installed python 2.4.4 with > pywin32-210.win32-py2.4. I have bought Mark Hammonds book > which references such modules wdclass.py and the use of > easyword. Could some one point a newbie in the right > direction. It would be much appreciated. Thanks You can find the samples from the book at http://starship.python.net/crew/mhammond/ppw32/index.html Cheers, Mark From pc88mxer at gmail.com Sat May 19 14:17:44 2007 From: pc88mxer at gmail.com (E R) Date: Sat, 19 May 2007 07:17:44 -0500 Subject: [python-win32] interacting with Windows Media Player In-Reply-To: <3a69fa7c0705180911p76d9ed23m6b56da0df0024ff4@mail.gmail.com> References: <3a69fa7c0705180911p76d9ed23m6b56da0df0024ff4@mail.gmail.com> Message-ID: <3a69fa7c0705190517r24259f1ak6706d7bce4900a06@mail.gmail.com> Okay - I found the MediaCtrl in wxPython which looks like it has everything I need. It provides a generic media playback interface can be configured to use WMP, Quicktime or Directshow. I'd still like to learn how to interact with ActiveX and COM objects, but that can now wait for another day. Regards, ER On 5/18/07, E R wrote: > Hello, > > I am trying to write a simple video bookmarking tool with python. It > would allow you to keep track of and annotate locations in video files > so you can quickly find and jump to them. > > To do this I just need to solve two technical problems. The first is > to instantiate a visible instance of Windows Media Player. The code > listed in this posting works: > > http://mail.python.org/pipermail/python-win32/2005-August/003626.html > > but WMP doesn't show a user interface. I think I need to put the WMP > COM object into a GUI object, but I'm very new to Win32 programming, > so any help would be greatly appreciated! > > The second technical problem is to be able to ask WMP where in the > video stream it currently is. And then I need to be able to tell WMP > to start playing a file from a certain offset. Does anyone know how to > do this? > > Also, I don't have to use WMP if this can be done easier with another > media player. All I need to play are MPEG2 video files. > > Thanks, > > ER > From teekaysoh at gmail.com Mon May 21 19:14:43 2007 From: teekaysoh at gmail.com (TK Soh) Date: Mon, 21 May 2007 12:14:43 -0500 Subject: [python-win32] [Python-Win32] error on shell.SHChangeNotify Message-ID: <58b84f8e0705211014g7d42bbf8t8efcd02920e29e39@mail.gmail.com> I am trying to use SHChangeNotify to refresh the icon on the explorer windows in the following script, but got an error: ---------------------------------- import sys from win32com.shell import shell, shellcon def notify(f): shell.SHChangeNotify(shellcon.SHCNE_UPDATEITEM, shellcon.SHCNF_PATH | shellcon.SHCNF_FLUSHNOWAIT, f, None) for f in sys.argv[1:]: notify(f) ---------------------------------- Traceback (most recent call last): File "notify.py", line 11, in ? notify(f) File "notify.py", line 8, in notify None) TypeError: Only sequences (but not strings) are valid ITEMIDLIST objects (got str). Does anyone has any idea what I did wrong? I can't find much info on google. Thanks. From rwupole at msn.com Tue May 22 08:59:10 2007 From: rwupole at msn.com (Roger Upole) Date: Tue, 22 May 2007 02:59:10 -0400 Subject: [python-win32] error on shell.SHChangeNotify Message-ID: <000701c79c3e$b5c39e30$0100a8c0@rupole> TK Soh wrote: >I am trying to use SHChangeNotify to refresh the icon on the explorer > windows in the following script, but got an error: > ---------------------------------- > import sys > from win32com.shell import shell, shellcon > > def notify(f): > shell.SHChangeNotify(shellcon.SHCNE_UPDATEITEM, > shellcon.SHCNF_PATH | shellcon.SHCNF_FLUSHNOWAIT, > f, > None) > > for f in sys.argv[1:]: > notify(f) > ---------------------------------- > > Traceback (most recent call last): > File "notify.py", line 11, in ? > notify(f) > File "notify.py", line 8, in notify > None) > TypeError: Only sequences (but not strings) are valid ITEMIDLIST > objects (got str). > > > Does anyone has any idea what I did wrong? I can't find much info on > google. Thanks Try a newer build of pywin32. There was a bug in some older versions regarding how the function determined whether it needed a file path or an id list. Roger From teekaysoh at gmail.com Tue May 22 16:12:23 2007 From: teekaysoh at gmail.com (TK Soh) Date: Tue, 22 May 2007 09:12:23 -0500 Subject: [python-win32] error on shell.SHChangeNotify In-Reply-To: <000701c79c3e$b5c39e30$0100a8c0@rupole> References: <000701c79c3e$b5c39e30$0100a8c0@rupole> Message-ID: <58b84f8e0705220712s30cdadc1j1a9af6c4132115cf@mail.gmail.com> On 5/22/07, Roger Upole wrote: > Try a newer build of pywin32. There was a bug in some older versions > regarding how the function determined whether it needed a file path > or an id list. Thanks. Actually I'm using the win32 extension bundled with ActivePython, so I'd like to stick it when ever possible. Right now I just use pass the SHCNF_IDLIST flag and use id list instead. From zhaodapu at gmail.com Wed May 23 12:59:54 2007 From: zhaodapu at gmail.com (Zhao Dapu) Date: Wed, 23 May 2007 18:59:54 +0800 Subject: [python-win32] How to Impletments COM Interface: IInternetProtocol Message-ID: <9ead098f0705230359v3fde6acftf2467f5a9efe8e29@mail.gmail.com> Hi, all I want to implements an Asynchronous Pluggable Protocol handler, which can handle a custom protocol like "http" or "mk". Follow the instruction of MSDN, I must Implements at least 3 interfaces: IInternetProtocol, IInternetProtocolRoot and IClassFactory. But I'm not clear how to do this and didn't find any clue in the win32com documents. Shoule I use makepy first to generate the a wrap py-file? But I don't know the name of the typelib. I'm a newbie in COM. I also find any thing about "IInternetProtocol" in my registry. Below is some code I thought it should be. Without the _com_interfaces_ lines, it works( i.e. I can create the COM object and call the methods). But now it will generate many errors. Any clue is appreciated! import win32com class MyProtocol: _com_interfaces_ = ['IInternetProtocol', 'IInternetProtocolRoot', 'IClassFactory',] _com_interfaces_ = ['IDispatch'] _reg_clsid_ = '{F662AB76-9BE9-440F-9F33-42750C86EA2C}' _reg_progid_ = 'MyProtocol' _public_methods_ = ['Read', 'Seek'] def __init__(self): print "create a com obj" # IInternetProtocol def Read(self, pv, cb, pcbread): print "Method called: Read 1" def Seek(self, dlibMove, dwOrigin, plibNewPosition): print "Method called: Seek" # IInternetProtocolRoot def Start( self, szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved): print "Method called: Start" def Abort(hrReason, dwOptions): print "Method called: Abort" Dapu From teekaysoh at gmail.com Wed May 23 16:03:19 2007 From: teekaysoh at gmail.com (TK Soh) Date: Wed, 23 May 2007 09:03:19 -0500 Subject: [python-win32] error on shell.SHChangeNotify In-Reply-To: <000701c79c3e$b5c39e30$0100a8c0@rupole> References: <000701c79c3e$b5c39e30$0100a8c0@rupole> Message-ID: <58b84f8e0705230703y425615d0q8fd041d73a4f9d3@mail.gmail.com> On 5/22/07, Roger Upole wrote: > Try a newer build of pywin32. There was a bug in some older versions > regarding how the function determined whether it needed a file path > or an id list. BTW, any idea which versions of pywin32 have the bug, or which version has the fix? Just want to make a note in my code. Thanks. From zhaodapu at gmail.com Wed May 23 21:49:17 2007 From: zhaodapu at gmail.com (Zhao Dapu) Date: Thu, 24 May 2007 03:49:17 +0800 Subject: [python-win32] How to Impletments COM Interface: IInternetProtocol In-Reply-To: <465427ED.3000809@optusnet.com.au> References: <9ead098f0705230359v3fde6acftf2467f5a9efe8e29@mail.gmail.com> <465427ED.3000809@optusnet.com.au> Message-ID: <9ead098f0705231249n504b812dm699af120ddd4b4a@mail.gmail.com> Hi, Steve, Thank you for your information. I've read chapter 12 in detail, some concepts are clear. But I still don't get it. Maybe I miss something. 1. I need to make a COM server. In the book, it just told how to implements user-defined interfaces. How do I implement some system interfaces, like IInternetProtocol. I supposed if there is a wrap class of the interfaces, I can just inherit the class. The code maybe like this: class MyProtocol(PyIInternetProtocol, PyIClassFactory): ...... or like this: class MyProtocol: _com_interfaces_ = ['IInternetProtocol', 'IClassFactory'] ...... But these are not the real thing. There are no such wrap class PyIInternetProtocol. 2. Makepy can create wrap classed of a typelib. The generated wrap class can be used in a COM client (for early-bound and constants). Do I need to use it when I create a sever-side COM object? As question 1 said , generating wrap class and inherit it? Even the answer is Yes, I still don't know which typelib it is. I didn't find it in the typelib list. How can I know which typelib defines these interfaces? 3. This question is not about python or PythonCOM. In my opinion, every interface should have a entry int the registry. But I don't find any information about IInternetProtocol. I found the IID of these interfaces by google. They are not in my registry, except the last one (IInternetSecurityMananer). They have similar IIDs and all implemented in urlmon.dll. It puzzles me. IInternetProtocol "{79EAC9E4-BAF9-11CE-8C82-00AA004BA90B}" IInternetProtocolInfo "{79EAC9EC-BAF9-11CE-8C82-00AA004BA90B}" IInternetProtocolRoot "{79EAC9E3-BAF9-11CE-8C82-00AA004BA90B}" IInternetProtocolSink "{79EAC9E5-BAF9-11CE-8C82-00AA004BA90B}" IInternetSecurityManager "{79EAC9EE-BAF9-11CE-8C82-00AA004BA90B}" If the questions are stupid, please just let me know why. Dapu 2007/5/23, steve george : > Did you read Chapter 12 > http://www.oreilly.com/catalog/pythonwin32/chapter/ch12.html > > Zhao Dapu wrote: > > Hi, all > > > > I want to implements an Asynchronous Pluggable Protocol handler, which > > can handle a custom protocol like "http" or "mk". Follow the > > instruction of MSDN, I must Implements at least 3 interfaces: > > IInternetProtocol, IInternetProtocolRoot and IClassFactory. But I'm > > not clear how to do this and didn't find any clue in the win32com > > documents. > > > > Shoule I use makepy first to generate the a wrap py-file? But I don't > > know the name of the typelib. I'm a newbie in COM. I also find any > > thing about "IInternetProtocol" in my registry. > > > > Below is some code I thought it should be. Without the > > _com_interfaces_ lines, it works( i.e. I can create the COM object and > > call the methods). But now it will generate many errors. > > > > Any clue is appreciated! > > > > import win32com > > class MyProtocol: > > _com_interfaces_ = ['IInternetProtocol', > > 'IInternetProtocolRoot', > > 'IClassFactory',] > > _com_interfaces_ = ['IDispatch'] > > > > _reg_clsid_ = '{F662AB76-9BE9-440F-9F33-42750C86EA2C}' > > _reg_progid_ = 'MyProtocol' > > _public_methods_ = ['Read', 'Seek'] > > > > def __init__(self): > > print "create a com obj" > > > > # IInternetProtocol > > def Read(self, pv, cb, pcbread): > > print "Method called: Read 1" > > def Seek(self, dlibMove, dwOrigin, plibNewPosition): > > print "Method called: Seek" > > > > # IInternetProtocolRoot > > def Start( self, szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved): > > print "Method called: Start" > > def Abort(hrReason, dwOptions): > > print "Method called: Abort" > > > > > > Dapu > > _______________________________________________ > > Python-win32 mailing list > > Python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > > From steve_geo at optusnet.com.au Thu May 24 01:15:14 2007 From: steve_geo at optusnet.com.au (Stephen George) Date: Thu, 24 May 2007 09:15:14 +1000 Subject: [python-win32] Python Programmming on win32 - the book Message-ID: <4654CB02.80800@optusnet.com.au> Hi, I was considering buying Python Programming On Win32 which was written in 2000. I hate to buy out of date books. I'd like to ask if the contents of this book are still relevant in 2007 and recent releases of Python. Will this book continue to be relevant for a number of years to come? Are there any plans for a 2nd Edition in the next 6 months or so? Steve From mhammond at skippinet.com.au Thu May 24 01:18:37 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 24 May 2007 09:18:37 +1000 Subject: [python-win32] error on shell.SHChangeNotify In-Reply-To: <58b84f8e0705230703y425615d0q8fd041d73a4f9d3@mail.gmail.com> Message-ID: <032701c79d90$b1c1fb80$1f0a0a0a@enfoldsystems.local> > On 5/22/07, Roger Upole wrote: > > Try a newer build of pywin32. There was a bug in some > older versions > > regarding how the function determined whether it needed a file path > > or an id list. > > BTW, any idea which versions of pywin32 have the bug, or which version > has the fix? Just want to make a note in my code. Thanks. It was in the following revision of shell.cpp: revision 1.42 date: 2006/01/12 15:20:31; author: rupole; state: Exp; lines: +37 -32 Allow SHFileOperation to accept a string containing multiple file names, and some doc improvements (thanks Roger!) which theoretically first appeared in b208. Cheers, Mark From mhammond at skippinet.com.au Thu May 24 01:21:27 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 24 May 2007 09:21:27 +1000 Subject: [python-win32] Python Programmming on win32 - the book In-Reply-To: <4654CB02.80800@optusnet.com.au> Message-ID: <032801c79d91$16f915b0$1f0a0a0a@enfoldsystems.local> > Hi, > > I was considering buying > Python Programming On Win32 which was written in 2000. > > I hate to buy out of date books. > > I'd like to ask if the contents of this book are still > relevant in 2007 > and recent releases of Python. Yep - some things have changed, but the concepts are all still good. > Will this book continue to be relevant for a number of years to come? > > Are there any plans for a 2nd Edition in the next 6 months or so? I'm afraid that I've been messing poor John around for many months now. I'd like to think a new version would be on the shelves in 12 months time (but you could probably find me saying something similar 12 months ago...) Mark From mhammond at skippinet.com.au Thu May 24 01:29:16 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 24 May 2007 09:29:16 +1000 Subject: [python-win32] How to Impletments COM Interface:IInternetProtocol In-Reply-To: <9ead098f0705231249n504b812dm699af120ddd4b4a@mail.gmail.com> Message-ID: <032901c79d92$2e714630$1f0a0a0a@enfoldsystems.local> > 1. I need to make a COM server. In the book, it just told how to > implements user-defined interfaces. How do I implement some system > interfaces, like IInternetProtocol. I supposed if there is a wrap > class of the interfaces, I can just inherit the class. The code maybe > like this: > > class MyProtocol(PyIInternetProtocol, PyIClassFactory): > ...... > > or like this: > > class MyProtocol: > _com_interfaces_ = ['IInternetProtocol', 'IClassFactory'] > ...... > > But these are not the real thing. There are no such wrap class > PyIInternetProtocol. What you want is the win32com.internet module. >>> from win32com.internet import internet >>> internet.IID_IInternetProtocol IID('{79EAC9E4-BAF9-11CE-8C82-00AA004BA90B}') >>> So your code could look something like: class MyProtocol: _com_interfaces_ = [internet.IID_IInternetProtocol] ...... > 2. Makepy can create wrap classed of a typelib. The generated wrap > class can be used in a COM client (for early-bound and constants). Do > I need to use it when I create a sever-side COM object? As question 1 > said , generating wrap class and inherit it? > > Even the answer is Yes, I still don't know which typelib it is. I > didn't find it in the typelib list. > How can I know which typelib defines these interfaces? You would need to do that if the interface you were trying to support existed in a typelib. As the internet module handles this, you can ignore makepy. > 3. This question is not about python or PythonCOM. In my opinion, > every interface should have a entry int the registry. Maybe I misunderstand you, but if you are stating your opinion on what should have been done, I'm afraid that will not change reality. If you meant to say that it is your *understanding* that every interface gets a registry entry, then I'm afraid you are wrong. Note that an interface is *not* a COM object (but even then, not all COM objects are in the registry either - only ones that are CoCreatable are). > But I don't find > any information about IInternetProtocol. I found the IID of these > interfaces by google. They are not in my registry, except the last one > (IInternetSecurityMananer). They have similar IIDs and all implemented > in urlmon.dll. It puzzles me. There is no requirement that interfaces be listed in the registry. If you want automatic marshalling of interfaces then you probably do need some registration for them, but in general, interfaces do not need to be in the registry to work. A .IDL file is usually what you are looking for. Hope this helps, Mark From teekaysoh at gmail.com Thu May 24 04:22:14 2007 From: teekaysoh at gmail.com (TK Soh) Date: Wed, 23 May 2007 21:22:14 -0500 Subject: [python-win32] HookMessage fails In-Reply-To: <018d01c79757$796c5440$1d0a0a0a@enfoldsystems.local> References: <464A41D6.2070906@probo.com> <018d01c79757$796c5440$1d0a0a0a@enfoldsystems.local> Message-ID: <58b84f8e0705231922l2ad4878lec028b95d0f87175@mail.gmail.com> On 5/15/07, Mark Hammond wrote: > > > This is the magic of MFC - if no parent is specified, the > > "main window" for > > > the application is automatically used. > > > > > > > Isn't that the issue, then? He's writing a dialog to plug in to > > Explorer, and every time he runs, there's a different "main window". > > MFC gets its concept of a "main window" from its global > > state, so unless > > something in the process tells MFC to refresh its global > > state, it will > > have stale information. > > Quite possibly - I'm afraid I can't recall the exact semantics for dialog > based apps, but I suspect that a number of things in MFC will end up getting > upset if the nominated main window dies but the application does not - but > win32ui.GetApp().SetMainFrame() can be used to change this value > dynamically. I'm afraid I haven't found the time to read the other messages > in enough detail to offer more concrete suggestions (other than to possibly > consider using win32gui to avoid future MFCisms from biting) Hi Mark, Not sure it's helps to clarify my situation, but the dialog in question is actually a simple subclass of pywin.mfc.dialog, with a resize handler hooked to WM_SIZE with HookMessage(). This dialog forms part of the shell extension registered to Explorer, which does work similar to TortoiseSVN or TortoiseCVS. The dialog is then called from the context menu in the Explorer windows by a simple call of something like this: dlg = MyResizableDialog() dlg.CreateWindow() Everything in the dialog works fine, except the ability to resize is somehow lost when the dialog is opened from subsequent Explorer windows. In any case, if you think it helps, I can email you the code. It'd be great if you can suggest anything I can try to debug this.Thanks. From mhammond at skippinet.com.au Thu May 24 05:03:41 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 24 May 2007 13:03:41 +1000 Subject: [python-win32] HookMessage fails In-Reply-To: <58b84f8e0705231922l2ad4878lec028b95d0f87175@mail.gmail.com> Message-ID: <034401c79db0$22e5f810$1f0a0a0a@enfoldsystems.local> I think the problem is likely related to the "main frame" issue quoted below. I suggest you debug what the app's "main frame" is at any given point in time, and confirming the value is still appropriate. Mark > On 5/15/07, Mark Hammond wrote: > > > > This is the magic of MFC - if no parent is specified, the > > > "main window" for > > > > the application is automatically used. > > > > > > > > > > Isn't that the issue, then? He's writing a dialog to plug in to > > > Explorer, and every time he runs, there's a different > "main window". > > > MFC gets its concept of a "main window" from its global > > > state, so unless > > > something in the process tells MFC to refresh its global > > > state, it will > > > have stale information. > > > > Quite possibly - I'm afraid I can't recall the exact > semantics for dialog > > based apps, but I suspect that a number of things in MFC > will end up getting > > upset if the nominated main window dies but the application > does not - but > > win32ui.GetApp().SetMainFrame() can be used to change this value > > dynamically. I'm afraid I haven't found the time to read > the other messages > > in enough detail to offer more concrete suggestions (other > than to possibly > > consider using win32gui to avoid future MFCisms from biting) > > Hi Mark, > > Not sure it's helps to clarify my situation, but the dialog in > question is actually a simple subclass of pywin.mfc.dialog, with a > resize handler hooked to WM_SIZE with HookMessage(). > > This dialog forms part of the shell extension registered to Explorer, > which does work similar to TortoiseSVN or TortoiseCVS. The dialog is > then called from the context menu in the Explorer windows by a simple > call of something like this: > > dlg = MyResizableDialog() > dlg.CreateWindow() > > Everything in the dialog works fine, except the ability to resize is > somehow lost when the dialog is opened from subsequent Explorer > windows. > > In any case, if you think it helps, I can email you the code. It'd be > great if you can suggest anything I can try to debug this.Thanks. > From teekaysoh at gmail.com Thu May 24 05:13:13 2007 From: teekaysoh at gmail.com (TK Soh) Date: Wed, 23 May 2007 22:13:13 -0500 Subject: [python-win32] HookMessage fails In-Reply-To: <034401c79db0$22e5f810$1f0a0a0a@enfoldsystems.local> References: <58b84f8e0705231922l2ad4878lec028b95d0f87175@mail.gmail.com> <034401c79db0$22e5f810$1f0a0a0a@enfoldsystems.local> Message-ID: <58b84f8e0705232013t7c8326b5u12dcbf68dd44e100@mail.gmail.com> On 5/23/07, Mark Hammond wrote: > I think the problem is likely related to the "main frame" issue quoted below. I suggest you debug what the app's "main frame" is at any given point in time, and confirming the value is still appropriate. Being new to pywin32, I'm not sure I completely understand this. Though I'm going take a good look at it. Appreciate the advice. From teekaysoh at gmail.com Thu May 24 05:25:44 2007 From: teekaysoh at gmail.com (TK Soh) Date: Wed, 23 May 2007 22:25:44 -0500 Subject: [python-win32] Python Programmming on win32 - the book In-Reply-To: <032801c79d91$16f915b0$1f0a0a0a@enfoldsystems.local> References: <4654CB02.80800@optusnet.com.au> <032801c79d91$16f915b0$1f0a0a0a@enfoldsystems.local> Message-ID: <58b84f8e0705232025o229a7fa0s7a177bebe6c3d518@mail.gmail.com> On 5/23/07, Mark Hammond wrote: > > Will this book continue to be relevant for a number of years to come? > > > > Are there any plans for a 2nd Edition in the next 6 months or so? > > I'm afraid that I've been messing poor John around for many months now. I'd > like to think a new version would be on the shelves in 12 months time (but > you could probably find me saying something similar 12 months ago...) I was about to ask the same question. Guess I know the answer now. Let's how quick Amazon can deliver the book to my door ;-) From it at crummock.com Thu May 24 11:32:05 2007 From: it at crummock.com (Ross McKerchar) Date: Thu, 24 May 2007 10:32:05 +0100 Subject: [python-win32] extending com objects In-Reply-To: <39238.81.171.156.66.1166451212.squirrel@81.171.156.66> References: <458699B0.8000801@crummock.com> <39238.81.171.156.66.1166451212.squirrel@81.171.156.66> Message-ID: <46555B95.3050906@crummock.com> A few months ago I posted asking for some advice on ways to extend classes provided by com objects. Primarily I was keen to make a com library that I work with a lot (Notes/Domino if anyone's interested) nicer and more pythonic to use. I've spent a good few hours bashing away and have found two ways which appear to work with my simplistic test suite. However I'm not particularly comfortable with either of them (the black magic I'm using is all a bit new to me). Consequently if anyone has time to have a look at my solutions I'd be very grateful. Attempt #1 (code at http://www2.crummock.com/comwrapper.py): Based on what Tim Golden called a "Delegation model", involved holding an internal copy of my com class and by implementing getattr/setattr calling the com object when necessary. This turned out a fair bit more complicated than I originally expected as lots of the com objects methods returned other com objects from the same library. I wanted these returned com objects to also be automatically wrapped in my extension classes to save having to constantly wrap in my client code. To do this I ended up with some very convoluted code that intercepted all my com method calls to see if they returned a com object for which I had a corresponding wrapper class and if so, wrap it. Of course I then had to check all tuples returned to see if they also contained candidates for wrapping. I got this working (well enough that it passed my far-from-comprehensive test-suite) but I wasn't convinced by it: the complexity of my wrapping system is bound to contain some subtle bugs and it also introduced a significant performance overhead (about 15% runtime overhead from some rough tests). Attempt #2: This very simple, alternative method then occured to me: #My custom classes class IDocument: ... class IDatabase: ... class IDocumentCollection: ... from win32com.client.gencache import GetModuleForProgID module = GetModuleForProgID('Lotus.NotesSession') implementedChildClasses = (IDocument,IDatabase,IDocumentCollection) for klass in implementedChildClasses: #find parent class of same name parentclass = getattr(module,klass.__name__) parentclass.__dict__.update(klass.__dict__) I just put this code at the bottom of my module and it automagically adds all my methods & attributes from classes listed in "implementedChildClasses" to the com class (at the expense of needing to run makepy on the com library, of course). The beauty of this is that I dont have to worry about wrapping the results of any functions as I'm always dealing with the real com class, just with some extra methods added. It is also a more efficient - a small overhead when loading the module but a lot quicker when using it. Unfortunately, it does feel like a big hack and I'm not convinced it's a sensible thing to do? So, I dont actually have any real problems as such I'm just looking for advice/comments from anyone who is more familiar with all these magical techniques. -ross From teekaysoh at gmail.com Thu May 24 15:42:34 2007 From: teekaysoh at gmail.com (TK Soh) Date: Thu, 24 May 2007 08:42:34 -0500 Subject: [python-win32] HookMessage fails In-Reply-To: <034401c79db0$22e5f810$1f0a0a0a@enfoldsystems.local> References: <58b84f8e0705231922l2ad4878lec028b95d0f87175@mail.gmail.com> <034401c79db0$22e5f810$1f0a0a0a@enfoldsystems.local> Message-ID: <58b84f8e0705240642v24077e16h76bf0996060ca056@mail.gmail.com> On 5/23/07, Mark Hammond wrote: > I think the problem is likely related to the "main frame" issue quoted below. > I suggest you debug what the app's "main frame" is at any given point in > time, and confirming the value is still appropriate. I tried putting this statement in the context menu before calling the dialog, as well as inside OnInitDialog() of the custom dialog, but both generate the same errors: print "mainframe = ", win32ui.GetMainFrame() win32ui: The frame does not exist I wonder this could be caused by the fact the my code isn't really an app, but simply a shell extension. Anything else I should try? From mhammond at skippinet.com.au Thu May 24 16:20:13 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 25 May 2007 00:20:13 +1000 Subject: [python-win32] HookMessage fails In-Reply-To: <58b84f8e0705240642v24077e16h76bf0996060ca056@mail.gmail.com> Message-ID: <001101c79e0e$a548c950$1f0a0a0a@enfoldsystems.local> > On 5/23/07, Mark Hammond wrote: > > I think the problem is likely related to the "main frame" > issue quoted below. > > I suggest you debug what the app's "main frame" is at any > given point in > > time, and confirming the value is still appropriate. > > I tried putting this statement in the context menu before calling the > dialog, as well as inside OnInitDialog() of the custom dialog, but > both generate the same errors: > > print "mainframe = ", win32ui.GetMainFrame() > > win32ui: The frame does not exist > > I wonder this could be caused by the fact the my code isn't really an > app, but simply a shell extension. Anything else I should try? I hate to say it, but if you really are a "shell extension", you really should be using win32com.shell and win32gui. win32com\shell\demos might give you some inspiration. On the plus side, this is stuff I'm still regularly involved in, so my ability to offer real advice remains high (and actually higher than win32ui). I had a similar conversation today, where I effectively declared win32ui 'dead' - more because it is dead in the Windows development world than because it is dead in pywin32. On the plus side, I just today got pythonwin working in an x64 environment (thanks to Steve Yin for contributing the bulk of that) Cheers, Mark From mhammond at skippinet.com.au Thu May 24 16:58:17 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 25 May 2007 00:58:17 +1000 Subject: [python-win32] AMD64 support In-Reply-To: Message-ID: <001e01c79e13$f6b12440$1f0a0a0a@enfoldsystems.local> Some time ago, Sidnei writes: > Sent: Friday, 22 December 2006 11:24 AM > To: python-win32 at python.org > Subject: [python-win32] AMD64 support > > > Hi there, > > I've spent some time today experimenting with building pywin32 for > AMD64. That is, mostly the Py_ssize_t changes from PEP 353 and > whatever else the compiler complained about. Thanks Sid - I've merged this branch into the trunk, along with a number of changes I made and those from Steve Yin. This work, along with the excellent ongoing x64 work by Roger Upole on the trunk means that I'm happy to declare that branch "dead", and that given enough magic, an x64 build from the trunk is now amazingly functional! Thanks guys, Mark From mail at timgolden.me.uk Thu May 24 22:01:09 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 24 May 2007 21:01:09 +0100 Subject: [python-win32] extending com objects In-Reply-To: <46555B95.3050906@crummock.com> References: <458699B0.8000801@crummock.com> <39238.81.171.156.66.1166451212.squirrel@81.171.156.66> <46555B95.3050906@crummock.com> Message-ID: <4655EF05.7040809@timgolden.me.uk> Ross McKerchar wrote: > I've spent a good few hours bashing away and have found two ways which > appear to work with my simplistic test suite. However I'm not > particularly comfortable with either of them (the black magic I'm using > is all a bit new to me). Consequently if anyone has time to have a look > at my solutions I'd be very grateful. > > Based on what Tim Golden called a "Delegation model", involved holding > an internal copy of my com class and by implementing getattr/setattr > calling the com object when necessary. This turned out a fair bit more > complicated than I originally expected as lots of the com objects > methods returned other com objects from the same library. I wanted these > returned com objects to also be automatically wrapped in my extension > classes to save having to constantly wrap in my client code. This is exactly the problem I have with things like active_directory and WMI. In the case of the latter you're slightly better off because the thing allows for a certain amount of introspection. With the former, I've just bitten the bullet and explictly wrapped the most popular classes (User, Group, OU etc.) But I agree: it's something of a pain. > ... it also introduced a significant performance overhead > (about 15% runtime overhead from some rough tests). Yes, this doesn't bother me directly, but I was contacted by someone who wanted to do real-time monitoring with WMI where it starts to matter, so I did some work with him to speed things up. > Attempt #2: > > This very simple, alternative method then occured to me: > > #My custom classes > class IDocument: ... > class IDatabase: ... > class IDocumentCollection: ... > > from win32com.client.gencache import GetModuleForProgID > module = GetModuleForProgID('Lotus.NotesSession') > implementedChildClasses = (IDocument,IDatabase,IDocumentCollection) > for klass in implementedChildClasses: > #find parent class of same name > parentclass = getattr(module,klass.__name__) > parentclass.__dict__.update(klass.__dict__) This -- just in case you haven't come across the expression -- is called monkey-patching. It's a slightly general-purpose example of it, but it's something which is usefully easy to do in Python. (Consequently, it's easy to abuse but...) Frankly, I never even thought of doing it. You may already have covered this, but it does have one or corner-cases you might want to consider. If one of your methods needs to completely cover one of the original ones *and* to call the original one as well (say to get the data you're going to wrap) then you have to do something a bit smarter than the straight __dict__.update you're doing there. Not very much harder, but you'd have to do it. > The beauty of this is that I > dont have to worry about wrapping the results of any functions as I'm > always dealing with the real com class, just with some extra methods > added. Presumably, then, if the original COM class exposed, say, a .GetGroups method which returned a list of groups, each of which you wanted to wrap, in this implementation, you'd add a .MyGetGroups method which called the original and wrapped the result? This is the sort of thing I was averting to above. You *could* rename (on the fly) .GetGroups to ._GetGroups and add your own .GetGroups which called ._GetGroups under the covers etc. This is obviously only important if you're trying to present an API faithful to a documented original. If you're simply rolling your own, then you can do what you like. I think what you've done is fine, and I'll certainly look into it for my own stuff, not least because, as you point out, it gives a speed advantage. Others may point out hidden flaws which I've missed, and I'll be glad to hear them, but if it works for you... :) TJG From pc88mxer at gmail.com Thu May 24 22:14:58 2007 From: pc88mxer at gmail.com (E R) Date: Thu, 24 May 2007 15:14:58 -0500 Subject: [python-win32] interacting with Windows Media Player In-Reply-To: <464DDEF9.6080107@vintech.bg> References: <3a69fa7c0705180911p76d9ed23m6b56da0df0024ff4@mail.gmail.com> <464DDEF9.6080107@vintech.bg> Message-ID: <3a69fa7c0705241314vb1b308fr59f66e8b9aed3dda@mail.gmail.com> Is this what you were thinking of? http://liris.cnrs.fr/advene/ I just happened to stumble across it. It uses VLC which looks like it will work well for what I want to do. Now I just have to build the python MediaCtrl binding. ER On 5/18/07, Niki Spahiev wrote: > IIRC there is wxPython based project with same goals. And IIRC its open > source. > > Niki Spahiev > From f.guerrieri at gmail.com Fri May 25 11:37:27 2007 From: f.guerrieri at gmail.com (Francesco Guerrieri) Date: Fri, 25 May 2007 11:37:27 +0200 Subject: [python-win32] DCOM Message-ID: <79b79e730705250237g6312b08ex3ecbab15f0e129ba@mail.gmail.com> Hello :-) I've got another newbie question. I'm trying to use DCOM. If I'm right, I have to register my application on both the client and the server, then set up the correct access/launch rights. It's easier said than done, though: in fact I continue getting runtime errors, namely 430 (automation error) and 429 (ActiveX can't create object). I've searched the web and found that it is rather common (and rather Python-unrelated) to get these errors, but didn't find any clear solution. I think that the problem has to do with the way I'm registering the object. I have tried to set _reg_clsctx_ = pythoncom.CLSCTX_Remote_Server on the server side and CLSCTX_Local_Server on the client side, but it doesn't work (although, by trying the various combinations, I'm able to change the error that I get from runtime error 429 to 430 and back...). Do you have any suggestions? thanks in advance :-) Francesco From it at crummock.com Fri May 25 11:38:41 2007 From: it at crummock.com (Ross McKerchar) Date: Fri, 25 May 2007 10:38:41 +0100 Subject: [python-win32] extending com objects In-Reply-To: <4655EF05.7040809@timgolden.me.uk> References: <458699B0.8000801@crummock.com> <39238.81.171.156.66.1166451212.squirrel@81.171.156.66> <46555B95.3050906@crummock.com> <4655EF05.7040809@timgolden.me.uk> Message-ID: <4656AEA1.4060302@crummock.com> Tim Golden wrote: > This -- just in case you haven't come across the expression -- > is called monkey-patching. It's a slightly general-purpose > example of it, but it's something which is usefully easy > to do in Python. (Consequently, it's easy to abuse but...) Ah right - nice to know my dodgy hack is a member of a well known family :) > Frankly, I never even thought of doing it. You may already > have covered this, but it does have one or corner-cases > you might want to consider. If one of your methods needs > to completely cover one of the original ones *and* to call > the original one as well (say to get the data you're going > to wrap) then you have to do something a bit smarter than > the straight __dict__.update you're doing there. Not very > much harder, but you'd have to do it. Yep - currently I'm just using it to add some basic convenience functions (particularly __iter__, __getitem__, and the likes) so it's not an issue. I suppose a slightly less naive technique would rename conflicts first. > > The beauty of this is that I >> dont have to worry about wrapping the results of any functions as I'm >> always dealing with the real com class, just with some extra methods >> added. > > Presumably, then, if the original COM class exposed, > say, a .GetGroups method which returned a list of > groups, each of which you wanted to wrap, in this > implementation, you'd add a .MyGetGroups method which > called the original and wrapped the result? It's simpler than that: as long as you've monkey-patched the original COM groups class, the groups returned by the GetGroups method will already have your methods: no need to wrap. Of course this presumes it's easy to find the Group class: my current implementation assumes everything is in the same module, hence the #find parent class of same name parentclass = getattr(com_genpy_module,klass.__name__) parentclass.__dict__.update(klass.__dict__) If your com library returned com classes from another library (is that even possible?) and hence used another genpy module then I suppose you'd have more problems... > Others may point out hidden flaws which I've missed, > and I'll be glad to hear them, but if it works for > you... :) I've already come across some minor problems (not currently affecting me too much but could become major headaches), mainly to do with existing magic used by pythoncom: 1) Using your own attributes gets tricky as they pythoncom tries to automatically assign them to the underlying com object. I've been bypassing the __setattr__ override by doing "self.__dict__['spam'] = 'ham'" which would could get tedious rather quickly... 2) Defining your own __init__ causes all sorts of problems :) 3) You "take over" the com classes: that is, comclass.__class__ is your class, not the original com_class: any kind on explicit introspection (isinstance, etc.), within pythoncom or existing client code could now fail. Again a less naive patching process that didn't overwrite everything blindly should be easy. -ross From mail at timgolden.me.uk Fri May 25 12:03:18 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 25 May 2007 11:03:18 +0100 Subject: [python-win32] extending com objects In-Reply-To: <4656AEA1.4060302@crummock.com> References: <458699B0.8000801@crummock.com> <39238.81.171.156.66.1166451212.squirrel@81.171.156.66> <46555B95.3050906@crummock.com> <4655EF05.7040809@timgolden.me.uk> <4656AEA1.4060302@crummock.com> Message-ID: <4656B466.6040607@timgolden.me.uk> [Tim Golden] >> Presumably, then, if the original COM class exposed, >> say, a .GetGroups method which returned a list of >> groups, each of which you wanted to wrap, in this >> implementation, you'd add a .MyGetGroups method which >> called the original and wrapped the result? [Ross McKerchar] > It's simpler than that: as long as you've monkey-patched the original > COM groups class, the groups returned by the GetGroups method will > already have your methods: no need to wrap. I see what you mean. As you say, this assumes they're already "victims" of your patching, but I imagine this is usually the case. [Ross McKerchar] > 1) Using your own attributes gets tricky as they pythoncom tries to > automatically assign them to the underlying com object. I've been > bypassing the __setattr__ override by doing "self.__dict__['spam'] = > 'ham'" which would could get tedious rather quickly... You could -- probably -- define a __setattribute__ method, but that would only work if the pywin32-generated classes were new-style (and I doubt they are). > 2) Defining your own __init__ causes all sorts of problems :) > > 3) You "take over" the com classes: that is, comclass.__class__ is your > class, not the original com_class: any kind on explicit introspection > (isinstance, etc.), within pythoncom or existing client code could now > fail. Again a less naive patching process that didn't overwrite > everything blindly should be easy. As you say. Well for the kind of modules I find myself churning out, this looks like an interesting approach, so do report back with pitfalls or... whatever the opposite of pitfalls is! TJG From mhammond at skippinet.com.au Fri May 25 13:01:14 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 25 May 2007 21:01:14 +1000 Subject: [python-win32] DCOM In-Reply-To: <79b79e730705250237g6312b08ex3ecbab15f0e129ba@mail.gmail.com> Message-ID: <010c01c79ebc$04aaef60$1f0a0a0a@enfoldsystems.local> > Hello :-) > I've got another newbie question. > > I'm trying to use DCOM. If I'm right, I have to register my > application on both the client and the server, then set up the correct > access/launch rights. After you've registered the COM object on the remote machine, you also need to configure dcom itself 'dcomcnfg' tool (which should already exist on the box). I cover this in the book, but you should be able to work out how to set things up (its a little involved - but google can probably find some non-python articles - it will be the same process...) Cheers, Mark From f.guerrieri at gmail.com Fri May 25 13:36:15 2007 From: f.guerrieri at gmail.com (Francesco Guerrieri) Date: Fri, 25 May 2007 13:36:15 +0200 Subject: [python-win32] DCOM In-Reply-To: <010c01c79ebc$04aaef60$1f0a0a0a@enfoldsystems.local> References: <79b79e730705250237g6312b08ex3ecbab15f0e129ba@mail.gmail.com> <010c01c79ebc$04aaef60$1f0a0a0a@enfoldsystems.local> Message-ID: <79b79e730705250436p5ae65b6u9ffb0d670b7eb4b7@mail.gmail.com> hi Mark, actually I have used dcomcnfg to set the various accesses. Now I'm at loss, since I have looked at all the various tabs and settings available, and it seems that all refer to enabling DCOM (which I did) and granting access (which I think I did). But I will continue trying... I've googled around and found many VB users stumbling on the same problems. Only problem is, I didn't stumble on the posts with the solution :-) thanks, francesco On 5/25/07, Mark Hammond wrote: > After you've registered the COM object on the remote machine, you also need > to configure dcom itself 'dcomcnfg' tool (which should already exist on the > box). I cover this in the book, but you should be able to work out how to > set things up (its a little involved - but google can probably find some > non-python articles - it will be the same process...) > > Cheers, > > Mark > > -- "Voil?! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of fate. This visage, no mere veneer of vanity, is a vestige of the vox populi, now vacant, vanished. However, this valorous visitation of a bygone vexation stands vivified, and has vowed to vanquish these venal and virulent vermin vanguarding vice and vouchsafing the violently vicious and voracious violation of volition. The only verdict is vengeance; a vendetta held as a votive, not in vain, for the value and veracity of such shall one day vindicate the vigilant and the virtuous. Verily, this vichyssoise of verbiage veers most verbose vis-?-vis an introduction, so let me simply add that it's my very good honor to meet you and you may call me V." -- V's introduction to Evey From theller at ctypes.org Fri May 25 14:24:40 2007 From: theller at ctypes.org (Thomas Heller) Date: Fri, 25 May 2007 14:24:40 +0200 Subject: [python-win32] DCOM In-Reply-To: <79b79e730705250436p5ae65b6u9ffb0d670b7eb4b7@mail.gmail.com> References: <79b79e730705250237g6312b08ex3ecbab15f0e129ba@mail.gmail.com> <010c01c79ebc$04aaef60$1f0a0a0a@enfoldsystems.local> <79b79e730705250436p5ae65b6u9ffb0d670b7eb4b7@mail.gmail.com> Message-ID: Francesco Guerrieri schrieb: > hi Mark, > > actually I have used dcomcnfg to set the various accesses. Now I'm at > loss, since I have looked at all the various tabs and settings > available, and it seems that all refer to enabling DCOM (which I did) > and granting access (which I think I did). > But I will continue trying... I've googled around and found many VB > users stumbling on the same problems. Only problem is, I didn't > stumble on the posts with the solution :-) IIRC, you have to open the firewall for the protocols and ports that DCOM uses. Thomas From rbell01824 at earthlink.net Fri May 25 15:50:11 2007 From: rbell01824 at earthlink.net (Richard Bell) Date: Fri, 25 May 2007 09:50:11 -0400 Subject: [python-win32] Getting HRESULT back from a com automation Message-ID: <004001c79ed3$9d5945b0$6801a8c0@homeoffice.benchmarkinternational.com> I'm working on an application that automated IE in an apartment threaded model. I'm trying to get back the result of ie.Navigate(). According to the MSDN documentation it should return a HRESULT. It appears to return None. Is there a way to get the return code from the com interaction? Thanks. From mhammond at skippinet.com.au Sat May 26 10:16:40 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 26 May 2007 18:16:40 +1000 Subject: [python-win32] Getting HRESULT back from a com automation In-Reply-To: <004001c79ed3$9d5945b0$6801a8c0@homeoffice.benchmarkinternational.com> Message-ID: <01e001c79f6e$30c36840$1f0a0a0a@enfoldsystems.local> > I'm trying to get back the result of ie.Navigate(). > According to the MSDN > documentation it should return a HRESULT. It appears to > return None. Is > there a way to get the return code from the com interaction? All error HRESULTs are returned via exceptions. Unfortunately, there isn't a reliable way to get a success HRESULT - when it is known to be significant, functions often return them, and it sounds like we could also do that in your case (assuming it *always* returns None now). It should also be possible to stick all HRESULTs in some thread-local-storage and fetchable via "GetLastHRESULT()" or similar. What codes are you expecting to see? Mark From teekaysoh at gmail.com Sat May 26 14:50:23 2007 From: teekaysoh at gmail.com (TK Soh) Date: Sat, 26 May 2007 07:50:23 -0500 Subject: [python-win32] shell extension property sheet Message-ID: <58b84f8e0705260550i43395965qdd08ac5b41ad9929@mail.gmail.com> I'm try to add a property sheet to my shell extension project, but found that pywin32 doesn't support it. What's the best thing I can do, other than hoping it will supportef pywin32 soon? I'm using pywin32 bundled with ActivePython 2.4. From mhammond at skippinet.com.au Sun May 27 16:42:05 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 28 May 2007 00:42:05 +1000 Subject: [python-win32] shell extension property sheet In-Reply-To: <58b84f8e0705260550i43395965qdd08ac5b41ad9929@mail.gmail.com> Message-ID: <02c501c7a06d$3227b150$1f0a0a0a@enfoldsystems.local> > I'm try to add a property sheet to my shell extension project, but > found that pywin32 doesn't support it. What's the best thing I can do, > other than hoping it will supportef pywin32 soon? I'm using pywin32 > bundled with ActivePython 2.4. Use ctypes I would think. Cheers, Mark. From teekaysoh at gmail.com Mon May 28 05:32:45 2007 From: teekaysoh at gmail.com (TK Soh) Date: Sun, 27 May 2007 22:32:45 -0500 Subject: [python-win32] shell extension property sheet In-Reply-To: <02c501c7a06d$3227b150$1f0a0a0a@enfoldsystems.local> References: <58b84f8e0705260550i43395965qdd08ac5b41ad9929@mail.gmail.com> <02c501c7a06d$3227b150$1f0a0a0a@enfoldsystems.local> Message-ID: <58b84f8e0705272032j6fc62a1atf1fd7a4a313ce767@mail.gmail.com> On 5/27/07, Mark Hammond wrote: > > I'm try to add a property sheet to my shell extension project, but > > found that pywin32 doesn't support it. What's the best thing I can do, > > other than hoping it will supportef pywin32 soon? I'm using pywin32 > > bundled with ActivePython 2.4. > > Use ctypes I would think. Any chance of a demo hiding somewhere in pywin32 distribution that can help kick things off? From mhammond at skippinet.com.au Mon May 28 06:22:13 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 28 May 2007 14:22:13 +1000 Subject: [python-win32] shell extension property sheet In-Reply-To: <58b84f8e0705272032j6fc62a1atf1fd7a4a313ce767@mail.gmail.com> Message-ID: <031001c7a0df$c5c19da0$1f0a0a0a@enfoldsystems.local> > On 5/27/07, Mark Hammond wrote: > > > I'm try to add a property sheet to my shell extension project, but > > > found that pywin32 doesn't support it. What's the best > thing I can do, > > > other than hoping it will supportef pywin32 soon? I'm > using pywin32 > > > bundled with ActivePython 2.4. > > > > Use ctypes I would think. > > Any chance of a demo hiding somewhere in pywin32 distribution that can > help kick things off? I'm afraid not. I can't recall hearing about anyone one else doing it either. An alternative I didn't mention which I hope is obvious, is that you could help contribute such support into pywin32 - this way you don't need to "hope". I understand that not everyone has the knowledge or resources to be able to do that. Even just doing the research of exactly what interfaces you need and any special data structures etc might help get it in too... Cheers, Mark From niki at vintech.bg Mon May 28 09:57:25 2007 From: niki at vintech.bg (Niki Spahiev) Date: Mon, 28 May 2007 10:57:25 +0300 Subject: [python-win32] interacting with Windows Media Player In-Reply-To: <3a69fa7c0705241314vb1b308fr59f66e8b9aed3dda@mail.gmail.com> References: <3a69fa7c0705180911p76d9ed23m6b56da0df0024ff4@mail.gmail.com> <464DDEF9.6080107@vintech.bg> <3a69fa7c0705241314vb1b308fr59f66e8b9aed3dda@mail.gmail.com> Message-ID: <465A8B65.80109@vintech.bg> E R wrote: > Is this what you were thinking of? > > http://liris.cnrs.fr/advene/ No. I found it now. Its http://sourceforge.net/projects/transana Niki Spahiev From mbelzile at softimage.com Tue May 29 00:27:37 2007 From: mbelzile at softimage.com (=?iso-8859-1?Q?Marc-Andr=E9_Belzile?=) Date: Mon, 28 May 2007 18:27:37 -0400 Subject: [python-win32] Win32 COM cache problem Message-ID: <0BCB4AE868D8934A8B3DCE3A58126A894EF1F0@tewk-mbpf3> Hi, My win32 app is hosting python 2.5 via the scripting ActiveX object. Everything works perfectly but the win32 COM cache behaves strangely if the app current folder (e.g. c:\temp) is different than the application path (e.g. c:\bin\MyApp). At some point when the app needs to create a new python scripting engine, the whole cache gets re-created from scratch which makes things pretty slow. This will not happen if the app is executed from it's normal application folder. Is there anything I can do to avoid this problem other than running the app from its normal application folder ? Below is an excerpt of a filemon log that shows the cache generation. Thanks for your help. -mab 5:47:26 PM XSI.exe:4964 OPEN C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.py NOT FOUND Options: Open Access: 00010080 5:47:26 PM XSI.exe:4964 OPEN C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.pyc NOT FOUND Options: Open Access: 00010080 5:47:26 PM XSI.exe:4964 OPEN C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.pyo NOT FOUND Options: Open Access: 00010080 5:47:26 PM XSI.exe:4964 CREATE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Options: OverwriteIf Access: 00120196 5:47:26 PM XSI.exe:4964 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS FileFsVolumeInformation 5:47:26 PM XSI.exe:4964 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py BUFFER OVERFLOW FileAllInformation 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 0 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 1024 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 2048 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 3072 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 4096 Length: 72 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 4168 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 5192 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 6216 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 7240 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 8264 Length: 56 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 8320 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 9344 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 10368 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 11392 Length: 1024 etc... From rbell01824 at earthlink.net Tue May 29 14:21:38 2007 From: rbell01824 at earthlink.net (Richard Bell) Date: Tue, 29 May 2007 07:21:38 -0500 Subject: [python-win32] Getting HRESULT back from a com automation In-Reply-To: <01e001c79f6e$30c36840$1f0a0a0a@enfoldsystems.local> References: <004001c79ed3$9d5945b0$6801a8c0@homeoffice.benchmarkinternational.com> <01e001c79f6e$30c36840$1f0a0a0a@enfoldsystems.local> Message-ID: <008c01c7a1eb$eb3f5010$6701a8c0@rjbmain> Mark, Aside from the example I posted earlier, I adopted the approach you outlined in your note, ie. I placed any exception results in class instance storage. It looks like that will work although I've got a good deal more development to do before being sure. As to what codes I'm expecting ... heaven only knows. I'm working with IE 7 now and it appears willing to return most anything under various boundary conditions. I'm in the process now of some systematic testing in an effort to bring some kind of order to the affair. Regards, Richard |-----Original Message----- |From: Mark Hammond [mailto:mhammond at skippinet.com.au] |Sent: Saturday, May 26, 2007 3:17 AM |To: 'Richard Bell'; python-win32 at python.org |Subject: RE: [python-win32] Getting HRESULT back from a com automation | |> I'm trying to get back the result of ie.Navigate(). |> According to the MSDN |> documentation it should return a HRESULT. It appears to |> return None. Is |> there a way to get the return code from the com interaction? | |All error HRESULTs are returned via exceptions. Unfortunately, there isn't |a reliable way to get a success HRESULT - when it is known to be |significant, functions often return them, and it sounds like we could also |do that in your case (assuming it *always* returns None now). It should |also be possible to stick all HRESULTs in some thread-local-storage and |fetchable via "GetLastHRESULT()" or similar. What codes are you expecting |to see? | |Mark From mhammond at skippinet.com.au Tue May 29 14:41:55 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 29 May 2007 22:41:55 +1000 Subject: [python-win32] Getting HRESULT back from a com automation In-Reply-To: <008c01c7a1eb$eb3f5010$6701a8c0@rjbmain> Message-ID: <041d01c7a1ee$be0c8b50$1f0a0a0a@enfoldsystems.local> > As to what codes I'm expecting ... heaven only knows. I'm > working with IE 7 > now and it appears willing to return most anything under > various boundary conditions. I guess I was asking if you are expecting any 'success' codes other than S_OK. These are rare, and always explicitly documented. If your concern is restricted to errors, then you will find that catching pythoncom.com_error is reliable. Cheers, Mark From theodorei at yahoo.com Tue May 29 15:41:48 2007 From: theodorei at yahoo.com (Teodor Ivanov) Date: Tue, 29 May 2007 13:41:48 +0000 (UTC) Subject: [python-win32] win32net References: <7ED3CA664474C84891E0DD86162C70F20120B4C3@dereu1nexc3.al-lighting.com> <450199FC.3080406@probo.com> Message-ID: Tim Roberts probo.com> writes: > > Wolf, Matthias ALRT/ELD wrote: > > >Thanks for your answer! > > > >You are right, but in the group 'GROUP' are users and groups and I want to receive both. Probably I need > something like "win32net.NetGroupGetGroups" instead of "win32net.NetGroupGetUsers". Is there any > possible way to realise this? > > > > > > According to the MSDN documentation, NetGroupGetUsers is used to list > the members of a "global group", and a "global group" can only contain > domain users. It cannot contain other groups. > > Local groups can contain other groups, but you use > NetLocalGroupGetMembers to examine those. > The statement '"global group" can only contain domain users' is true only for MS domains running in mixed mode ( I mean the OS of primary domain controller is Windows 2000 or 2003 ), but if it is in native 2000 or native 2003 mode, then the global security groups can contain other security groups: http://technet2.microsoft.com/windowsserver/en/library/95107162-47eb-4891-832f-0c0b15b7c8581033.mspx?mfr=true and independant from NetGroupGetUsers documentation: http://msdn2.microsoft.com/en-us/library/aa370430.aspx it returns just the 'user members', but not the 'group members'. Does anybody have an ideia how to get the 'group members' of a group from domain running in native mode, as well? Thank you! Teodor From teekaysoh at gmail.com Tue May 29 16:09:18 2007 From: teekaysoh at gmail.com (TK Soh) Date: Tue, 29 May 2007 09:09:18 -0500 Subject: [python-win32] shell extension property sheet In-Reply-To: <031001c7a0df$c5c19da0$1f0a0a0a@enfoldsystems.local> References: <58b84f8e0705272032j6fc62a1atf1fd7a4a313ce767@mail.gmail.com> <031001c7a0df$c5c19da0$1f0a0a0a@enfoldsystems.local> Message-ID: <58b84f8e0705290709q7638bcd2u7792940007b5b281@mail.gmail.com> On 5/27/07, Mark Hammond wrote: > > On 5/27/07, Mark Hammond wrote: > > > > I'm try to add a property sheet to my shell extension project, but > > > > found that pywin32 doesn't support it. What's the best > > thing I can do, > > > > other than hoping it will supportef pywin32 soon? I'm > > using pywin32 > > > > bundled with ActivePython 2.4. > > > > > > Use ctypes I would think. > > > > Any chance of a demo hiding somewhere in pywin32 distribution that can > > help kick things off? > > I'm afraid not. I can't recall hearing about anyone one else doing it either. > > An alternative I didn't mention which I hope is obvious, is that you could help > contribute such support into pywin32 - this way you don't need to "hope". > I understand that not everyone has the knowledge or resources to be able to > do that. Even just doing the research of exactly what interfaces you need > and any special data structures etc might help get it in too... I'd certainly love to be able to contribute, but right now I simply don't possess the skill to do so. Nonetheless I will keep this on my "to-do" list ;-) From mail at timgolden.me.uk Tue May 29 16:09:11 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 29 May 2007 15:09:11 +0100 Subject: [python-win32] win32net In-Reply-To: References: <7ED3CA664474C84891E0DD86162C70F20120B4C3@dereu1nexc3.al-lighting.com> <450199FC.3080406@probo.com> Message-ID: <465C3407.8010305@timgolden.me.uk> Teodor Ivanov wrote: > The statement '"global group" can only contain domain users' is true only for > MS domains running in mixed mode ( I mean the OS of primary domain controller is > Windows 2000 or 2003 ), but if it is in native 2000 or native 2003 mode, then > the global security groups can contain other security groups: > http://technet2.microsoft.com/windowsserver/en/library/95107162-47eb-4891-832f-0c0b15b7c8581033.mspx?mfr=true > and independant from NetGroupGetUsers documentation: > http://msdn2.microsoft.com/en-us/library/aa370430.aspx > it returns just the 'user members', but not the 'group members'. > Does anybody have an ideia how to get the 'group members' of a group from domain > running in native mode, as well? I seem to have missed the start of this thread, but is there anything to stop you interrogating AD for this info? If not, then have a look at these examples: http://tgolden.sc.sabren.com/python/ad_cookbook.html TJG From rbell01824 at earthlink.net Tue May 29 16:38:41 2007 From: rbell01824 at earthlink.net (Richard Bell) Date: Tue, 29 May 2007 09:38:41 -0500 Subject: [python-win32] Getting HRESULT back from a com automation In-Reply-To: <041d01c7a1ee$be0c8b50$1f0a0a0a@enfoldsystems.local> References: <008c01c7a1eb$eb3f5010$6701a8c0@rjbmain> <041d01c7a1ee$be0c8b50$1f0a0a0a@enfoldsystems.local> Message-ID: <009601c7a1ff$0dcefd70$6701a8c0@rjbmain> My misunderstanding. As far as I know now absent some error all I really expect is S_OK. I'm adding in the python.com_error checking now and starting careful testing. If something other than S_OK turns up in the IE interface I'll let you know. Thanks. Regards, Richard |> As to what codes I'm expecting ... heaven only knows. I'm |> working with IE 7 |> now and it appears willing to return most anything under |> various boundary conditions. | |I guess I was asking if you are expecting any 'success' codes other than |S_OK. These are rare, and always explicitly documented. If your concern |is |restricted to errors, then you will find that catching pythoncom.com_error |is reliable. | |Cheers, | |Mark From rbell01824 at earthlink.net Tue May 29 23:51:31 2007 From: rbell01824 at earthlink.net (Richard Bell) Date: Tue, 29 May 2007 16:51:31 -0500 Subject: [python-win32] Can pythoncom.PumpWaitingMessages() generate a COM error? In-Reply-To: <009601c7a1ff$0dcefd70$6701a8c0@rjbmain> References: <008c01c7a1eb$eb3f5010$6701a8c0@rjbmain><041d01c7a1ee$be0c8b50$1f0a0a0a@enfoldsystems.local> <009601c7a1ff$0dcefd70$6701a8c0@rjbmain> Message-ID: <009a01c7a23b$87a16520$6701a8c0@rjbmain> Can pythoncom.PumpWaitingMessages() generate a COM error? In particular if there is a running instance of IE that is terminated by some external event, say the user or a script, will pythoncom.PumpWaitingMessages() generate a COM error since the automation object is gone? Thanks for any clues. Regards, Richard From mbelzile at softimage.com Wed May 30 01:12:50 2007 From: mbelzile at softimage.com (=?iso-8859-1?Q?Marc-Andr=E9_Belzile?=) Date: Tue, 29 May 2007 19:12:50 -0400 Subject: [python-win32] Win32 COM cache problem In-Reply-To: <0BCB4AE868D8934A8B3DCE3A58126A894EF1F0@tewk-mbpf3> Message-ID: <0BCB4AE868D8934A8B3DCE3A58126A894EF1FA@tewk-mbpf3> I dig a bit more and it appears that the python win32 com module requires all target typelibs to be in the app current directory. Otherwise the cache is systematically re-generated anytime a new scripting engine is created. Am I doing something wrong ? Thanks in advance... -mab -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Marc-Andr? Belzile Sent: May 28, 2007 6:28 PM To: python-win32 at python.org Subject: [python-win32] Win32 COM cache problem Hi, My win32 app is hosting python 2.5 via the scripting ActiveX object. Everything works perfectly but the win32 COM cache behaves strangely if the app current folder (e.g. c:\temp) is different than the application path (e.g. c:\bin\MyApp). At some point when the app needs to create a new python scripting engine, the whole cache gets re-created from scratch which makes things pretty slow. This will not happen if the app is executed from it's normal application folder. Is there anything I can do to avoid this problem other than running the app from its normal application folder ? Below is an excerpt of a filemon log that shows the cache generation. Thanks for your help. -mab 5:47:26 PM XSI.exe:4964 OPEN C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.py NOT FOUND Options: Open Access: 00010080 5:47:26 PM XSI.exe:4964 OPEN C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.pyc NOT FOUND Options: Open Access: 00010080 5:47:26 PM XSI.exe:4964 OPEN C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.pyo NOT FOUND Options: Open Access: 00010080 5:47:26 PM XSI.exe:4964 CREATE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Options: OverwriteIf Access: 00120196 5:47:26 PM XSI.exe:4964 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS FileFsVolumeInformation 5:47:26 PM XSI.exe:4964 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py BUFFER OVERFLOW FileAllInformation 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 0 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 1024 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 2048 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 3072 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 4096 Length: 72 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 4168 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 5192 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 6216 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 7240 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 8264 Length: 56 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 8320 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 9344 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 10368 Length: 1024 5:47:28 PM XSI.exe:4964 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 11392 Length: 1024 etc... _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From steve_geo at optusnet.com.au Wed May 30 02:44:23 2007 From: steve_geo at optusnet.com.au (Stephen George) Date: Wed, 30 May 2007 10:44:23 +1000 Subject: [python-win32] Python Programmming on win32 - the book In-Reply-To: <032801c79d91$16f915b0$1f0a0a0a@enfoldsystems.local> References: <032801c79d91$16f915b0$1f0a0a0a@enfoldsystems.local> Message-ID: <465CC8E7.4030404@optusnet.com.au> Hi Mark, For your info I contacted O'Reilly about the book after being told by a bookseller it appears "out of print" Here is their response > Hello, > > "Python Programming On Win32" is still "In Print". > We have it on a "Print on demand" status. > Every month or so we print enough to fill our backorders. > > So if you would like to get this book you would need to order it and you > will receive it when it is printed. > Several of our older books are now "Print on Demand" books. > > Regards, > > Tammie Jean > O'Reilly Media Inc. > Sebastopol, CA, USA > 800-998-9938 US & Canada > 707-829-0515 International Mark Hammond wrote: >> Hi, >> >> I was considering buying >> Python Programming On Win32 which was written in 2000. >> >> I hate to buy out of date books. >> >> I'd like to ask if the contents of this book are still >> relevant in 2007 >> and recent releases of Python. >> > > Yep - some things have changed, but the concepts are all still good. > > >> Will this book continue to be relevant for a number of years to come? >> >> Are there any plans for a 2nd Edition in the next 6 months or so? >> > > I'm afraid that I've been messing poor John around for many months now. I'd > like to think a new version would be on the shelves in 12 months time (but > you could probably find me saying something similar 12 months ago...) > > Mark > > > From mhammond at skippinet.com.au Wed May 30 04:24:14 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 30 May 2007 12:24:14 +1000 Subject: [python-win32] Win32 COM cache problem In-Reply-To: <0BCB4AE868D8934A8B3DCE3A58126A894EF1FA@tewk-mbpf3> Message-ID: <04cf01c7a261$9e7629e0$1f0a0a0a@enfoldsystems.local> > I dig a bit more and it appears that the python win32 com > module requires all target typelibs to be in the app current > directory. Otherwise the cache is systematically re-generated > anytime a new scripting engine is created. This should not be the case, and there should be no assumption about the location of the typelib - indeed, we generally just ask COM to load it for us. I'm afraid I have no insights to the problems you face, so you might need to dig a little more to see what is going wrong, or work out a way so I can reproduce the problem locally. Cheers, Mark > > Am I doing something wrong ? Thanks in advance... > > -mab > > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org] On Behalf Of > Marc-Andr? Belzile > Sent: May 28, 2007 6:28 PM > To: python-win32 at python.org > Subject: [python-win32] Win32 COM cache problem > > Hi, > > My win32 app is hosting python 2.5 via the scripting ActiveX > object. Everything works perfectly but the win32 COM cache > behaves strangely if the app current folder (e.g. c:\temp) is > different than the application path (e.g. c:\bin\MyApp). At > some point when the app needs to create a new python > scripting engine, the whole cache gets re-created from > scratch which makes things pretty slow. This will not happen > if the app is executed from it's normal application folder. > > Is there anything I can do to avoid this problem other than > running the app from its normal application folder ? > > Below is an excerpt of a filemon log that shows the cache generation. > > Thanks for your help. > > -mab > > 5:47:26 PM XSI.exe:4964 OPEN > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0.py NOT FOUND Options: Open > Access: 00010080 > 5:47:26 PM XSI.exe:4964 OPEN > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0.pyc NOT FOUND Options: Open > Access: 00010080 > 5:47:26 PM XSI.exe:4964 OPEN > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0.pyo NOT FOUND Options: Open > Access: 00010080 > 5:47:26 PM XSI.exe:4964 CREATE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Options: > OverwriteIf Access: 00120196 > 5:47:26 PM XSI.exe:4964 QUERY INFORMATION > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS FileFsVolumeInformation > 5:47:26 PM XSI.exe:4964 QUERY INFORMATION > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py BUFFER OVERFLOW > FileAllInformation > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 0 Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 1024 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 2048 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 3072 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 4096 Length: 72 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 4168 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 5192 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 6216 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 7240 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 8264 Length: 56 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 8320 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 9344 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 10368 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 11392 > Length: 1024 etc... > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 3440 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20070530/fa4deffc/attachment.bin From mhammond at skippinet.com.au Wed May 30 04:25:46 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 30 May 2007 12:25:46 +1000 Subject: [python-win32] Can pythoncom.PumpWaitingMessages() generate a COMerror? In-Reply-To: <009a01c7a23b$87a16520$6701a8c0@rjbmain> Message-ID: <04d301c7a261$d55d08c0$1f0a0a0a@enfoldsystems.local> > Can pythoncom.PumpWaitingMessages() generate a COM error? In > particular if > there is a running instance of IE that is terminated by some > external event, > say the user or a script, will > pythoncom.PumpWaitingMessages() generate a > COM error since the automation object is gone? PumpWaitingMessages will never return a COM exception. Mark From mbelzile at softimage.com Wed May 30 17:19:03 2007 From: mbelzile at softimage.com (=?iso-8859-1?Q?Marc-Andr=E9_Belzile?=) Date: Wed, 30 May 2007 11:19:03 -0400 Subject: [python-win32] Win32 COM cache problem In-Reply-To: <04cf01c7a261$9e7629e0$1f0a0a0a@enfoldsystems.local> Message-ID: <0BCB4AE868D8934A8B3DCE3A58126A894EF1FF@tewk-mbpf3> That's odd, if I copy the tlb in the current folder then the __init__.py is not recreated: 10:33:14 AM XSI.exe:3896 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\__init__.py SUCCESS Attributes: A 10:33:14 AM XSI.exe:3896 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.py NOT FOUND Attributes: Error 10:33:14 AM XSI.exe:3896 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.pyc NOT FOUND Attributes: Error >>> 10:33:14 AM XSI.exe:3896 QUERY INFORMATION C:\Softimage\XSI_6.02_Debug-0528\Application\si3dobjectmodel.tlb SUCCESS Attributes: A Otherwise, multiple write access calls are performed on __init__.py: 10:11:50 AM XSI.exe:3896 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\__init__.py SUCCESS Attributes: A 10:11:50 AM XSI.exe:3896 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.py NOT FOUND Attributes: Error 10:11:50 AM XSI.exe:3896 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.pyc NOT FOUND Attributes: Error >>> 10:11:50 AM XSI.exe:3896 QUERY INFORMATION C:\Softimage\XSI_6.02_Debug-0528\Application\si3dobjectmodel.tlb NOT FOUND Attributes: Error 10:11:50 AM XSI.exe:3896 QUERY INFORMATION C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmodel.tlb SUCCESS Attributes: N 10:11:50 AM XSI.exe:3896 OPEN C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmodel.tlb SUCCESS Options: Open Access: Read 10:11:50 AM XSI.exe:3896 OPEN C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmodel.tlb SUCCESS Options: Open Access: 00100080 10:11:50 AM XSI.exe:3896 QUERY INFORMATION C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmodel.tlb SUCCESS FileInternalInformation 10:11:50 AM XSI.exe:3896 QUERY INFORMATION C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmodel.tlb SUCCESS Length: 479208 10:11:50 AM XSI.exe:3896 READ C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmodel.tlb SUCCESS Offset: 0 Length: 64 10:11:50 AM XSI.exe:3896 CLOSE C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmodel.tlb SUCCESS 10:11:50 AM XSI.exe:3896 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\__init__.py SUCCESS Attributes: A 10:11:50 AM XSI.exe:3896 OPEN C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.py NOT FOUND Options: Open Access: 00010080 10:11:50 AM XSI.exe:3896 OPEN C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.pyc NOT FOUND Options: Open Access: 00010080 10:11:50 AM XSI.exe:3896 OPEN C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.pyo NOT FOUND Options: Open Access: 00010080 10:11:50 AM XSI.exe:3896 CREATE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Options: OverwriteIf Access: 00120196 10:11:50 AM XSI.exe:3896 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS FileFsVolumeInformation 10:11:50 AM XSI.exe:3896 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py BUFFER OVERFLOW FileAllInformation >>> 10:11:51 AM XSI.exe:3896 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 0 Length: 1024 10:11:51 AM XSI.exe:3896 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 1024 Length: 1024 10:11:51 AM XSI.exe:3896 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 2048 Length: 1024 10:11:51 AM XSI.exe:3896 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 3072 Length: 1024 10:11:51 AM XSI.exe:3896 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 4096 Length: 72 10:11:51 AM XSI.exe:3896 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 4168 Length: 1024 10:11:51 AM XSI.exe:3896 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 5192 Length: 1024 10:11:51 AM XSI.exe:3896 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 6216 Length: 1024 10:11:51 AM XSI.exe:3896 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 7240 Length: 1024 10:11:51 AM XSI.exe:3896 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 8264 Length: 56 ... and the list goes on The write access calls occur when typelibs are added to the scripting ActiveX : pythonEngine->AddTypeLib( theLibGUID, dwLibMajorVersion, dwLibMinorVersion, SCRIPTTYPELIB_ISCONTROL ); -mab -----Original Message----- From: Mark Hammond [mailto:mhammond at skippinet.com.au] Sent: May 29, 2007 10:24 PM To: Marc-Andr? Belzile; python-win32 at python.org Subject: RE: [python-win32] Win32 COM cache problem > I dig a bit more and it appears that the python win32 com module > requires all target typelibs to be in the app current directory. > Otherwise the cache is systematically re-generated anytime a new > scripting engine is created. This should not be the case, and there should be no assumption about the location of the typelib - indeed, we generally just ask COM to load it for us. I'm afraid I have no insights to the problems you face, so you might need to dig a little more to see what is going wrong, or work out a way so I can reproduce the problem locally. Cheers, Mark > > Am I doing something wrong ? Thanks in advance... > > -mab > > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org] On Behalf Of Marc-Andr? > Belzile > Sent: May 28, 2007 6:28 PM > To: python-win32 at python.org > Subject: [python-win32] Win32 COM cache problem > > Hi, > > My win32 app is hosting python 2.5 via the scripting ActiveX object. > Everything works perfectly but the win32 COM cache behaves strangely > if the app current folder (e.g. c:\temp) is different than the > application path (e.g. c:\bin\MyApp). At some point when the app needs > to create a new python scripting engine, the whole cache gets > re-created from scratch which makes things pretty slow. This will not > happen if the app is executed from it's normal application folder. > > Is there anything I can do to avoid this problem other than running > the app from its normal application folder ? > > Below is an excerpt of a filemon log that shows the cache generation. > > Thanks for your help. > > -mab > > 5:47:26 PM XSI.exe:4964 OPEN > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0.py NOT FOUND Options: Open > Access: 00010080 > 5:47:26 PM XSI.exe:4964 OPEN > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0.pyc NOT FOUND Options: Open > Access: 00010080 > 5:47:26 PM XSI.exe:4964 OPEN > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0.pyo NOT FOUND Options: Open > Access: 00010080 > 5:47:26 PM XSI.exe:4964 CREATE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Options: > OverwriteIf Access: 00120196 > 5:47:26 PM XSI.exe:4964 QUERY INFORMATION > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS FileFsVolumeInformation > 5:47:26 PM XSI.exe:4964 QUERY INFORMATION > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py BUFFER OVERFLOW > FileAllInformation > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 0 Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 1024 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 2048 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 3072 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 4096 Length: 72 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 4168 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 5192 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 6216 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 7240 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 8264 Length: 56 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 8320 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 9344 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 10368 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 11392 > Length: 1024 etc... > _______________________________________________ > 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 mbelzile at softimage.com Wed May 30 17:28:30 2007 From: mbelzile at softimage.com (=?iso-8859-1?Q?Marc-Andr=E9_Belzile?=) Date: Wed, 30 May 2007 11:28:30 -0400 Subject: [python-win32] Win32 COM cache problem In-Reply-To: <0BCB4AE868D8934A8B3DCE3A58126A894EF1FF@tewk-mbpf3> Message-ID: <0BCB4AE868D8934A8B3DCE3A58126A894EF201@tewk-mbpf3> Sorry, the code is rather: pythonEngine->AddTypeLib( theLibGUID, dwLibMajorVersion, dwLibMinorVersion, SCRIPTTYPELIB_ISCONTROL ); -mab -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Marc-Andr? Belzile Sent: May 30, 2007 11:19 AM To: Mark Hammond; python-win32 at python.org Subject: Re: [python-win32] Win32 COM cache problem That's odd, if I copy the tlb in the current folder then the __init__.py is not recreated: 10:33:14 AM XSI.exe:3896 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\__init__.py SUCCESS Attributes: A 10:33:14 AM XSI.exe:3896 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.py NOT FOUND Attributes: Error 10:33:14 AM XSI.exe:3896 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.pyc NOT FOUND Attributes: Error >>> 10:33:14 AM XSI.exe:3896 QUERY INFORMATION C:\Softimage\XSI_6.02_Debug-0528\Application\si3dobjectmodel.tlb SUCCESS Attributes: A Otherwise, multiple write access calls are performed on __init__.py: 10:11:50 AM XSI.exe:3896 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\__init__.py SUCCESS Attributes: A 10:11:50 AM XSI.exe:3896 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.py NOT FOUND Attributes: Error 10:11:50 AM XSI.exe:3896 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.pyc NOT FOUND Attributes: Error >>> 10:11:50 AM XSI.exe:3896 QUERY INFORMATION C:\Softimage\XSI_6.02_Debug-0528\Application\si3dobjectmodel.tlb NOT FOUND Attributes: Error 10:11:50 AM XSI.exe:3896 QUERY INFORMATION C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmodel.tlb SUCCESS Attributes: N 10:11:50 AM XSI.exe:3896 OPEN C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmodel.tlb SUCCESS Options: Open Access: Read 10:11:50 AM XSI.exe:3896 OPEN C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmodel.tlb SUCCESS Options: Open Access: 00100080 10:11:50 AM XSI.exe:3896 QUERY INFORMATION C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmodel.tlb SUCCESS FileInternalInformation 10:11:50 AM XSI.exe:3896 QUERY INFORMATION C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmodel.tlb SUCCESS Length: 479208 10:11:50 AM XSI.exe:3896 READ C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmodel.tlb SUCCESS Offset: 0 Length: 64 10:11:50 AM XSI.exe:3896 CLOSE C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmodel.tlb SUCCESS 10:11:50 AM XSI.exe:3896 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\__init__.py SUCCESS Attributes: A 10:11:50 AM XSI.exe:3896 OPEN C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.py NOT FOUND Options: Open Access: 00010080 10:11:50 AM XSI.exe:3896 OPEN C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.pyc NOT FOUND Options: Open Access: 00010080 10:11:50 AM XSI.exe:3896 OPEN C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.pyo NOT FOUND Options: Open Access: 00010080 10:11:50 AM XSI.exe:3896 CREATE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Options: OverwriteIf Access: 00120196 10:11:50 AM XSI.exe:3896 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS FileFsVolumeInformation 10:11:50 AM XSI.exe:3896 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py BUFFER OVERFLOW FileAllInformation >>> 10:11:51 AM XSI.exe:3896 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 0 Length: 1024 10:11:51 AM XSI.exe:3896 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 1024 Length: 1024 10:11:51 AM XSI.exe:3896 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 2048 Length: 1024 10:11:51 AM XSI.exe:3896 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 3072 Length: 1024 10:11:51 AM XSI.exe:3896 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 4096 Length: 72 10:11:51 AM XSI.exe:3896 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 4168 Length: 1024 10:11:51 AM XSI.exe:3896 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 5192 Length: 1024 10:11:51 AM XSI.exe:3896 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 6216 Length: 1024 10:11:51 AM XSI.exe:3896 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 7240 Length: 1024 10:11:51 AM XSI.exe:3896 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 8264 Length: 56 ... and the list goes on The write access calls occur when typelibs are added to the scripting ActiveX : pythonEngine->AddTypeLib( theLibGUID, dwLibMajorVersion, pythonEngine->dwLibMinorVersion, SCRIPTTYPELIB_ISCONTROL ); -mab -----Original Message----- From: Mark Hammond [mailto:mhammond at skippinet.com.au] Sent: May 29, 2007 10:24 PM To: Marc-Andr? Belzile; python-win32 at python.org Subject: RE: [python-win32] Win32 COM cache problem > I dig a bit more and it appears that the python win32 com module > requires all target typelibs to be in the app current directory. > Otherwise the cache is systematically re-generated anytime a new > scripting engine is created. This should not be the case, and there should be no assumption about the location of the typelib - indeed, we generally just ask COM to load it for us. I'm afraid I have no insights to the problems you face, so you might need to dig a little more to see what is going wrong, or work out a way so I can reproduce the problem locally. Cheers, Mark > > Am I doing something wrong ? Thanks in advance... > > -mab > > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org] On Behalf Of Marc-Andr? > Belzile > Sent: May 28, 2007 6:28 PM > To: python-win32 at python.org > Subject: [python-win32] Win32 COM cache problem > > Hi, > > My win32 app is hosting python 2.5 via the scripting ActiveX object. > Everything works perfectly but the win32 COM cache behaves strangely > if the app current folder (e.g. c:\temp) is different than the > application path (e.g. c:\bin\MyApp). At some point when the app needs > to create a new python scripting engine, the whole cache gets > re-created from scratch which makes things pretty slow. This will not > happen if the app is executed from it's normal application folder. > > Is there anything I can do to avoid this problem other than running > the app from its normal application folder ? > > Below is an excerpt of a filemon log that shows the cache generation. > > Thanks for your help. > > -mab > > 5:47:26 PM XSI.exe:4964 OPEN > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0.py NOT FOUND Options: Open > Access: 00010080 > 5:47:26 PM XSI.exe:4964 OPEN > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0.pyc NOT FOUND Options: Open > Access: 00010080 > 5:47:26 PM XSI.exe:4964 OPEN > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0.pyo NOT FOUND Options: Open > Access: 00010080 > 5:47:26 PM XSI.exe:4964 CREATE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Options: > OverwriteIf Access: 00120196 > 5:47:26 PM XSI.exe:4964 QUERY INFORMATION > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS FileFsVolumeInformation > 5:47:26 PM XSI.exe:4964 QUERY INFORMATION > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py BUFFER OVERFLOW > FileAllInformation > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 0 Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 1024 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 2048 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 3072 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 4096 Length: 72 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 4168 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 5192 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 6216 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 7240 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 8264 Length: 56 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 8320 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 9344 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 10368 > Length: 1024 > 5:47:28 PM XSI.exe:4964 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 11392 > Length: 1024 etc... > _______________________________________________ > 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 > _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From theller at ctypes.org Wed May 30 18:07:37 2007 From: theller at ctypes.org (Thomas Heller) Date: Wed, 30 May 2007 18:07:37 +0200 Subject: [python-win32] Win32 COM cache problem In-Reply-To: <0BCB4AE868D8934A8B3DCE3A58126A894EF1FA@tewk-mbpf3> References: <0BCB4AE868D8934A8B3DCE3A58126A894EF1F0@tewk-mbpf3> <0BCB4AE868D8934A8B3DCE3A58126A894EF1FA@tewk-mbpf3> Message-ID: Marc-Andr? Belzile schrieb: > I dig a bit more and it appears that the python win32 com module requires all target typelibs to be in the app current directory. Otherwise the cache is systematically re-generated anytime a new scripting engine is created. > > Am I doing something wrong ? Thanks in advance... > > -mab > > -----Original Message----- > From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Marc-Andr? Belzile > Sent: May 28, 2007 6:28 PM > To: python-win32 at python.org > Subject: [python-win32] Win32 COM cache problem > > Hi, > > My win32 app is hosting python 2.5 via the scripting ActiveX object. Everything works perfectly but the win32 COM cache behaves strangely if the app current folder (e.g. c:\temp) is different than the application path (e.g. c:\bin\MyApp). At some point when the app needs to create a new python scripting engine, the whole cache gets re-created from scratch which makes things pretty slow. This will not happen if the app is executed from it's normal application folder. > > Is there anything I can do to avoid this problem other than running the app from its normal application folder ? > > Below is an excerpt of a filemon log that shows the cache generation. > > Thanks for your help. > > -mab > > 5:47:26 PM XSI.exe:4964 OPEN C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.py NOT FOUND Options: Open Access: 00010080 > 5:47:26 PM XSI.exe:4964 OPEN C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.pyc NOT FOUND Options: Open Access: 00010080 > 5:47:26 PM XSI.exe:4964 OPEN C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.pyo NOT FOUND Options: Open Access: 00010080 > 5:47:26 PM XSI.exe:4964 CREATE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Options: OverwriteIf Access: 00120196 > 5:47:26 PM XSI.exe:4964 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS FileFsVolumeInformation > 5:47:26 PM XSI.exe:4964 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py BUFFER OVERFLOW FileAllInformation ^^^^^^^^^^^^^^^ Have you investigated why the above call fails? To me this looks like pywin cannot determine something about the file, and then recreates it just in case... Thomas From daryl.spitzer at gmail.com Wed May 30 18:55:42 2007 From: daryl.spitzer at gmail.com (Daryl Spitzer) Date: Wed, 30 May 2007 09:55:42 -0700 Subject: [python-win32] Error when trying to open a Microsoft Project file Message-ID: I'm trying to open a Microsoft Project file using the following: >>> from win32com.client import Dispatch >>> a=Dispatch("MSProject.Application") >>> a.Visible=1 >>> a.FileOpen("C:\test.mpp") ...but I get this error message. Traceback (most recent call last): File "", line 1, in File "", line 8, in FileOpen com_error: (-2147352567, 'Exception occurred.', (1004, 'Microsoft Office Project', 'Project cannot open the file.', 'C:\\Program Files\\Microsoft Office\\OFFICE11\\VBAPJ.CHM', 131072, 0), None) Project (Standard 2003 SP1) will open C:\test.mpp just fine interactively. Can anyone tell me why I'm getting this error message? What is that 'C:\\Program Files\\Microsoft Office\\OFFICE11\\VBAPJ.CHM' file? It doesn't exist in that location, but I found it in C:\Program Files\Microsoft Office\OFFICE11\1033\. I tried copying it to C:\Program Files\Microsoft Office\OFFICE11\ but I get the same error. -- Daryl Spitzer From mbelzile at softimage.com Wed May 30 19:44:42 2007 From: mbelzile at softimage.com (=?iso-8859-1?Q?Marc-Andr=E9_Belzile?=) Date: Wed, 30 May 2007 13:44:42 -0400 Subject: [python-win32] Win32 COM cache problem In-Reply-To: Message-ID: <0BCB4AE868D8934A8B3DCE3A58126A894EF202@tewk-mbpf3> The buffer overflow occurs after the __init__file.py has been re-created: 1:40:02 PM XSI.exe:3836 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\__init__.py SUCCESS Attributes: A 1:40:02 PM XSI.exe:3836 OPEN C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.py NOT FOUND Options: Open Access: 00010080 1:40:02 PM XSI.exe:3836 OPEN C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.pyc NOT FOUND Options: Open Access: 00010080 1:40:02 PM XSI.exe:3836 OPEN C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.pyo NOT FOUND Options: Open Access: 00010080 1:40:02 PM XSI.exe:3836 CREATE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Options: OverwriteIf Access: 00120196 1:40:02 PM XSI.exe:3836 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS FileFsVolumeInformation 1:40:02 PM XSI.exe:3836 QUERY INFORMATION C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py BUFFER OVERFLOW FileAllInformation 1:40:03 PM XSI.exe:3836 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 0 Length: 1024 1:40:03 PM XSI.exe:3836 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 1024 Length: 1024 1:40:03 PM XSI.exe:3836 WRITE C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 2048 Length: 1024 For some reasons, pywin recreates it if 269C4D8C-E32D-11D3-811D-00A0C9AC19A9x0x1x0.py doesn't exist. This also happens for other typelibs added to the python engine. -mab -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Thomas Heller Sent: May 30, 2007 12:08 PM To: python-win32 at python.org Subject: Re: [python-win32] Win32 COM cache problem Marc-Andr? Belzile schrieb: > I dig a bit more and it appears that the python win32 com module requires all target typelibs to be in the app current directory. Otherwise the cache is systematically re-generated anytime a new scripting engine is created. > > Am I doing something wrong ? Thanks in advance... > > -mab > > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org] On Behalf Of Marc-Andr? > Belzile > Sent: May 28, 2007 6:28 PM > To: python-win32 at python.org > Subject: [python-win32] Win32 COM cache problem > > Hi, > > My win32 app is hosting python 2.5 via the scripting ActiveX object. Everything works perfectly but the win32 COM cache behaves strangely if the app current folder (e.g. c:\temp) is different than the application path (e.g. c:\bin\MyApp). At some point when the app needs to create a new python scripting engine, the whole cache gets re-created from scratch which makes things pretty slow. This will not happen if the app is executed from it's normal application folder. > > Is there anything I can do to avoid this problem other than running the app from its normal application folder ? > > Below is an excerpt of a filemon log that shows the cache generation. > > Thanks for your help. > > -mab > > 5:47:26 PM XSI.exe:4964 OPEN > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D- > 00A0C9AC19A9x0x1x0.py NOT FOUND Options: Open Access: 00010080 > 5:47:26 PM XSI.exe:4964 OPEN > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D- > 00A0C9AC19A9x0x1x0.pyc NOT FOUND Options: Open Access: 00010080 > 5:47:26 PM XSI.exe:4964 OPEN > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D- > 00A0C9AC19A9x0x1x0.pyo NOT FOUND Options: Open Access: 00010080 > 5:47:26 PM XSI.exe:4964 CREATE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D- > 00A0C9AC19A9x0x1x0\__init__.py SUCCESS Options: OverwriteIf Access: > 00120196 > 5:47:26 PM XSI.exe:4964 QUERY INFORMATION > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D- > 00A0C9AC19A9x0x1x0\__init__.py SUCCESS FileFsVolumeInformation > 5:47:26 PM XSI.exe:4964 QUERY INFORMATION > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11D3-811D- > 00A0C9AC19A9x0x1x0\__init__.py BUFFER OVERFLOW FileAllInformation ^^^^^^^^^^^^^^^ Have you investigated why the above call fails? To me this looks like pywin cannot determine something about the file, and then recreates it just in case... Thomas _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From timr at probo.com Wed May 30 20:08:39 2007 From: timr at probo.com (Tim Roberts) Date: Wed, 30 May 2007 11:08:39 -0700 Subject: [python-win32] Error when trying to open a Microsoft Project file In-Reply-To: References: Message-ID: <465DBDA7.2010103@probo.com> Daryl Spitzer wrote: > I'm trying to open a Microsoft Project file using the following: > > >>>> from win32com.client import Dispatch >>>> a=Dispatch("MSProject.Application") >>>> a.Visible=1 >>>> a.FileOpen("C:\test.mpp") >>>> > > ...but I get this error message. > > Traceback (most recent call last): > File "", line 1, in > File "", line 8, in FileOpen > com_error: (-2147352567, 'Exception occurred.', (1004, 'Microsoft > Office Project', 'Project cannot open the file.', 'C:\\Program > Files\\Microsoft Office\\OFFICE11\\VBAPJ.CHM', 131072, 0), None) > > Project (Standard 2003 SP1) will open C:\test.mpp just fine interactively. > > Can anyone tell me why I'm getting this error message? Yes, I can. You are trying to open a file name with a tab character in it. That is, your file name is C colon tab E S T dot M P P. Use a.FileOpen( "C:\\test.mpp" ) or a.FileOpen( "C:/test.mpp" ) > What is that > 'C:\\Program Files\\Microsoft Office\\OFFICE11\\VBAPJ.CHM' file? It > doesn't exist in that location, but I found it in C:\Program > Files\Microsoft Office\OFFICE11\1033\. I tried copying it to > C:\Program Files\Microsoft Office\OFFICE11\ but I get the same error. > That's the online help. Project is just telling you where you could look for more information about the error message. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From daryl.spitzer at gmail.com Wed May 30 21:00:06 2007 From: daryl.spitzer at gmail.com (Daryl Spitzer) Date: Wed, 30 May 2007 12:00:06 -0700 Subject: [python-win32] Error when trying to open a Microsoft Project file In-Reply-To: <465DBDA7.2010103@probo.com> References: <465DBDA7.2010103@probo.com> Message-ID: D'oh! That's embarrasing. a.FileOpen( r'C:\test.mpp' ) ...works too. I should have clued in to the double backslashes in the path in the error. (I guess it goes without saying that I don't use Python on Windows very often.) Thanks Tim. -- Daryl On 5/30/07, Tim Roberts wrote: > Daryl Spitzer wrote: > > I'm trying to open a Microsoft Project file using the following: > > > > > >>>> from win32com.client import Dispatch > >>>> a=Dispatch("MSProject.Application") > >>>> a.Visible=1 > >>>> a.FileOpen("C:\test.mpp") > >>>> > > > > ...but I get this error message. > > > > Traceback (most recent call last): > > File "", line 1, in > > File "", line 8, in FileOpen > > com_error: (-2147352567, 'Exception occurred.', (1004, 'Microsoft > > Office Project', 'Project cannot open the file.', 'C:\\Program > > Files\\Microsoft Office\\OFFICE11\\VBAPJ.CHM', 131072, 0), None) > > > > Project (Standard 2003 SP1) will open C:\test.mpp just fine interactively. > > > > Can anyone tell me why I'm getting this error message? > > Yes, I can. You are trying to open a file name with a tab character in > it. That is, your file name is C colon tab E S T dot M P P. > > Use > a.FileOpen( "C:\\test.mpp" ) > or > a.FileOpen( "C:/test.mpp" ) > > > > What is that > > 'C:\\Program Files\\Microsoft Office\\OFFICE11\\VBAPJ.CHM' file? It > > doesn't exist in that location, but I found it in C:\Program > > Files\Microsoft Office\OFFICE11\1033\. I tried copying it to > > C:\Program Files\Microsoft Office\OFFICE11\ but I get the same error. > > > > That's the online help. Project is just telling you where you could > look for more information about the error message. > > -- > 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 rbell01824 at earthlink.net Wed May 30 21:30:20 2007 From: rbell01824 at earthlink.net (Richard Bell) Date: Wed, 30 May 2007 14:30:20 -0500 Subject: [python-win32] Getting HRESULT back from a com automation In-Reply-To: <041d01c7a1ee$be0c8b50$1f0a0a0a@enfoldsystems.local> References: <008c01c7a1eb$eb3f5010$6701a8c0@rjbmain> <041d01c7a1ee$be0c8b50$1f0a0a0a@enfoldsystems.local> Message-ID: <004a01c7a2f0$f80582f0$6701a8c0@rjbmain> The GenPY output for IE contains two _dispid_to_func list: _dispid_to_func_ = { 101 : "OnNavigateComplete", 103 : "OnQuit", 201 : "OnFrameNavigateComplete", 108 : "OnProgressChange", 110 : "OnWindowResize", 109 : "OnWindowMove", 104 : "OnDownloadComplete", 107 : "OnNewWindow", 111 : "OnWindowActivate", 102 : "OnStatusTextChange", 200 : "OnFrameBeforeNavigate", 204 : "OnFrameNewWindow", 105 : "OnCommandStateChange", 106 : "OnDownloadBegin", 113 : "OnTitleChange", 100 : "OnBeforeNavigate", 112 : "OnPropertyChange", } _dispid_to_func_ = { 227 : "OnUpdatePageStatus", 270 : "OnFileDownload", 104 : "OnDownloadComplete", 250 : "OnBeforeNavigate2", 269 : "OnSetSecureLockIcon", 108 : "OnProgressChange", 271 : "OnNavigateError", 283 : "OnWindowStateChanged", 105 : "OnCommandStateChange", 268 : "OnClientToHostWindow", 113 : "OnTitleChange", 266 : "OnWindowSetWidth", 259 : "OnDocumentComplete", 256 : "OnMenuBar", 272 : "OnPrivacyImpactedStateChange", 112 : "OnPropertyChange", 255 : "OnToolBar", 260 : "OnTheaterMode", 265 : "OnWindowSetTop", 102 : "OnStatusTextChange", 263 : "OnWindowClosing", 257 : "OnStatusBar", 262 : "OnWindowSetResizable", 251 : "OnNewWindow2", 273 : "OnNewWindow3", 226 : "OnPrintTemplateTeardown", 225 : "OnPrintTemplateInstantiation", 258 : "OnFullScreen", 282 : "OnSetPhishingFilterStatus", 253 : "OnQuit", 264 : "OnWindowSetLeft", 267 : "OnWindowSetHeight", 252 : "OnNavigateComplete2", 106 : "OnDownloadBegin", 254 : "OnVisible", } Does anyone know if these are ALL the IE events passed through by the Python COM interface? I'm curious because the MSDN online documentation for the browser automation objects are not entirely consistent with this list. Thanks for any help. Regards, Richard From pkoning at equallogic.com Wed May 30 21:54:32 2007 From: pkoning at equallogic.com (Paul Koning) Date: Wed, 30 May 2007 15:54:32 -0400 Subject: [python-win32] Error when trying to open a Microsoft Project file References: <465DBDA7.2010103@probo.com> Message-ID: <18013.54904.122141.828472@pkoning.equallogic.com> >>>>> "Tim" == Tim Roberts writes: >> Can anyone tell me why I'm getting this error message? Tim> Yes, I can. You are trying to open a file name with a tab Tim> character in it. That is, your file name is C colon tab E S T Tim> dot M P P. Tim> Use a.FileOpen( "C:\\test.mpp" ) or a.FileOpen( "C:/test.mpp" ) or a.FileOpen (r"C:\test.mpp"). I like raw strings when dealing with DOS style filenames. That way I don't have to double the backslashes and I don't have to remember whether forward slashes are supported in that particular spot. paul From mhammond at skippinet.com.au Thu May 31 00:22:36 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 31 May 2007 08:22:36 +1000 Subject: [python-win32] Win32 COM cache problem In-Reply-To: <0BCB4AE868D8934A8B3DCE3A58126A894EF1FF@tewk-mbpf3> Message-ID: <058c01c7a309$07b1e280$1f0a0a0a@enfoldsystems.local> That is a huge amount of data, and I don't have time to digest it. I'm going to need help to work out why things are happening like this, otherwise I simply am not going to find the time myself. Mark > -----Original Message----- > From: Marc-Andr? Belzile [mailto:mbelzile at softimage.com] > Sent: Thursday, 31 May 2007 1:19 AM > To: Mark Hammond; python-win32 at python.org > Subject: RE: [python-win32] Win32 COM cache problem > > > That's odd, if I copy the tlb in the current folder then the > __init__.py is not recreated: > > 10:33:14 AM XSI.exe:3896 QUERY INFORMATION > C:\Python25\lib\site-packages\win32com\gen_py\__init__.py > SUCCESS Attributes: A > 10:33:14 AM XSI.exe:3896 QUERY INFORMATION > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0.py NOT FOUND Attributes: Error > 10:33:14 AM XSI.exe:3896 QUERY INFORMATION > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0.pyc NOT FOUND > Attributes: Error > >>> 10:33:14 AM XSI.exe:3896 QUERY INFORMATION > C:\Softimage\XSI_6.02_Debug-0528\Application\si3dobjectmo > del.tlb SUCCESS Attributes: A > > Otherwise, multiple write access calls are performed on __init__.py: > > 10:11:50 AM XSI.exe:3896 QUERY INFORMATION > C:\Python25\lib\site-packages\win32com\gen_py\__init__.py > SUCCESS Attributes: A > 10:11:50 AM XSI.exe:3896 QUERY INFORMATION > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0.py NOT FOUND Attributes: Error > 10:11:50 AM XSI.exe:3896 QUERY INFORMATION > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0.pyc NOT FOUND > Attributes: Error > >>> 10:11:50 AM XSI.exe:3896 QUERY INFORMATION > C:\Softimage\XSI_6.02_Debug-0528\Application\si3dobjectmo > del.tlb NOT FOUND Attributes: Error > 10:11:50 AM XSI.exe:3896 QUERY INFORMATION > C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmo > del.tlb SUCCESS Attributes: N > 10:11:50 AM XSI.exe:3896 OPEN > C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmo > del.tlb SUCCESS Options: Open Access: Read > 10:11:50 AM XSI.exe:3896 OPEN > C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmo > del.tlb SUCCESS Options: Open Access: 00100080 > 10:11:50 AM XSI.exe:3896 QUERY INFORMATION > C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmo > del.tlb SUCCESS FileInternalInformation > 10:11:50 AM XSI.exe:3896 QUERY INFORMATION > C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmo > del.tlb SUCCESS Length: 479208 > 10:11:50 AM XSI.exe:3896 READ > C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmo > del.tlb SUCCESS Offset: 0 Length: 64 > 10:11:50 AM XSI.exe:3896 CLOSE > C:\Softimage\XSI_6.02_Debug-0528\Application\bin\si3dobjectmo > del.tlb SUCCESS > 10:11:50 AM XSI.exe:3896 QUERY INFORMATION > C:\Python25\lib\site-packages\win32com\gen_py\__init__.py > SUCCESS Attributes: A > 10:11:50 AM XSI.exe:3896 OPEN > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0.py NOT FOUND Options: Open > Access: 00010080 > 10:11:50 AM XSI.exe:3896 OPEN > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0.pyc NOT FOUND > Options: Open Access: 00010080 > 10:11:50 AM XSI.exe:3896 OPEN > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0.pyo NOT FOUND > Options: Open Access: 00010080 > 10:11:50 AM XSI.exe:3896 CREATE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS > Options: OverwriteIf Access: 00120196 > 10:11:50 AM XSI.exe:3896 QUERY INFORMATION > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS > FileFsVolumeInformation > 10:11:50 AM XSI.exe:3896 QUERY INFORMATION > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py BUFFER OVERFLOW > FileAllInformation > >>> > 10:11:51 AM XSI.exe:3896 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: > 0 Length: 1024 > 10:11:51 AM XSI.exe:3896 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: > 1024 Length: 1024 > 10:11:51 AM XSI.exe:3896 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: > 2048 Length: 1024 > 10:11:51 AM XSI.exe:3896 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: > 3072 Length: 1024 > 10:11:51 AM XSI.exe:3896 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: > 4096 Length: 72 > 10:11:51 AM XSI.exe:3896 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: > 4168 Length: 1024 > 10:11:51 AM XSI.exe:3896 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: > 5192 Length: 1024 > 10:11:51 AM XSI.exe:3896 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: > 6216 Length: 1024 > 10:11:51 AM XSI.exe:3896 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: > 7240 Length: 1024 > 10:11:51 AM XSI.exe:3896 WRITE > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: > 8264 Length: 56 > ... and the list goes on > > The write access calls occur when typelibs are added to the > scripting ActiveX : > > pythonEngine->AddTypeLib( theLibGUID, dwLibMajorVersion, > dwLibMinorVersion, SCRIPTTYPELIB_ISCONTROL ); > > -mab > > -----Original Message----- > From: Mark Hammond [mailto:mhammond at skippinet.com.au] > Sent: May 29, 2007 10:24 PM > To: Marc-Andr? Belzile; python-win32 at python.org > Subject: RE: [python-win32] Win32 COM cache problem > > > I dig a bit more and it appears that the python win32 com module > > requires all target typelibs to be in the app current directory. > > Otherwise the cache is systematically re-generated anytime a new > > scripting engine is created. > > This should not be the case, and there should be no > assumption about the location of the typelib - indeed, we > generally just ask COM to load it for us. I'm afraid I have > no insights to the problems you face, so you might need to > dig a little more to see what is going wrong, or work out a > way so I can reproduce the problem locally. > > Cheers, > > Mark > > > > > Am I doing something wrong ? Thanks in advance... > > > > -mab > > > > -----Original Message----- > > From: python-win32-bounces at python.org > > [mailto:python-win32-bounces at python.org] On Behalf Of Marc-Andr? > > Belzile > > Sent: May 28, 2007 6:28 PM > > To: python-win32 at python.org > > Subject: [python-win32] Win32 COM cache problem > > > > Hi, > > > > My win32 app is hosting python 2.5 via the scripting > ActiveX object. > > Everything works perfectly but the win32 COM cache behaves > strangely > > if the app current folder (e.g. c:\temp) is different than the > > application path (e.g. c:\bin\MyApp). At some point when > the app needs > > to create a new python scripting engine, the whole cache gets > > re-created from scratch which makes things pretty slow. > This will not > > happen if the app is executed from it's normal application folder. > > > > Is there anything I can do to avoid this problem other than running > > the app from its normal application folder ? > > > > Below is an excerpt of a filemon log that shows the cache > generation. > > > > Thanks for your help. > > > > -mab > > > > 5:47:26 PM XSI.exe:4964 OPEN > > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > > D3-811D-00A0C9AC19A9x0x1x0.py NOT FOUND Options: Open > > Access: 00010080 > > 5:47:26 PM XSI.exe:4964 OPEN > > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > > D3-811D-00A0C9AC19A9x0x1x0.pyc NOT FOUND Options: Open > > Access: 00010080 > > 5:47:26 PM XSI.exe:4964 OPEN > > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > > D3-811D-00A0C9AC19A9x0x1x0.pyo NOT FOUND Options: Open > > Access: 00010080 > > 5:47:26 PM XSI.exe:4964 CREATE > > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Options: > > OverwriteIf Access: 00120196 > > 5:47:26 PM XSI.exe:4964 QUERY INFORMATION > > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS > FileFsVolumeInformation > > 5:47:26 PM XSI.exe:4964 QUERY INFORMATION > > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > > D3-811D-00A0C9AC19A9x0x1x0\__init__.py BUFFER OVERFLOW > > FileAllInformation > > 5:47:28 PM XSI.exe:4964 WRITE > > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 0 > Length: 1024 > > 5:47:28 PM XSI.exe:4964 WRITE > > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 1024 > > Length: 1024 > > 5:47:28 PM XSI.exe:4964 WRITE > > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 2048 > > Length: 1024 > > 5:47:28 PM XSI.exe:4964 WRITE > > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 3072 > > Length: 1024 > > 5:47:28 PM XSI.exe:4964 WRITE > > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 4096 > Length: 72 > > 5:47:28 PM XSI.exe:4964 WRITE > > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 4168 > > Length: 1024 > > 5:47:28 PM XSI.exe:4964 WRITE > > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 5192 > > Length: 1024 > > 5:47:28 PM XSI.exe:4964 WRITE > > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 6216 > > Length: 1024 > > 5:47:28 PM XSI.exe:4964 WRITE > > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 7240 > > Length: 1024 > > 5:47:28 PM XSI.exe:4964 WRITE > > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 8264 > Length: 56 > > 5:47:28 PM XSI.exe:4964 WRITE > > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 8320 > > Length: 1024 > > 5:47:28 PM XSI.exe:4964 WRITE > > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 9344 > > Length: 1024 > > 5:47:28 PM XSI.exe:4964 WRITE > > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 10368 > > Length: 1024 > > 5:47:28 PM XSI.exe:4964 WRITE > > C:\Python25\lib\site-packages\win32com\gen_py\269C4D8C-E32D-11 > > D3-811D-00A0C9AC19A9x0x1x0\__init__.py SUCCESS Offset: 11392 > > Length: 1024 etc... > > _______________________________________________ > > Python-win32 mailing list > > Python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > _______________________________________________ > > Python-win32 mailing list > > Python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 5408 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20070531/a3351865/attachment-0001.bin From rbell01824 at earthlink.net Thu May 31 00:24:15 2007 From: rbell01824 at earthlink.net (Richard Bell) Date: Wed, 30 May 2007 17:24:15 -0500 Subject: [python-win32] How to use GetProperty and PutProperty COM interface in IE? In-Reply-To: <009601c7a1ff$0dcefd70$6701a8c0@rjbmain> References: <008c01c7a1eb$eb3f5010$6701a8c0@rjbmain><041d01c7a1ee$be0c8b50$1f0a0a0a@enfoldsystems.local> <009601c7a1ff$0dcefd70$6701a8c0@rjbmain> Message-ID: <005d01c7a309$42a85630$6701a8c0@rjbmain> I'm having trouble using the GetProperty and PutProperty COM interfaces with IE. Example: >>> import win32com.client >>> ie = win32com.client.Dispatch('InternetExplorer.Application') >>> ie.visible >>> ie.Navigate('www.google.com') So there's an IE with a loaded page. >>> dir(ie) ['CLSID', 'ClientToWindow', 'ExecWB', 'GetProperty', 'GoBack', 'GoForward', 'GoHome', 'GoSearch', 'Navigate', 'Navigate2', 'PutProperty', 'QueryStatusWB', 'Quit', 'Refresh', 'Refresh2', 'ShowBrowserBar', 'Stop', '_ApplyTypes_', '__call__', '__cmp__', '__doc__', '__getattr__', '__init__', '__int__', '__module__', '__repr__', '__setattr__', '__str__', '__unicode__', '_get_good_object_', '_get_good_single_object_', '_oleobj_', '_prop_map_get_', '_prop_map_put_', 'coclass_clsid'] Clearly there are GetProperty and PutProperty methods. >>> ie._prop_map_put_.keys() ['FullScreen', 'Width', 'Silent', 'Resizable', 'Visible', 'RegisterAsBrowser', 'StatusText', 'Top', 'Height', 'RegisterAsDropTarget', 'StatusBar', 'TheaterMode', 'Offline', 'Left', 'AddressBar', 'ToolBar', 'MenuBar'] >>> ie._prop_map_get_.keys() ['ReadyState', 'Busy', 'Container', 'Silent', 'Top', 'RegisterAsDropTarget', 'LocationName', 'Application', 'Offline', 'Document', 'Type', 'ToolBar', 'MenuBar', 'FullScreen', 'Parent', 'TheaterMode', 'Path', 'Name', 'RegisterAsBrowser', 'StatusText', 'Left', 'TopLevelContainer', 'Resizable', 'Width', 'StatusBar', 'HWND', 'Height', 'Visible', 'FullName', 'LocationURL', 'AddressBar'] Clearly there is a 'Height' property for Put and Get. >>> ie.Height = 600 Actually changes IE's height. >>> ie.Height 600 Reports it. But ... >>> print ie.GetProperty('Height') None >>> And ... >>> print ie.PutProperty('Height', 400) None >>> Does nothing. Any clues how to use the GetProperty and PutProperty methods? Thanks! Richard From timr at probo.com Thu May 31 02:03:03 2007 From: timr at probo.com (Tim Roberts) Date: Wed, 30 May 2007 17:03:03 -0700 Subject: [python-win32] How to use GetProperty and PutProperty COM interface in IE? In-Reply-To: <005d01c7a309$42a85630$6701a8c0@rjbmain> References: <008c01c7a1eb$eb3f5010$6701a8c0@rjbmain><041d01c7a1ee$be0c8b50$1f0a0a0a@enfoldsystems.local> <009601c7a1ff$0dcefd70$6701a8c0@rjbmain> <005d01c7a309$42a85630$6701a8c0@rjbmain> Message-ID: <465E10B7.70207@probo.com> Richard Bell wrote: > I'm having trouble using the GetProperty and PutProperty COM interfaces with > IE. ... >>>> ie.Height = 600 >>>> > > Actually changes IE's height. > > >>>> ie.Height >>>> > 600 > Reports it. > But ... > >>>> print ie.GetProperty('Height') >>>> > None > And ... > > >>>> print ie.PutProperty('Height', 400) >>>> > None > Does nothing. > > Any clues how to use the GetProperty and PutProperty methods? > I may be mistaken, but from my reading of the documents, GetProperty and PutProperty are intended to pass property information to the web page currently being displayed, not as an alternate method of manipulating the properties of the IE object itself. http://msdn2.microsoft.com/en-us/library/ms976136.aspx -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rbell01824 at earthlink.net Thu May 31 16:42:46 2007 From: rbell01824 at earthlink.net (Richard Bell) Date: Thu, 31 May 2007 09:42:46 -0500 Subject: [python-win32] How to use GetProperty and PutProperty COM interface in IE? In-Reply-To: <465E10B7.70207@probo.com> References: <008c01c7a1eb$eb3f5010$6701a8c0@rjbmain><041d01c7a1ee$be0c8b50$1f0a0a0a@enfoldsystems.local> <009601c7a1ff$0dcefd70$6701a8c0@rjbmain><005d01c7a309$42a85630$6701a8c0@rjbmain> <465E10B7.70207@probo.com> Message-ID: <002801c7a391$f4e3be60$6701a8c0@rjbmain> Tim, You are, of course, completely right as this example which may be useful to others shows. >>> import win32com.client >>> ie=win32com.client.Dispatch('InternetExplorer.Application') >>> ie.Visible=True >>> ie.Navigate('www.cnn.com') >>> ie.PutProperty('aProperty', 'this is the value') >>> ie.GetProperty('aProperty') u'this is the value' >>> Interestingly >>> ie.Navigate('www.cnn.com') >>> ie.GetProperty('aProperty') u'this is the value' >>> so the property is preserved across navigation as the reference describes. Thanks again for your help. Regards, Richard | |I may be mistaken, but from my reading of the documents, GetProperty and |PutProperty are intended to pass property information to the web page |currently being displayed, not as an alternate method of manipulating |the properties of the IE object itself. | | http://msdn2.microsoft.com/en-us/library/ms976136.aspx | |-- |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