From lkcl at lkcl.net Mon Aug 3 00:22:11 2009 From: lkcl at lkcl.net (lkcl) Date: Sun, 2 Aug 2009 15:22:11 -0700 (PDT) Subject: [python-win32] MSHTML wrapper class and example using IWebBrowser2 Message-ID: <24782740.post@talk.nabble.com> hi there, from about a dozen different sources i've managed to put together something similar to the old ctypes atl.py example. the purpose of the exercise is to create a port of pyjamas-desktop to MSHTML, and to do that, i need a GDK window in which an IWebBrowser2 COM object is the only object, and then to get access to its Document. i'll be committing the code as free software in the next few days to the svn repository for http://pyjs.org but i wanted to point people at this example code in the mean time: http://lkcl.net/pyjamas - ie_in_gtk.py and ie_in_win.py as you can see they're a bit of a mess because i took stuff from a boat-load of different places and just whopped it all together until something worked how i wanted. now that i have the proof-of-concept, i'll be quickly moving on to encompass absolutely every single bit of the MSHTML DOM model and i do mean absolutely all of it (and including XMLHttpRequest). the reason is that pyjamas-desktop relies on manipulation of the DOM model to create the widget set API. currently supported is XULRunner and pywebkitgtk but win32 users are left out in the cold somewhat so... MSHTML-time it is. what's particularly strategically important is that the intermediate DOM wrapper classes, of which there are two (pyjd/hula.py and pyjd/pywebkitgtk.py) make the DOM look *absolutely identical* as far as the interface is concerned. i'll be adding an _mshtml.py wrapper which - again - makes the DOM look utterly and 100% identical to the other two. just to emphasise that in a different way: with these three DOM wrapper modules it will be possible to write python web browser engine applications that will work across a ton of different platforms, whether they be Win32, Mac, GNU/Linux, FreeBSD or embedded devices. the wrapper class, _mshtml.py, it's worth noting, will take care of COM "coclass" interfaces. one of the lairy daft messes in MSHTML.IDL is the melding of different COM interfaces, and you're expected to either know or remember what to do, typecasting objects using QueryInterface to the right type, before accessing the required property or function. ... i can't be bothered with that kind of crap :) so, the _mshtml.py class will take care of it, and so instead of this: style.left = 0 style2 = style.QueryInterface(MSHTML.IHTMLStyle2) style2.position = "absolute" you just do this: style.left = 0 style.position = "absolute" ahhhh, peace of miiind :) behind the scenes, there's a coclass wrapper which inherits from the necessary classes (in this case, _mshtml.IHTMLStyle2, _mshtml.IHTMLStyle3 .... etc.) and each of those classes has properties: def _get_position(self): return wrap(self.__get_instance_IHTMLStyle3().position position = property(self._get_position,....) def __get_instance_IHTMLStyle3(self): return self.__instance__.QueryInterface(MSHTML.IHTMLStyle3) etc. etc. so - not blazingly efficient, but that's the price to pay for convenience. if you're interested, keep an eye on http://pyjs.org svn repository, pyjamas/pyjd subdirectory, over the next few days. l. -- View this message in context: http://www.nabble.com/MSHTML-wrapper-class-and-example-using-IWebBrowser2-tp24782740p24782740.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From arve.knudsen at gmail.com Mon Aug 3 16:48:37 2009 From: arve.knudsen at gmail.com (Arve Knudsen) Date: Mon, 3 Aug 2009 16:48:37 +0200 Subject: [python-win32] IADsGroup not wrapped? Message-ID: Hi When requesting the IADsGroup interface from an Active Directory group object, I get a TypeError saying that: 'There is no interface object registered that supports this IID'. Does this mean that pywin32 does not wrap this interface? If so, is this easily fixed? Thanks, Arve -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdriscoll at co.marshall.ia.us Mon Aug 3 16:53:30 2009 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Mon, 03 Aug 2009 09:53:30 -0500 Subject: [python-win32] Please suggest me a good Python MAPI module... In-Reply-To: References: Message-ID: <4A76F9EA.4090408@co.marshall.ia.us> durumdara at gmail.com wrote: > Hi! > > I'm searching a good Python MAPI module... > > I wanna send many pictures, I wanna split them into 5 MB sized mails, > and I wanna see them in default mailer as new mails. > > The sending is not needed, only mapi call with "New mail/Mailto" and > with attachments. > > Thanks for your help: > dd I think you're looking for is the email module. See the following: http://docs.python.org/library/email http://docs.python.org/library/email-examples.html The second link actually has code that sounds almost like what you want to do. - Mike From gerdusvanzyl at gmail.com Mon Aug 3 16:54:04 2009 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Mon, 3 Aug 2009 16:54:04 +0200 Subject: [python-win32] MSHTML wrapper class and example using IWebBrowser2 In-Reply-To: <24782740.post@talk.nabble.com> References: <24782740.post@talk.nabble.com> Message-ID: <91882ea90908030754y52a7e3d2taf3f53f82bdf3251@mail.gmail.com> very nice! I was looking at pyjd a while back but didn't like the gtk dependency. Any posibility on porting hulahop to windows? ~Gerdus On Mon, Aug 3, 2009 at 12:22 AM, lkcl wrote: > > hi there, > > from about a dozen different sources i've managed to put together something > similar to the old ctypes atl.py example. ?the purpose of the exercise is to > create a port of pyjamas-desktop to MSHTML, and to do that, i need a GDK > window in which an IWebBrowser2 COM object is the only object, and then to > get access to its Document. > > i'll be committing the code as free software in the next few days to the svn > repository for http://pyjs.org but i wanted to point people at this example > code in the mean time: > http://lkcl.net/pyjamas - ie_in_gtk.py and ie_in_win.py > > as you can see they're a bit of a mess because i took stuff from a boat-load > of different places and just whopped it all together until something worked > how i wanted. > > now that i have the proof-of-concept, i'll be quickly moving on to encompass > absolutely every single bit of the MSHTML DOM model and i do mean absolutely > all of it (and including XMLHttpRequest). ?the reason is that > pyjamas-desktop relies on manipulation of the DOM model to create the widget > set API. ?currently supported is XULRunner and pywebkitgtk but win32 users > are left out in the cold somewhat so... MSHTML-time it is. > > what's particularly strategically important is that the intermediate DOM > wrapper classes, of which there are two (pyjd/hula.py and > pyjd/pywebkitgtk.py) make the DOM look *absolutely identical* as far as the > interface is concerned. ?i'll be adding an _mshtml.py wrapper which - again > - makes the DOM look utterly and 100% identical to the other two. > > just to emphasise that in a different way: with these three DOM wrapper > modules it will be possible to write python web browser engine applications > that will work across a ton of different platforms, whether they be Win32, > Mac, GNU/Linux, FreeBSD or embedded devices. > > the wrapper class, _mshtml.py, it's worth noting, will take care of COM > "coclass" interfaces. ?one of the lairy daft messes in MSHTML.IDL is the > melding of different COM interfaces, and you're expected to either know or > remember what to do, typecasting objects using QueryInterface to the right > type, before accessing the required property or function. > > ... i can't be bothered with that kind of crap :) > > so, the _mshtml.py class will take care of it, and so instead of this: > > ? style.left = 0 > ? style2 = style.QueryInterface(MSHTML.IHTMLStyle2) > ? style2.position = "absolute" > > you just do this: > > ? style.left = 0 > ? style.position = "absolute" > > ahhhh, peace of miiind :) > > behind the scenes, there's a coclass wrapper which inherits from the > necessary classes (in this case, _mshtml.IHTMLStyle2, _mshtml.IHTMLStyle3 > .... etc.) and each of those classes has properties: > > ? def _get_position(self): > ? ? ? ?return wrap(self.__get_instance_IHTMLStyle3().position > ? position = property(self._get_position,....) > > ? def __get_instance_IHTMLStyle3(self): > ? ? ?return self.__instance__.QueryInterface(MSHTML.IHTMLStyle3) > > etc. etc. > > so - not blazingly efficient, but that's the price to pay for convenience. > > if you're interested, keep an eye on http://pyjs.org svn repository, > pyjamas/pyjd subdirectory, over the next few days. > > l. > -- > View this message in context: http://www.nabble.com/MSHTML-wrapper-class-and-example-using-IWebBrowser2-tp24782740p24782740.html > Sent from the Python - python-win32 mailing list archive at Nabble.com. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From lkcl at lkcl.net Mon Aug 3 17:50:49 2009 From: lkcl at lkcl.net (Luke Kenneth Casson Leighton) Date: Mon, 3 Aug 2009 15:50:49 +0000 Subject: [python-win32] MSHTML wrapper class and example using IWebBrowser2 In-Reply-To: <91882ea90908030754y52a7e3d2taf3f53f82bdf3251@mail.gmail.com> References: <24782740.post@talk.nabble.com> <91882ea90908030754y52a7e3d2taf3f53f82bdf3251@mail.gmail.com> Message-ID: On 8/3/09, Gerdus van Zyl wrote: > very nice! I was looking at pyjd a while back but didn't like the gtk > dependency. that's why i based mshtml.py on the Win32 GDI not gtk. > Any posibility on porting hulahop to windows? it's tricky as hell - it's a _whopping_ great build. you start with python, then you build xulrunner/win32 making sure that you enable both xpcom and python-xpcom subcomponent, _then_ you can build hulahop, theeeen you can use pyjd w/hulahop-win32. oh - and don't forget to get that proprietary compiler, to build it all, unless you want to try (like i did) building python with mingw32 (which actually worked, but the python-dev team didn't understand why it would be needed, and deemed it a waste of time, so i stopped)... not even the sugarlabs team have tackled this one. last time i looked, there _was_ a vague reference somewhere on a novell web site which had the xulrunner-xpcom build, but i don't know if it included python-xpcom as well. .... to be absolutely honest, building webkit patched with #16401 isn't much better, either: you _still_ have to have libpython2.N.dll.a (or python2N.lib if you use the proprietary compiler). so to cut a long story short, this is the whole reason why i'm doing the MSHTML build. at least you only need win32con, ctypes and a few other small standard python libraries, and you're away. with exactly the same API (that's the plan, anyway. wish me luck...) l. From arve.knudsen at gmail.com Mon Aug 3 10:23:46 2009 From: arve.knudsen at gmail.com (Arve Knudsen) Date: Mon, 3 Aug 2009 10:23:46 +0200 Subject: [python-win32] PyIADsUser.put_LastName Message-ID: Hi Is there any reason for PyIADsUser.put_LastName not being implemented (while put_FirstName is implemented)? See http://docs.activestate.com/activepython/2.5/pywin32/PyIADsUser.html. Thanks, Arve -------------- next part -------------- An HTML attachment was scrubbed... URL: From arve.knudsen at gmail.com Mon Aug 3 18:56:46 2009 From: arve.knudsen at gmail.com (Arve Knudsen) Date: Mon, 3 Aug 2009 18:56:46 +0200 Subject: [python-win32] IADsContainer.GetObject returns objects of different type than IADsContainer.Create Message-ID: Hello I am thoroughly confused by win32com.adsi at this point. Right now I am finding that IADsContainer.GetObject returns objects of a different type than IADsContainer.Create, that expose only a subset of the expected methods! For instance I have to set the members of a group, using the method PutEx, which I can do just fine by first querying the IADsContainer interface on the object returned by Create. However, if I try to do the same with an object returned by GetObject, it doesn't have this method (although it does have "Put")! If I print the presentation of an object returned by Create, it looks like this: . The representation of an object returned by GetObject: . Someone please explain what's going on :) Arve -------------- next part -------------- An HTML attachment was scrubbed... URL: From lkcl at lkcl.net Mon Aug 3 12:13:30 2009 From: lkcl at lkcl.net (lkcl) Date: Mon, 3 Aug 2009 03:13:30 -0700 (PDT) Subject: [python-win32] MSHTML wrapper class and example using IWebBrowser2 In-Reply-To: <24782740.post@talk.nabble.com> References: <24782740.post@talk.nabble.com> Message-ID: <24788289.post@talk.nabble.com> as promised the mshtml.py "loader", _mshtml.py "wrapper" and the experiment ie_in_win.py have been committed here: http://pyjamas.svn.sourceforge.net/viewvc/pyjamas/trunk/pyjd/ -- View this message in context: http://www.nabble.com/MSHTML-wrapper-class-and-example-using-IWebBrowser2-tp24782740p24788289.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From timr at probo.com Mon Aug 3 22:24:52 2009 From: timr at probo.com (Tim Roberts) Date: Mon, 03 Aug 2009 13:24:52 -0700 Subject: [python-win32] IADsContainer.GetObject returns objects of different type than IADsContainer.Create In-Reply-To: References: Message-ID: <4A774794.7000309@probo.com> Arve Knudsen wrote: > > I am thoroughly confused by win32com.adsi at this point. Right now I > am finding that IADsContainer.GetObject returns objects of a different > type than IADsContainer.Create, that expose only a subset of the > expected methods! How do you know? Are you using dir() to look at the list of methods? That's not reliable with COM objects, unless you have used makepy on them. The win32com stuff doesn't go query the complete list of methods and properties. When you ask for one, it checks for it, and will remember that for later. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From arve.knudsen at gmail.com Mon Aug 3 23:17:09 2009 From: arve.knudsen at gmail.com (Arve Knudsen) Date: Mon, 3 Aug 2009 23:17:09 +0200 Subject: [python-win32] IADsContainer.GetObject returns objects of different type than IADsContainer.Create In-Reply-To: <4A774794.7000309@probo.com> References: <4A774794.7000309@probo.com> Message-ID: Well, for one the representations of the objects returned by the two methods are different and with one type I can access .PutEx but not with the other. Arve On 8/3/09, Tim Roberts wrote: > Arve Knudsen wrote: >> >> I am thoroughly confused by win32com.adsi at this point. Right now I >> am finding that IADsContainer.GetObject returns objects of a different >> type than IADsContainer.Create, that expose only a subset of the >> expected methods! > > How do you know? Are you using dir() to look at the list of methods? > That's not reliable with COM objects, unless you have used makepy on > them. The win32com stuff doesn't go query the complete list of methods > and properties. When you ask for one, it checks for it, and will > remember that for later. > > -- > 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 > -- Sent from my mobile device From kekkonen.kimmo at gmail.com Mon Aug 3 17:05:19 2009 From: kekkonen.kimmo at gmail.com (Kimmo Kekkonen) Date: Mon, 03 Aug 2009 18:05:19 +0300 Subject: [python-win32] Dealing with windows in Windows Message-ID: <1249311919.3628.1.camel@kekkoset-desktop> Hi! I were wondering if it is possible to use Python to select a window (by title or somehow) and then input text into it? I'd need the trick to input text to program I am running from cmd. When program opens it also opens one "GUI" window and focus to the cmd will lost. Now I'd like to get focus back to cmd and then input text into it. I tried PIPEs with Popen but after 6 hours of work it still did not work. I think it is because of this my program. Also I am trying to close active window. Is there a solution to send "alt+f4" to currently active window? I managed to do these tricks using WSH but I would like to use Python so I would not have to do these "window activations and closing" by WSH. Then I will have 100% Python script without any others. Thanks in advance! -------------- next part -------------- An HTML attachment was scrubbed... URL: From arve.knudsen at gmail.com Tue Aug 4 09:56:24 2009 From: arve.knudsen at gmail.com (Arve Knudsen) Date: Tue, 4 Aug 2009 09:56:24 +0200 Subject: [python-win32] IADsContainer.GetObject returns objects of different type than IADsContainer.Create In-Reply-To: References: <4A774794.7000309@probo.com> Message-ID: To exemplify, when I try to call PutEx on , which was obtained by calling QueryInterface(IID_IADs) on an object returned from IADsContainer.GetObject, I get an AttributeError: 'PyIADs' object has no attribute 'PutEx'. This correlates with the documentation for PyIADs at http://docs.activestate.com/activepython/2.5/pywin32/PyIADs.html. The __class__ of objects returned by GetObject, is , whereas for Create it is . Why not just the second class, which appears more complete (i.e., it implements PutEx)? Arve On Mon, Aug 3, 2009 at 11:17 PM, Arve Knudsen wrote: > Well, for one the representations of the objects returned by the two > methods are different and with one type I can access .PutEx but not > with the other. > > Arve > > On 8/3/09, Tim Roberts wrote: > > Arve Knudsen wrote: > >> > >> I am thoroughly confused by win32com.adsi at this point. Right now I > >> am finding that IADsContainer.GetObject returns objects of a different > >> type than IADsContainer.Create, that expose only a subset of the > >> expected methods! > > > > How do you know? Are you using dir() to look at the list of methods? > > That's not reliable with COM objects, unless you have used makepy on > > them. The win32com stuff doesn't go query the complete list of methods > > and properties. When you ask for one, it checks for it, and will > > remember that for later. > > > > -- > > 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 > > > > -- > Sent from my mobile device > -------------- next part -------------- An HTML attachment was scrubbed... URL: From arve.knudsen at gmail.com Tue Aug 4 10:49:06 2009 From: arve.knudsen at gmail.com (Arve Knudsen) Date: Tue, 4 Aug 2009 10:49:06 +0200 Subject: [python-win32] IADsContainer.GetObject returns objects of different type than IADsContainer.Create In-Reply-To: References: <4A774794.7000309@probo.com> Message-ID: Looking at the implementation of PyIADs, I can see that the PutEx implementation is commented out. This just gets more and more mysterious, to me at least. Arve On Tue, Aug 4, 2009 at 9:56 AM, Arve Knudsen wrote: > To exemplify, when I try to call PutEx on 0x003C1EB8>, which was obtained by calling QueryInterface(IID_IADs) on an > object returned from IADsContainer.GetObject, I get an AttributeError: > 'PyIADs' object has no attribute 'PutEx'. This correlates with the > documentation for PyIADs at > http://docs.activestate.com/activepython/2.5/pywin32/PyIADs.html. > The __class__ of objects returned by GetObject, is , whereas > for Create it is . Why not > just the second class, which appears more complete (i.e., it implements > PutEx)? > > Arve > > On Mon, Aug 3, 2009 at 11:17 PM, Arve Knudsen wrote: > >> Well, for one the representations of the objects returned by the two >> methods are different and with one type I can access .PutEx but not >> with the other. >> >> Arve >> >> On 8/3/09, Tim Roberts wrote: >> > Arve Knudsen wrote: >> >> >> >> I am thoroughly confused by win32com.adsi at this point. Right now I >> >> am finding that IADsContainer.GetObject returns objects of a different >> >> type than IADsContainer.Create, that expose only a subset of the >> >> expected methods! >> > >> > How do you know? Are you using dir() to look at the list of methods? >> > That's not reliable with COM objects, unless you have used makepy on >> > them. The win32com stuff doesn't go query the complete list of methods >> > and properties. When you ask for one, it checks for it, and will >> > remember that for later. >> > >> > -- >> > 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 >> > >> >> -- >> Sent from my mobile device >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdriscoll at co.marshall.ia.us Tue Aug 4 16:49:15 2009 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Tue, 04 Aug 2009 09:49:15 -0500 Subject: [python-win32] Dealing with windows in Windows In-Reply-To: <1249311919.3628.1.camel@kekkoset-desktop> References: <1249311919.3628.1.camel@kekkoset-desktop> Message-ID: <4A784A6B.9030500@co.marshall.ia.us> Kimmo Kekkonen wrote: > Hi! > > I were wondering if it is possible to use Python to select a window > (by title or somehow) and then input text into it? I'd need the trick > to input text to program I am running from cmd. When program opens it > also opens one "GUI" window and focus to the cmd will lost. Now I'd > like to get focus back to cmd and then input text into it. I tried > PIPEs with Popen but after 6 hours of work it still did not work. I > think it is because of this my program. > > Also I am trying to close active window. Is there a solution to send > "alt+f4" to currently active window? There's SendKeys: http://pypi.python.org/pypi/SendKeys/0.3 Or if you know the application will only have one instance running at any one time, you can use the sledgehammer approach and do one of the following: from killProcName import killProcName killProcName(procName) or import subprocess subprocess.Popen('taskkill /f /im evilGUI_process.exe') Note that the first method presumes that you have PyWin32 installed as it is included with that package. On my PC, it's located here: C:\Python25\Lib\site-packages\win32\scripts > > I managed to do these tricks using WSH but I would like to use Python > so I would not have to do these "window activations and closing" by > WSH. Then I will have 100% Python script without any others. > > Thanks in advance! HTH - Mike From durumdara at gmail.com Tue Aug 4 17:05:57 2009 From: durumdara at gmail.com (durumdara at gmail.com) Date: Tue, 04 Aug 2009 17:05:57 +0200 Subject: [python-win32] Please suggest me a good Python MAPI module... In-Reply-To: <4A76F9EA.4090408@co.marshall.ia.us> References: <4A76F9EA.4090408@co.marshall.ia.us> Message-ID: Hi! On Mon, 03 Aug 2009 16:53:30 +0200, Mike Driscoll wrote: > durumdara at gmail.com wrote: >> Hi! >> >> I'm searching a good Python MAPI module... >> >> I wanna send many pictures, I wanna split them into 5 MB sized mails, >> and I wanna see them in default mailer as new mails. >> >> The sending is not needed, only mapi call with "New mail/Mailto" and >> with attachments. >> >> Thanks for your help: >> dd > > I think you're looking for is the email module. See the following: Not-not! :-) I wanna search for a good working module that can open a default mail client with MAPI as I predefine it: with sender/recips/body/subject/attachments... I have same routine in Delphi, but I wanna realize this in Python. With your technics (email) I can create and send email, and I can create EML files. But I cannot import them into Thunderbird, only once in one time... :-( I search for a solution that uses MAPI to I can change some things before I send the mails, and I can control the sending. Thanks: dd From vernondcole at gmail.com Tue Aug 4 17:54:27 2009 From: vernondcole at gmail.com (Vernon Cole) Date: Tue, 4 Aug 2009 09:54:27 -0600 Subject: [python-win32] Dealing with windows in Windows In-Reply-To: <1249311919.3628.1.camel@kekkoset-desktop> References: <1249311919.3628.1.camel@kekkoset-desktop> Message-ID: I have successfully used windpysend for several years. It is not elegant -- you have to feed the characters slowly -- but works reliably enough that I automated several casino server start-up scripts using it, and the casino is very happy that the users no longer foul things up. It is not open source, but the license is inexpensive. See: http://users.swing.be/wintclsend/windpysend/ -- Vernon Cole On Mon, Aug 3, 2009 at 9:05 AM, Kimmo Kekkonen wrote: > Hi! > > I were wondering if it is possible to use Python to select a window > (by title or somehow) and then input text into it? I'd need the trick > to input text to program I am running from cmd. When program opens it > also opens one "GUI" window and focus to the cmd will lost. Now I'd > like to get focus back to cmd and then input text into it. I tried > PIPEs with Popen but after 6 hours of work it still did not work. I > think it is because of this my program. > > Also I am trying to close active window. Is there a solution to send > "alt+f4" to currently active window? > > I managed to do these tricks using WSH but I would like to use Python > so I would not have to do these "window activations and closing" by > WSH. Then I will have 100% Python script without any others. > > Thanks in advance! > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Aug 4 18:48:25 2009 From: timr at probo.com (Tim Roberts) Date: Tue, 04 Aug 2009 09:48:25 -0700 Subject: [python-win32] Dealing with windows in Windows In-Reply-To: <1249311919.3628.1.camel@kekkoset-desktop> References: <1249311919.3628.1.camel@kekkoset-desktop> Message-ID: <4A786659.5010708@probo.com> Kimmo Kekkonen wrote: > > I were wondering if it is possible to use Python to select a window > (by title or somehow) and then input text into it? I'd need the trick > to input text to program I am running from cmd. When program opens it > also opens one "GUI" window and focus to the cmd will lost. Now I'd > like to get focus back to cmd and then input text into it. I tried > PIPEs with Popen but after 6 hours of work it still did not work. I > think it is because of this my program. Windows GUI apps do not communicate using stdin and stdout. Instead, everything is done via window messages. You need to use the Win32 API for this. You can use win32gui.FindWindow to locate your window by title. If you're trying to send to a particular control inside that window, you'll probably have to enumerate the children of that window, which can be a bit tedious. Once you have your target, you might be able to use win32gui.SetWindowText to send a string to it (depending on the control type). You can use other messages to click buttons in the window. > Also I am trying to close active window. Is there a solution to send > "alt+f4" to currently active window? You can use win32api.SendMessage to send a WM_CLOSE message to the window. That's usually enough. > I managed to do these tricks using WSH but I would like to use Python > so I would not have to do these "window activations and closing" by > WSH. Then I will have 100% Python script without any others. If you post your WSH script, perhaps we can translate it for you. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From whatyoulookin at yahoo.com Tue Aug 4 23:04:43 2009 From: whatyoulookin at yahoo.com (Alec Bennett) Date: Tue, 4 Aug 2009 14:04:43 -0700 (PDT) Subject: [python-win32] faster way to get printer status? Message-ID: <882731.24407.qm@web112618.mail.gq1.yahoo.com> I'm trying to get the online/offline status of a printer, and using WMI I'm finding it very slow. Here's the code I'm working, maybe there's some way to opimize it? Or some other way? I'm able to use win32print to query the status of an online printer, but not to find out whether its online or not (its pStatus always returns 'Idle'). def check_printer(printer_name): .....c = wmi.WMI () .....for p in c.Win32_Printer(): ..........if p.caption == printer_name: ...............if p.WorkOffline: ..................print "its offline" ...............else: ..................print "its online" From Marc-Andre.Belzile at autodesk.com Tue Aug 4 19:55:07 2009 From: Marc-Andre.Belzile at autodesk.com (Marc-Andre Belzile) Date: Tue, 4 Aug 2009 10:55:07 -0700 Subject: [python-win32] pywin32 build 214 released In-Reply-To: References: <4A5419F8.50405@skippinet.com.au> <904A0B8F53C34AA2B491FEA30946FDA1@efcore> <4A545B6C.1010401@gmail.com> Message-ID: Hi, I can't install build 214 (amd64), the installer gives this error message --------------------------- Cannot install --------------------------- Python version 3.1 required, which was not found in the registry. --------------------------- OK --------------------------- Is there anything special to do to get passed this ? Yes, I've installed python 3.1 thanks for your help. -mab -----Original Message----- From: python-win32-bounces+marc-andre.belzile=autodesk.com at python.org [mailto:python-win32-bounces+marc-andre.belzile=autodesk.com at python.org] On Behalf Of Elias Fotinis Sent: Wednesday, July 08, 2009 6:22 AM To: mhammond at skippinet.com.au Cc: Python-win32 at python.org Subject: Re: [python-win32] pywin32 build 214 released From: "Mark Hammond" > Thanks for the note - can someone with build 213 for Python 3.0 installed > check if they have the same problem or not (ie, if it is a regression or > just the first report of a problem existing for a few months)? I just tried 213 for 3.0.1 and it works OK, so it looks like a 214/3.1 regression. > Ideally an issue should be opened at sourceforge too - I'm busy at the > moment, so may end up forgetting about then when I next find pywin32 > time... Done: http://sourceforge.net/tracker/?func=detail&aid=2818443&group_id=78018&atid=551954 _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From mhammond at skippinet.com.au Wed Aug 5 01:25:19 2009 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 05 Aug 2009 09:25:19 +1000 Subject: [python-win32] pywin32 build 214 released In-Reply-To: References: <4A5419F8.50405@skippinet.com.au> <904A0B8F53C34AA2B491FEA30946FDA1@efcore> <4A545B6C.1010401@gmail.com> Message-ID: <4A78C35F.5040804@skippinet.com.au> On 5/08/2009 3:55 AM, Marc-Andre Belzile wrote: > Hi, > > I can't install build 214 (amd64), the installer gives this error message > > --------------------------- > Cannot install > --------------------------- > Python version 3.1 required, which was not found in the registry. > --------------------------- > OK > --------------------------- > > Is there anything special to do to get passed this ? Yes, I've installed python 3.1 My guess is you made a mismatch between the 64 and 32 bit versions of Python and Pywin32 - ie, you probably have the 32bit version of Python 3.1, but the 64bit version of PyWin32. Cheers, Mark. > > -----Original Message----- > From: python-win32-bounces+marc-andre.belzile=autodesk.com at python.org [mailto:python-win32-bounces+marc-andre.belzile=autodesk.com at python.org] On Behalf Of Elias Fotinis > Sent: Wednesday, July 08, 2009 6:22 AM > To: mhammond at skippinet.com.au > Cc: Python-win32 at python.org > Subject: Re: [python-win32] pywin32 build 214 released > > From: "Mark Hammond" >> Thanks for the note - can someone with build 213 for Python 3.0 installed >> check if they have the same problem or not (ie, if it is a regression or >> just the first report of a problem existing for a few months)? > > I just tried 213 for 3.0.1 and it works OK, so it looks like a 214/3.1 > regression. > >> Ideally an issue should be opened at sourceforge too - I'm busy at the >> moment, so may end up forgetting about then when I next find pywin32 >> time... > > Done: > http://sourceforge.net/tracker/?func=detail&aid=2818443&group_id=78018&atid=551954 > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From Marc-Andre.Belzile at autodesk.com Wed Aug 5 15:06:21 2009 From: Marc-Andre.Belzile at autodesk.com (Marc-Andre Belzile) Date: Wed, 5 Aug 2009 06:06:21 -0700 Subject: [python-win32] pywin32 build 214 released In-Reply-To: <4A78C35F.5040804@skippinet.com.au> References: <4A5419F8.50405@skippinet.com.au> <904A0B8F53C34AA2B491FEA30946FDA1@efcore> <4A545B6C.1010401@gmail.com> <4A78C35F.5040804@skippinet.com.au> Message-ID: Yes, sorry, I just realized that after sending the mail. I have another problem though when I try to bind the scripting engine to the script site object in my C++ app. Calling IActiveScript::SetScriptSite returns E_FAIL. I haven't try yet with 3.0 and build 213. Is it a known regression with 214? thanks -mab -----Original Message----- From: Mark Hammond [mailto:mhammond at skippinet.com.au] Sent: Tuesday, August 04, 2009 7:25 PM To: Marc-Andre Belzile Cc: Python-win32 at python.org Subject: Re: [python-win32] pywin32 build 214 released On 5/08/2009 3:55 AM, Marc-Andre Belzile wrote: > Hi, > > I can't install build 214 (amd64), the installer gives this error message > > --------------------------- > Cannot install > --------------------------- > Python version 3.1 required, which was not found in the registry. > --------------------------- > OK > --------------------------- > > Is there anything special to do to get passed this ? Yes, I've installed python 3.1 My guess is you made a mismatch between the 64 and 32 bit versions of Python and Pywin32 - ie, you probably have the 32bit version of Python 3.1, but the 64bit version of PyWin32. Cheers, Mark. > > -----Original Message----- > From: python-win32-bounces+marc-andre.belzile=autodesk.com at python.org [mailto:python-win32-bounces+marc-andre.belzile=autodesk.com at python.org] On Behalf Of Elias Fotinis > Sent: Wednesday, July 08, 2009 6:22 AM > To: mhammond at skippinet.com.au > Cc: Python-win32 at python.org > Subject: Re: [python-win32] pywin32 build 214 released > > From: "Mark Hammond" >> Thanks for the note - can someone with build 213 for Python 3.0 installed >> check if they have the same problem or not (ie, if it is a regression or >> just the first report of a problem existing for a few months)? > > I just tried 213 for 3.0.1 and it works OK, so it looks like a 214/3.1 > regression. > >> Ideally an issue should be opened at sourceforge too - I'm busy at the >> moment, so may end up forgetting about then when I next find pywin32 >> time... > > Done: > http://sourceforge.net/tracker/?func=detail&aid=2818443&group_id=78018&atid=551954 > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From mhammond at skippinet.com.au Wed Aug 5 16:12:49 2009 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 06 Aug 2009 00:12:49 +1000 Subject: [python-win32] pywin32 build 214 released In-Reply-To: References: <4A5419F8.50405@skippinet.com.au> <904A0B8F53C34AA2B491FEA30946FDA1@efcore> <4A545B6C.1010401@gmail.com> <4A78C35F.5040804@skippinet.com.au> Message-ID: <4A799361.2040905@skippinet.com.au> On 5/08/2009 11:06 PM, Marc-Andre Belzile wrote: > I have another problem though when I try to bind the scripting engine to the script site object in my C++ app. Calling IActiveScript::SetScriptSite returns E_FAIL. I haven't try yet with 3.0 and build 213. Is it a known regression with 214? No. Cheers, Mark From Marc-Andre.Belzile at autodesk.com Wed Aug 5 17:11:28 2009 From: Marc-Andre.Belzile at autodesk.com (Marc-Andre Belzile) Date: Wed, 5 Aug 2009 08:11:28 -0700 Subject: [python-win32] pywin32 build 214 released In-Reply-To: <4A799361.2040905@skippinet.com.au> References: <4A5419F8.50405@skippinet.com.au> <904A0B8F53C34AA2B491FEA30946FDA1@efcore> <4A545B6C.1010401@gmail.com> <4A78C35F.5040804@skippinet.com.au> <4A799361.2040905@skippinet.com.au> Message-ID: I have the same problem with 3.0. -mab -----Original Message----- From: Mark Hammond [mailto:mhammond at skippinet.com.au] Sent: Wednesday, August 05, 2009 10:13 AM To: Marc-Andre Belzile Cc: Python-win32 at python.org Subject: Re: [python-win32] pywin32 build 214 released On 5/08/2009 11:06 PM, Marc-Andre Belzile wrote: > I have another problem though when I try to bind the scripting engine to the script site object in my C++ app. Calling IActiveScript::SetScriptSite returns E_FAIL. I haven't try yet with 3.0 and build 213. Is it a known regression with 214? No. Cheers, Mark From mail at timgolden.me.uk Wed Aug 5 22:12:42 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 05 Aug 2009 21:12:42 +0100 Subject: [python-win32] faster way to get printer status? In-Reply-To: <882731.24407.qm@web112618.mail.gq1.yahoo.com> References: <882731.24407.qm@web112618.mail.gq1.yahoo.com> Message-ID: <4A79E7BA.6060603@timgolden.me.uk> Alec Bennett wrote: > I'm trying to get the online/offline status of a printer, and using WMI I'm finding it very slow. Here's the code I'm working, maybe there's some way to opimize it? Or some other way? I'm able to use win32print to query the status of an online printer, but not to find out whether its online or not (its pStatus always returns 'Idle'). > > def check_printer(printer_name): > > .....c = wmi.WMI () > > .....for p in c.Win32_Printer(): > > ..........if p.caption == printer_name: > > ...............if p.WorkOffline: > ..................print "its offline" > ...............else: > ..................print "its online" > > Generally, check out the speedup hints here: http://timgolden.me.uk/python/wmi-tutorial.html#speeding-things-up but as a rule WMI is not the fastest thing on earth, so if you really need speed, you'll need to drop down to the Win32 API and go from there. I can't remember exactly what you need off-hand, altho' it's probably in the win32print module. Perhaps someone else can fill in for me here...? TJG From lkcl at lkcl.net Wed Aug 5 22:25:35 2009 From: lkcl at lkcl.net (Luke Kenneth Casson Leighton) Date: Wed, 5 Aug 2009 20:25:35 +0000 Subject: [python-win32] MSHTML wrapper class and example using IWebBrowser2 In-Reply-To: <91882ea90908030754y52a7e3d2taf3f53f82bdf3251@mail.gmail.com> References: <24782740.post@talk.nabble.com> <91882ea90908030754y52a7e3d2taf3f53f82bdf3251@mail.gmail.com> Message-ID: searching around on the internet for code snippets to do event handling on MSHTML, e.g. HTMLElement insertEvent, i find ... nothing! everybody has been struggling literally since about 2000 when the idea of combining python and MSHTML first really took off. i just wanted to let people know, for those doing google searches - i did it! i _actually_ managed to come up with the right voodoo magic incantations where you can pass in a python callback function into HTMLElement insertEvent. the key was combining ctypes pointer to a comtypes.automation.VARIANT with a python COM object with an IDispatch interface on it, which is what you're _supposed_ to do, but it's tricky as hell to work out. what i had to do was take a _much_ older version of comtypes.client._events.py and hack it into submission: http://pyjamas.svn.sourceforge.net/viewvc/pyjamas/trunk/pyjd/mshtmlevents.py there are two styles that you can use: def addEventListener(self, node, event_name, event_fn): rcvr = mshtmlevents.GetDispEventReceiver(MSHTML.HTMLElementEvents2, event_fn, "on%s" % event_name) rcvr.sender = node ifc = rcvr.QueryInterface(IDispatch) node.attachEvent("on%s" % event_name, ifc) return ifc def _addWindowEventListener(self, event_name, event_fn): print "_addWindowEventListener", event_name, event_fn #rcvr = mshtmlevents.GetDispEventReceiver(MSHTML.HTMLWindowEvents, # event_fn, "on%s" % event_name) #print rcvr #rcvr.sender = self.getGdomWindow() #print rcvr.sender #ifc = rcvr.QueryInterface(IDispatch) #print ifc #v = VARIANT(ifc) #print v #setattr(self.getGdomWindow(), "on%s" % event_name, v) #return ifc self.getGdomWindow just returns the parentWindow object. but... this second style, when the COM object created by GetDispEventReceiver's IDispatch_Invoke function is called, you _do not_ receive the actual IHTMLEventObj back! so - don't use that style :) it works, but it's useless. i wasted 3 hours last night finding that out. but - i'm including it here simply for completeness. use the first style, instead: attachEvent. then you end up with the MSHTML event handling system doing an Invoke on you whilst also passing the IHTMLEventObj to you in the arguments - hooray! so you can get event.type, event.target etc. etc. btw please don't be confused by me attempting to do event handling on window, in the commented-out code, i'm still struggling to get window event handling working, but HTMLElement it actually works. one thing that's important to note is that the MSHTML event dispatch system will only pass 0 as the method number, NOT i repeat NOT a whole range of numbers representing different event types. the hacked-together code in mshtmlevents.py looks very similar to GetEvents, which was designed to get multiple events and to cope with multiple callbacks onto one COM object - but this is _completely_ different. attachEvent expects a COM Object with an _exclusive_ purpose in mind. l. From rwupole at msn.com Thu Aug 6 19:29:17 2009 From: rwupole at msn.com (Roger Upole) Date: Thu, 6 Aug 2009 13:29:17 -0400 Subject: [python-win32] faster way to get printer status? Message-ID: You should be able to get the "Work Offline" status using win32print.GetPrinter with level 2. The returned Attributes will contain PRINTER_ATTRIBUTE_WORK_OFFLINE Roger From lkcl at lkcl.net Thu Aug 6 22:35:12 2009 From: lkcl at lkcl.net (Luke Kenneth Casson Leighton) Date: Thu, 6 Aug 2009 20:35:12 +0000 Subject: [python-win32] MSHTML wrapper class and example using IWebBrowser2 In-Reply-To: References: <24782740.post@talk.nabble.com> <91882ea90908030754y52a7e3d2taf3f53f82bdf3251@mail.gmail.com> Message-ID: would you believe it - XMLHttpRequest needs that third version, the one where you have to set up a VARIANT which contains a pointer to a COM object with an IDispatch interface :) ughhh. this is the one where, inside the Dispatch Invoke callback, the args received when the event (onreadystatechange in this case) fires do _not_ contain the event itself. fortunately, in the case of XMLHttpRequest handling, you don't actually care about the event, you only care that it happened. as long as the original COM object python class instance has a pointer to the original XMLHttpRequest object, you can start doing checks for readyState, get the responseText, responseXML etc. etc. so - mshtmlevents is a botched-up version of comtypes.events from several years ago. this time, i didn't bother using GetDispEventsReceiver i just threw together an _DispEventReceiver() and set the dispmap manually, given that the XMLHttpRequest is going to call its IDispatch Invoke method with 0. def _addXMLHttpRequestEventListener(self, node, event_name, event_fn): rcvr = mshtmlevents._DispEventReceiver() rcvr.dispmap = {0: event_fn} rcvr.sender = node ifc = rcvr.QueryInterface(IDispatch) v = VARIANT(ifc) setattr(node, event_name, v) # node is the XMLHttpRequest COM object return ifc to actually create the XMLHttpRequest, you do this: from comtypes.client.dynamic import Dispatch def getXmlHttpRequest(self): print "getXMLHttpRequest" o = comtypes.client.CreateObject('MSXML2.XMLHTTP.3.0') print "getXMLHttpRequest", o return Dispatch(o) that's it! now you have an XMLHttpRequest object - in python - you can set up a python callback, and you're away. i'm just really surprised that this has been, apart from the voodoo magic incantations, pretty straightforward. the only bugbear is that the MSHTML COM interfaces are just as usly as.. well... IE6 :) so, ironically, it's going to be necessary to examine pyjamas's IE6 support (overrides) to see what needs to be done in python! event.returnValue = True; instead of event.preventDefault() etc. etc. argh.... From jbaker at zeomega.com Fri Aug 7 17:46:12 2009 From: jbaker at zeomega.com (Jason Baker) Date: Fri, 7 Aug 2009 10:46:12 -0500 Subject: [python-win32] Why can I compile a C extension if I replace python25.lib with python25.dll? Message-ID: I've been trying to get Storm's C extensions to compile under windows. For some reason, it wasn't able to find python25.dll, even if I paste it directly under libs or DLLs. My theory was that it was finding python25.lib (which I'm guessing is a static library) and trying to use that instead. If I remove python25.lib and replace it with python25.dll, it works fine. This solution doesn't really seem like a good one to me though. Is there a better solution? From timr at probo.com Fri Aug 7 18:40:07 2009 From: timr at probo.com (Tim Roberts) Date: Fri, 07 Aug 2009 09:40:07 -0700 Subject: [python-win32] Why can I compile a C extension if I replace python25.lib with python25.dll? In-Reply-To: References: Message-ID: <4A7C58E7.7050606@probo.com> Jason Baker wrote: > I've been trying to get Storm's C extensions to compile under windows. > For some reason, it wasn't able to find python25.dll, even if I paste > it directly under libs or DLLs. My theory was that it was finding > python25.lib (which I'm guessing is a static library) and trying to > use that instead. > No. Python25.lib is an import library. It doesn't contain any code. All it contains is special linker records that say "this entry point will be found in python25.dll at run-time". You need Python25.lib when you build the extension. You need Python25.dll when you run a program that uses it. > If I remove python25.lib and replace it with python25.dll, it works > fine. This solution doesn't really seem like a good one to me though. > That doesn't make sense. The linker won't use python25.dll. It can't -- it's not in the right format. The linker needs the .lib. Then, when you run the app, the DLL must be accessible somewhere. Does the build process try to test the extensions? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From jbaker at zeomega.com Fri Aug 7 19:11:17 2009 From: jbaker at zeomega.com (Jason Baker) Date: Fri, 7 Aug 2009 12:11:17 -0500 Subject: [python-win32] Why can I compile a C extension if I replace python25.lib with python25.dll? In-Reply-To: <4A7C58E7.7050606@probo.com> References: <4A7C58E7.7050606@probo.com> Message-ID: On Fri, Aug 7, 2009 at 11:40 AM, Tim Roberts wrote: > Jason Baker wrote: >> I've been trying to get Storm's C extensions to compile under windows. >> ?For some reason, it wasn't able to find python25.dll, even if I paste >> it directly under libs or DLLs. ?My theory was that it was finding >> python25.lib (which I'm guessing is a static library) and trying to >> use that instead. >> > > No. ?Python25.lib is an import library. ?It doesn't contain any code. > All it contains is special linker records that say "this entry point > will be found in python25.dll at run-time". > > You need Python25.lib when you build the extension. ?You need > Python25.dll when you run a program that uses it. > >> If I remove python25.lib and replace it with python25.dll, it works >> fine. ?This solution doesn't really seem like a good one to me though. >> > > That doesn't make sense. ?The linker won't use python25.dll. ?It can't > -- it's not in the right format. ?The linker needs the .lib. ?Then, when > you run the app, the DLL must be accessible somewhere. ?Does the build > process try to test the extensions? > > -- > 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 > Nope. I get linker errors saying it cant find a whole slew of symbols from the Python library. I haven't been able to figure out any other way to get it to work without replacing python25.lib with python25.dll (from C:\WINDOWS\SYSTEM32). If it makes any difference, I'm using MinGW to build this. From timr at probo.com Fri Aug 7 19:19:28 2009 From: timr at probo.com (Tim Roberts) Date: Fri, 07 Aug 2009 10:19:28 -0700 Subject: [python-win32] Why can I compile a C extension if I replace python25.lib with python25.dll? In-Reply-To: References: <4A7C58E7.7050606@probo.com> Message-ID: <4A7C6220.6000002@probo.com> Jason Baker wrote: > > Nope. I get linker errors saying it cant find a whole slew of symbols > from the Python library. I haven't been able to figure out any other > way to get it to work without replacing python25.lib with python25.dll > (from C:\WINDOWS\SYSTEM32). > > If it makes any difference, I'm using MinGW to build this. > It makes a HUGE difference. The gcc compiler in MinGW doesn't understand the Microsoft library format. If you want to build extensions with MinGW, then you must build your Python from source, using MinGW. You can't use a standard distribution. (Well, you could use the Python that is available through Cygwin, I believe). I believe there are recipes on the web that describe this. On the whole, I would think it would be much easier to go download the appropriate free Visual Studio Express Edition that matches your Python version, and use that to build your extension. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From drobinow at gmail.com Fri Aug 7 19:58:21 2009 From: drobinow at gmail.com (David Robinow) Date: Fri, 7 Aug 2009 13:58:21 -0400 Subject: [python-win32] Why can I compile a C extension if I replace python25.lib with python25.dll? In-Reply-To: <4A7C6220.6000002@probo.com> References: <4A7C58E7.7050606@probo.com> <4A7C6220.6000002@probo.com> Message-ID: <4eb0089f0908071058u7ef109fcxf9e95cbe1d946d20@mail.gmail.com> On Fri, Aug 7, 2009 at 1:19 PM, Tim Roberts wrote: > Jason Baker wrote: >> Nope. ?I get linker errors saying it cant find a whole slew of symbols >> from the Python library. ?I haven't been able to figure out any other >> way to get it to work without replacing python25.lib with python25.dll >> (from C:\WINDOWS\SYSTEM32). ... > I believe there are recipes on the web that describe this. ?On the > whole, I would think it would be much easier to go download the > appropriate free Visual Studio Express Edition that matches your Python > version, and use that to build your extension. I don't believe there is such a thing for his Python version. Microsoft periodically pulls the older editions of their free compilers. If possible, Jason should upgrade to Python 2.6 From gerdusvanzyl at gmail.com Fri Aug 7 21:27:19 2009 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Fri, 7 Aug 2009 21:27:19 +0200 Subject: [python-win32] Why can I compile a C extension if I replace python25.lib with python25.dll? In-Reply-To: <4eb0089f0908071058u7ef109fcxf9e95cbe1d946d20@mail.gmail.com> References: <4A7C58E7.7050606@probo.com> <4A7C6220.6000002@probo.com> <4eb0089f0908071058u7ef109fcxf9e95cbe1d946d20@mail.gmail.com> Message-ID: <91882ea90908071227l4698f924v8d32a4e573d0a5ba@mail.gmail.com> See this page: http://eli.thegreenplace.net/2008/06/28/compiling-python-extensions-with-distutils-and-mingw/ it has helped me with something similar and tells how to make a mingw compatable libpython25.a; In newer mingw version I think it can figure out the exports (the .a) from the dll itself. ~Gerdus On Fri, Aug 7, 2009 at 7:58 PM, David Robinow wrote: > On Fri, Aug 7, 2009 at 1:19 PM, Tim Roberts wrote: >> Jason Baker wrote: >>> Nope. ?I get linker errors saying it cant find a whole slew of symbols >>> from the Python library. ?I haven't been able to figure out any other >>> way to get it to work without replacing python25.lib with python25.dll >>> (from C:\WINDOWS\SYSTEM32). > ... >> I believe there are recipes on the web that describe this. ?On the >> whole, I would think it would be much easier to go download the >> appropriate free Visual Studio Express Edition that matches your Python >> version, and use that to build your extension. > ?I don't believe there is such a thing for his Python version. > Microsoft periodically pulls the older editions of their free compilers. > If possible, Jason should upgrade to Python 2.6 > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From torriem at gmail.com Fri Aug 7 22:24:30 2009 From: torriem at gmail.com (Michael Torrie) Date: Fri, 07 Aug 2009 14:24:30 -0600 Subject: [python-win32] Why can I compile a C extension if I replace python25.lib with python25.dll? In-Reply-To: <4A7C6220.6000002@probo.com> References: <4A7C58E7.7050606@probo.com> <4A7C6220.6000002@probo.com> Message-ID: <4A7C8D7E.8000309@gmail.com> Tim Roberts wrote: > It makes a HUGE difference. The gcc compiler in MinGW doesn't > understand the Microsoft library format. If you want to build > extensions with MinGW, then you must build your Python from source, > using MinGW. You can't use a standard distribution. (Well, you could > use the Python that is available through Cygwin, I believe). I've built python extensions in MingW before, against the stock libpython.dll. And it worked. But there's a real potential for problems as mingw typically links against an older version of the MS standard C library. Microsoft warns that mixing msvcrt versions is dangerous. From waldemar.osuch at gmail.com Fri Aug 7 22:47:42 2009 From: waldemar.osuch at gmail.com (Waldemar Osuch) Date: Fri, 7 Aug 2009 14:47:42 -0600 Subject: [python-win32] Why can I compile a C extension if I replace python25.lib with python25.dll? In-Reply-To: <4A7C6220.6000002@probo.com> References: <4A7C58E7.7050606@probo.com> <4A7C6220.6000002@probo.com> Message-ID: <6fae95540908071347k75cfad6dj895657d754c42ec8@mail.gmail.com> On Fri, Aug 7, 2009 at 11:19 AM, Tim Roberts wrote: > Jason Baker wrote: >> >> Nope. ?I get linker errors saying it cant find a whole slew of symbols >> from the Python library. ?I haven't been able to figure out any other >> way to get it to work without replacing python25.lib with python25.dll >> (from C:\WINDOWS\SYSTEM32). >> >> If it makes any difference, I'm using MinGW to build this. >> > > It makes a HUGE difference. ?The gcc compiler in MinGW doesn't > understand the Microsoft library format. ?If you want to build > extensions with MinGW, then you must build your Python from source, > using MinGW. ?You can't use a standard distribution. ?(Well, you could > use the Python that is available through Cygwin, I believe). This is not true the standard distribution includes libpython26.a that is usable from MinGW. The only thing I have to do is to specify compiler, like so setup.py -c mingw32 and the rest is taken care off by magic of distutils. > > I believe there are recipes on the web that describe this. ?On the > whole, I would think it would be much easier to go download the > appropriate free Visual Studio Express Edition that matches your Python > version, and use that to build your extension. > Unfortunately some extension do not build using VS. An example is is python-ldap Waldemar From orest.kozyar at gmail.com Fri Aug 7 23:43:10 2009 From: orest.kozyar at gmail.com (Orest Kozyar) Date: Fri, 7 Aug 2009 16:43:10 -0500 Subject: [python-win32] help passing a buffer to an ActiveX object via win32com Message-ID: I'm trying to use an ActiveX object to read data from hardware. Certain methods do not appear to work, specifically ones that expect a pointer to an array of 32-bit floats as one of the variables. One method is *ReadTag*. The C prototype is *long ReadTag(LPCTSTR name, float* pBuf, long nOS, long nWords);* Using MakePy, the signature is *def ReadTag(self, Name=defaultNamedNotOptArg, pBuf=defaultNamedNotOptArg, nOS=defaultNamedNotOptArg, nWords=defaultNamedNotOptArg): return self._oleobj_.InvokeTypes(9, LCID, 1, (3, 0), ((8, 0), (16388,0), (3, 0), (3, 0)),Name, pBuf, nOS, nWords)* When I attempt to pass an array to it via: *x = numpy.zeros(100) obj.ReadTag('microphone', x, 0, 100)* I get the following error: *only length-1 arrays can be converted to Python scalars* Alternatively: *x = numpy.zeros(100) obj.ReadTag('microphone', x.ctypes.data, 0, 100) *returns a tuple and no error is raised: *(1, 4.28, 0, 100)* However, x is not updated with the new data from the hardware buffer. The following does not work either: *x = numpy.zeros(100)* *ptr = x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)) obj.ReadTag('microphone', ptr, 0, 100)* Nor does:* ptr = x.ctypes.data_as(ctypes.c_voidp).value obj.ReadTag('microphone', ptr, 0, 100)* Although no error is raised for the above two examples where I am attempting to pass a pointer to the array, x remains an array of zeros (the microphone is reading a 1 kHz sinusoid so x should be a sine wave). I'm a bit confused and not sure what the best way to proceed at this point is. How do a pass a pointer to my array into the ActiveX method? Thanks! Orest -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Sat Aug 8 00:21:52 2009 From: timr at probo.com (Tim Roberts) Date: Fri, 07 Aug 2009 15:21:52 -0700 Subject: [python-win32] help passing a buffer to an ActiveX object via win32com In-Reply-To: References: Message-ID: <4A7CA900.1090101@probo.com> Orest Kozyar wrote: > I'm trying to use an ActiveX object to read data from hardware. > Certain methods do not appear to work, specifically ones that expect a > pointer to an array of 32-bit floats as one of the variables. One > method is /ReadTag/. > > The C prototype is > /long ReadTag(LPCTSTR name, float* pBuf, long nOS, long nWords);/ That's not really the COM-approved way to declare that. Note the signature: > Using MakePy, the signature is > /def ReadTag(self, Name=defaultNamedNotOptArg, > pBuf=defaultNamedNotOptArg, nOS=defaultNamedNotOptArg, > nWords=defaultNamedNotOptArg): > return self._oleobj_.InvokeTypes(9, LCID, 1, (3, 0), ((8, 0), > (16388,0), (3, 0), (3, 0)),Name, pBuf, nOS, nWords)/ 16388 means it a single float (VT_R4), passed by reference. That matches your first experience. > Alternatively: > /x = numpy.zeros(100) > obj.ReadTag('microphone', x.ctypes.data, 0, 100) > /returns a tuple and no error is raised: > /(1, 4.28, 0, 100)/ > However, x is not updated with the new data from the hardware buffer. No, because x is not an array of floats (4-byte). It's an array of doubles (8-byte). You might try: x = numpy.zeros( 100, numpy.float32 ) but I'm not hopeful. > The following does not work either: > /x = numpy.zeros(100)/ > /ptr = x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)) > obj.ReadTag('microphone', ptr, 0, 100)/ No, again, because you're passing a chunk of doubles to an API that expects an array of singles. > Although no error is raised for the above two examples where I am > attempting to pass a pointer to the array, x remains an array of zeros > (the microphone is reading a 1 kHz sinusoid so x should be a sine > wave). I'm a bit confused and not sure what the best way to proceed > at this point is. How do a pass a pointer to my array into the > ActiveX method? Whatever you do is going to be a hack, because it's not declared in a COM-safe manner, but I suspect you're on the right track with the ctypes scheme. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From skip at pobox.com Sat Aug 8 23:16:03 2009 From: skip at pobox.com (skip at pobox.com) Date: Sat, 8 Aug 2009 16:16:03 -0500 (CDT) Subject: [python-win32] Looking for a little help with SpamBayes Outlook plugin Message-ID: <20090808211603.A6B1D11A9060@montanaro.dyndns.org> I'm looking for someone with a little bit of experience with COM add-ins written in Python to debug and hopefully fix a long-standing problem with the SpamBayes Outlook add-in. If you have a little time available, drop me a note. If you would like to know what you'd be getting into first, here's the current problem: https://sourceforge.net/tracker/?func=detail&atid=498103&aid=1103976&group_id=61702 Thanks, -- Skip Montanaro - skip at pobox.com - http://www.smontanaro.net/ Getting old sucks, but it beats dying young From blade.eric at gmail.com Sun Aug 9 18:09:19 2009 From: blade.eric at gmail.com (Eric Blade) Date: Sun, 9 Aug 2009 12:09:19 -0400 Subject: [python-win32] determining information about a window Message-ID: <59ce684e0908090909u2af89c62m20c0f3a3288b82e@mail.gmail.com> This is kind of a weird question - I have a process that has two windows with the exact same name. I need to figure out some way to differentiate between the two windows - what functions are there available that I can call to find out information about the two windows, so that I might be able to figure out exactly which one it is that my application needs to work with? Sorry about the vagueness of the question, but I just really don't have even the slightest idea about how to find out what it is that i want to know... -- Cheers, - Eric From gerdusvanzyl at gmail.com Sun Aug 9 20:16:32 2009 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Sun, 9 Aug 2009 20:16:32 +0200 Subject: [python-win32] determining information about a window In-Reply-To: <59ce684e0908090909u2af89c62m20c0f3a3288b82e@mail.gmail.com> References: <59ce684e0908090909u2af89c62m20c0f3a3288b82e@mail.gmail.com> Message-ID: <91882ea90908091116u5c7075eft988fd0dd12fea59e@mail.gmail.com> Have you tried Spy++ I think it's part of the windows SDK tools. On Sun, Aug 9, 2009 at 6:09 PM, Eric Blade wrote: > This is kind of a weird question - I have a process that has two > windows with the exact same name. ?I need to figure out some way to > differentiate between the two windows - what functions are there > available that I can call to find out information about the two > windows, so that I might be able to figure out exactly which one it is > that my application needs to work with? ?Sorry about the vagueness of > the question, but I just really don't have even the slightest idea > about how to find out what it is that i want to know... > > > -- > Cheers, > ?- Eric > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From orest.kozyar at gmail.com Mon Aug 10 00:42:07 2009 From: orest.kozyar at gmail.com (Orest Kozyar) Date: Sun, 9 Aug 2009 18:42:07 -0400 Subject: [python-win32] help passing a buffer to an ActiveX object via win32com In-Reply-To: <4A7CA900.1090101@probo.com> References: <4A7CA900.1090101@probo.com> Message-ID: > > > The C prototype is > > /long ReadTag(LPCTSTR name, float* pBuf, long nOS, long nWords);/ > > That's not really the COM-approved way to declare that. Note the > signature: > > > Using MakePy, the signature is > > /def ReadTag(self, Name=defaultNamedNotOptArg, > > pBuf=defaultNamedNotOptArg, nOS=defaultNamedNotOptArg, > > nWords=defaultNamedNotOptArg): > > return self._oleobj_.InvokeTypes(9, LCID, 1, (3, 0), ((8, 0), > > (16388,0), (3, 0), (3, 0)),Name, pBuf, nOS, nWords)/ > > 16388 means it a single float (VT_R4), passed by reference. That > matches your first experience. Hi Tim: Thanks for the clarification. The company that wrote this software is working with me to identify the best way to fix the COM object but they don't have much experience with Python (they're a Matlab/C++ shop). Their COM objects used to be compatible only with Matlab, but a lot of researchers protested this so they're working to fix up their code. What is the appropriate way to declare passing an array of doubles? I'll take a look at your other suggestions regarding the ctype schemes/hack. Thanks, Brad > > > > Alternatively: > > /x = numpy.zeros(100) > > obj.ReadTag('microphone', x.ctypes.data, 0, 100) > > /returns a tuple and no error is raised: > > /(1, 4.28, 0, 100)/ > > However, x is not updated with the new data from the hardware buffer. > > No, because x is not an array of floats (4-byte). It's an array of > doubles (8-byte). You might try: > x = numpy.zeros( 100, numpy.float32 ) > but I'm not hopeful. > > > > The following does not work either: > > /x = numpy.zeros(100)/ > > /ptr = x.ctypes.data_as(ctypes.POINTER(ctypes.c_double)) > > obj.ReadTag('microphone', ptr, 0, 100)/ > > No, again, because you're passing a chunk of doubles to an API that > expects an array of singles. > > > > Although no error is raised for the above two examples where I am > > attempting to pass a pointer to the array, x remains an array of zeros > > (the microphone is reading a 1 kHz sinusoid so x should be a sine > > wave). I'm a bit confused and not sure what the best way to proceed > > at this point is. How do a pass a pointer to my array into the > > ActiveX method? > > Whatever you do is going to be a hack, because it's not declared in a > COM-safe manner, but I suspect you're on the right track with the ctypes > scheme. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From davea at ieee.org Mon Aug 10 17:05:10 2009 From: davea at ieee.org (Dave Angel) Date: Mon, 10 Aug 2009 11:05:10 -0400 Subject: [python-win32] determining information about a window In-Reply-To: <59ce684e0908090909u2af89c62m20c0f3a3288b82e@mail.gmail.com> References: <59ce684e0908090909u2af89c62m20c0f3a3288b82e@mail.gmail.com> Message-ID: <4A803726.2050507@ieee.org> Eric Blade wrote: > This is kind of a weird question - I have a process that has two > windows with the exact same name. I need to figure out some way to > differentiate between the two windows - what functions are there > available that I can call to find out information about the two > windows, so that I might be able to figure out exactly which one it is > that my application needs to work with? Sorry about the vagueness of > the question, but I just really don't have even the slightest idea > about how to find out what it is that i want to know... > > > I doubt if I can give you an answer, but I might be able to narrow down the question so that either you or someone else on the list might be able to solve it. There are at least three scenarios you could be describing. 1) You're writing a program (using tkinter, or wxPython, or ... gui tools), and you've created two windows that need the same name. And from the same program you want to manipulate widgets/controls within one of those windows. but can't just use the window name. If this is the case, there are lots of answers, but they're all dependent on the particular GUI you're using. 2) You're running a 3rd party application that uses the same name for more than one window, and you (the person at the keyboard) want to be able to tell things about them. In this case, a program like SPY+ might just help. 3) You're running a 3rd party app as above, but you're writing a Python program that needs to interact with it, perhaps by injecting messages into its process. In this case, you need to find some other property of each of the two windows that lets you distinguish them. If so, you need to say so, and somebody (other than I) could help you find such information. DaveA From blade.eric at gmail.com Mon Aug 10 17:25:21 2009 From: blade.eric at gmail.com (Eric Blade) Date: Mon, 10 Aug 2009 11:25:21 -0400 Subject: [python-win32] determining information about a window In-Reply-To: <4A803726.2050507@ieee.org> References: <59ce684e0908090909u2af89c62m20c0f3a3288b82e@mail.gmail.com> <4A803726.2050507@ieee.org> Message-ID: <59ce684e0908100825gfc52044yaeee2be38901572b@mail.gmail.com> It's mostly like the 3rd scenario there - although i don't need to output into the process, i just need to be able to differentiate between two different windows that have identical names, so that i can choose which window to have the user interact with from python. On Mon, Aug 10, 2009 at 11:05 AM, Dave Angel wrote: > Eric Blade wrote: >> >> This is kind of a weird question - I have a process that has two >> windows with the exact same name. ?I need to figure out some way to >> differentiate between the two windows - what functions are there >> available that I can call to find out information about the two >> windows, so that I might be able to figure out exactly which one it is >> that my application needs to work with? ?Sorry about the vagueness of >> the question, but I just really don't have even the slightest idea >> about how to find out what it is that i want to know... >> >> >> > > I doubt if I can give you an answer, but I might be able to narrow down the > question so that either you or someone else on the list might be able to > solve it. > > There are at least three scenarios you could be describing. > > 1) You're writing a program (using tkinter, or wxPython, or ... ?gui tools), > and you've created two windows that need the same name. ?And from the same > program you want to manipulate widgets/controls within one of those windows. > but can't just use the window name. ?If this is the case, there are lots of > answers, but they're all dependent on the particular GUI you're using. > > > 2) You're running a 3rd party application that uses the same name for more > than one window, and you (the person at the keyboard) want to be able to > tell things about them. ?In this case, ?a program like SPY+ might just help. > > 3) You're running a 3rd party app as above, but you're writing a Python > program that needs to interact with it, perhaps by injecting messages into > its process. ?In this case, you need to find some other property of each of > the two windows that lets you distinguish them. ?If so, you need to say so, > and somebody (other than I) could help you find such information. > > > DaveA > > -- Cheers, - Eric From timr at probo.com Mon Aug 10 19:58:19 2009 From: timr at probo.com (Tim Roberts) Date: Mon, 10 Aug 2009 10:58:19 -0700 Subject: [python-win32] determining information about a window In-Reply-To: <59ce684e0908090909u2af89c62m20c0f3a3288b82e@mail.gmail.com> References: <59ce684e0908090909u2af89c62m20c0f3a3288b82e@mail.gmail.com> Message-ID: <4A805FBB.30103@probo.com> Eric Blade wrote: > This is kind of a weird question - I have a process that has two > windows with the exact same name. I need to figure out some way to > differentiate between the two windows - what functions are there > available that I can call to find out information about the two > windows, so that I might be able to figure out exactly which one it is > that my application needs to work with? As a human being, how would you decide which one you need? That sounds flippant, but I'm being serious. If you can describe the decision-making process you would go through, then I think we can help you create a program that does the same thing. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From amhoov at gmail.com Mon Aug 10 22:34:13 2009 From: amhoov at gmail.com (Aaron Hoover) Date: Mon, 10 Aug 2009 13:34:13 -0700 Subject: [python-win32] Calling COM methods that expect arguments by reference Message-ID: This question is similar to one posed by Mike Graham in a recent thread, but I thought I'd see if I could rustle up any additional feedback. I'm trying to called a COM automation object using Python. The wrinkle is that the method I need uses arguments by reference to store output from its execution. The signature looks like this: TileGraphic(int FileType, int Margin, intObjMargin, BSTR FileName, BSTR DestName, float KFactor1, float KFactor2, int* Rows, int* Columns, int* X0, int* Y0, int* XExtent, int* YExtent, long InMemory, int* ErrorCode) The Python code generated by makepy looks like: def TileGraphic(self, FileType=defaultNamedNotOptArg, Margin=defaultNamedNotOptArg, ObjMargin=defaultNamedNotOptArg, FileName=defaultNamedNotOptArg , DestName=defaultNamedNotOptArg, KFactor1=defaultNamedNotOptArg, KFactor2=defaultNamedNotOptArg, Rows=pythoncom.Missing, Columns=pythoncom.Missing , X0=pythoncom.Missing, Y0=pythoncom.Missing, XExtent=pythoncom.Missing, YExtent=pythoncom.Missing, InMemory=defaultNamedNotOptArg , ErrorCode=pythoncom.Missing): return self._ApplyTypes_(125, 1, (24, 0), ((3, 1), (3, 1), (3, 1), (8, 1), (8, 1), (4, 1), (4, 1), (16387, 2), (16387, 2), (16387, 2), (16387, 2), (16387, 2), (16387, 2), (3, 1), (16387, 2)), 'TileGraphic', None,FileType , Margin, ObjMargin, FileName, DestName, KFactor1 , KFactor2, Rows, Columns, X0, Y0 , XExtent, YExtent, InMemory, ErrorCode) I'm somewhat unsure how to call it. If I just pass in variables with integer values for the by reference arguments, this is the output: ## All args after 940.0 are just variables containing integers >>> app.TileGraphic(9, 0, 0, "Test.dxf", "Results", 1.0, 940.0, rows, cols, x0, y0, xExtent, yExtent, 0, ErrorCode) ERROR: An unexpected error occurred while tokenizing input The following traceback may be corrupted or invalid The error message is: ('EOF in multi-line statement', (156, 0)) --------------------------------------------------------------------------- com_error Traceback (most recent call last) c:\users\aaron\code\ in () C:\Python25\lib\site-packages\pywin32-210n1-py2.5-win32.egg\win32com \gen_py\DAE1 337F-69EF-4233-B4E3-27C348C3D9D6x0x1x0.pyc in TileGraphic(self, FileType, Margin , ObjMargin, FileName, DestName, KFactor1, KFactor2, Rows, Columns, X0, Y0, XExt ent, YExtent, InMemory, ErrorCode) 648 , Margin, ObjMargin, FileName, DestName, KFactor 1 649 , KFactor2, Rows, Columns, X0, Y0 --> 650 , XExtent, YExtent, InMemory, ErrorCode) 651 652 def TurnLaserOff(self, CardNum=defaultNamedNotOptArg): C:\Python25\lib\site-packages\pywin32-210n1-py2.5-win32.egg\win32com \client\__in it__.pyc in _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCL SID, *args) 446 return self._get_good_object_( 447 self._oleobj_.InvokeTypes( --> 448 dispid, 0, wFlags, retType, argTypes, *arg s), 449 user, resultCLSID) 450 com_error: (-2147352567, 'Exception occurred.', (0, 'winlase.Automate', 'Error d uring Tiling', None, 0, -2147467259), None) I have also tried using pythoncom.Missing and pythoncom.ArgNotFound per Mark Hammond's suggestion. I thought by reference input variables were supposed to be converted to output tuples by makepy. Am I missing something here? If I try and execute the method without any of the input reference variables, I get this error: TypeError: int() argument must be a string or a number, not 'NoneType' -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.antal at ata-e.com Mon Aug 10 23:30:57 2009 From: greg.antal at ata-e.com (Greg Antal) Date: Mon, 10 Aug 2009 14:30:57 -0700 Subject: [python-win32] Calling COM methods that expect arguments by reference In-Reply-To: References: Message-ID: <4A809191.5030509@ata-e.com> An HTML attachment was scrubbed... URL: From amhoov at gmail.com Tue Aug 11 02:41:16 2009 From: amhoov at gmail.com (Aaron Hoover) Date: Mon, 10 Aug 2009 17:41:16 -0700 Subject: [python-win32] Calling COM methods that expect arguments by reference In-Reply-To: <4A809191.5030509@ata-e.com> References: <4A809191.5030509@ata-e.com> Message-ID: <7F043036-5E9E-4F1E-9667-3FA9C1EBEEAA@gmail.com> Hi Greg, I gave your suggestion a shot, but I get the following perplexing error: TypeError: int() argument must be a string or a number, not 'NoneType' which makes me think it's still somehow expecting to get those values as input even though they're explicitly set to be outputs in the generated file. I'll dig a bit deeper tomorrow to see what I can come up with. Thanks, Aaron On Aug 10, 2009, at 2:30 PM, Greg Antal wrote: > Aaron: > > From the Python definition you show, PythonCOM is going to treat > your call-by-reference arguments as output values whether they're > supposed to be or not. This is for all the parameters defined with > type (16387, 2). > > When you have parameters identified like that, your Python call has > to treat them as return values, not as calling arguments. In your > case, that means your call should look like Rows, Cols, X0, Y0, > Xext, Yext, ErrCode = app.TileGraphic (9, 0, 0, "Test.dxf", > "Results", 1.0, 940.0, 0) . > > Of course, that may not actually solve all your problems. Mike > Graham and I had ongoing trouble even after we got the calling > sequence right, for completely different reasons. If that happens > to you, I'm afraid you'll have to get advice from someone much wiser > than I. (There are a lot of them monitoring this list, fortunately.) > > - Greg Antal > Gregory W. Antal > Senior Technical Advisor > ATA Engineering, Inc. > 11995 El Camino Real, Suite 200 > San Diego, CA 92130 > www.ata-e.com > > greg.antal at ata-e.com > 858-480-2072 (Phone) > 858-792-8932 (Fax) > > > Aaron Hoover wrote, On 8/10/2009 1:34 PM: >> >> This question is similar to one posed by Mike Graham in a recent >> thread, but I thought I'd see if I could rustle up any additional >> feedback. >> >> I'm trying to called a COM automation object using Python. The >> wrinkle is that the method I need uses arguments by reference to >> store output from its execution. The signature looks like this: >> >> TileGraphic(int FileType, int Margin, intObjMargin, BSTR FileName, >> BSTR DestName, float KFactor1, float KFactor2, int* Rows, int* >> Columns, int* X0, int* Y0, int* XExtent, int* YExtent, long >> InMemory, int* ErrorCode) >> >> >> The Python code generated by makepy looks like: >> >> def TileGraphic(self, FileType=defaultNamedNotOptArg, >> Margin=defaultNamedNotOptArg, ObjMargin=defaultNamedNotOptArg, >> FileName=defaultNamedNotOptArg >> , DestName=defaultNamedNotOptArg, KFactor1=defaultNamedNotOptArg, >> KFactor2=defaultNamedNotOptArg, Rows=pythoncom.Missing, >> Columns=pythoncom.Missing >> , X0=pythoncom.Missing, Y0=pythoncom.Missing, >> XExtent=pythoncom.Missing, YExtent=pythoncom.Missing, >> InMemory=defaultNamedNotOptArg >> , ErrorCode=pythoncom.Missing): >> return self._ApplyTypes_(125, 1, (24, 0), ((3, 1), (3, 1), (3, 1), >> (8, 1), (8, 1), (4, 1), (4, 1), (16387, 2), (16387, 2), (16387, 2), >> (16387, 2), (16387, 2), (16387, 2), (3, 1), (16387, >> 2)), 'TileGraphic', None,FileType >> , Margin, ObjMargin, FileName, DestName, KFactor1 >> , KFactor2, Rows, Columns, X0, Y0 >> , XExtent, YExtent, InMemory, ErrorCode) >> >> >> I'm somewhat unsure how to call it. If I just pass in variables >> with integer values for the by reference arguments, this is the >> output: >> >> ## All args after 940.0 are just variables containing integers >> >> >> >>> app.TileGraphic(9, 0, 0, "Test.dxf", "Results", 1.0, 940.0, >> rows, cols, >> x0, y0, xExtent, yExtent, 0, ErrorCode) >> ERROR: An unexpected error occurred while tokenizing input >> The following traceback may be corrupted or invalid >> The error message is: ('EOF in multi-line statement', (156, 0)) >> >> --------------------------------------------------------------------------- >> com_error Traceback (most recent >> call last) >> >> c:\users\aaron\code\ in () >> >> C:\Python25\lib\site-packages\pywin32-210n1-py2.5-win32.egg\win32com >> \gen_py\DAE1 >> 337F-69EF-4233-B4E3-27C348C3D9D6x0x1x0.pyc in TileGraphic(self, >> FileType, Margin >> , ObjMargin, FileName, DestName, KFactor1, KFactor2, Rows, Columns, >> X0, Y0, XExt >> ent, YExtent, InMemory, ErrorCode) >> 648 , Margin, ObjMargin, FileName, >> DestName, KFactor >> 1 >> 649 , KFactor2, Rows, Columns, X0, Y0 >> --> 650 , XExtent, YExtent, InMemory, >> ErrorCode) >> 651 >> 652 def TurnLaserOff(self, >> CardNum=defaultNamedNotOptArg): >> >> C:\Python25\lib\site-packages\pywin32-210n1-py2.5-win32.egg\win32com >> \client\__in >> it__.pyc in _ApplyTypes_(self, dispid, wFlags, retType, argTypes, >> user, resultCL >> SID, *args) >> 446 return self._get_good_object_( >> 447 self._oleobj_.InvokeTypes( >> --> 448 dispid, 0, wFlags, retType, >> argTypes, *arg >> s), >> 449 user, resultCLSID) >> 450 >> >> com_error: (-2147352567, 'Exception occurred.', (0, >> 'winlase.Automate', 'Error d >> uring Tiling', None, 0, -2147467259), None) >> >> >> I have also tried using pythoncom.Missing and pythoncom.ArgNotFound >> per Mark Hammond's suggestion. I thought by reference input >> variables were supposed to be converted to output tuples by makepy. >> Am I missing something here? If I try and execute the method >> without any of the input reference variables, I get this error: >> >> TypeError: int() argument must be a string or a number, not >> 'NoneType' >> >> >> >> _______________________________________________ >> 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: From blade.eric at gmail.com Tue Aug 11 07:16:53 2009 From: blade.eric at gmail.com (Eric Blade) Date: Tue, 11 Aug 2009 00:16:53 -0500 Subject: [python-win32] python-win32 Digest, Vol 77, Issue 13 In-Reply-To: References: Message-ID: <59ce684e0908102216w604bce4bve461249df3a29ffd@mail.gmail.com> > > As a human being, how would you decide which one you need? > > That sounds flippant, but I'm being serious. ?If you can describe the > decision-making process you would go through, then I think we can help > you create a program that does the same thing. What I need is a function that will tell me some sort of information about the window, except that I haven't got the slightest idea what is actually available to me to do that, or what information is available. I'm sure that the operating system knows something about the window (like, one has titlebars, and one doesn't) that i can't see from just looking at a task list - but i don't know what i want, or how to get it. Am I making sense? I am in my head, but I don't know about anyone else's. From mdriscoll at co.marshall.ia.us Tue Aug 11 15:22:03 2009 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Tue, 11 Aug 2009 08:22:03 -0500 Subject: [python-win32] Winshell issues Message-ID: <4A81707B.5090209@co.marshall.ia.us> Hi, I've been using Tim Golden's winshell module for a couple of years and just in the last week or so, I've been receiving the following error from multiple users: Traceback (most recent call last): File "\\debianso\loginscript$\MCISpy.py", line 267, in ? import SoScripts File "\\debianso\loginscript$\PythonPackages\Utilities\SoScripts.py", line 49, in ? program_files = winshell.programs() File "\\Debianis\loginscript$\Python24\lib\site-packages\winshell.py", line 71, in programs return get_path ((shellcon.CSIDL_PROGRAMS, shellcon.CSIDL_COMMON_PROGRAMS)[common]) File "\\Debianis\loginscript$\Python24\lib\site-packages\winshell.py", line 44, in get_path return shell.SHGetPathFromIDList (shell.SHGetSpecialFolderLocation (0, folder_id)) com_error: (-2147024893, 'The system cannot find the path specified.', None, None) I don't understand why this is happening. Nothing has been changed with their Python install or the winshell module. Can this be caused if the user's remote roaming profile cannot be located and they end up logged in as a temporary user? Oddly enough, right before that line, I call winshell.desktop() and that works. This is running from a Python 2.4 installation with winshell 0.2 (I think). As you can see from the paths above, it is running from a network location on a linux box, although the client is a Windows XP Pro box. Thanks, Mike From timr at probo.com Tue Aug 11 18:41:23 2009 From: timr at probo.com (Tim Roberts) Date: Tue, 11 Aug 2009 09:41:23 -0700 Subject: [python-win32] determining information about a window In-Reply-To: <59ce684e0908102216w604bce4bve461249df3a29ffd@mail.gmail.com> References: <59ce684e0908102216w604bce4bve461249df3a29ffd@mail.gmail.com> Message-ID: <4A819F33.80701@probo.com> Eric Blade wrote: >> As a human being, how would you decide which one you need? >> >> That sounds flippant, but I'm being serious. If you can describe the >> decision-making process you would go through, then I think we can help >> you create a program that does the same thing. >> > > What I need is a function that will tell me some sort of information > about the window, except that I haven't got the slightest idea what is > actually available to me to do that, or what information is available. > I'm sure that the operating system knows something about the window > (like, one has titlebars, and one doesn't) that i can't see from just > looking at a task list - but i don't know what i want, or how to get > it. Am I making sense? I am in my head, but I don't know about > anyone else's. > You didn't really answer the question. You can query virtually any attribute of the window that you imagine: title, class, size, presence of title bar, presence of close box, stretchable border, how many child windows it has, contents of child windows, menu bar contents, etc. Some of this comes from APIs that send messages (like GetWindowText), some from the data structures (GetWindowLong, GetClassLong), some from enumerations (EnumChildWindows), and so on. So, if you can tell us how YOU would tell the difference, we can suggest which APIs you can use to find those attributes. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From michael at shamirlens.co.uk Tue Aug 11 19:41:07 2009 From: michael at shamirlens.co.uk (Michael M Mason) Date: Tue, 11 Aug 2009 18:41:07 +0100 Subject: [python-win32] Winshell issues In-Reply-To: <4A81707B.5090209@co.marshall.ia.us> References: <4A81707B.5090209@co.marshall.ia.us> Message-ID: <64FDBE5D11B902469AB33D1EFD0D37C2A4666E@sirius.shamirlens.co.uk> > Hi, > > I've been using Tim Golden's winshell module for a couple of years and > just in the last week or so, I've been receiving the following error > from multiple users: > > Traceback (most recent call last): > File "\\debianso\loginscript$\MCISpy.py", line 267, in ? > import SoScripts > File "\\debianso\loginscript$\PythonPackages\Utilities\SoScripts.py", line 49, in ? > program_files = winshell.programs() > File "\\Debianis\loginscript$\Python24\lib\site-packages\winshell.py", line 71, in programs > return get_path ((shellcon.CSIDL_PROGRAMS, shellcon.CSIDL_COMMON_PROGRAMS)[common]) > File "\\Debianis\loginscript$\Python24\lib\site-packages\winshell.py", line 44, in get_path > return shell.SHGetPathFromIDList (shell.SHGetSpecialFolderLocation (0, folder_id)) > com_error: (-2147024893, 'The system cannot find the path specified.', None, None) Does it work any better if you try this (in the Python Shell):- >>> from win32com.shell import shell, shellcon >>> shell.SHGetFolderPath (0, shellcon.CSIDL_COMMON_PROGRAMS, None, 0) I'm using Python 3 so I had to mess about to get winshell.py to work. I've also found that the results returned from winshell are byte arrays whereas the results returned from the example above are strings. I don't know whether that matters in Python 2.4, but it matters in Python 3. I have no idea at all why you should suddenly have a problem if it was working before. -- Michael From Marc-Andre.Belzile at autodesk.com Tue Aug 11 20:04:23 2009 From: Marc-Andre.Belzile at autodesk.com (Marc-Andre Belzile) Date: Tue, 11 Aug 2009 11:04:23 -0700 Subject: [python-win32] Array of 64 bit int Message-ID: Hi, This is probably not the right list for this kind of question but is it possible to build an array of 64 bit int with Python ? thanks for your help! -mab -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Aug 11 20:35:39 2009 From: timr at probo.com (Tim Roberts) Date: Tue, 11 Aug 2009 11:35:39 -0700 Subject: [python-win32] Array of 64 bit int In-Reply-To: References: Message-ID: <4A81B9FB.3050106@probo.com> Marc-Andre Belzile wrote: > > > > This is probably not the right list for this kind of question but is > it possible to build an array of 64 bit int with Python ? > Are you specifically talking about passing 64-bit ints to external APIs? Integers in Python are of infinite size, so the question needs a little clarification. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From Marc-Andre.Belzile at autodesk.com Tue Aug 11 20:58:22 2009 From: Marc-Andre.Belzile at autodesk.com (Marc-Andre Belzile) Date: Tue, 11 Aug 2009 11:58:22 -0700 Subject: [python-win32] Array of 64 bit int In-Reply-To: <4A81B9FB.3050106@probo.com> References: <4A81B9FB.3050106@probo.com> Message-ID: My goal is to use an array of 64 bit integers in python to store byte values and pass the array an activex object. I thought of using array but unlike struct, it doesn't support the 64 bit int type. So I'm looking for an alternative to the array module. e.g. import array a64 = array.array( 'q', ['blip blip','blop'] ) myObject.StroreArray64( a64 ) where StoreArray64 takes a safearray variant arg. I also tried using an array of doubles for storing the bytes but that doesn't seem to work as the values are completly wrong after casting to long64. thanks. -mab -----Original Message----- From: python-win32-bounces+marc-andre.belzile=autodesk.com at python.org [mailto:python-win32-bounces+marc-andre.belzile=autodesk.com at python.org] On Behalf Of Tim Roberts Sent: Tuesday, August 11, 2009 2:36 PM To: Python-Win32 List Subject: Re: [python-win32] Array of 64 bit int Marc-Andre Belzile wrote: > > > > This is probably not the right list for this kind of question but is > it possible to build an array of 64 bit int with Python ? > Are you specifically talking about passing 64-bit ints to external APIs? Integers in Python are of infinite size, so the question needs a little clarification. -- 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 mdriscoll at co.marshall.ia.us Wed Aug 12 20:50:25 2009 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Wed, 12 Aug 2009 13:50:25 -0500 Subject: [python-win32] Winshell issues In-Reply-To: <64FDBE5D11B902469AB33D1EFD0D37C2A4666E@sirius.shamirlens.co.uk> References: <4A81707B.5090209@co.marshall.ia.us> <64FDBE5D11B902469AB33D1EFD0D37C2A4666E@sirius.shamirlens.co.uk> Message-ID: <4A830EF1.2000306@co.marshall.ia.us> Michael M Mason wrote: >> Hi, >> >> I've been using Tim Golden's winshell module for a couple of years and >> > > >> just in the last week or so, I've been receiving the following error >> from multiple users: >> >> Traceback (most recent call last): >> File "\\debianso\loginscript$\MCISpy.py", line 267, in ? >> import SoScripts >> File >> > "\\debianso\loginscript$\PythonPackages\Utilities\SoScripts.py", line > 49, in ? > >> program_files =inshell.programs() >> File >> > "\\Debianis\loginscript$\Python24\lib\site-packages\winshell.py", line > 71, in programs > >> return get_path ((shellcon.CSIDL_PROGRAMS, >> > shellcon.CSIDL_COMMON_PROGRAMS)[common]) > >> File >> > "\\Debianis\loginscript$\Python24\lib\site-packages\winshell.py", line > 44, in get_path > >> return shell.SHGetPathFromIDList (shell.SHGetSpecialFolderLocation >> > (0, folder_id)) > >> com_error: (-2147024893, 'The system cannot find the path >> > specified.', None, None) > > Does it work any better if you try this (in the Python Shell):- > > >>>> from win32com.shell import shell, shellcon >>>> shell.SHGetFolderPath (0, shellcon.CSIDL_COMMON_PROGRAMS, None, 0) >>>> > > I'm using Python 3 so I had to mess about to get winshell.py to work. > I've also found that the results returned from winshell are byte arrays > whereas the results returned from the example above are strings. I > don't know whether that matters in Python 2.4, but it matters in Python > 3. > > I have no idea at all why you should suddenly have a problem if it was > working before. > > Well, I haven't figured it out either. One of my colleagues suggested that maybe a MS update broke something, which is possible I suppose. They've been releasing a lot of updates lately. For the time being, I've wrapped it in a try/except and am creating the path in a more convoluted fashion if it fails. Not ideal, but it works. Hopefully Golden will have an idea. - Mike From michael at shamirlens.co.uk Thu Aug 13 13:11:22 2009 From: michael at shamirlens.co.uk (Michael M Mason) Date: Thu, 13 Aug 2009 12:11:22 +0100 Subject: [python-win32] Winshell issues In-Reply-To: <4A830EF1.2000306@co.marshall.ia.us> References: <4A81707B.5090209@co.marshall.ia.us> <64FDBE5D11B902469AB33D1EFD0D37C2A4666E@sirius.shamirlens.co.uk> <4A830EF1.2000306@co.marshall.ia.us> Message-ID: <64FDBE5D11B902469AB33D1EFD0D37C2A466DD@sirius.shamirlens.co.uk> Mike Driscoll wrote:- > Michael M Mason wrote: > >> Hi, > >> > >> I've been using Tim Golden's winshell module for a > >> couple of years and just in the last week or so, I've > >> been receiving the following error from multiple users: [snip] > > I'm using Python 3 so I had to mess about to get winshell.py > > to work. I've also found that the results returned from > > winshell are byte arrays whereas the results returned from > > the example above are strings. I don't know whether that > > matters in Python 2.4, but it matters in Python 3. > > > > I have no idea at all why you should suddenly have a problem > > if it was working before. > > Well, I haven't figured it out either. One of my colleagues suggested > that maybe a MS update broke something, which is possible I suppose. > They've been releasing a lot of updates lately. For the time being, > I've wrapped it in a try/except and am creating the path in a more > convoluted fashion if it fails. Not ideal, but it works. Hopefully > Golden will have an idea. You could try running the following code snippet to see what results you get:- from win32com.shell import shell for i in range(0,60): try: print(i, shell.SHGetSpecialFolderPath(0, i, 0)) except: print(i) This will print a list of the folder paths you can retrieve and tell you which value of 'i' gets that value. The blank lines are values that don't work, which may be because they aren't defined or it may be because the folder is a 'virtual' folder that has no physical location on the disk. Equipped with the info from the code snippet you could then use code like this to retrieve certain know folders:- mydocs = shell.SHGetSpecialFolderPath(0, 5, 0) allusersdocs = shell.SHGetSpecialFolderPath(0, 46, 0) Hope that helps -- Michael From myrtactle at gmail.com Thu Aug 13 19:17:44 2009 From: myrtactle at gmail.com (Marte Soliza) Date: Fri, 14 Aug 2009 01:17:44 +0800 Subject: [python-win32] Immediately disconnecting a socket in Windows Message-ID: I'm using httplib as an HTTP client for a custom HTTP server. One thing I need is to be able to immediately force disconnect a request that takes too long on the server side (and hasn't returned any data) or if the connection becomes problematic to the point that no data returns for a long period of time. The blocking part happens when getresponse is being called on the HTTPConnection object. In Linux, on a separate thread, I can call shutdown on the socket of the connection object and the getresponse call immediately raises an error. However, in Windows (XP SP3 in particular), this seems to be not the case. It still waits for the server to communicate something back. Do I need to call a Windows-specific function to achieve the same as in Linux? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gary.smith28 at comcast.net Thu Aug 13 05:42:42 2009 From: gary.smith28 at comcast.net (Gary Smith) Date: Wed, 12 Aug 2009 23:42:42 -0400 Subject: [python-win32] Problem registering Python COM object Message-ID: <0391550240194400BA1F64D4938E598F@hermes> Re: Problem registering Python COM object (suddenly) Hi, I've been volunteering for the Research Dept. of Selby Botanical Gardens here in Sarasota, FL. In support of my project I wrote a Python COM server to extend Python's regular expression capabilities to VB. (I'm aware of VB regular expression support, which doesn't include look-behinds.) The computer I use at the Gardens has XP SP2 and Access 2003. Two or three weeks ago I installed Pywin32 (Active State) at the Gardens by downloading the latest version of 2.5 (build 211?). At home I run Active State 2.5 211.1. I believe the software is up-to-date. When I originally installed my Python COM object, the Access application ran flawlessly. However, after a week's absence, I can't even seem to register the COM object (which has changed). The symptoms occur during a query that computes a value using the COM object. I get the Access message "Error ??? the object doesn't support that method". If I stop the query with a break point in VB, I can see that my object exists (probably from the DIM statement). However, it doesn't seem to be associated with the Python COM object. Everything works swimmingly at my development computer. Between last week's visit and today's visit, things won't work at the Gardens. The computer there is very low on C: disk space. Could this have an effect on win32com's registration of the COM object? Is there a method for positive validation that the object is registered? The Tools.References menu item doesn't help, and at my development computer it doesn't show up as an ActiveX component, although it is obviously registered and accessible to VB. Also Application.COMAddins.Item() doesn't show it on either machine. This is puzzling. I've run out of leads. Any clues, anyone? The code follows, although I don't believe it is the code, but rather some external condition of which I'm unaware. Here is the Python code: class reObj: import pythoncom import re import string _public_methods_ = ["allMatches","substitute","replaceAll","occurs","listem"] _reg_progid_ = "Python.reObj" _reg_clsid_ = pythoncom.CreateGuid() def __init__ (self): pass def allMatches(self, pattern, str): import re import string result='' matchGroup=re.search(pattern,str) while matchGroup<>None: (start,end)=matchGroup.span() result = result + ", " + str[start:end] str=str.replace(str[start:end],'',1) matchGroup=re.search(pattern,str) return result[2:] def substitute(self,str,pattern,replacement,count=1): str=str.replace(pattern,replacement,count) return str def replaceAll(self,str,pattern,replacement): str=str.replace(pattern,replacement) return str def occurs(self,str,pattern): result='' matchGroup=re.search(pattern,str) count=0 while matchGroup<>None: count=count+1 (start,end)=matchGroup.span() str=str.replace(str[start:end],'',1) matchGroup=re.search(pattern,str) return (count) if __name__ == '__main__': import win32com.server.register win32com.server.register.UseCommandLine(reObj) And here is the VB code that calls it: Public Function fLatitude(str As String) As String Dim degreesPattern As String Dim minutesPattern As String Dim secondsPattern As String Dim degrees As String Dim minutes As String Dim seconds As String Dim s As String Dim ns As String Dim r As Object Set r = CreateObject("Python.reObj") degreesPattern = "(\d+(\.\d+)?[@])" minutesPattern = "(\s?\d+(\.\d+)?[!])" secondsPattern = "(\s?\d+(\.\d+)?[=])" latitudePattern = "(\d+(\.\d+)?[@!=]\s?)+[NS](?=[\s\.,;]|$)" agn = fAgnosticLatLong(str) s = r.allMatches(latitudePattern, agn) If Len(s) = 0 Then fLatitude = "" Exit Function End If ns = Right(s, 1) degrees = r.allMatches(degreesPattern, s) minutes = r.allMatches(minutesPattern, s) seconds = r.allMatches(secondsPattern, s) degrees = r.replaceAll(degrees, "@", "*") minutes = r.replaceAll(minutes, "!", "'") seconds = r.replaceAll(seconds, "=", """") fLatitude = degrees & minutes & seconds & ns Set r = Nothing End Function Works perfectly at home, but not at all (now) at the pro-bono client. If you've read this far, my deepest thanks, Cheers, Gary ___________________________________ "Even for practical purposes theory generally turns out the most important thing in the end." Oliver Wendell Holmes. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdriscoll at co.marshall.ia.us Thu Aug 13 20:08:56 2009 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Thu, 13 Aug 2009 13:08:56 -0500 Subject: [python-win32] Problem registering Python COM object In-Reply-To: <0391550240194400BA1F64D4938E598F@hermes> References: <0391550240194400BA1F64D4938E598F@hermes> Message-ID: <4A8456B8.5010202@co.marshall.ia.us> Gary Smith wrote: > > Re: Problem registering Python COM object (suddenly) > > Hi, > > I?ve been volunteering for the Research Dept. of Selby Botanical > Gardens here in Sarasota, FL. In support of my project I wrote a > Python COM server to extend Python?s regular expression capabilities > to VB. (I?m aware of VB regular expression support, which doesn?t > include look-behinds.) > > The computer I use at the Gardens has XP SP2 and Access 2003. Two or > three weeks ago I installed Pywin32 (Active State) at the Gardens by > downloading the latest version of 2.5 (build 211?). At home I run > Active State 2.5 211.1. > ActiveState must not be keeping up. The latest version is 214. See here: http://sourceforge.net/projects/pywin32/files/ > I believe the software is up-to-date. When I originally installed my > Python COM object, the Access application ran flawlessly. However, > after a week?s absence, I can?t even seem to register the COM object > (which has changed). > > The symptoms occur during a query that computes a value using the COM > object. I get the Access message ?Error ??? the object doesn?t support > that method?. If I stop the query with a break point in VB, I can see > that my object exists (probably from the DIM statement). However, it > doesn?t seem to be associated with the Python COM object. > > Everything works swimmingly at my development computer. Between last > week?s visit and today?s visit, things won?t work at the Gardens. > > The computer there is very low on C: disk space. Could this have an > effect on win32com?s registration of the COM object? > You can free up some space on the hard drive by going to Start, Programs, Accessories, System Tools and Disk Cleanup. I can't tell if anything is wrong with the code or not as I try to limit my COM experience. Hopefully someone else here will pipe up. - Mike From gerdusvanzyl at gmail.com Fri Aug 14 09:59:07 2009 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Fri, 14 Aug 2009 09:59:07 +0200 Subject: [python-win32] Immediately disconnecting a socket in Windows In-Reply-To: References: Message-ID: <91882ea90908140059i5bddecdejc14321a962159a93@mail.gmail.com> Do you set a socket timeout value via socket.setdefaulttimeout? see: http://www.python.org/doc/2.6/library/socket.html#socket.setdefaulttimeout ~Gerdus On Thu, Aug 13, 2009 at 7:17 PM, Marte Soliza wrote: > I'm using httplib as an HTTP client for a custom HTTP server. One thing I > need is to be able to immediately force disconnect a request that takes too > long on the server side (and hasn't returned any data) or if the connection > becomes problematic to the point that no data returns for a long period of > time. The blocking part happens when getresponse is being called on the > HTTPConnection object. In Linux, on a separate thread, I can call shutdown > on the socket of the connection object and the getresponse call immediately > raises an error. However, in Windows (XP SP3 in particular), this seems to > be not the case. It still waits for the server to communicate something > back. Do I need to call a Windows-specific function to achieve the same as > in Linux? > > Thanks. > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From myrtactle at gmail.com Fri Aug 14 10:28:57 2009 From: myrtactle at gmail.com (Marte Soliza) Date: Fri, 14 Aug 2009 16:28:57 +0800 Subject: [python-win32] Immediately disconnecting a socket in Windows In-Reply-To: <91882ea90908140059i5bddecdejc14321a962159a93@mail.gmail.com> References: <91882ea90908140059i5bddecdejc14321a962159a93@mail.gmail.com> Message-ID: I'm aware of that but what I need is to disconnect on demand. It will only disconnect if needed, and not after a fixed time. By the way, I tried to set the timeout to 0 while the socket is waiting for a response, but it didn't work (and probably not supposed to work by design). Thanks. On Fri, Aug 14, 2009 at 3:59 PM, Gerdus van Zyl wrote: > Do you set a socket timeout value via socket.setdefaulttimeout? > see: > http://www.python.org/doc/2.6/library/socket.html#socket.setdefaulttimeout > > ~Gerdus > > On Thu, Aug 13, 2009 at 7:17 PM, Marte Soliza wrote: > > I'm using httplib as an HTTP client for a custom HTTP server. One thing I > > need is to be able to immediately force disconnect a request that takes > too > > long on the server side (and hasn't returned any data) or if the > connection > > becomes problematic to the point that no data returns for a long period > of > > time. The blocking part happens when getresponse is being called on the > > HTTPConnection object. In Linux, on a separate thread, I can call > shutdown > > on the socket of the connection object and the getresponse call > immediately > > raises an error. However, in Windows (XP SP3 in particular), this seems > to > > be not the case. It still waits for the server to communicate something > > back. Do I need to call a Windows-specific function to achieve the same > as > > in Linux? > > > > Thanks. > > > > > > _______________________________________________ > > 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: From s.teller at gmx.net Fri Aug 14 20:33:21 2009 From: s.teller at gmx.net (steller) Date: Fri, 14 Aug 2009 20:33:21 +0200 Subject: [python-win32] Some problems with instantiating a type library Message-ID: <4A85ADF1.2010105@gmx.net> try this! #the basic win32com interface generated by makepy.py from rhinov4scripttypes import RhinoScript import time import win32com.client #init rhino Rhino = win32com.client.Dispatch("Rhino4.Application") time.sleep(3) Rhino.Visible = True RS = Rhino.GetScriptObject RS = RhinoScript(RS) RS.AddLine((0,0,0), (1,1,1)) cu From timr at probo.com Fri Aug 14 21:07:56 2009 From: timr at probo.com (Tim Roberts) Date: Fri, 14 Aug 2009 12:07:56 -0700 Subject: [python-win32] Some problems with instantiating a type library In-Reply-To: <4A85ADF1.2010105@gmx.net> References: <4A85ADF1.2010105@gmx.net> Message-ID: <4A85B60C.7090706@probo.com> steller wrote: > try this! > > #the basic win32com interface generated by makepy.py > from rhinov4scripttypes import RhinoScript > import time > import win32com.client > #init rhino > Rhino = win32com.client.Dispatch("Rhino4.Application") > time.sleep(3) > Rhino.Visible = True > RS = Rhino.GetScriptObject > RS = RhinoScript(RS) > RS.AddLine((0,0,0), (1,1,1)) > None of us can "try this" unless we have the Rhino4 application installed. What do you see? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From urifaber at gmx.ch Sun Aug 16 00:14:14 2009 From: urifaber at gmx.ch (Uri Faber) Date: Sun, 16 Aug 2009 00:14:14 +0200 Subject: [python-win32] Problems importing win32com Message-ID: <20090815221414.166290@gmx.net> Hi, I have installed pywin32-214.win32 on Vista. Python Version 2.5.2. PYTHONPATH is set to C:\Python25\Lib\site-packages\win32;C:\Python25\Lib\site-packages; when I try to import win32com I get the following traceback: >>> import win32com Traceback (most recent call last): File "", line 1, in File "C:\Python25\Lib\site-packages\win32com\__init__.py", line 5, in import win32api, sys, os File "c:\Python25\Lib\site-packages\isapi\test\build\bdist.win32\winexe\temp\win32api.py", line 15 , in __load() File "c:\Python25\Lib\site-packages\isapi\test\build\bdist.win32\winexe\temp\win32api.py", line 13 , in __load mod = imp.load_dynamic(__name__, path) ImportError: DLL load failed: The specified module could not be found. When importing win32api I get: >>> import win32com Traceback (most recent call last): File "", line 1, in File "C:\Python25\Lib\site-packages\win32com\__init__.py", line 5, in import win32api, sys, os File "c:\Python25\Lib\site-packages\isapi\test\build\bdist.win32\winexe\temp\win32api.py", line 15 , in __load() File "c:\Python25\Lib\site-packages\isapi\test\build\bdist.win32\winexe\temp\win32api.py", line 13 , in __load mod = imp.load_dynamic(__name__, path) ImportError: DLL load failed: The specified module could not be found. If I hardcode the path 'C:\Python25\Lib\site-packages\win32' into the line mod = imp.load_dynamic(__name__, path) the import works fine. print __loader__ gives: NameError: global name '__loader__' is not defined. So the resulting path is therefor c:\Python25\win32api.pyd which is wrong. I am relatively new to python (I haven't really got the idea behind __loader__ ). Any help would be very much appreciated. Uri -- Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3 - sicherer, schneller und einfacher! http://portal.gmx.net/de/go/atbrowser From mc at mclaveau.com Sun Aug 16 06:51:27 2009 From: mc at mclaveau.com (Michel Claveau) Date: Sun, 16 Aug 2009 06:51:27 +0200 Subject: [python-win32] Problems importing win32com In-Reply-To: <20090815221414.166290@gmx.net> References: <20090815221414.166290@gmx.net> Message-ID: <1C9B665A00894247986CFC211452ADE7@MCI1330> Hi! I suggest you desactivate UAC. Then reinstall Pywin32. @-salutations -- Michel Claveau From skippy.hammond at gmail.com Mon Aug 17 08:59:54 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Mon, 17 Aug 2009 16:59:54 +1000 Subject: [python-win32] Problem registering Python COM object In-Reply-To: <0391550240194400BA1F64D4938E598F@hermes> References: <0391550240194400BA1F64D4938E598F@hermes> Message-ID: <4A88FFEA.2090005@gmail.com> On 13/08/2009 1:42 PM, Gary Smith wrote: > Re: Problem registering Python COM object (suddenly) > > Hi, > > I?ve been volunteering for the Research Dept. of Selby Botanical Gardens > here in Sarasota, FL. In support of my project I wrote a Python COM > server to extend Python?s regular expression capabilities to VB. (I?m > aware of VB regular expression support, which doesn?t include look-behinds.) > > The computer I use at the Gardens has XP SP2 and Access 2003. Two or > three weeks ago I installed Pywin32 (Active State) at the Gardens by > downloading the latest version of 2.5 (build 211?). At home I run Active > State 2.5 211.1. > > I believe the software is up-to-date. When I originally installed my > Python COM object, the Access application ran flawlessly. However, after > a week?s absence, I can?t even seem to register the COM object (which > has changed). What do you mean you can't register it? What error do you get when you try? > The symptoms occur during a query that computes a value using the COM > object. I get the Access message ?Error ??? the object doesn?t support > that method?. If I stop the query with a break point in VB, I can see > that my object exists (probably from the DIM statement). However, it > doesn?t seem to be associated with the Python COM object. Assuming you *can* register it but just fail to use it, you may like to google for using --debug when registering, then using the win32trace module to look at lots of debug messages which will be spewed out as the object is instantiated and attempted to be used. It could be as simple as a syntax error in your .py file... Cheers, Mark > > Everything works swimmingly at my development computer. Between last > week?s visit and today?s visit, things won?t work at the Gardens. > > The computer there is very low on C: disk space. Could this have an > effect on win32com?s registration of the COM object? > > Is there a method for positive validation that the object is registered? > The Tools?References menu item doesn?t help, and at my development > computer it doesn?t show up as an ActiveX component, although it is > obviously registered and accessible to VB. Also > Application.COMAddins.Item() doesn?t show it on either machine. This is > puzzling. > > I?ve run out of leads. Any clues, anyone? The code follows, although I > don?t believe it is the code, but rather some external condition of > which I?m unaware. > > Here is the Python code: > > class reObj: > > import pythoncom > > import re > > import string > > _public_methods_ = > ["allMatches","substitute","replaceAll","occurs","listem"] > > _reg_progid_ = "Python.reObj" > > _reg_clsid_ = pythoncom.CreateGuid() > > def __init__ (self): > > pass > > def allMatches(self, pattern, str): > > import re > > import string > > result='' > > matchGroup=re.search(pattern,str) > > while matchGroup<>None: > > (start,end)=matchGroup.span() > > result = result + ", " + str[start:end] > > str=str.replace(str[start:end],'',1) > > matchGroup=re.search(pattern,str) > > return result[2:] > > def substitute(self,str,pattern,replacement,count=1): > > str=str.replace(pattern,replacement,count) > > return str > > def replaceAll(self,str,pattern,replacement): > > str=str.replace(pattern,replacement) > > return str > > def occurs(self,str,pattern): > > result='' > > matchGroup=re.search(pattern,str) > > count=0 > > while matchGroup<>None: > > count=count+1 > > (start,end)=matchGroup.span() > > str=str.replace(str[start:end],'',1) > > matchGroup=re.search(pattern,str) > > return (count) > > if __name__ == '__main__': > > import win32com.server.register > > win32com.server.register.UseCommandLine(reObj) > > And here is the VB code that calls it: > > Public Function fLatitude(str As String) As String > > Dim degreesPattern As String > > Dim minutesPattern As String > > Dim secondsPattern As String > > Dim degrees As String > > Dim minutes As String > > Dim seconds As String > > Dim s As String > > Dim ns As String > > Dim r As Object > > Set r = CreateObject("Python.reObj") > > degreesPattern = "(\d+(\.\d+)?[@])" > > minutesPattern = "(\s?\d+(\.\d+)?[!])" > > secondsPattern = "(\s?\d+(\.\d+)?[=])" > > latitudePattern = "(\d+(\.\d+)?[@!=]\s?)+[NS](?=[\s\.,;]|$)" > > agn = fAgnosticLatLong(str) > > s = r.allMatches(latitudePattern, agn) > > If Len(s) = 0 Then > > fLatitude = "" > > Exit Function > > End If > > ns = Right(s, 1) > > degrees = r.allMatches(degreesPattern, s) > > minutes = r.allMatches(minutesPattern, s) > > seconds = r.allMatches(secondsPattern, s) > > degrees = r.replaceAll(degrees, "@", "*") > > minutes = r.replaceAll(minutes, "!", "'") > > seconds = r.replaceAll(seconds, "=", """") > > fLatitude = degrees & minutes & seconds & ns > > Set r = Nothing > > End Function > > Works perfectly at home, but not at all (now) at the pro-bono client. > > If you?ve read this far, my deepest thanks, > > Cheers, Gary > > ___________________________________ > > "Even for practical purposes theory generally turns out the most > important thing in the end." Oliver Wendell Holmes. > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From skippy.hammond at gmail.com Mon Aug 17 09:04:13 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Mon, 17 Aug 2009 17:04:13 +1000 Subject: [python-win32] Problems importing win32com In-Reply-To: <20090815221414.166290@gmx.net> References: <20090815221414.166290@gmx.net> Message-ID: <4A8900ED.2000508@gmail.com> On 16/08/2009 8:14 AM, Uri Faber wrote: > Hi, > > I have installed pywin32-214.win32 on Vista. Python Version 2.5.2. > > PYTHONPATH is set to > C:\Python25\Lib\site-packages\win32;C:\Python25\Lib\site-packages; Don't set PYTHONPATH - if you think you need to, something else has gone wrong which may be the problem you are actually chaing. > > when I try to import win32com I get the following traceback: > >>>> import win32com > Traceback (most recent call last): > File "", line 1, in > File "C:\Python25\Lib\site-packages\win32com\__init__.py", line 5, in > > import win32api, sys, os > File > "c:\Python25\Lib\site-packages\isapi\test\build\bdist.win32\winexe\temp\win32api.py", You should most certainly *not* be loading win32api via that path, but it isn't at all obvious how it happens that you are. Cheers, Mark From urifaber at gmx.ch Mon Aug 17 10:41:20 2009 From: urifaber at gmx.ch (Uri Faber) Date: Mon, 17 Aug 2009 10:41:20 +0200 Subject: [python-win32] Problems importing win32com In-Reply-To: <4A8900ED.2000508@gmail.com> References: <20090815221414.166290@gmx.net> <4A8900ED.2000508@gmail.com> Message-ID: <20090817084120.166310@gmx.net> -------- Original-Nachricht -------- > Datum: Mon, 17 Aug 2009 17:04:13 +1000 > Von: Mark Hammond > An: Uri Faber > CC: python-win32 at python.org > Betreff: Re: [python-win32] Problems importing win32com > On 16/08/2009 8:14 AM, Uri Faber wrote: > > Hi, > > > > I have installed pywin32-214.win32 on Vista. Python Version 2.5.2. > > > > PYTHONPATH is set to > > C:\Python25\Lib\site-packages\win32;C:\Python25\Lib\site-packages; > > Don't set PYTHONPATH - if you think you need to, something else has gone > wrong which may be the problem you are actually chaing. > > > > > when I try to import win32com I get the following traceback: > > > >>>> import win32com > > Traceback (most recent call last): > > File "", line 1, in > > File "C:\Python25\Lib\site-packages\win32com\__init__.py", line 5, in > > > > import win32api, sys, os > > File > > > "c:\Python25\Lib\site-packages\isapi\test\build\bdist.win32\winexe\temp\win32api.py", > > You should most certainly *not* be loading win32api via that path, but > it isn't at all obvious how it happens that you are. > > Cheers, > > Mark Hi installing win32 again as administrator solved the problem thanks uri -- Neu: GMX Doppel-FLAT mit Internet-Flatrate + Telefon-Flatrate f?r nur 19,99 Euro/mtl.!* http://portal.gmx.net/de/go/dsl02 From gary.smith28 at comcast.net Wed Aug 19 02:31:11 2009 From: gary.smith28 at comcast.net (Gary Smith) Date: Tue, 18 Aug 2009 20:31:11 -0400 Subject: [python-win32] Problem registering Python COM object In-Reply-To: <4A88FFEA.2090005@gmail.com> References: <0391550240194400BA1F64D4938E598F@hermes> <4A88FFEA.2090005@gmail.com> Message-ID: Mark, Thanks for helping. Of course your answers bring more questions. You wrote: >>Assuming you *can* register it [the COM server] but just fail to use it Do you mean it's registered, but I'm accessing it wrong, so not at all? I can see that possibility. Also, I think it's a fault to use Pythoncom.CreateGuid each and every time I register the object. Perhaps I should reuse the guid. You wrote: >>you may like to google for using --debug when registering, then using the win32trace I was unaware of win32trace, so thanks for that. Can it be that win32trace causes the Python error to be elevated to VB's awareness -- that's where I now see details of a Python com server failure -- rather than in the Python trace collector? That's clever. Thank you for your suggestions. You've given me a couple of new lines of attack. Cheers, Gary Smith From mhammond at skippinet.com.au Wed Aug 19 03:41:14 2009 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 19 Aug 2009 11:41:14 +1000 Subject: [python-win32] Problem registering Python COM object In-Reply-To: References: <0391550240194400BA1F64D4938E598F@hermes> <4A88FFEA.2090005@gmail.com> Message-ID: <4A8B583A.6060606@skippinet.com.au> On 19/08/2009 10:31 AM, Gary Smith wrote: > Mark, > Thanks for helping. Of course your answers bring more questions. > You wrote: >>> Assuming you *can* register it [the COM server] but just fail to use it > Do you mean it's registered, but I'm accessing it wrong, so not at all? I > can see that possibility. Also, I think it's a fault to use > Pythoncom.CreateGuid each and every time I register the object. Perhaps I > should reuse the guid. You most certainly should not use CreateGuid each time you are registering it - that will cause all sorts of problems, including lots of garbage entries in your registry. I suspect this is the root of your problem. If you can find any examples which do this, please let us know so we can correct them. Mark > You wrote: >>> you may like to google for using --debug when registering, then using the > win32trace > I was unaware of win32trace, so thanks for that. Can it be that win32trace > causes the Python error to be elevated to VB's awareness -- that's where I > now see details of a Python com server failure -- rather than in the Python > trace collector? That's clever. > Thank you for your suggestions. You've given me a couple of new lines of > attack. > Cheers, Gary Smith > From paul.bilokon at citi.com Tue Aug 18 15:29:20 2009 From: paul.bilokon at citi.com (Bilokon, Paul ) Date: Tue, 18 Aug 2009 14:29:20 +0100 Subject: [python-win32] Starting a New excel.exe Process as Opposed to Recycling an Existing Excel Message-ID: Hi all, I notice that excel = win32com.client.Dispatch("Excel.Application") does not necessarily create a new excel.exe process. If excel.exe is already running, then it will be recycled and a new process will not be created. However, I would like to have some control over this and tell it to create a new process -- simply for the sake of having a cleaner environment. Is this at all possible? Many thanks, Paul Paul Bilokon, Vice President Citigroup | FX - Options Trading | Quants 33 Canada Square | Canary Wharf | Floor 3 London, E14 5LB Phone: +44 20 798-62191 paul.bilokon at citi.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From paul.bilokon at citi.com Wed Aug 19 18:12:57 2009 From: paul.bilokon at citi.com (Bilokon, Paul ) Date: Wed, 19 Aug 2009 17:12:57 +0100 Subject: [python-win32] Starting a New excel.exe Process as Opposed to Recycling an Existing Excel In-Reply-To: Message-ID: I shall answer my own question (thanks to David Foster who pointed this out and Tim Golden for posting it): http://www.thalesians.com/finance/index.php/Knowledge_Base/Python/General#Starting_a_new_instance_of_a_COM_application The trick is to use DispatchEx rather than Dispatch. Best wishes, Paul ________________________________ From: python-win32-bounces+paul.bilokon=citi.com at python.org [mailto:python-win32-bounces+paul.bilokon=citi.com at python.org] On Behalf Of Bilokon, Paul [ICG-MKTS] Sent: 18 August 2009 14:29 To: 'python-win32 at python.org' Subject: [python-win32] Starting a New excel.exe Process as Opposed to Recycling an Existing Excel Hi all, I notice that excel = win32com.client.Dispatch("Excel.Application") does not necessarily create a new excel.exe process. If excel.exe is already running, then it will be recycled and a new process will not be created. However, I would like to have some control over this and tell it to create a new process -- simply for the sake of having a cleaner environment. Is this at all possible? Many thanks, Paul Paul Bilokon, Vice President Citigroup | FX - Options Trading | Quants 33 Canada Square | Canary Wharf | Floor 3 London, E14 5LB Phone: +44 20 798-62191 paul.bilokon at citi.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From theller at ctypes.org Wed Aug 19 21:33:15 2009 From: theller at ctypes.org (Thomas Heller) Date: Wed, 19 Aug 2009 21:33:15 +0200 Subject: [python-win32] comtypes-0.6.1 released Message-ID: Finally, I found the time to make the long overdue release: http://sourceforge.net/projects/comtypes/ comtypes 0.6.1 released. Summary of important changes: - SAFEARRAYs can now be created from array.array objects, and from multidimensional numpy arrays. - Completely new implementation of the comtypes.server.automation.VARIANTEnumerator class. - Added comtypes.client.GetClassObject() function which returns a factory able to create COM objects. - Much improved IClassObject::CreateInstance() method. - SAFEARRAYs now support the typecodes VT_I8 and VT_UI8. - Added comtypes.IServiceProvider interface (unfortunately there is no ChangleLog entry for this one). -------------------------------------------------------------------------- Detailed changelog since version 0.6.0: 2009-08-19 Thomas Heller * Bumped version number to 0.6.1. 2009-08-07 Thomas Heller * When an interface was specified in the call to IClassObject.CreateInstance, return that instead of calling GetBestInterface. Patch from James Teh. 2009-08-04 Thomas Heller * Added comtypes.CoGetClassObject() low-level function, comtypes.client.GetClassObject() high-level function, and implemented a pythonic interface to IClassFactory's CreateInstance method: def CreateInstance(self, punkouter=None, interface=None, dynamic=False) * Added the 'dynamic=False' parameter to the comtypes.client.CoGetObject and comtypes.client.GetActiveObject functions. Suggested by James Teh. 2009-06-17 Thomas Heller * comtypes.automation: Support VT_I8 and VT_UI8 SAFEARRAYs. * comtypes._comobject: Restore compatibility with Python 2.3. * Add the comtypes.IServiceProvider interface. Based on a patch from Michael Curran. 2009-04-30 Thomas Heller * Change version number in repository to 0.6.0.2dev. * Replace the VARIANTEnumerator implementation class in comtypes.server.automation with a new one which should actually be usable. * A completely new way how localserver and inproc server instances are managed: A comtypes.LocalServer or comtypes.InprocServer instance is attached to the comtypes.COMObject class at runtime. These changes keep localserver running as long as COMObject instances are alive. 2009-04-29 Thomas Heller * comtypes.errorinfo.ReportException now takes an additional 'stacklevel' named argument. * Add E_OUTOFMEMORY hresult code. * Register the InprocServer32 only when running as script or py2exe dll, not when running as py2exe exe server. 2009-04-25 Thomas Heller * SAFEARRAYs can now also be created from multi-dimensional numpy arrays. 2009-04-23 Thomas Heller * Change version number in repository to 0.6.0.1dev. * SAFEARRAYs can now also be created from array.array objects, and from (one-dimensional) numpy arrays. This is a lot faster than creating them from Python lists or tuples, at least for large arrays. * ctypes instances like c_int, c_ubyte, and so on can now be assigned to VARIANT().value. This allows to force creation of VARIANTs with the corresponding typecodes V_I4, VT_UI1 and alike. * Accept typelibs that contain SAFEARRAY(char). 2009-03-17 Thomas Heller * Fixed the return type of ITypeLib::ReleaseTLibAttr, which is documented wrongly in MSDN. The return type is void, not HRESULT. Reported to cause crashes on Windows 7. 2009-01-29 Thomas Heller * Restore compatibility with Python 2.3. * comtypes\client\_code_cache.py: Add missing 'import types' in comtypes\client\_code_cache.py. -- Enjoy, Thomas From davea at ieee.org Wed Aug 19 22:06:00 2009 From: davea at ieee.org (Dave Angel) Date: Wed, 19 Aug 2009 16:06:00 -0400 Subject: [python-win32] Converting DD MM YYYY into YYYY-MM-DD? In-Reply-To: References: Message-ID: <4A8C5B28.3010001@ieee.org> Gilles Ganault wrote: > I find it odd that the regex library can't handle European characters > :-/ > Can you show us an example where regex doesn't handle Unicode strings reasonably? DaveA From kc.python at gmail.com Thu Aug 20 14:40:56 2009 From: kc.python at gmail.com (k c) Date: Thu, 20 Aug 2009 18:10:56 +0530 Subject: [python-win32] How to add Pylint for the Komodo IDE. Message-ID: Can you please help me, to add pylint for Komodo IDE. for analyze the source code. -------------- next part -------------- An HTML attachment was scrubbed... URL: From toddw at activestate.com Thu Aug 20 21:59:01 2009 From: toddw at activestate.com (Todd Whiteman) Date: Thu, 20 Aug 2009 12:59:01 -0700 Subject: [python-win32] How to add Pylint for the Komodo IDE. In-Reply-To: References: Message-ID: <4A8DAB05.6020006@activestate.com> k c wrote: > Can you please help me, to add pylint for Komodo IDE. for analyze the > source code. Check out this blog (first hit from google...): http://mateusz.loskot.net/2006/01/15/running-pylint-from-komodo/ From lotemguy at gmail.com Sun Aug 23 08:32:46 2009 From: lotemguy at gmail.com (lotem guy) Date: Sun, 23 Aug 2009 09:32:46 +0300 Subject: [python-win32] is there a "yellow bar identifier"? Message-ID: <508252630908222332g2fef2892r313fed6ce74656a5@mail.gmail.com> Hello, I'm using win32com.client to run IE from python interpreter, and would like to know if there is a way to get/identify IE events, such as the yellow bar IE opens to block pop-up windows or when modifying XSS. If there is any method who does it, I would really appreciate if you'll send me a link for some explanation or documentation. Thank you, Guy. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ron.arts at neonova.nl Tue Aug 25 13:26:20 2009 From: ron.arts at neonova.nl (Ron Arts) Date: Tue, 25 Aug 2009 13:26:20 +0200 Subject: [python-win32] I want to get a message when the screen is locked/unlocked. How? Message-ID: <4A93CA5C.2040708@neonova.nl> Hi, I want to logout the user from a remote session when the desktop is locked, and log her in again when it is unlocked. There seem to be various ways of catching these events: - WTS API - ISensLogon Interface (SENS) - Using Service Control Manager (SCM) Notifications (only for services?) - Winlogon Notification Packages (deprecated and removed from Vista) I currently am trying the following (using WTS API): if "wxMSW" in wx.PlatformInfo: import win32ts win32ts.WTSRegisterSessionNotification(self.GetHandle(), win32ts.NOTIFY_FOR_THIS_SESSION) This does not throw errors at me, but now I am baffled as how I can catch the WTS events. Also, is this the appropriate method as the docs state that it requires Windows Terminal Services loaded (which I don't have running). On the other hand SENS seems to be a good approach as well, but I can't find that in the pywin32 package. Can someone shed some light on this? Thanks, Ron Art -- NeoNova BV innovatieve internetoplossingen http://www.neonova.nl Science Park 140 1098 XG Amsterdam info: 020-5611300 servicedesk: 020-5611302 fax: 020-5611301 KvK Amsterdam 34151241 Op dit bericht is de volgende disclaimer van toepassing: http://www.neonova.nl/maildisclaimer From paul.bilokon at citi.com Tue Aug 25 13:30:41 2009 From: paul.bilokon at citi.com (Bilokon, Paul ) Date: Tue, 25 Aug 2009 12:30:41 +0100 Subject: [python-win32] Excel Calculation - Check when it's done Message-ID: Hi, My apologies as this question is indeed Excel specific though it's wide applicability probably merits inclusion here. Is there any way to determine when a calculation is done in Excel from Python over COM, without busy-waiting? Does anyone have any examples? Many thanks, Paul -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Aug 25 19:13:07 2009 From: timr at probo.com (Tim Roberts) Date: Tue, 25 Aug 2009 10:13:07 -0700 Subject: [python-win32] I want to get a message when the screen is locked/unlocked. How? In-Reply-To: <4A93CA5C.2040708@neonova.nl> References: <4A93CA5C.2040708@neonova.nl> Message-ID: <4A941BA3.4060200@probo.com> Ron Arts wrote: > > I want to logout the user from a remote session when the desktop is > locked, and log her in again when it is unlocked. > > There seem to be various ways of catching these events: > > - WTS API > - ISensLogon Interface (SENS) > - Using Service Control Manager (SCM) Notifications (only for services?) > - Winlogon Notification Packages (deprecated and removed from Vista) > > I currently am trying the following (using WTS API): > > if "wxMSW" in wx.PlatformInfo: > import win32ts > win32ts.WTSRegisterSessionNotification(self.GetHandle(), > win32ts.NOTIFY_FOR_THIS_SESSION) > > This does not throw errors at me, but now I am baffled as how I can > catch the WTS events. Your window will now receive WM_WTSSESSION_CHANGE messages. There's a sample at http://wiki.wxpython.org/MonitoringWindowsUsb that provides a wxPython mixin class that allows you to capture arbitrary window messages. When using this, you'd just say: self.addMsgHandler( WM_WTSSESSION_CHANGE, self.onSessionChange ) self.hookWndProc() def onSessionChange( self, wParam, lParam ): ... WM_WTSSESSION_CHANGE is 0x02b1. > Also, is this the appropriate method as the docs state that it > requires Windows Terminal > Services loaded (which I don't have running). Starting with XP, all systems run with Windows Terminal Services enabled. That's how fast user switching is implemented, among other things. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Tue Aug 25 19:13:14 2009 From: timr at probo.com (Tim Roberts) Date: Tue, 25 Aug 2009 10:13:14 -0700 Subject: [python-win32] Excel Calculation - Check when it's done In-Reply-To: References: Message-ID: <4A941BAA.3060202@probo.com> Bilokon, Paul wrote: > > My apologies as this question is indeed Excel specific though it's > wide applicability probably merits inclusion here. > > Is there any way to determine when a calculation is done in Excel from > Python over COM, without busy-waiting? > > Does anyone have any examples? Assuming you can register yourself as an event sink, there is a Worksheet_Calculate event that gets fired any time Excel recalculates a cell. However, it gets hit an awful lot. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From ron.arts at neonova.nl Tue Aug 25 22:53:23 2009 From: ron.arts at neonova.nl (Ron Arts) Date: Tue, 25 Aug 2009 22:53:23 +0200 Subject: [python-win32] SOLVED: I want to get a message when the screen is locked/unlocked. How? In-Reply-To: <4A941BA3.4060200@probo.com> References: <4A93CA5C.2040708@neonova.nl> <4A941BA3.4060200@probo.com> Message-ID: <4A944F43.60307@neonova.nl> Tim Roberts schreef: > Ron Arts wrote: >> I want to logout the user from a remote session when the desktop is >> locked, and log her in again when it is unlocked. >> >> There seem to be various ways of catching these events: >> >> - WTS API >> - ISensLogon Interface (SENS) >> - Using Service Control Manager (SCM) Notifications (only for services?) >> - Winlogon Notification Packages (deprecated and removed from Vista) >> >> I currently am trying the following (using WTS API): >> >> if "wxMSW" in wx.PlatformInfo: >> import win32ts >> win32ts.WTSRegisterSessionNotification(self.GetHandle(), >> win32ts.NOTIFY_FOR_THIS_SESSION) >> >> This does not throw errors at me, but now I am baffled as how I can >> catch the WTS events. > > Your window will now receive WM_WTSSESSION_CHANGE messages. There's a > sample at http://wiki.wxpython.org/MonitoringWindowsUsb that provides a > wxPython mixin class that allows you to capture arbitrary window > messages. When using this, you'd just say: > self.addMsgHandler( WM_WTSSESSION_CHANGE, self.onSessionChange ) > self.hookWndProc() > > def onSessionChange( self, wParam, lParam ): > ... > > WM_WTSSESSION_CHANGE is 0x02b1. > > >> Also, is this the appropriate method as the docs state that it >> requires Windows Terminal >> Services loaded (which I don't have running). > > Starting with XP, all systems run with Windows Terminal Services > enabled. That's how fast user switching is implemented, among other things. > Tim, that's great, it works like a charm. Thanks a lot! Ron -- NeoNova BV innovatieve internetoplossingen http://www.neonova.nl Science Park 140 1098 XG Amsterdam info: 020-5611300 servicedesk: 020-5611302 fax: 020-5611301 KvK Amsterdam 34151241 Op dit bericht is de volgende disclaimer van toepassing: http://www.neonova.nl/maildisclaimer From arn.vollebregt at xs4all.nl Wed Aug 26 00:21:10 2009 From: arn.vollebregt at xs4all.nl (Arn Vollebregt) Date: Wed, 26 Aug 2009 00:21:10 +0200 Subject: [python-win32] Implementing IID_IMAPIAdviseSink Message-ID: <122A8733F8C84C76B89B34937AD6CDB8@xcomputer> Hi, I am trying to hook an advise sink into Outlook to receive new email notifications, but I cannot find any examples on this. I've scraped together the code below, but that yields an error. Can anybody point me to a working sample, or provide a quick sample of how to imlement this? I've been banging my head on this for some days now, I am not making any progres... class Sink(): _com_interfaces_ = [mapi.IID_IMAPIAdviseSink] _reg_progid_ = 'IMAPIAdviseSinkTest' _reg_clsid_ = str(mapi.IID_IMAPIAdviseSink) #_reg_clsid_ = str(pythoncom.CreateGuid()) _public_methods_ = ['OnNotify'] def OnNotify(self, foo, bar): print "DEBUG: received an OnNotify()" def main(): sink = pythoncom.CoCreateInstance(Sink._reg_clsid_, None, pythoncom.CLSCTX_ALL, mapi.IID_IMAPIAdviseSink) if __name__ == '__main__': main() sink = pythoncom.CoCreateInstance(Sink._reg_clsid_, None, pythoncom.CLSCTX_ALL, mapi.IID_IMAPIAdviseSink) pywintypes.com_error: (-2147221164, 'Class not registered', None, None) Thank you in advance, Arn Vollebregt P.S.: Yes, I am running build 214 :) From skippy.hammond at gmail.com Wed Aug 26 02:20:21 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 26 Aug 2009 10:20:21 +1000 Subject: [python-win32] Implementing IID_IMAPIAdviseSink In-Reply-To: <122A8733F8C84C76B89B34937AD6CDB8@xcomputer> References: <122A8733F8C84C76B89B34937AD6CDB8@xcomputer> Message-ID: <4A947FC5.7000001@gmail.com> On 26/08/2009 8:21 AM, Arn Vollebregt wrote: > Hi, > > I am trying to hook an advise sink into Outlook to receive new email > notifications, but I cannot find any examples on this. I've scraped together > the code below, but that yields an error. Can anybody point me to a working > sample, or provide a quick sample of how to imlement this? I've been banging > my head on this for some days now, I am not making any progres... > > > class Sink(): > _com_interfaces_ = [mapi.IID_IMAPIAdviseSink] > _reg_progid_ = 'IMAPIAdviseSinkTest' > _reg_clsid_ = str(mapi.IID_IMAPIAdviseSink) > #_reg_clsid_ = str(pythoncom.CreateGuid()) > _public_methods_ = ['OnNotify'] > > def OnNotify(self, foo, bar): > print "DEBUG: received an OnNotify()" > > def main(): > sink = pythoncom.CoCreateInstance(Sink._reg_clsid_, None, > pythoncom.CLSCTX_ALL, mapi.IID_IMAPIAdviseSink) > > if __name__ == '__main__': > main() > > > > sink = pythoncom.CoCreateInstance(Sink._reg_clsid_, None, > pythoncom.CLSCTX_ALL, mapi.IID_IMAPIAdviseSink) > pywintypes.com_error: (-2147221164, 'Class not registered', None, None) > You don't need to CoCreateInstance, and don't need the _reg_* attributes. Something like: from win32com.server.util import wrap site = wrap(Sink()) should allow you to pass the 'site' object to a function which expects an IMAPIAdviceSink interface. Cheers, Mark From Paul.Harrington at deshaw.com Wed Aug 26 05:57:31 2009 From: Paul.Harrington at deshaw.com (Harrington, Paul) Date: Tue, 25 Aug 2009 23:57:31 -0400 Subject: [python-win32] Is it possible for some VBA code in Excel to create a Python class and access it as a inproc COM server without write access to the registry? Message-ID: My (casual) use of python within Excel has been to register COM servers in Python and get a handle to a local server out-of-process instance via CreateObject in Auto_Open. This works fine for me as I have a local admin account with access to HKEY_CLASSES_ROOT. I would like Excel users to access functionality implemented in Python by calling functions/subs which are VBA wrappers around invocations on the COM server. Having pythoncom take care of the marshalling is preferable to the 'eval' interface offered by MSScriptControl.ScriptControl. I would love some mechanism whereby the Excel VBA code could -- on startup -- create an inprocess COM server implemented in Python. Is this possible? pjjH -------------- next part -------------- An HTML attachment was scrubbed... URL: From paul.bilokon at citi.com Wed Aug 26 09:50:17 2009 From: paul.bilokon at citi.com (Bilokon, Paul ) Date: Wed, 26 Aug 2009 08:50:17 +0100 Subject: [python-win32] Excel Calculation - Check when it's done In-Reply-To: <4A941BAA.3060202@probo.com> Message-ID: Hi Tim, Thanks so much! Is there anything like a "global" Worksheet_Calculate, which would get hit when the entire worksheet calculation is done? Also, are there many event sync examples in Python? Many thanks! Paul -----Original Message----- From: python-win32-bounces+paul.bilokon=citi.com at python.org [mailto:python-win32-bounces+paul.bilokon=citi.com at python.org] On Behalf Of Tim Roberts Sent: 25 August 2009 18:13 To: Python-Win32 List Subject: Re: [python-win32] Excel Calculation - Check when it's done Bilokon, Paul wrote: > > My apologies as this question is indeed Excel specific though it's > wide applicability probably merits inclusion here. > > Is there any way to determine when a calculation is done in Excel from > Python over COM, without busy-waiting? > > Does anyone have any examples? Assuming you can register yourself as an event sink, there is a Worksheet_Calculate event that gets fired any time Excel recalculates a cell. However, it gets hit an awful lot. -- 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 timr at probo.com Thu Aug 27 00:05:56 2009 From: timr at probo.com (Tim Roberts) Date: Wed, 26 Aug 2009 15:05:56 -0700 Subject: [python-win32] Excel Calculation - Check when it's done In-Reply-To: References: Message-ID: <4A95B1C4.2040405@probo.com> Bilokon, Paul wrote: > Thanks so much! > > Is there anything like a "global" Worksheet_Calculate, which would get hit when the entire worksheet calculation is done? > Not that I am aware of, but you probably want to experiment with it to see if it does what you need. > Also, are there many event sync examples in Python? > I found quite a few, most using the very handy comtypes module: http://www.lmgtfy.com/?q=python+excel+event+sink -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From grant at p-s.co.nz Thu Aug 27 02:51:29 2009 From: grant at p-s.co.nz (Grant Paton-Simpson) Date: Thu, 27 Aug 2009 12:51:29 +1200 Subject: [python-win32] Running the COM MakePy Utility from python Message-ID: <4A95D891.2030205@p-s.co.nz> Hi, Basically I want to have an installation package automatically run the COM MakePy utility for the ADO 2.8 library. I believe I need to do this so that constants like win32com.client.constants.adTinyInt will be available when my application (http://www.sofastatistics.com) connects to MS Access and MS SQL Server databases. Ideally I would have a line doing something like this: win32com.runmakepy("Microsoft ActiveX Data Objects 2.8 Library (2.8)") Is it possible to do this programmatically? All the best, Grant From paul.bilokon at citi.com Thu Aug 27 09:03:20 2009 From: paul.bilokon at citi.com (Bilokon, Paul ) Date: Thu, 27 Aug 2009 08:03:20 +0100 Subject: [python-win32] Excel Calculation - Check when it's done In-Reply-To: <4A95B1C4.2040405@probo.com> Message-ID: Hi Tim, Many thanks for your reply! Best wishes, Paul -----Original Message----- From: python-win32-bounces+paul.bilokon=citi.com at python.org [mailto:python-win32-bounces+paul.bilokon=citi.com at python.org] On Behalf Of Tim Roberts Sent: 26 August 2009 23:06 To: Python-Win32 List Subject: Re: [python-win32] Excel Calculation - Check when it's done Bilokon, Paul wrote: > Thanks so much! > > Is there anything like a "global" Worksheet_Calculate, which would get hit when the entire worksheet calculation is done? > Not that I am aware of, but you probably want to experiment with it to see if it does what you need. > Also, are there many event sync examples in Python? > I found quite a few, most using the very handy comtypes module: http://www.lmgtfy.com/?q=python+excel+event+sink -- 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 grant at p-s.co.nz Thu Aug 27 13:51:10 2009 From: grant at p-s.co.nz (Grant Paton-Simpson) Date: Thu, 27 Aug 2009 23:51:10 +1200 Subject: [python-win32] [Fwd: Re: Running the COM MakePy Utility from python] Message-ID: <4A96732E.9060700@p-s.co.nz> Hi Harald, I managed to make a file containing everything I needed. NB the command is makepy.py not makepy. There was, however, an issue with genpy.py asserting there had to be a self.file.encoding even though I couldn't see where that was set. I temporarily commented that assert out. File creation then worked. I then took out the small portion of the script I needed - all the data type constants - and put those in my own module. Success! For the benefit of others, the reason you don't have to specify the library e.g. ActiveX 2.8, is that you will be prompted for it via a pop up GUI. All the best, Grant Massa, Harald Armin wrote: > Grant, > > that is possible. Just read the makepy.py script within > win32com.client, and you will find that someway down main() there is > > --------- > GenerateFromTypeLibSpec(arg, f, verboseLevel = verboseLevel, > bForDemand = bForDemand, bBuildHidden = hiddenSpec) > --------- > > which does this. > > BUT, for "static" usage of makepy-COM-Mappings I suggest to make > makepy output it's results in a named file > > makepy -o ADO28.py > > and furtheron import that ADO28 file to access the variables. That > does also work with Excel and Word, and I am used to > > import ExcelXX as Excel > ec=Excel.constants > > and further on us ec.* for excel constants. > > Best wishes, > > HArald > > On Thu, Aug 27, 2009 at 2:51 AM, Grant Paton-Simpson > wrote: > > Hi, > > Basically I want to have an installation package automatically run the > COM MakePy utility for the ADO 2.8 library. I believe I need to do > this > so that constants like win32com.client.constants.adTinyInt will be > available when my application (http://www.sofastatistics.com) > connects to > MS Access and MS SQL Server databases. > > Ideally I would have a line doing something like this: > > win32com.runmakepy("Microsoft ActiveX Data Objects 2.8 Library (2.8)") > > Is it possible to do this programmatically? > > > All the best, Grant > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > > > -- > GHUM Harald Massa > persuadere et programmare > Harald Armin Massa > Spielberger Stra?e 49 > 70435 Stuttgart > 0173/9409607 > no fx, no carrier pigeon > - > LASIK good, steroids bad? From chef at ghum.de Thu Aug 27 10:29:45 2009 From: chef at ghum.de (Massa, Harald Armin) Date: Thu, 27 Aug 2009 10:29:45 +0200 Subject: [python-win32] Running the COM MakePy Utility from python In-Reply-To: <4A95D891.2030205@p-s.co.nz> References: <4A95D891.2030205@p-s.co.nz> Message-ID: Grant, that is possible. Just read the makepy.py script within win32com.client, and you will find that someway down main() there is --------- GenerateFromTypeLibSpec(arg, f, verboseLevel = verboseLevel, bForDemand = bForDemand, bBuildHidden = hiddenSpec) --------- which does this. BUT, for "static" usage of makepy-COM-Mappings I suggest to make makepy output it's results in a named file makepy -o ADO28.py and furtheron import that ADO28 file to access the variables. That does also work with Excel and Word, and I am used to import ExcelXX as Excel ec=Excel.constants and further on us ec.* for excel constants. Best wishes, HArald On Thu, Aug 27, 2009 at 2:51 AM, Grant Paton-Simpson wrote: > Hi, > > Basically I want to have an installation package automatically run the > COM MakePy utility for the ADO 2.8 library. I believe I need to do this > so that constants like win32com.client.constants.adTinyInt will be > available when my application (http://www.sofastatistics.com) connects to > MS Access and MS SQL Server databases. > > Ideally I would have a line doing something like this: > > win32com.runmakepy("Microsoft ActiveX Data Objects 2.8 Library (2.8)") > > Is it possible to do this programmatically? > > > All the best, Grant > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- GHUM Harald Massa persuadere et programmare Harald Armin Massa Spielberger Stra?e 49 70435 Stuttgart 0173/9409607 no fx, no carrier pigeon - LASIK good, steroids bad? -------------- next part -------------- An HTML attachment was scrubbed... URL: From davea at dejaviewphoto.com Thu Aug 27 10:52:19 2009 From: davea at dejaviewphoto.com (Dave Angel) Date: Thu, 27 Aug 2009 04:52:19 -0400 Subject: [python-win32] Find IP address for a UNC path Message-ID: <4A964943.3020403@dejaviewphoto.com> I'd like to be able to figure out the IP address for a Windows XP file server (on a local subnet, not across the Internet), based on a successfully connected share. So I know the UNC name of the share, for example \\server\sharename\... (which was enabled by a NET USE to some other share on the same server) I know the IP address will be of the form 192.168.1.nnn and it's on the same router as my user's machine. The local machines are running XP and Vista (and OS-X), on a workgroup, not a domain. And the server uses DHCP (I think it's called), so the IP address is not fixed over time. The user of this utility will be then doing a Remote Desktop to the server, if that helps. We know he has permission, since he was able to successfully NET USE to the server. But Remote Desktop doesn't seem to permit him to use the server name, only the IP address. I've successfully written such a utility, using subprocess to launch IPCONFIG.EXE on the server, but I need to be able to do it from the user's machine, when the server is physically inaccessible. Suggestions anyone? Thanks, DaveA From chef at ghum.de Thu Aug 27 13:57:30 2009 From: chef at ghum.de (Massa, Harald Armin) Date: Thu, 27 Aug 2009 13:57:30 +0200 Subject: [python-win32] [Fwd: Re: Running the COM MakePy Utility from python] In-Reply-To: <4A96732E.9060700@p-s.co.nz> References: <4A96732E.9060700@p-s.co.nz> Message-ID: Grant, for your problems with the assertion there is a patch... - ----------------------------------------------------------------------------------------------- in Version 213 of pywin32 within win32com\client\genpy.py on line 814, within def do_gen_file_header(self): there is the assertion: # You must provide a file correctly configured for writing unicode. # We assert this is it may indicate somewhere in pywin32 that needs # upgrading. assert self.file.encoding, self.file But using makepy.py via makepy.py -v -o OLE_Excel11.py "Microsoft Excel 11.0 Object Library" this assertion fails ... as self.file.encoding is None The culprit is makepy.py itself: starting at line 367ff there is: if outputName is not None: path = os.path.dirname(outputName) if path is not '' and not os.path.exists(path): os.makedirs(path) f = open(outputName, "w") else: f = None and this "f" will have encoding=None I patched this to: if outputName is not None: path = os.path.dirname(outputName) if path is not '' and not os.path.exists(path): os.makedirs(path) #~ f = open(outputName, "w") import codecs f= codecs.open(outputName, mode="w",encoding="mbcs") else: f = None use codecs to create a file with mbcs encoding. After this, I get a nice create ole_excel11.py file, with the good line # -*- coding: mbcs -*- at the beginning. I propose to put this fix into makepy.py for everybody; (any rights you need are hereby granted) - ----------------------------------------------------------------------------------------------- (of which you could not know; I guess it got lost somewhere between Europe and Australia, where Mark Hammond, the master of pywin32, was before) Now I have put out this patch to the public, for others to enjoy untill it may or may not be worked into makepy.py best wishes, Harald On Thu, Aug 27, 2009 at 1:51 PM, Grant Paton-Simpson wrote: > Hi Harald, > > I managed to make a file containing everything I needed. NB the command > is makepy.py not makepy. There was, however, an issue with genpy.py > asserting there had to be a self.file.encoding even though I couldn't > see where that was set. I temporarily commented that assert out. File > creation then worked. I then took out the small portion of the script I > needed - all the data type constants - and put those in my own module. > Success! > > For the benefit of others, the reason you don't have to specify the > library e.g. ActiveX 2.8, is that you will be prompted for it via a pop > up GUI. > > > All the best, Grant > > > Massa, Harald Armin wrote: > > Grant, > > > > that is possible. Just read the makepy.py script within > > win32com.client, and you will find that someway down main() there is > > > > --------- > > GenerateFromTypeLibSpec(arg, f, verboseLevel = verboseLevel, > > bForDemand = bForDemand, bBuildHidden = hiddenSpec) > > --------- > > > > which does this. > > > > BUT, for "static" usage of makepy-COM-Mappings I suggest to make > > makepy output it's results in a named file > > > > makepy -o ADO28.py > > > > and furtheron import that ADO28 file to access the variables. That > > does also work with Excel and Word, and I am used to > > > > import ExcelXX as Excel > > ec=Excel.constants > > > > and further on us ec.* for excel constants. > > > > Best wishes, > > > > HArald > > > > On Thu, Aug 27, 2009 at 2:51 AM, Grant Paton-Simpson > > wrote: > > > > Hi, > > > > Basically I want to have an installation package automatically run > the > > COM MakePy utility for the ADO 2.8 library. I believe I need to do > > this > > so that constants like win32com.client.constants.adTinyInt will be > > available when my application (http://www.sofastatistics.com) > > connects to > > MS Access and MS SQL Server databases. > > > > Ideally I would have a line doing something like this: > > > > win32com.runmakepy("Microsoft ActiveX Data Objects 2.8 Library > (2.8)") > > > > Is it possible to do this programmatically? > > > > > > All the best, Grant > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > > > > > > -- > > GHUM Harald Massa > > persuadere et programmare > > Harald Armin Massa > > Spielberger Stra?e 49 > > 70435 Stuttgart > > 0173/9409607 > > no fx, no carrier pigeon > > - > > LASIK good, steroids bad? > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- GHUM Harald Massa persuadere et programmare Harald Armin Massa Spielberger Stra?e 49 70435 Stuttgart 0173/9409607 no fx, no carrier pigeon - LASIK good, steroids bad? -------------- next part -------------- An HTML attachment was scrubbed... URL: From rdahlstrom at directedge.com Thu Aug 27 14:59:16 2009 From: rdahlstrom at directedge.com (Dahlstrom, Roger) Date: Thu, 27 Aug 2009 08:59:16 -0400 Subject: [python-win32] Find IP address for a UNC path In-Reply-To: <4A964943.3020403@dejaviewphoto.com> References: <4A964943.3020403@dejaviewphoto.com> Message-ID: <70D9B06B9E99EE4E98E4893703ADA1411693FC7BE6@EXCHANGE1.global.knight.com> Ping it and get the address. -----Original Message----- From: python-win32-bounces+rdahlstrom=directedge.com at python.org [mailto:python-win32-bounces+rdahlstrom=directedge.com at python.org] On Behalf Of Dave Angel Sent: Thursday, August 27, 2009 4:52 AM To: Python-Win32 List Subject: [python-win32] Find IP address for a UNC path I'd like to be able to figure out the IP address for a Windows XP file server (on a local subnet, not across the Internet), based on a successfully connected share. So I know the UNC name of the share, for example \\server\sharename\... (which was enabled by a NET USE to some other share on the same server) I know the IP address will be of the form 192.168.1.nnn and it's on the same router as my user's machine. The local machines are running XP and Vista (and OS-X), on a workgroup, not a domain. And the server uses DHCP (I think it's called), so the IP address is not fixed over time. The user of this utility will be then doing a Remote Desktop to the server, if that helps. We know he has permission, since he was able to successfully NET USE to the server. But Remote Desktop doesn't seem to permit him to use the server name, only the IP address. I've successfully written such a utility, using subprocess to launch IPCONFIG.EXE on the server, but I need to be able to do it from the user's machine, when the server is physically inaccessible. Suggestions anyone? Thanks, DaveA _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 DISCLAIMER: This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. NOTICE REGARDING PRIVACY AND CONFIDENTIALITY Direct Edge ECN LLC may, at its discretion, monitor and review the content of all e-mail communications. www.directedge.com From gerdusvanzyl at gmail.com Thu Aug 27 15:35:22 2009 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Thu, 27 Aug 2009 15:35:22 +0200 Subject: [python-win32] Find IP address for a UNC path In-Reply-To: <70D9B06B9E99EE4E98E4893703ADA1411693FC7BE6@EXCHANGE1.global.knight.com> References: <4A964943.3020403@dejaviewphoto.com> <70D9B06B9E99EE4E98E4893703ADA1411693FC7BE6@EXCHANGE1.global.knight.com> Message-ID: <91882ea90908270635j7f7bb96cwa75045af81db602b@mail.gmail.com> I would say try socket.gethostbyname; http://docs.python.org/library/socket.html#socket.gethostbyname On Thu, Aug 27, 2009 at 2:59 PM, Dahlstrom, Roger wrote: > Ping it and get the address. > > -----Original Message----- > From: python-win32-bounces+rdahlstrom=directedge.com at python.org [mailto:python-win32-bounces+rdahlstrom=directedge.com at python.org] On Behalf Of Dave Angel > Sent: Thursday, August 27, 2009 4:52 AM > To: Python-Win32 List > Subject: [python-win32] Find IP address for a UNC path > > I'd like to be able to figure out the IP address for a Windows XP file > server (on a local subnet, not across the Internet), based on a > successfully connected share. > > So I know the UNC name of the share, for example > ? ?\\server\sharename\... > > (which was enabled by a NET USE to some other share on the same server) > > I know the IP address will be of the form ?192.168.1.nnn ? and it's on > the same router as my user's machine. ?The local machines are running XP > and Vista (and OS-X), on a workgroup, not a domain. ?And the server uses > DHCP (I think it's called), so the IP address is not fixed over time. > > The user of this utility will be then doing a Remote Desktop to the > server, if that helps. ?We know he has permission, since he was able to > successfully ?NET USE to the server. ?But Remote Desktop doesn't seem to > permit him to use the server name, only the IP address. > > I've successfully written such a utility, using subprocess to launch > IPCONFIG.EXE on the server, but I need to be able to do it from the > user's machine, when the server is physically inaccessible. > > Suggestions anyone? > > Thanks, DaveA > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > DISCLAIMER: > This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and > may contain legally privileged and/or confidential information. If you are not the intended recipient > of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and > any attachments thereto, is strictly prohibited. If you have received this in error, please immediately notify > me and permanently delete the original and any copy of any e-mail and any printout thereof. > E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept > liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. > > NOTICE REGARDING PRIVACY AND CONFIDENTIALITY > Direct Edge ECN LLC may, at its discretion, monitor and review the content of all e-mail communications. > > www.directedge.com > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From steven.james at gmail.com Thu Aug 27 16:34:47 2009 From: steven.james at gmail.com (Steven James) Date: Thu, 27 Aug 2009 10:34:47 -0400 Subject: [python-win32] Find IP address for a UNC path In-Reply-To: <91882ea90908270635j7f7bb96cwa75045af81db602b@mail.gmail.com> References: <4A964943.3020403@dejaviewphoto.com> <70D9B06B9E99EE4E98E4893703ADA1411693FC7BE6@EXCHANGE1.global.knight.com> <91882ea90908270635j7f7bb96cwa75045af81db602b@mail.gmail.com> Message-ID: I think the bigger issue is being passed over...why write a program to do what RDP should already be able to do? RDP should work by machine name. If it does not, then DNS probably is not set up correctly. Are you, by any chance, using OpenDNS as your DNS servers? Does your router support DHCP assignment by MAC address (for static-like IPs with DHCP)? If so, you can always use the same IP instead of looking it up. Other than that, I second the "socket.gethostbyname" suggestion. SJ On Thu, Aug 27, 2009 at 9:35 AM, Gerdus van Zyl wrote: > I would say try socket.gethostbyname; > http://docs.python.org/library/socket.html#socket.gethostbyname > > > On Thu, Aug 27, 2009 at 2:59 PM, Dahlstrom, > Roger wrote: > > Ping it and get the address. > > > > -----Original Message----- > > From: python-win32-bounces+rdahlstrom=directedge.com at python.org [mailto: > python-win32-bounces+rdahlstrom = > directedge.com at python.org] On Behalf Of Dave Angel > > Sent: Thursday, August 27, 2009 4:52 AM > > To: Python-Win32 List > > Subject: [python-win32] Find IP address for a UNC path > > > > I'd like to be able to figure out the IP address for a Windows XP file > > server (on a local subnet, not across the Internet), based on a > > successfully connected share. > > > > So I know the UNC name of the share, for example > > \\server\sharename\... > > > > (which was enabled by a NET USE to some other share on the same server) > > > > I know the IP address will be of the form 192.168.1.nnn and it's on > > the same router as my user's machine. The local machines are running XP > > and Vista (and OS-X), on a workgroup, not a domain. And the server uses > > DHCP (I think it's called), so the IP address is not fixed over time. > > > > The user of this utility will be then doing a Remote Desktop to the > > server, if that helps. We know he has permission, since he was able to > > successfully NET USE to the server. But Remote Desktop doesn't seem to > > permit him to use the server name, only the IP address. > > > > I've successfully written such a utility, using subprocess to launch > > IPCONFIG.EXE on the server, but I need to be able to do it from the > > user's machine, when the server is physically inaccessible. > > > > Suggestions anyone? > > > > Thanks, DaveA > > > > > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > > DISCLAIMER: > > This e-mail, and any attachments thereto, is intended only for use by the > addressee(s) named herein and > > may contain legally privileged and/or confidential information. If you > are not the intended recipient > > of this e-mail, you are hereby notified that any dissemination, > distribution or copying of this e-mail, and > > any attachments thereto, is strictly prohibited. If you have received > this in error, please immediately notify > > me and permanently delete the original and any copy of any e-mail and any > printout thereof. > > E-mail transmission cannot be guaranteed to be secure or error-free. The > sender therefore does not accept > > liability for any errors or omissions in the contents of this message > which arise as a result of e-mail transmission. > > > > NOTICE REGARDING PRIVACY AND CONFIDENTIALITY > > Direct Edge ECN LLC may, at its discretion, monitor and review the > content of all e-mail communications. > > > > www.directedge.com > > _______________________________________________ > > 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: From vernondcole at gmail.com Thu Aug 27 18:34:42 2009 From: vernondcole at gmail.com (Vernon Cole) Date: Thu, 27 Aug 2009 10:34:42 -0600 Subject: [python-win32] [Fwd: Re: Running the COM MakePy Utility from python] In-Reply-To: <4A96732E.9060700@p-s.co.nz> References: <4A96732E.9060700@p-s.co.nz> Message-ID: Grant: ( I read your new source code before commenting ... NICE PROJECT ! ) The constants you are using here are hard-coded into adodbapi, therefore adodbapi.adTinyInt has the same value as adTinyInt in your dbe_globals.py and win32com.client.constants.adTinyInt I assume that those values are not likely to change -- since they end up in a lot of static compiled code -- and a few extra hard-coded definitions of them laying around in Python source modules should not be a source of difficulty. IMHO your recent solution is correct. My goal is to get adodbapi to the point where it can be pretty much a drop-in replacement for pgdb and MySQLdb in most cases, so that programmers can use it to start moving code like yours into newer and/or weirder environments (i.e. IronPython and Python 3). I will be referring to your work as I add postgresql tests to the adodbapi suite. -- Vernon Cole On Thu, Aug 27, 2009 at 5:51 AM, Grant Paton-Simpson wrote: > Hi Harald, > > I managed to make a file containing everything I needed. NB the command > is makepy.py not makepy. There was, however, an issue with genpy.py > asserting there had to be a self.file.encoding even though I couldn't > see where that was set. I temporarily commented that assert out. File > creation then worked. I then took out the small portion of the script I > needed - all the data type constants - and put those in my own module. > Success! > > For the benefit of others, the reason you don't have to specify the > library e.g. ActiveX 2.8, is that you will be prompted for it via a pop > up GUI. > > > All the best, Grant > > > Massa, Harald Armin wrote: > > Grant, > > > > that is possible. Just read the makepy.py script within > > win32com.client, and you will find that someway down main() there is > > > > --------- > > GenerateFromTypeLibSpec(arg, f, verboseLevel = verboseLevel, > > bForDemand = bForDemand, bBuildHidden = hiddenSpec) > > --------- > > > > which does this. > > > > BUT, for "static" usage of makepy-COM-Mappings I suggest to make > > makepy output it's results in a named file > > > > makepy -o ADO28.py > > > > and furtheron import that ADO28 file to access the variables. That > > does also work with Excel and Word, and I am used to > > > > import ExcelXX as Excel > > ec=Excel.constants > > > > and further on us ec.* for excel constants. > > > > Best wishes, > > > > HArald > > > > > On Thu, Aug 27, 2009 at 2:51 AM, Grant Paton-Simpson > > wrote: > > > > Hi, > > > > Basically I want to have an installation package automatically run > the > > COM MakePy utility for the ADO 2.8 library. I believe I need to do > > this > > so that constants like win32com.client.constants.adTinyInt will be > > available when my application (http://www.sofastatistics.com) > > connects to > > MS Access and MS SQL Server databases. > > > > Ideally I would have a line doing something like this: > > > > win32com.runmakepy("Microsoft ActiveX Data Objects 2.8 Library > (2.8)") > > > > Is it possible to do this programmatically? > > > > > > All the best, Grant > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > > > > > > -- > > GHUM Harald Massa > > persuadere et programmare > > Harald Armin Massa > > Spielberger Stra?e 49 > > 70435 Stuttgart > > 0173/9409607 > > no fx, no carrier pigeon > > - > > LASIK good, steroids bad? > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu Aug 27 19:27:29 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 27 Aug 2009 10:27:29 -0700 Subject: [python-win32] Find IP address for a UNC path In-Reply-To: <4A964943.3020403@dejaviewphoto.com> References: <4A964943.3020403@dejaviewphoto.com> Message-ID: <4A96C201.6050803@probo.com> Dave Angel wrote: > I'd like to be able to figure out the IP address for a Windows XP file > server (on a local subnet, not across the Internet), based on a > successfully connected share. > > So I know the UNC name of the share, for example > \\server\sharename\... > > (which was enabled by a NET USE to some other share on the same server) > ... > The user of this utility will be then doing a Remote Desktop to the > server, if that helps. We know he has permission, since he was able > to successfully NET USE to the server. But Remote Desktop doesn't > seem to permit him to use the server name, only the IP address. This doesn't help solve your immediate problem, but what this screams out to me is a configuration issue. It's true that the \\host and the "ping host" names spaces are different, but as long as you have WINS running somewhere, WINS talks to DNS so that the namespaces are equivalent. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Thu Aug 27 21:12:13 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 27 Aug 2009 12:12:13 -0700 Subject: [python-win32] [Fwd: Re: Running the COM MakePy Utility from python] In-Reply-To: <4A96732E.9060700@p-s.co.nz> References: <4A96732E.9060700@p-s.co.nz> Message-ID: <4A96DA8D.7040309@probo.com> Grant Paton-Simpson wrote: > > I managed to make a file containing everything I needed. NB the command > is makepy.py not makepy. Let me give you a little hint. Go into your environment variables, edit the PATHEXT variable, and add .py and .pyw to the extensions so it looks something like this: PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.py;.pyw Now you can type "makepy", and the shell will find and execute "makepy.py". It is a very handy little tweak. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From davea at dejaviewphoto.com Thu Aug 27 17:55:57 2009 From: davea at dejaviewphoto.com (Dave Angel) Date: Thu, 27 Aug 2009 11:55:57 -0400 Subject: [python-win32] Find IP address for a UNC path In-Reply-To: References: <4A964943.3020403@dejaviewphoto.com> <70D9B06B9E99EE4E98E4893703ADA1411693FC7BE6@EXCHANGE1.global.knight.com> <91882ea90908270635j7f7bb96cwa75045af81db602b@mail.gmail.com> Message-ID: <4A96AC8D.7080406@dejaviewphoto.com> I'll try PING when I next get to the location. Steven James wrote: > I think the bigger issue is being passed over...why write a program to do > what RDP should already be able to do? RDP should work by machine name. If > it does not, then DNS probably is not set up correctly. > > I don't know why RDP won't work by name; I assumed it was because it's a workgroup setup, not a domain. But your comment about DNS makes more sense. There is no administrator for this system; I have been trying to fake it (It's a non-profit, and I'm a volunteer), mostly by keeping things simple. My only admin experience has been with a home network, though I've been involved in computer software for 40 years, and had computers at home for 30. I don't know how to set up DNS on an XPPro system. This machine is a (file) server only in the sense that it's the only one with shares defined. And it normally has no keyboard or monitor. So RDP is the only easy way in. > Are you, by any chance, using OpenDNS as your DNS servers? > > Does your router support DHCP assignment by MAC address (for static-like IPs > with DHCP)? If so, you can always use the same IP instead of looking it up. > Thanks, that would be perfect. I guess it's got to be possible, since they have a shared printer that has a fixed IP. But the printer setup software did it automatically. The router is a plain-vanilla Linksys unit, but I'll be happy to get the password for it, and walk through its menus to see if I can make a static IP. Thanks all of you. DaveA > Other than that, I second the "socket.gethostbyname" suggestion. > > SJ > > > On Thu, Aug 27, 2009 at 9:35 AM, Gerdus van Zyl wrote: > > >> I would say try socket.gethostbyname; >> http://docs.python.org/library/socket.html#socket.gethostbyname >> >> >> On Thu, Aug 27, 2009 at 2:59 PM, Dahlstrom, >> Roger wrote: >> >>> Ping it and get the address. >>> >>> -----Original Message----- >>> From: python-win32-bounces+rdahlstrom=directedge.com at python.org [mailto: >>> >> python-win32-bounces+rdahlstrom = >> directedge.com at python.org] On Behalf Of Dave Angel >> >>> Sent: Thursday, August 27, 2009 4:52 AM >>> To: Python-Win32 List >>> Subject: [python-win32] Find IP address for a UNC path >>> >>> I'd like to be able to figure out the IP address for a Windows XP file >>> server (on a local subnet, not across the Internet), based on a >>> successfully connected share. >>> >>> So I know the UNC name of the share, for example >>> \\server\sharename\... >>> >>> (which was enabled by a NET USE to some other share on the same server) >>> >>> I know the IP address will be of the form 192.168.1.nnn and it's on >>> the same router as my user's machine. The local machines are running XP >>> and Vista (and OS-X), on a workgroup, not a domain. And the server uses >>> DHCP (I think it's called), so the IP address is not fixed over time. >>> >>> The user of this utility will be then doing a Remote Desktop to the >>> server, if that helps. We know he has permission, since he was able to >>> successfully NET USE to the server. But Remote Desktop doesn't seem to >>> permit him to use the server name, only the IP address. >>> >>> I've successfully written such a utility, using subprocess to launch >>> IPCONFIG.EXE on the server, but I need to be able to do it from the >>> user's machine, when the server is physically inaccessible. >>> >>> Suggestions anyone? >>> >>> Thanks, DaveA >>> >>> >>> _______________________________________________ >>> python-win32 mailing list >>> python-win32 at python.org >>> http://mail.python.org/mailman/listinfo/python-win32 >>> >>> >>> DISCLAIMER: >>> This e-mail, and any attachments thereto, is intended only for use by the >>> >> addressee(s) named herein and >> >>> may contain legally privileged and/or confidential information. If you >>> >> are not the intended recipient >> >>> of this e-mail, you are hereby notified that any dissemination, >>> >> distribution or copying of this e-mail, and >> >>> any attachments thereto, is strictly prohibited. If you have received >>> >> this in error, please immediately notify >> >>> me and permanently delete the original and any copy of any e-mail and any >>> >> printout thereof. >> >>> E-mail transmission cannot be guaranteed to be secure or error-free. The >>> >> sender therefore does not accept >> >>> liability for any errors or omissions in the contents of this message >>> >> which arise as a result of e-mail transmission. >> >>> NOTICE REGARDING PRIVACY AND CONFIDENTIALITY >>> Direct Edge ECN LLC may, at its discretion, monitor and review the >>> >> content of all e-mail communications. >> >>> www.directedge.com >>> _______________________________________________ >>> 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 skippy.hammond at gmail.com Fri Aug 28 00:36:21 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Fri, 28 Aug 2009 08:36:21 +1000 Subject: [python-win32] [Fwd: Re: Running the COM MakePy Utility from python] In-Reply-To: <4A96732E.9060700@p-s.co.nz> References: <4A96732E.9060700@p-s.co.nz> Message-ID: <4A970A65.3030607@gmail.com> Look for the win32com.client.gencache module - it exposes a number of functions (EnsureDispatch, EnsureModule etc) designed simply to avoid the requirement to explicitly run makepy before using an object. Cheers, Mark On 27/08/2009 9:51 PM, Grant Paton-Simpson wrote: > Hi Harald, > > I managed to make a file containing everything I needed. NB the command > is makepy.py not makepy. There was, however, an issue with genpy.py > asserting there had to be a self.file.encoding even though I couldn't > see where that was set. I temporarily commented that assert out. File > creation then worked. I then took out the small portion of the script I > needed - all the data type constants - and put those in my own module. > Success! > > For the benefit of others, the reason you don't have to specify the > library e.g. ActiveX 2.8, is that you will be prompted for it via a pop > up GUI. > > > All the best, Grant > > > Massa, Harald Armin wrote: > > Grant, > > > > that is possible. Just read the makepy.py script within > > win32com.client, and you will find that someway down main() there is > > > > --------- > > GenerateFromTypeLibSpec(arg, f, verboseLevel = verboseLevel, > > bForDemand = bForDemand, bBuildHidden = hiddenSpec) > > --------- > > > > which does this. > > > > BUT, for "static" usage of makepy-COM-Mappings I suggest to make > > makepy output it's results in a named file > > > > makepy -o ADO28.py > > > > and furtheron import that ADO28 file to access the variables. That > > does also work with Excel and Word, and I am used to > > > > import ExcelXX as Excel > > ec=Excel.constants > > > > and further on us ec.* for excel constants. > > > > Best wishes, > > > > HArald > > > > On Thu, Aug 27, 2009 at 2:51 AM, Grant Paton-Simpson > > wrote: > > > > Hi, > > > > Basically I want to have an installation package automatically run the > > COM MakePy utility for the ADO 2.8 library. I believe I need to do > > this > > so that constants like win32com.client.constants.adTinyInt will be > > available when my application (http://www.sofastatistics.com) > > connects to > > MS Access and MS SQL Server databases. > > > > Ideally I would have a line doing something like this: > > > > win32com.runmakepy("Microsoft ActiveX Data Objects 2.8 Library (2.8)") > > > > Is it possible to do this programmatically? > > > > > > All the best, Grant > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > > > > > > -- > > GHUM Harald Massa > > persuadere et programmare > > Harald Armin Massa > > Spielberger Stra?e 49 > > 70435 Stuttgart > > 0173/9409607 > > no fx, no carrier pigeon > > - > > LASIK good, steroids bad? > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From grant at p-s.co.nz Fri Aug 28 00:47:26 2009 From: grant at p-s.co.nz (Grant Paton-Simpson) Date: Fri, 28 Aug 2009 10:47:26 +1200 Subject: [python-win32] [Fwd: Re: Running the COM MakePy Utility from python] In-Reply-To: References: <4A96732E.9060700@p-s.co.nz> Message-ID: <4A970CFE.7020602@p-s.co.nz> Cool - that's what I love about the open source community. You can see the code, fix the code, and share the fix. Massa, Harald Armin wrote: > Grant, > > for your problems with the assertion there is a patch... > > - > ----------------------------------------------------------------------------------------------- > > in Version 213 of pywin32 within > > win32com\client\genpy.py > > on line 814, within def do_gen_file_header(self): there is the assertion: > > # You must provide a file correctly configured for writing unicode. > # We assert this is it may indicate somewhere in pywin32 that needs > # upgrading. > assert self.file.encoding, self.file > > > But using makepy.py via > makepy.py -v -o OLE_Excel11.py "Microsoft Excel 11.0 Object Library" > > this assertion fails ... as self.file.encoding is None > > The culprit is makepy.py itself: > > starting at line 367ff there is: > > if outputName is not None: > path = os.path.dirname(outputName) > if path is not '' and not os.path.exists(path): > os.makedirs(path) > f = open(outputName, "w") > else: > f = None > > and this "f" will have encoding=None > > I patched this to: > > if outputName is not None: > path = os.path.dirname(outputName) > if path is not '' and not os.path.exists(path): > os.makedirs(path) > #~ f = open(outputName, "w") > import codecs > f= codecs.open(outputName, mode="w",encoding="mbcs") > else: > f = None > > use codecs to create a file with mbcs encoding. After this, I get a > nice create ole_excel11.py file, with the good line > # -*- coding: mbcs -*- > > at the beginning. > > I propose to put this fix into makepy.py for everybody; (any rights > you need are hereby granted) > - > ----------------------------------------------------------------------------------------------- > > (of which you could not know; I guess it got lost somewhere between > Europe and Australia, where Mark Hammond, the master of pywin32, was > before) > > Now I have put out this patch to the public, for others to enjoy > untill it may or may not be worked into makepy.py > > best wishes, > > Harald > > On Thu, Aug 27, 2009 at 1:51 PM, Grant Paton-Simpson > wrote: > > Hi Harald, > > I managed to make a file containing everything I needed. NB the > command > is makepy.py not makepy. There was, however, an issue with genpy.py > asserting there had to be a self.file.encoding even though I couldn't > see where that was set. I temporarily commented that assert out. > File > creation then worked. I then took out the small portion of the > script I > needed - all the data type constants - and put those in my own > module. Success! > > For the benefit of others, the reason you don't have to specify the > library e.g. ActiveX 2.8, is that you will be prompted for it via > a pop > up GUI. > > > All the best, Grant > > > Massa, Harald Armin wrote: > > Grant, > > > > that is possible. Just read the makepy.py script within > > win32com.client, and you will find that someway down main() there is > > > > --------- > > GenerateFromTypeLibSpec(arg, f, verboseLevel = verboseLevel, > > bForDemand = bForDemand, bBuildHidden = hiddenSpec) > > --------- > > > > which does this. > > > > BUT, for "static" usage of makepy-COM-Mappings I suggest to make > > makepy output it's results in a named file > > > > makepy -o ADO28.py > > > > and furtheron import that ADO28 file to access the variables. That > > does also work with Excel and Word, and I am used to > > > > import ExcelXX as Excel > > ec=Excel.constants > > > > and further on us ec.* for excel constants. > > > > Best wishes, > > > > HArald > > > > On Thu, Aug 27, 2009 at 2:51 AM, Grant Paton-Simpson > > > >> wrote: > > > > Hi, > > > > Basically I want to have an installation package > automatically run the > > COM MakePy utility for the ADO 2.8 library. I believe I need > to do > > this > > so that constants like win32com.client.constants.adTinyInt > will be > > available when my application (http://www.sofastatistics.com) > > connects to > > MS Access and MS SQL Server databases. > > > > Ideally I would have a line doing something like this: > > > > win32com.runmakepy("Microsoft ActiveX Data Objects 2.8 > Library (2.8)") > > > > Is it possible to do this programmatically? > > > > > > All the best, Grant > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > > > > > > -- > > GHUM Harald Massa > > persuadere et programmare > > Harald Armin Massa > > Spielberger Stra?e 49 > > 70435 Stuttgart > > 0173/9409607 > > no fx, no carrier pigeon > > - > > LASIK good, steroids bad? > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > > > -- > GHUM Harald Massa > persuadere et programmare > Harald Armin Massa > Spielberger Stra?e 49 > 70435 Stuttgart > 0173/9409607 > no fx, no carrier pigeon > - > LASIK good, steroids bad? From skip at pobox.com Fri Aug 28 13:04:10 2009 From: skip at pobox.com (skip at pobox.com) Date: Fri, 28 Aug 2009 06:04:10 -0500 (CDT) Subject: [python-win32] Exception when manipulating paths containing non-ASCII characters Message-ID: <20090828110410.9AB2F11EB638@montanaro.dyndns.org> I have zero Windows programming experience and also no experience manipulating paths containing non-ASCII characters. A Windows user of Task Coach (which uses the lockfile module) is getting a traceback in this code: self.unique_name = os.path.join(dirname, "%s.%s%s" % (self.hostname, tname, self.pid)) raising a UnicodeDecodeError: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 3: ordinal not in range(128) on a WIndows system when the hostname contains non-ASCII data. (All the other elements involved in the os.path.join call are ASCII or numbers.) I can't reproduce this on my Mac in the obvious way: >>> h = u'\u00ef' >>> n = "abc" >>> p = 123 >>> os.path.join("c:/temp", "%s.%s.%s" % (h, n, p)) u'c:/temp/\xef.abc.123' so I don't know how to fix what appears not to be broke or how to test it once I do. I tried the above code snippet on my Mac using a number of different versions, including CVS trunk, Python 2.5.4 and 2.4.5 from MacPorts and Apple's /usr/bin/python (2.5.1). All worked just fine. The full text of the problem is in the nascent lockfile issue tracker on bitbucket: http://bitbucket.org/smontanaro/lockfile/issue/1/ Frank Niessink, the author of Task Coach, who reported the problem, seems not to be able to reproduce it in his Windows environment either, though in further exchanges with his user Frank reported that if she changed the name of her computer to not contain accented characters lockfile worked for her. Task Coach comes with an embedded copy of Python 2.5.1. Can anyone here shed some light on what the problem might be? Thanks, -- Skip Montanaro - skip at pobox.com - http://www.smontanaro.net/ Getting old sucks, but it beats dying young From chef at ghum.de Fri Aug 28 14:38:33 2009 From: chef at ghum.de (Massa, Harald Armin) Date: Fri, 28 Aug 2009 14:38:33 +0200 Subject: [python-win32] Exception when manipulating paths containing non-ASCII characters In-Reply-To: <20090828110410.9AB2F11EB638@montanaro.dyndns.org> References: <20090828110410.9AB2F11EB638@montanaro.dyndns.org> Message-ID: Skip, self.unique_name = os.path.join(dirname, > "%s.%s%s" % (self.hostname, > tname, > self.pid)) > > raising a UnicodeDecodeError: > > UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 3: > ordinal not in range(128) > > on a WIndows system when the hostname contains non-ASCII data. (All the > other elements involved in the os.path.join call are ASCII or numbers.) > A quite common pain within the non-ASCII-World of Python on Windows programming. The quickest soliution I found is to switch the sys.setdefaultencoding to UTF-8, follower on slot 2 is to switch default-encoding to latin-1. Both solutions are productive in real world projects for 5 (utf-8) and 9 years (latin-1) with various apps by me; and a similiar solution is reported by Chris Withers for running productive for 5 years. Both solutions were called being highly dangerous by MvL and others on c.p.dev; esp. pointing out problems that can happen concerning hashes / dict-keys not comparing as expected. A more work-intensive soluton: only use unicode inside your application and have a dedicated encoding step when interfacing with the environment (the MAL recommend way, find slides here: http://www.egenix.com/library/presentations/#DesigningUnicodeAwareApplicationsInPython ) one try in that step: make that string-substituion a unicode substitution. (guessing that self.hostname is Unicode not String on winnt and up) self.unique_name = os.path.join(dirname, u"%s.%s%s" % (self.hostname, tname, self.pid)) (ATM converting my code step-by-step to that "only use unicode inside" way, with having a sys.defaultencoding = "UTF-8" as "get less unicodexx errors fallback") best wishes, Harald -- GHUM Harald Massa persuadere et programmare Harald Armin Massa Spielberger Stra?e 49 70435 Stuttgart 0173/9409607 no fx, no carrier pigeon - LASIK good, steroids bad? -------------- next part -------------- An HTML attachment was scrubbed... URL: From tharan at nsidc.org Sat Aug 29 02:43:21 2009 From: tharan at nsidc.org (Terry Haran) Date: Fri, 28 Aug 2009 18:43:21 -0600 Subject: [python-win32] Unable to install PyWin32 with Python 2.6.2 In-Reply-To: References: Message-ID: <4A9879A9.40300@nsidc.org> Hi Chris: I'm getting: error: Unable to find vcvarsall.bat when running setup.py install with pywin32-214 and Python 2.6.2 under Microsoft Windows XP [Version 5.1.2600] on a Panasonic CF-19 Series Toughbook. Any help would be greatly appreciated. Thanks, --Terry -- Terence (Terry) Haran National Snow & Ice Data Center tharan at nsidc.org University of Colorado voice: 303-492-1847 449 UCB fax: 303-492-2468 Boulder, CO 80309-0449 From kpoman at hotmail.com Sat Aug 29 15:06:58 2009 From: kpoman at hotmail.com (Patricio Stegmann) Date: Sat, 29 Aug 2009 10:06:58 -0300 Subject: [python-win32] problem on data type conversion Message-ID: Hello to all, I am trying to use an activex component that has a property named Display: """ _prop_map_get_ = { "AcquisitionMode": (1610743818, 2, (3, 0), (), "AcquisitionMode", None), "Display": (1610743816, 2, (3, 0), (), "Display", None), "TimeOut": (1610743820, 2, (3, 0), (), "TimeOut", None), } _prop_map_put_ = { "AcquisitionMode": ((1610743818, LCID, 4, 0),()), "Display": ((1610743816, LCID, 4, 0),()), "TimeOut": ((1610743820, LCID, 4, 0),()), } """ This works: print l__acq.Display However this doesnt: l__acq.Display = 135780 # 135780 is the handle to a window on my screen and I get this: *** com_error: (-2147467262, 'Interfaz no compatible', None, None) Please can someone help me ? _________________________________________________________________ Show them the way! Add maps and directions to your party invites. http://www.microsoft.com/windows/windowslive/products/events.aspx -------------- next part -------------- An HTML attachment was scrubbed... URL: From breamoreboy at yahoo.co.uk Sat Aug 29 15:14:23 2009 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 29 Aug 2009 14:14:23 +0100 Subject: [python-win32] Unable to install PyWin32 with Python 2.6.2 In-Reply-To: <4A9879A9.40300@nsidc.org> References: <4A9879A9.40300@nsidc.org> Message-ID: Terry Haran wrote: > Hi Chris: > > I'm getting: > error: Unable to find vcvarsall.bat > when running > setup.py install > with pywin32-214 > and Python 2.6.2 > under > Microsoft Windows XP [Version 5.1.2600] > on a > Panasonic CF-19 Series Toughbook. > > Any help would be greatly appreciated. > > Thanks, > --Terry > My work around for this was to edit the distutils msvc9compiler.py file. I commented out the line vcvarsall = find_vcvarsall(version) in the function query_vcvarsall and hard coded vcvarsall = r'C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat'. This assumes that you've got a copy of Visual C++!:) HTH. -- Kindest regards. Mark Lawrence. From kpoman at hotmail.com Mon Aug 31 02:39:53 2009 From: kpoman at hotmail.com (Patricio Stegmann) Date: Sun, 30 Aug 2009 21:39:53 -0300 Subject: [python-win32] bug with CastTo and py2exe Message-ID: Hi to all, I am encountering a problem which seems like a bug when using the CastTo method. Basically see this test (msiecontrols is a generated module, initially named B025F75A-CD86-4D11-A0C8-D7644FDBFB5Ax0x1x0.py or """Microsoft Internet Controls"""). testie.py ------------------------- import msiecontrols import win32com l__iev1 = msiecontrols.InternetExplorer() l__iev2 = win32com.client.CastTo(l__iev1, 'IWebBrowserApp') print 'ok' ------------------------- This, executed on command line python testie.py gives as expected: C:\tmp\cap>python test_ie.py ok C:\tmp\cap> But when doing a py2exe of it with this script: build_binary.py ------------------------- from distutils.core import setup import py2exe import sys if len(sys.argv) == 1: sys.argv.append("py2exe") setup( options = {"py2exe": {"compressed": 1, "optimize": 2}},zipfile = 'libfiles.zip', console = [{"script": 'test_ie.py'}] ) ------------------------- I get this when executing: C:\tmp\cap\dist>test_ie.exe Traceback (most recent call last): File "test_ie.py", line 5, in File "win32com\client\__init__.pyo", line 147, in CastTo AttributeError: 'NoneType' object has no attribute 'CLSID' C:\tmp\cap\dist> Please can someone point me to a little light on this ? This happens whenever I use CastTo. _________________________________________________________________ Share your memories online with anyone you want. http://www.microsoft.com/middleeast/windows/windowslive/products/photos-share.aspx?tab=1 -------------- next part -------------- An HTML attachment was scrubbed... URL: