From timr at probo.com Sat Sep 1 00:17:41 2007 From: timr at probo.com (Tim Roberts) Date: Fri, 31 Aug 2007 15:17:41 -0700 Subject: [python-win32] Windows services in python In-Reply-To: <99069ac50708311446o5b200443l39da986ab626a1b7@mail.gmail.com> References: <99069ac50708311041q3718356ex70e0aaa0d2204507@mail.gmail.com> <46D861B8.7000404@probo.com> <99069ac50708311446o5b200443l39da986ab626a1b7@mail.gmail.com> Message-ID: <46D89385.8010007@probo.com> Dmitry Alekseenko wrote: > win32service methods produces the same problem: > > def Enable(self, serviceName, enable, autoStart=False): > startType = None > if not enable: > startType = win32service.SERVICE_DISABLED > elif autoStart: > startType = win32service.SERVICE_AUTO_START > else: > startType = win32service.SERVICE_DEMAND_START > > scm = win32service.OpenSCManager (None, None, > win32service.SC_MANAGER_ALL_ACCESS) > svc = win32service.OpenService(scm, serviceName, > win32service.SC_MANAGER_ALL_ACCESS) > win32service.ChangeServiceConfig(svc, win32service.SERVICE_NO_CHANGE, > startType, > win32service.SERVICE_NO_CHANGE, > None, None, 0, None, None, None, > None) > win32service.CloseServiceHandle(svc) I'm afraid I don't believe you. Did you change the ImagePath back to its proper value before you tested this? (It should be "%SystemRoot%\System32\svchost.exe -k netsvcs") Remember, this won't fix the damage that your previous script did; it just leaves ImagePath where it was. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From dalekseenko at gmail.com Sat Sep 1 01:22:05 2007 From: dalekseenko at gmail.com (Dmitry Alekseenko) Date: Fri, 31 Aug 2007 16:22:05 -0700 Subject: [python-win32] Windows services in python In-Reply-To: <46D89385.8010007@probo.com> References: <99069ac50708311041q3718356ex70e0aaa0d2204507@mail.gmail.com> <46D861B8.7000404@probo.com> <99069ac50708311446o5b200443l39da986ab626a1b7@mail.gmail.com> <46D89385.8010007@probo.com> Message-ID: <99069ac50708311622r54dfbf28i1ba736beb3bd67dd@mail.gmail.com> You're right. Sorry about that. And thank you for help! Dmitry On 8/31/07, Tim Roberts wrote: > > Dmitry Alekseenko wrote: > > win32service methods produces the same problem: > > > > def Enable(self, serviceName, enable, autoStart=False): > > startType = None > > if not enable: > > startType = win32service.SERVICE_DISABLED > > elif autoStart: > > startType = win32service.SERVICE_AUTO_START > > else: > > startType = win32service.SERVICE_DEMAND_START > > > > scm = win32service.OpenSCManager (None, None, > > win32service.SC_MANAGER_ALL_ACCESS) > > svc = win32service.OpenService(scm, serviceName, > > win32service.SC_MANAGER_ALL_ACCESS) > > win32service.ChangeServiceConfig(svc, win32service.SERVICE_NO_CHANGE > , > > startType, > > win32service.SERVICE_NO_CHANGE, > > None, None, 0, None, None, None, > > None) > > win32service.CloseServiceHandle(svc) > > I'm afraid I don't believe you. Did you change the ImagePath back to > its proper value before you tested this? (It should be > "%SystemRoot%\System32\svchost.exe -k netsvcs") Remember, this won't > fix the damage that your previous script did; it just leaves ImagePath > where it was. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070831/93a30d24/attachment.htm From oliver at hallmarkins.net Tue Sep 4 02:29:04 2007 From: oliver at hallmarkins.net (Oliver T. Nelson) Date: Mon, 03 Sep 2007 17:29:04 -0700 Subject: [python-win32] Canceling OnBeforeClick event in MapPoint, 2006 Message-ID: <46DCA6D0.8030906@hallmarkins.net> Roger, I have tried returning True and I get the same result. I've tried many variations, but none seem to work. Tim, I believe that its probably a VARIANT_BOOL. The tool I'm using (Oakland Software ActiveX/COM Inspector) just shows it as a bool* . Mark, I read the thread between you and Roger on named params. Maybe thats the issue, but my tests show that the parameters are being passed in the correct order. OLIVER From cgalvan at enthought.com Tue Sep 4 17:13:59 2007 From: cgalvan at enthought.com (Christopher Galvan) Date: Tue, 04 Sep 2007 10:13:59 -0500 Subject: [python-win32] MSI calling python.exe as part of Install Sequence Message-ID: <46DD7637.307@enthought.com> Hello all, I am in the process of creating a .msi that installs a couple of packages by extracting the .egg files to a directory and then running a python script that installs easy_install, if it's not already there, and then uses easy_install to install the packages. I have everything setup except that when I call python.exe to run my script, I do not want a command prompt window to appear. Does anyone know how to tell the msi installer to not open a command prompt window for a call to python.exe, or any executable for that matter? Thank you for your time. -- Chris Galvan From bruce at blazertech.net Tue Sep 4 17:22:32 2007 From: bruce at blazertech.net (Bruce at blazer) Date: Tue, 4 Sep 2007 23:22:32 +0800 Subject: [python-win32] MSI calling python.exe as part of Install Sequence In-Reply-To: <46DD7637.307@enthought.com> References: <46DD7637.307@enthought.com> Message-ID: <1095970873.20070904232232@blazertech.net> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070904/cc30a6f7/attachment.htm From larry.bates at websafe.com Thu Sep 6 16:00:00 2007 From: larry.bates at websafe.com (Larry Bates) Date: Thu, 06 Sep 2007 09:00:00 -0500 Subject: [python-win32] Writing .NET component in Python Message-ID: Does anyone have any insight where I would start looking for information on writing .NET compatible components in Python. I have a COM object that is written in Python and some developers have asked for a .NET port of it. I spent some time in Google and didn't come up with any information to get me going. Thanks in advance. Larry From graemeglass at gmail.com Thu Sep 6 16:13:07 2007 From: graemeglass at gmail.com (Graeme Glass) Date: Thu, 6 Sep 2007 16:13:07 +0200 Subject: [python-win32] Writing .NET component in Python In-Reply-To: References: Message-ID: On 9/6/07, Larry Bates wrote: > Does anyone have any insight where I would start looking for information on > writing .NET compatible components in Python. I have a COM object that is > written in Python and some developers have asked for a .NET port of it. I spent > some time in Google and didn't come up with any information to get me going. > > Thanks in advance. > Larry > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > IronPython? http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython From theller at ctypes.org Thu Sep 6 17:27:13 2007 From: theller at ctypes.org (Thomas Heller) Date: Thu, 06 Sep 2007 17:27:13 +0200 Subject: [python-win32] Writing .NET component in Python In-Reply-To: References: Message-ID: Larry Bates schrieb: > Does anyone have any insight where I would start looking for information on > writing .NET compatible components in Python. I have a COM object that is > written in Python and some developers have asked for a .NET port of it. I spent > some time in Google and didn't come up with any information to get me going. Not sure what you mean by .NET port. I have the impression (from reading, never used .NET myself) that .NET is able to use COM objects. It may be required that the COM objects must have a type library. Thomas From mc at mclaveau.com Thu Sep 6 17:41:10 2007 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 6 Sep 2007 17:41:10 +0200 Subject: [python-win32] Writing .NET component in Python References: Message-ID: <000401c7f09c$5a7ca0f0$0601a8c0@PORTABLES> Hi! > I have the impression (from reading, never used .NET myself) that .NET is > able to use COM objects. I confirm. dotNET can use COM objects. But. COM servers in Python has no TLB (Types-LiBrary). For use these components from C#, we MUST use a tech named "late binding". I have (but where?) an example of use that in C# for call my Python-COM-server. And If it's possible for C#, it's not possible for PowerShell. PowerShell can use ONLY COM-server with TLB. (wait next release?) @-salutations Michel Claveau (& sorry for my bad english) From sidnei at enfoldsystems.com Thu Sep 6 18:11:42 2007 From: sidnei at enfoldsystems.com (Sidnei da Silva) Date: Thu, 6 Sep 2007 13:11:42 -0300 Subject: [python-win32] Writing .NET component in Python References: Message-ID: [ Thomas Heller ] > Not sure what you mean by .NET port. I have the impression (from reading, > never > used .NET myself) that .NET is able to use COM objects. It may be > required that > the COM objects must have a type library. That's my understanding too. If you search for articles on .NET and COM Interop pretty much all of them talk about using type libraries. Soo... the question is, how to create a type library for Python COM objects? -- Sidnei da Silva Enfold Systems, Inc. From larry.bates at websafe.com Thu Sep 6 18:59:28 2007 From: larry.bates at websafe.com (Larry Bates) Date: Thu, 06 Sep 2007 11:59:28 -0500 Subject: [python-win32] Writing .NET component in Python In-Reply-To: References: Message-ID: Sidnei da Silva wrote: > [ Thomas Heller ] >> Not sure what you mean by .NET port. I have the impression (from reading, >> never >> used .NET myself) that .NET is able to use COM objects. It may be >> required that >> the COM objects must have a type library. > > That's my understanding too. If you search for articles on .NET and COM > Interop pretty much all of them talk about using type libraries. > > Soo... the question is, how to create a type library for Python COM objects? > I'm new to .NET so when .NET developers ask me "When are you going to deliver .NET port of your API" I sort of shrug and say "We are looking into it". I sort of intuitively knew that you should be able to call COM objects, it is just M$ developers seem to want people to do custom implementations for them. Now how to get TLB for my COM object? I guess that is the question. -Larry From theller at ctypes.org Thu Sep 6 19:29:58 2007 From: theller at ctypes.org (Thomas Heller) Date: Thu, 06 Sep 2007 19:29:58 +0200 Subject: [python-win32] Writing .NET component in Python In-Reply-To: References: Message-ID: Sidnei da Silva schrieb: > [ Thomas Heller ] >> Not sure what you mean by .NET port. I have the impression (from reading, >> never >> used .NET myself) that .NET is able to use COM objects. It may be >> required that >> the COM objects must have a type library. > > That's my understanding too. If you search for articles on .NET and COM > Interop pretty much all of them talk about using type libraries. > > Soo... the question is, how to create a type library for Python COM objects? > The canonical answer is: Write an IDL file, and compile it with the MIDL compiler: midl mytypelib.idl /tlb mytypelib.tlb This creates the 'mytypelib.tlb' typelibrary (among other files that you will not need). A MIDL compiler is probably included in the free VC 2005 express edition, or maybe even in the MS platform SDK. The syntax of IDL files is documented on MS sites. Also useful for reference is the OLEVIEW program which allows to decompile existing type libraries. The second approach would be to use pywin32 apis to create the type library programmatically; there have been several attempts in the past but I have not yet seen a finished solution. What I do NOT know: Is the presence of a typelibrary file sufficient for accessing the COM object, or must the typelib be integrated into the object itself? There are interfaces that allow a COM object to make its type information available to clients; I do not know if they are used by .NET or not. Thomas From sidnei at enfoldsystems.com Thu Sep 6 20:02:24 2007 From: sidnei at enfoldsystems.com (Sidnei da Silva) Date: Thu, 6 Sep 2007 15:02:24 -0300 Subject: [python-win32] Writing .NET component in Python References: Message-ID: Here's the information that I've found: http://msdn2.microsoft.com/en-us/library/ms973800.aspx So basically you use tlbimp to create a 'Runtime Callable Wrapper' which is a trusted .NET assembly that can call your COM object. -- Sidnei da Silva Enfold Systems, Inc. From fuzzyman at voidspace.org.uk Thu Sep 6 21:55:51 2007 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Thu, 06 Sep 2007 20:55:51 +0100 Subject: [python-win32] [python] Re: Writing .NET component in Python In-Reply-To: References: Message-ID: <46E05B47.3090404@voidspace.org.uk> Sidnei da Silva wrote: > Here's the information that I've found: > > http://msdn2.microsoft.com/en-us/library/ms973800.aspx > > So basically you use tlbimp to create a 'Runtime Callable Wrapper' which is > a trusted .NET assembly that can call your COM object. > > IronPython would certainly be a great way to test consuming your COM object from the .NET side. Michael http://www.ironpython.info/ From vernondcole at gmail.com Fri Sep 7 18:01:37 2007 From: vernondcole at gmail.com (Vernon Cole) Date: Fri, 7 Sep 2007 10:01:37 -0600 Subject: [python-win32] [python] Re: Writing .NET component in Python In-Reply-To: <46E05B47.3090404@voidspace.org.uk> References: <46E05B47.3090404@voidspace.org.uk> Message-ID: A user friendly distribution of iron python (with batteries included) is found at: http://fepy.sourceforge.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070907/e3a6b773/attachment.htm From m.gysel at gmx.ch Sun Sep 9 18:09:52 2007 From: m.gysel at gmx.ch (Martin Gysel) Date: Sun, 09 Sep 2007 18:09:52 +0200 Subject: [python-win32] High Baud Rate Serial Port Question Message-ID: <46E41AD0.7090904@gmx.ch> I brand new to this list, I just read this topic on the mail archive... > Normally baud rates higher than that take "special" hardware. this depends what you call "special" hardware, every FTDI chip (virtual com port) supports higher baudrates. I use one with 1000000 bps. so there's no problem to interface hardware which such rates. I also want to use python to communicate at 1000000 bps with my hardware, it would make live easier... Jeff did you find a practical solution? martin From aneubauer at ra.rockwell.com Mon Sep 10 21:23:57 2007 From: aneubauer at ra.rockwell.com (Andreas Neubauer) Date: Mon, 10 Sep 2007 21:23:57 +0200 Subject: [python-win32] Properly encoded HTML from MSXML XLST processor into python string (via IStream) ? Message-ID: Dear all, Using the Microsoft XML core services (MSXML 4.0) as an XSLT-processor for python i got into a trap when trying to generate properly unicode(UTF-8) encoded HTML: The encoding statement gets lost in the HTML header, and white-spaces UTF-8: HEX code C2 A0 convert to A0. Testing and reading the Microsoft doku I found this working fine if the target output is of type IStream ... Can I somehow use a Microsoft IStream object or implement it in a suitable manner ? The XSLT stylesheet controls it like this: However this output configuration statement gets ignored if the IXSLProcessor is not used with a custom output (e.g. IStream object). Microsoft: "When a new transform is started, the processor will use a QueryInterface this output for IStream. When the transform is complete or reset is called, IStream is released. The only method that is used on IStream is Write. The bytes written to the stream will be encoded according to the encoding attribute on the element. If you do not provide a custom output, then you will get a string when you read this property. The string contains the incrementally buffered transformation result. Reading this property has the side effect of resetting that internal buffer so that each time you read the property you get the next chunk of output. In this case, the output is always generated in the Unicode encoding, and the encoding attribute on the element is ignored." Like in this python example: ----------------------------------------------------------------------------------- _msxmlLib = win32com.client.gencache.EnsureModule("{F5078F18-C551-11D3-89B9-0000F81FE221}", 0, 4, 0) ... xslt = win32com.client.dynamic.Dispatch("Msxml2.XSLTemplate.4.0") ... xslProc = xslt.createProcessor(); xslProc.input = xmlDoc xslProc.transform() xmlData=xslProc.output ----------------------------------------------------------------------------------- If I use a custom output like this: ----------------------------------------------------------------------------------- xmlData="" xslProc.transform() xslProc.output(xmlData) ----------------------------------------------------------------------------------- MSXML com object returns an error: " Exception during xslt transformation: 'unicode' object is not callable " Is there a way in python to provide an appropriate unicode object receiving the output without ignoring the encoding statement ? Any proven way using IXSLProcessor generating properly encoded HTML into python ? Kind regards Andreas Neubauer -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070910/f5e2c702/attachment.htm From timr at probo.com Mon Sep 10 23:05:21 2007 From: timr at probo.com (Tim Roberts) Date: Mon, 10 Sep 2007 14:05:21 -0700 Subject: [python-win32] Properly encoded HTML from MSXML XLST processor into python string (via IStream) ? In-Reply-To: References: Message-ID: <46E5B191.2000306@probo.com> Andreas Neubauer wrote: > > Dear all, > Using the Microsoft XML core services (MSXML 4.0) as an XSLT-processor > for python > i got into a trap when trying to generate properly unicode(UTF-8) > encoded HTML: > The encoding statement gets lost in the HTML header, and > white-spaces UTF-8: HEX code C2 A0 convert to A0. > > Testing and reading the Microsoft doku I found this working fine if > the target output is of type IStream ... > Can I somehow use a Microsoft IStream object or implement it in a > suitable manner ? > ... > > ----------------------------------------------------------------------------------- > > If I use a custom output like this: > ----------------------------------------------------------------------------------- > > xmlData="" > xslProc.transform() > xslProc.output(xmlData) > ----------------------------------------------------------------------------------- > > MSXML com object returns an error: > " Exception during xslt transformation: 'unicode' object is not > callable " > "output" is a property, not a method. That statement will fetch the value of the property (a string) and try to call it like a function. You probably want this: xslProc.output = xmlData but xmlData has to be something that supports IStream. Python strings do not. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rwupole at msn.com Tue Sep 11 01:14:01 2007 From: rwupole at msn.com (Roger Upole) Date: Mon, 10 Sep 2007 19:14:01 -0400 Subject: [python-win32] High Baud Rate Serial Port Question Message-ID: <001801c7f400$47cf3e10$0100a8c0@rupole> Jeff Taylor wrote: > I know this has probably been brought up many years ago, but I'm rather > new to Python. > > Is there a way to open a serial port with a baudrate greater than > 115.2kbps? I'm currently using pyserial and it can handle over 115.2, > but when it calls win32file, win32file gives back a bad parameter error > for higher baudrates (like 230400 or 460800 bps). > > Any help would be appreciated. > > Thanks. Which function in win32file is throwing the exception ? It may be that the device only accepts specific baud rates. >From a quick look at pyserial, it has the buffer sizes hardcoded to 4096 in the call to win32file.SetupComm. Another possibility is that larger buffer sizes are needed for higher baud rates. Roger From rwupole at msn.com Tue Sep 11 01:36:17 2007 From: rwupole at msn.com (Roger Upole) Date: Mon, 10 Sep 2007 19:36:17 -0400 Subject: [python-win32] Properly encoded HTML from MSXML XLST processor into Message-ID: <003001c7f403$64131580$0100a8c0@rupole> See this thread for some discussion and examples of creating an object that implements IStream: http://mail.python.org/pipermail/python-win32/2007-August/006166.html Future builds will also have pythoncom.CreateStreamOnHGlobal for a quick and simple way to create an in-memory IStream. Roger From victor_lebrun at yahoo.fr Tue Sep 11 12:06:46 2007 From: victor_lebrun at yahoo.fr (victor LEBRUN) Date: Tue, 11 Sep 2007 10:06:46 +0000 (GMT) Subject: [python-win32] activeX persistent properties Message-ID: <595342.24071.qm@web27610.mail.ukl.yahoo.com> Hello python win32 users ! I would lik to know if it is possible to access persistent properties of an ole object (activeX control) with pywin ? tkank you for your help. regards, Victor _____________________________________________________________________________ Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail From mc at mclaveau.com Tue Sep 11 12:24:15 2007 From: mc at mclaveau.com (Michel Claveau) Date: Tue, 11 Sep 2007 12:24:15 +0200 Subject: [python-win32] activeX persistent properties References: <595342.24071.qm@web27610.mail.ukl.yahoo.com> Message-ID: <000701c7f45d$e9795f90$060aa8c0@PORTABLES> Bonjour ! > I would lik to know if it is possible to access persistent properties of > an ole object (activeX control) with pywin ? Par d?faut, j'aurais tendance ? r?pondre OUI, du moment qu'elles sont expos?es (publiques). Car Python+Pywin32 permet d'acc?der aux propri?t?s d'un objet COM. Attention ? un point : ? partir d'un objet OLE, il est des fois difficile de retrouver l'objet COM correspondant (sous-jacent). Mais, qu'appelez-vous propri?t?s "persistance", et, surtout, en quoi les distinguez-vous des propri?t?s normales. @-salutations Michel Claveau From victor_lebrun at yahoo.fr Tue Sep 11 12:42:18 2007 From: victor_lebrun at yahoo.fr (victor LEBRUN) Date: Tue, 11 Sep 2007 10:42:18 +0000 (GMT) Subject: [python-win32] Re : activeX persistent properties Message-ID: <780696.7130.qm@web27607.mail.ukl.yahoo.com> A persistent property is only accessible at design-time and not at run-time, and it drives the behavior of the activeX control. Those properties are public I think since you can modify them. But if you call the object with win32com.client.Dispatch it is tool late since the property can not be set at run-time.... I need to tell to the object when I create it that one of its property is 'Picture' (the property is ModuleName), if it is already there it is too late I change the property but nothing appends: tl=win32com.client.Dispatch('blabla') tl.ModuleName= 'Picture' <=nothing appends, I need to pass this property during tl=win32com.client.Dispatch('blabla') ------------------------------------------------- in french ------------------------------------------------- Pour moi une 'persistent property' est une propriete qui n'est modifiable que lors du design de l'application avec Visual Studio ou autre, elle conditionne le controle, par example si le control va afficher un bitmap ou si il va afficher une image 'active' etc... ma proprietee est 'ModuleName', si j' appelle l'objet avec tl=win32com.client.Dispatch('blabla') j'ai beau essayer tl.ModuleName= 'Picture' ca ne change pas le comportement.... il faut donc que le control activeX sache avant le run-time que je veux qu'il aille me chercher la fonctionnalite 'Picture', j'ai vu qu'il y a un win32ui.CreateControl qui est appele je me demande si je ne peux pas passer des arguments a cette methode.... ou autre chose Any ideas ? regards, Victor ----- Message d'origine ---- De : Michel Claveau ? : python-win32 at python.org Envoy? le : Mardi, 11 Septembre 2007, 12h24mn 15s Objet : Re: [python-win32] activeX persistent properties Bonjour ! > I would lik to know if it is possible to access persistent properties of > an ole object (activeX control) with pywin ? Par d?faut, j'aurais tendance ? r?pondre OUI, du moment qu'elles sont expos?es (publiques). Car Python+Pywin32 permet d'acc?der aux propri?t?s d'un objet COM. Attention ? un point : ? partir d'un objet OLE, il est des fois difficile de retrouver l'objet COM correspondant (sous-jacent). Mais, qu'appelez-vous propri?t?s "persistance", et, surtout, en quoi les distinguez-vous des propri?t?s normales. @-salutations Michel Claveau _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 _____________________________________________________________________________ Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail From tennis at digitalfountain.com Fri Sep 14 00:47:32 2007 From: tennis at digitalfountain.com (Tennis Smith) Date: Thu, 13 Sep 2007 15:47:32 -0700 Subject: [python-win32] Expect-like behavior Message-ID: Hi, I'm new to both python and consequently its use on win32. I understand from lots of sources that "pexpect" is the overall best Expect-like implementation in python. *But* I also see that the only way to make it work in win32 is on cygwin. Unfortunately, that isn't an option for my users. We use the ActiveState python and would like to have Expect functionality on that rather than installing/supporting 2 different python implementations on the same machine. Mostly what's needed is the ability to spawn processes (with a timeout) and parse their output. What's the best option currently available for us? Thanks, -T -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070913/233d4363/attachment.htm From mail at timgolden.me.uk Fri Sep 14 10:34:25 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 14 Sep 2007 09:34:25 +0100 Subject: [python-win32] Expect-like behavior In-Reply-To: References: Message-ID: <46EA4791.4000807@timgolden.me.uk> Tennis Smith wrote: > I'm new to both python and consequently its use on win32. I understand > from lots of sources that "pexpect" is the overall best Expect-like > implementation in python. *But* I also see that the only way to make it > work in win32 is on cygwin. Unfortunately, that isn't an option for my > users. We use the ActiveState python and would like to have Expect > functionality on that rather than installing/supporting 2 different > python implementations on the same machine. > Mostly what's needed is the ability to spawn processes (with a timeout) > and parse their output. I *assume* you're the same person who's already posted under the alias "gamename" with a question which seems identical in its essentials? If you're not then I apologise and chalk one up to the gods of coincidence. If you are, then I would suggest that it appears slightly rude to sidestep such advice as is already coming your way and to post again as though no-one's tried to help you so far. (Not sure where you are in the world, but I'm in the UK and I'm just returning to the online world after a few hours of sleep and other essentials) From your description above and the details of the problem yesterday, it looks to me as though an expect solution might well be overkill. The subprocess module, part of the stdlib from Python 2.4 onwards and available as an extension module before that, offers ways to kick off processes, read their output, and check for completion. I thought it also exposed some kind of .terminate method, but it doesn't look like it. Instead you can use win32api.TerminateProcess from the pywin32 extensions, passing in the (non-public) ._handle attribute of the subprocess Popen object. Noddy example which fires up a notepad instance and waits up to 10 seconds for you to close it. If you don't, it is forcibly terminated. import time import subprocess import win32api notepad = subprocess.Popen (["notepad.exe"]) t0 = time.time () while time.time () < t0 + 10: if notepad.poll () == 0: print "Finished" break else: print "Terminating..." win32api.TerminateProcess (notepad._handle, 0) TJG From mail at timgolden.me.uk Fri Sep 14 12:22:09 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 14 Sep 2007 11:22:09 +0100 Subject: [python-win32] Expect-like behavior In-Reply-To: <46EA4791.4000807@timgolden.me.uk> References: <46EA4791.4000807@timgolden.me.uk> Message-ID: <46EA60D1.6030605@timgolden.me.uk> Tim Golden wrote: > I *assume* you're the same person who's already posted under > the alias "gamename" with a question which seems identical > in its essentials? If you're not then I apologise and chalk > one up to the gods of coincidence. If you are, then I would > suggest that it appears slightly rude to sidestep such advice > as is already coming your way and to post again as though > no-one's tried to help you so far. Ah. Apologies from me on this one; I hadn't noticed that the previous thread had been on c.l.py and this one's on python-win32. (They both come into the same mailbox here). Hope the information was useful in any case. TJG From rwupole at msn.com Sat Sep 15 00:13:33 2007 From: rwupole at msn.com (Roger Upole) Date: Fri, 14 Sep 2007 18:13:33 -0400 Subject: [python-win32] Re: Expect-like behavior Message-ID: <000201c7f71c$7f76de30$0100a8c0@rupole> Tennis Smith wrote: > Hi, > > I'm new to both python and consequently its use on win32. I understand > from lots of sources that "pexpect" is the overall best Expect-like > implementation in python. *But* I also see that the only way to make it > work in win32 is on cygwin. Unfortunately, that isn't an option for my > users. We use the ActiveState python and would like to have Expect > functionality on that rather than installing/supporting 2 different > python implementations on the same machine. > > Mostly what's needed is the ability to spawn processes (with a timeout) > and parse their output. > > What's the best option currently available for us? You may be able to use the win32console module, which wraps the native Windows console functions. It allows you to simulate interactive command prompt input and read its output as pexpect does. Roger From timr at probo.com Sat Sep 15 00:55:46 2007 From: timr at probo.com (Tim Roberts) Date: Fri, 14 Sep 2007 15:55:46 -0700 Subject: [python-win32] Expect-like behavior In-Reply-To: <000201c7f71c$7f76de30$0100a8c0@rupole> References: <000201c7f71c$7f76de30$0100a8c0@rupole> Message-ID: <46EB1172.3030303@probo.com> Roger Upole wrote: > You may be able to use the win32console module, which wraps the native > Windows console functions. It allows you to simulate interactive command > prompt input and read its output as pexpect does. > I'm not convinced of that. The console APIs let you read keystrokes and write text and graphics to your OWN console window, but to the best of my knowledge there is nothing in there to help you either monitor or control another application. The subprocess module is probably the right path for the original poster. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rwupole at msn.com Sat Sep 15 02:34:35 2007 From: rwupole at msn.com (Roger Upole) Date: Fri, 14 Sep 2007 20:34:35 -0400 Subject: [python-win32] Expect-like behavior Message-ID: <000e01c7f730$32c5c060$0100a8c0@rupole> Tim Roberts wrote: > Roger Upole wrote: >> You may be able to use the win32console module, which wraps the native >> Windows console functions. It allows you to simulate interactive command >> prompt input and read its output as pexpect does. >> > > I'm not convinced of that. The console APIs let you read keystrokes and > write text and graphics to your OWN console window, but to the best of > my knowledge there is nothing in there to help you either monitor or > control another application. By default a subprocess runs in the same console as the process that created it. You can also explicitely pass your own console handles to be used as stdin, stdout, and stderr. Additionally, AttachConsole can be used to access the console of another process. > The subprocess module is probably the right path for the original poster. > As far as I know, the subprocess module doesn't provide any facilities for implementing a timeout, such as async reads/writes. The OP may be able to roll his own using overlapped ReadFile on stdout of the subprocess, though. Roger From raduciora at yahoo.com Wed Sep 19 12:51:03 2007 From: raduciora at yahoo.com (Radu Ciora) Date: Wed, 19 Sep 2007 03:51:03 -0700 (PDT) Subject: [python-win32] PyIEnumMoniker Message-ID: <278319.24319.qm@web50102.mail.re2.yahoo.com> Hi guys, Can someone tell me how to use PyIEnumMoniker? I've tried : import pythoncom print PyIEnumMoniker.Next() but I get the error: NameError: global name 'PyIEnumMoniker' is not defined. Thanks a million, Radu. ___________________________________________________________ Want ideas for reducing your carbon footprint? Visit Yahoo! For Good http://uk.promotions.yahoo.com/forgood/environment.html From mhammond at skippinet.com.au Thu Sep 20 03:54:24 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 20 Sep 2007 11:54:24 +1000 Subject: [python-win32] PyIEnumMoniker In-Reply-To: <278319.24319.qm@web50102.mail.re2.yahoo.com> References: <278319.24319.qm@web50102.mail.re2.yahoo.com> Message-ID: <078401c7fb29$2e420ce0$8ac626a0$@com.au> > Can someone tell me how to use PyIEnumMoniker? > I've tried : > import pythoncom > > print PyIEnumMoniker.Next() > but I get the error: > > NameError: global name 'PyIEnumMoniker' is not defined. IEnumMoniker is just a COM interface - generally an object implementing that interface will be returned from a function call, or in some cases, you might be expected to provide an implementation and pass it to some object. The standard "Running Object Table" does return this interface though, so for an example, try: >>> import pythoncom >>> rot=pythoncom.GetRunningObjectTable() >>> e=rot.EnumRunning() >>> e.Next() (,) >>> Mark From raduciora at yahoo.com Thu Sep 20 16:15:55 2007 From: raduciora at yahoo.com (Radu Ciora) Date: Thu, 20 Sep 2007 07:15:55 -0700 (PDT) Subject: [python-win32] Fw: PyIEnumMoniker Message-ID: <26094.80842.qm@web50102.mail.re2.yahoo.com> OK, so my question would then be how can I get the running objects which I can see from the combrowser.py? 'cos for example I have an object in the combrowse called "D:\Temp\my.pdf" which is an adobe acrobat instance. I want to be able to get that document's name&path. Thanks a million, Radu. ----- Original Message ---- From: Mark Hammond To: Radu Ciora ; python-win32 at python.org Sent: Thursday, 20 September, 2007 2:54:24 AM Subject: RE: [python-win32] PyIEnumMoniker > Can someone tell me how to use PyIEnumMoniker? > I've tried : > import pythoncom > > print PyIEnumMoniker.Next() > but I get the error: > > NameError: global name 'PyIEnumMoniker' is not defined. IEnumMoniker is just a COM interface - generally an object implementing that interface will be returned from a function call, or in some cases, you might be expected to provide an implementation and pass it to some object. The standard "Running Object Table" does return this interface though, so for an example, try: >>> import pythoncom >>> rot=pythoncom.GetRunningObjectTable() >>> e=rot.EnumRunning() >>> e.Next() (,) >>> Mark ___________________________________________________________ Want ideas for reducing your carbon footprint? Visit Yahoo! For Good http://uk.promotions.yahoo.com/forgood/environment.html ___________________________________________________________ Want ideas for reducing your carbon footprint? Visit Yahoo! For Good http://uk.promotions.yahoo.com/forgood/environment.html From timr at probo.com Thu Sep 20 18:36:55 2007 From: timr at probo.com (Tim Roberts) Date: Thu, 20 Sep 2007 09:36:55 -0700 Subject: [python-win32] Fw: PyIEnumMoniker In-Reply-To: <26094.80842.qm@web50102.mail.re2.yahoo.com> References: <26094.80842.qm@web50102.mail.re2.yahoo.com> Message-ID: <46F2A1A7.7050401@probo.com> Radu Ciora wrote: > , > so my question would then be how can I get the running objects which I can see from the combrowser.py? > 'cos for example I have an object in the combrowse called "D:\Temp\my.pdf" which is an adobe acrobat instance. > I want to be able to get that document's name&path. > In the specific case of Acrobat, you can use the Running Object Table to do this. rot = pythoncom.GetRunningObjectTable() ctx = pythoncom.CreateBindCtx(0) enu = rot.EnumRunning() for ob in rot.EnumRunning(): print ob.GetDisplayName( ctx, None ), ob.GetClassID() You can use the GetClassID GUID to figure out which application it is, but checking for ".pdf"; in the display name is probably enough. This does not work in the general case, however. Few applications register themselves in the ROT. What are you going to do with this information? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From gal.aviel at intel.com Fri Sep 21 12:05:55 2007 From: gal.aviel at intel.com (=?utf-8?b?QXZpZWws?= Gal) Date: Fri, 21 Sep 2007 10:05:55 +0000 (UTC) Subject: [python-win32] Python COM Server, C++ Client - How ??? Message-ID: Hi, After searching for two days now, I could not find a simple recepie to on how to connect to a python local com server (exe) from a C++ client (VC6.0). Note that eventually I would want to package my server using py2exe, however even without this step - it doesn't work. I'm getting kind of desperate since this means the code I've worked on is useless since the software guys can't connect to it from C++. I've counted on Python to do the trick but now I see it's not that simple and maybe not possible. Below you can find a simple example for a Python COM local server (exe) that has only 1 method - Add() - to add 2 integers and return the result. I've written the IDL file, compiled it with MIDL, and included into the C++, as explained in http://www.codeproject.com/com/LocalCOMServerClient.asp. The part most confusing is the differnt GUID numbers (type library, class, and interface) and exactly where to put what. Specifically, where should the value entered in '_reg_clsid_' (python) fit in the IDL file? and where to take the 2 other GUID's that should be entered in the IDL file? Also, Visual Studio OLE Viewer, I saw "Python Com Server" (and the PTCS interface under it after I register PTCS.py), will that be present or required in py2exe environmetn where there is no python installation? In addition, how can I make my server show in PythonWin's 'MakePy' utility or 'COM Browser'? Any help would be greatly appreciated, I'd later post the clean example for anyone to use. Thanks in advance - Gal. # ---------------------------- # PTCS.py # ---------------------------- # PTCS == Python Test Com Server # small local server (out of process) python com server, try to connect from C++ client (VC++6.0 client) import win32com.server.register import pythoncom class PTCS: """ PTCS - Python Test Com (local) Server has only 1 simple function - Add - to add two int's and return the result. """ _public_methods_ = [ 'Add' ] _reg_progid_ = "PTCS" _reg_clsid_ = "GUID1" # ------- GUID1 ----------- _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER def __init__(self): pass def Add(self,a,b): """ add the 2 passed integeres. """ return a+b if __name__ == '__main__': win32com.server.register.UseCommandLine(PTCS, debug=True) # ---------------------------- # PTCS.idl # ---------------------------- // PTCS.idl : IDL source for PTCS.dll // // This file will be processed by the MIDL tool to // produce the type library (PTCS.tlb) and marshalling code. import "oaidl.idl"; import "ocidl.idl"; [ object, uuid(GUID1), // ---- GUID1 -------- dual, helpstring("PTCS Com Interface"), pointer_default(unique) ] interface ICoPTCS : IDispatch { [id(1), helpstring("method Add: add 2 integers")] HRESULT Add([in] int* a, [in] int* b, [out, retval] int* res ); }; [ uuid(GUID2), // ---- GUID2 -------- version(1.0), helpstring("PTCS 1.0 Type Library") ] library PTCSLib { importlib("stdole32.tlb"); importlib("stdole2.tlb"); [ uuid(GUID3), // ---- GUID3 -------- helpstring("CoPTCS Class") ] coclass CoPTCS { [default] interface ICoPTCS; }; }; # ---------------------------- # main.cpp (modified from http://www.codeproject.com/com/LocalCOMServerClient.asp) # ---------------------------- #include "../../eclipse_workspace1\PTCS\src\IDL\PTCS.h" // use your own path here #include "../../eclipse_workspace1\PTCS\src\IDL\PTCS_i.c" // use your own path here #include "iostream.h" // for showing possible mistakes void ShowErrorMessage(LPCTSTR,HRESULT); int main() { // initialize the COM runtime cout << "Initialize the COM runtime..."; CoInitialize(NULL); cout << "success." << endl; // declare variables HRESULT hr; IClassFactory* pICF = NULL; ICoPTCS* pIPTCS = NULL; cout << endl << "Get the class factory interface for the PTCS class..."; hr = CoGetClassObject(CLSID_CoPTCS,CLSCTX_LOCAL_SERVER, // --------- what should I put here? --------- NULL,IID_IClassFactory,(void**)&pICF); if ( FAILED(hr) ) { ShowErrorMessage("CoGetClassObject()",hr); exit(1); } else cout << "success." << endl; cout << "Create the PTCS instance object and get back the IPTCS interface..."; hr = pICF->CreateInstance(NULL,IID_IPTCS,(void**)&pIPTCS); // --------- what should I put here? --------- if ( FAILED(hr) ) { ShowErrorMessage("CoCreateInstance()",hr); exit(1); } else cout << "success." << endl; if ( pICF ) pICF->Release(); if ( pIPTCS) pIPTCS->Release(); cout << endl << "Close the COM runtime..."; CoUninitialize(); cout << "success." << endl; return 0; } void ShowErrorMessage(LPCTSTR header, HRESULT hr) { void* pMsg; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,NULL,hr, MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), (LPTSTR)&pMsg,0,NULL); cout << header << ": Error(" << hex << hr << "): " << (LPTSTR)pMsg << endl; LocalFree(pMsg); } ---- end of mail From translation at ginstrom.com Sat Sep 22 11:45:40 2007 From: translation at ginstrom.com (Ryan Ginstrom) Date: Sat, 22 Sep 2007 18:45:40 +0900 Subject: [python-win32] Python COM Server, C++ Client - How ??? In-Reply-To: References: Message-ID: <021701c7fcfd$56c142a0$0203a8c0@MOUSE> > [mailto:python-win32-bounces at python.org] On Behalf Of Aviel, Gal > After searching for two days now, I could not find a simple > recepie to on how to connect to a python local com server > (exe) from a C++ client (VC6.0). Note that eventually I would > want to package my server using py2exe, however even without > this step - it doesn't work. I don't have an answer for this (and I hope somebody who does have the answer will respond), but a way around this is to use late binding from C++. I have a C++ class that wraps an IDispatch pointer and makes it relatively painless. Let me know if you want it, and I'll post it somewhere. Regards, Ryan Ginstrom From gal.aviel at intel.com Sun Sep 23 09:23:54 2007 From: gal.aviel at intel.com (Aviel, Gal) Date: Sun, 23 Sep 2007 09:23:54 +0200 Subject: [python-win32] Python COM Server, C++ Client - How ??? In-Reply-To: <021701c7fcfd$56c142a0$0203a8c0@MOUSE> References: <021701c7fcfd$56c142a0$0203a8c0@MOUSE> Message-ID: Hi Ryan, thanks for your reply, I appreciate it :) Yes I am very much interested and would appreciate if you can post your solution, anything that enables me to connect from C++ will do. Many thanks - Gal. --------------------------------------------------------------------- Intel Israel (74) Limited This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. From gal.aviel at intel.com Sun Sep 23 15:05:12 2007 From: gal.aviel at intel.com (Aviel, Gal) Date: Sun, 23 Sep 2007 15:05:12 +0200 Subject: [python-win32] Python COM Server, C++ Client - How ??? In-Reply-To: <03d301c7fdce$d3d43aa0$0203a8c0@MOUSE> References: <021701c7fcfd$56c142a0$0203a8c0@MOUSE> <03d301c7fdce$d3d43aa0$0203a8c0@MOUSE> Message-ID: Hi Ryan, Thanks very much for your post!! Your example looks short and sweet :) and is probably one of the only examples on the web today showing how to write a C++ client connecting to an late bound COM server, regardless or Python, so I guess people from even outside the Python community googling as of tomorrow will thanks you too .. Unfortunately, it seems that an include file being used in the code ("atlcomcli.h") is not available on my system, as here they software guys work with VC6.0 which (from short googling) does not seem to support ATL (not sure this is true). Probably you developed the code on a newer version of Visual Studio? So unfortunately I had to resort to a non-ATL example found at http://www.ddj.com/cpp/184403558?pgno=1; below is the slightly modified version of that example which seems to work on my system (note inclusion of 2 files generated by MIDL, probably not necessary but a simple way to include all the header files which I need otherwise it won't compile). Thanks again for your help p.s. love your web site, interesting stuff there :) Thanks - Gal. #include "../../eclipse_workspace1\Py2RTL\src\IDL\PTCS.h" // use your own path here #include "../../eclipse_workspace1\Py2RTL\src\IDL\PTCS_i.c" // use your own path here #include "iostream.h" // for showing possible mistakes void ShowErrorMessage(LPCTSTR,HRESULT); int main() { DISPID dispid; DISPPARAMS dp={NULL,NULL,0,0}; VARIANTARG vargs[2]; VARIANT arg1,arg2,result; IDispatch * idsp; WCHAR progid[255]; CLSID pclsid; // 'L' tells the compiler to // use two-byte characters // COM requires most strings // to be in this form to // support multiple spoken languages wcscpy(progid, L"VCD.PTCS"); CLSIDFromProgID( progid, &pclsid); HRESULT hr = CoInitialize(NULL); if ( FAILED(hr) ) { ShowErrorMessage("CoInitialize()",hr); exit(1); } hr = CoCreateInstance(pclsid, NULL, CLSCTX_ALL, IID_IDispatch, (void **)&idsp); if ( FAILED(hr) ) { ShowErrorMessage("CoGetClassObject()",hr); exit(1); } else cout << "success." << endl; OLECHAR * name=L"Add"; idsp->GetIDsOfNames(IID_NULL, &name, 1, GetUserDefaultLCID(), &dispid); arg1.vt= VT_UI4; arg1.intVal = 3; arg2.vt= VT_UI4; arg2.intVal = 9; vargs[0]=arg1; vargs[1]=arg2; dp.rgvarg=vargs; dp.cArgs = 2; //how many args idsp->Invoke(dispid, IID_NULL, GetUserDefaultLCID(), DISPATCH_METHOD, &dp, &result,0,0); cout<Release(); return 0; } void ShowErrorMessage(LPCTSTR header, HRESULT hr) { void* pMsg; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,NULL,hr, MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), (LPTSTR)&pMsg,0,NULL); cout << header << ": Error(" << hex << hr << "): " << (LPTSTR)pMsg << endl; LocalFree(pMsg); } --------------------------------------------------------------------- Intel Israel (74) Limited This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. From cappy2112 at gmail.com Sun Sep 23 18:57:10 2007 From: cappy2112 at gmail.com (Tony Cappellini) Date: Sun, 23 Sep 2007 09:57:10 -0700 Subject: [python-win32] python-win32 Digest, Vol 54, Issue 14 In-Reply-To: References: Message-ID: <8249c4ac0709230957q2101a176x106f38942e2faac8@mail.gmail.com> Take a look at SWIG and BOOST. Message: 1 Date: Sun, 23 Sep 2007 09:23:54 +0200 From: "Aviel, Gal" Subject: Re: [python-win32] Python COM Server, C++ Client - How ??? To: "Ryan Ginstrom" , Message-ID: From Andrew.MACKEITH at 3ds.com Mon Sep 24 02:57:49 2007 From: Andrew.MACKEITH at 3ds.com (MACKEITH Andrew) Date: Sun, 23 Sep 2007 20:57:49 -0400 Subject: [python-win32] Building win32 extensions on 64bit Windows Message-ID: I am looking for help building the win32 extensions on 64 bit windows using the .NET 2005 compiler? I followed the instructions "Building the extensions from sources" but found that certain headers could not be found. Alternatively, are windows 64 binaries available yet? Andrew MacKeith -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070923/103e1118/attachment.htm From mhammond at skippinet.com.au Mon Sep 24 03:16:27 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 24 Sep 2007 11:16:27 +1000 Subject: [python-win32] Building win32 extensions on 64bit Windows In-Reply-To: References: Message-ID: <0a9601c7fe48$8bf07300$a3d15900$@com.au> > I am looking for help building the win32 extensions on?64 bit windows > using the .NET 2005 compiler? You will need to use the CVS version of pywin32, and follow the instructions in the docstring for that file - there are specific instructions relating to x64 builds. ? > I followed the instructions "Building the extensions from sources" but found > that certain headers could not be found. What headers? We can't speculate without at least some clues! Please copy the exact errors you received. ? > Alternatively, are windows 64 binaries available yet? Nope - they will be fairly soon, but note that no Python x64 binaries are built with VC2005, and also note that all existing, official Python x64 binary installers have a bug which makes it very difficult for extensions to install (specifically, the installer writes the Python registry keys to the Wow64 node, meaning Python itself or extension installers don't see them - this bug will be fixed for the next official x64 Python release (which still will not be built with VS2005) Cheers, Mark From timr at probo.com Mon Sep 24 19:25:04 2007 From: timr at probo.com (Tim Roberts) Date: Mon, 24 Sep 2007 10:25:04 -0700 Subject: [python-win32] Python COM Server, C++ Client - How ??? In-Reply-To: References: <021701c7fcfd$56c142a0$0203a8c0@MOUSE> <03d301c7fdce$d3d43aa0$0203a8c0@MOUSE> Message-ID: <46F7F2F0.2010601@probo.com> Aviel, Gal wrote: > Unfortunately, it seems that an include file being used in the code > ("atlcomcli.h") is not available on my system, as here they software > guys work with VC6.0 which (from short googling) does not seem to > support ATL (not sure this is true). Yes, it includes ATL, but it was a very early version of ATL, and does not include . > Probably you developed the code on a newer version of Visual Studio? > As does almost everyone. Do you have any notion of how old VC6.0 is? You are talking about a tool that was first released almost a decade ago! Things were very, very different in 1998. C++ had not yet become an ISO standard, and because of that, the compiler implements a language which is not really C++. It is close, but there are many things in the template support that changed after VC6 was released. It is very difficult for me to imagine any company developing commercial software with a compiler that is 9 years old. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From s-t-python-win32 at wwwdotorg.org Tue Sep 25 06:41:49 2007 From: s-t-python-win32 at wwwdotorg.org (Stephen Warren) Date: Mon, 24 Sep 2007 22:41:49 -0600 Subject: [python-win32] VS.NET2005; missing include/lib paths and libraries Message-ID: <1190695272.18878.TMDA@tmda.severn.wwwdotorg.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I just grabbed the latest SVN head (trunk) of Python and attempted to build using VS .NET 2005 Express, and the sln/vcproj files in the PCbuild8 directory. I had a few problems building even the pythoncore and python targets. First off, the Python code appears to rely on the MS Platform SDK, although the documents don't seem to mention this. I guess it's just assumed this is available? Second, the project files don't explicitly reference the Platform SDK include/library directories, so various headers/libs can't be found. Is it just assumed that the IDE global settings (Tools -> Options -> Projects and Solutions -> VC++ Directories) are configured to point at the relevant platform SDK directories? The above two points may just be assumptions for usage of the project files. However, the final issue I had was missing libraries in the linker command; e.g. pythoncore needed me to add "user32.lib shell23.lib advapi32.lib" to the list of linker inputs. I don't think the IDE has a global list of libraries that always get linked in; how are these libraries expected to be found/known-about? Thanks for any information. If/when I find out the answer, I'll have a go at updating the PCbuild8/readme.txt with some extra tips for other people like myself! -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFG+JBFhk3bo0lNTrURAglHAKCu1qKBcfl9u9kPPz2yus0APEYTwgCgouYn uU13//LgzZvNwMvjW5cgfqE= =hCwq -----END PGP SIGNATURE----- From p.f.moore at gmail.com Tue Sep 25 09:31:34 2007 From: p.f.moore at gmail.com (Paul Moore) Date: Tue, 25 Sep 2007 08:31:34 +0100 Subject: [python-win32] VS.NET2005; missing include/lib paths and libraries In-Reply-To: <1190695272.18878.TMDA@tmda.severn.wwwdotorg.org> References: <1190695272.18878.TMDA@tmda.severn.wwwdotorg.org> Message-ID: <79990c6b0709250031x7b8345dbo74915137c0249075@mail.gmail.com> On 25/09/2007, Stephen Warren wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > I just grabbed the latest SVN head (trunk) of Python and attempted to > build using VS .NET 2005 Express, and the sln/vcproj files in the > PCbuild8 directory. > > I had a few problems building even the pythoncore and python targets. I had a go at this once, and found the same type of issues. I believe the PCBuild8 directory is targetted at (full) VS.NET 2005, not the Express edition. A good place to start may therefore be the Express edition documentation of how it differs from the full version. Unfortunately, I didn't have time to look further. > Thanks for any information. If/when I find out the answer, I'll have a > go at updating the PCbuild8/readme.txt with some extra tips for other > people like myself! That would be really useful. Now that MS have discontinued distribution of the toolkit VC7 compiler, there's no free build environment for MS Windows, which is a shame... Paul. From mhammond at skippinet.com.au Tue Sep 25 13:11:08 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 25 Sep 2007 21:11:08 +1000 Subject: [python-win32] VS.NET2005; missing include/lib paths and libraries In-Reply-To: <1190695272.18878.TMDA@tmda.severn.wwwdotorg.org> References: <1190695272.18878.TMDA@tmda.severn.wwwdotorg.org> Message-ID: <0bc501c7ff64$c9f72be0$5de583a0$@com.au> > I just grabbed the latest SVN head (trunk) of Python and attempted to > build using VS .NET 2005 Express, and the sln/vcproj files in the > PCbuild8 directory. > > I had a few problems building even the pythoncore and python targets. > > First off, the Python code appears to rely on the MS Platform SDK, > although the documents don't seem to mention this. I guess it's just > assumed this is available? Yep - and with the express edition you must manually install it. > Second, the project files don't explicitly reference the Platform SDK > include/library directories, so various headers/libs can't be found. Is > it just assumed that the IDE global settings (Tools -> Options -> > Projects and Solutions -> VC++ Directories) are configured to point at > the relevant platform SDK directories? > > The above two points may just be assumptions for usage of the project > files. However, the final issue I had was missing libraries in the > linker command; e.g. pythoncore needed me to add "user32.lib > shell23.lib > advapi32.lib" to the list of linker inputs. I don't think the IDE has a > global list of libraries that always get linked in; how are these > libraries expected to be found/known-about? I'm not sure about that. As Paul mentioned, this configuration isn't actually supported - PCBUild8 is contributed and generally used with the full version of VS, with updates happening only on the trunk. Anything you can come up with to help the next poor soul would be appreciated though - create a patch at bugs.python.org and assign it to me if you like. Cheers, Mark From s-t-python-win32 at wwwdotorg.org Tue Sep 25 17:39:06 2007 From: s-t-python-win32 at wwwdotorg.org (Stephen Warren) Date: Tue, 25 Sep 2007 09:39:06 -0600 Subject: [python-win32] VS.NET2005; missing include/lib paths and libraries In-Reply-To: <0bc501c7ff64$c9f72be0$5de583a0$@com.au> References: <1190695272.18878.TMDA@tmda.severn.wwwdotorg.org> <0bc501c7ff64$c9f72be0$5de583a0$@com.au> Message-ID: <1190734752.4212.TMDA@tmda.severn.wwwdotorg.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Mark Hammond wrote: > Stephen Warren wrote: >> First off, the Python code appears to rely on the MS Platform SDK, >> although the documents don't seem to mention this. I guess it's just >> assumed this is available? > > Yep - and with the express edition you must manually install it. Ah, so just so I understand - the full version of VC packages the platform SDK into the install so that it's automatically available without user action? (even in the express directory, there's a platform SDK directory that gets shipped with it; it's just empty except for a .bat file!) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFG+Suahk3bo0lNTrURAhQiAKCvX9vDPffqifmunB5FQe4wy/LVjgCeNrhj UQrCzX5i5FZAyZTfsaiouQ8= =Ln+i -----END PGP SIGNATURE----- From timr at probo.com Tue Sep 25 18:31:03 2007 From: timr at probo.com (Tim Roberts) Date: Tue, 25 Sep 2007 09:31:03 -0700 Subject: [python-win32] VS.NET2005; missing include/lib paths and libraries In-Reply-To: <1190734752.4212.TMDA@tmda.severn.wwwdotorg.org> References: <1190695272.18878.TMDA@tmda.severn.wwwdotorg.org> <0bc501c7ff64$c9f72be0$5de583a0$@com.au> <1190734752.4212.TMDA@tmda.severn.wwwdotorg.org> Message-ID: <46F937C7.3080401@probo.com> Stephen Warren wrote: > > Ah, so just so I understand - the full version of VC packages the > platform SDK into the install so that it's automatically available > without user action? Yes, a Platform SDK is installed with the package. It's an older one (April 2005), so it's not entirely clear that it is a benefit for them to do so... -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From s-t-python-win32 at wwwdotorg.org Tue Sep 25 20:01:35 2007 From: s-t-python-win32 at wwwdotorg.org (Stephen Warren) Date: Tue, 25 Sep 2007 12:01:35 -0600 Subject: [python-win32] VS.NET2005; missing include/lib paths and libraries In-Reply-To: <46F937C7.3080401@probo.com> References: <1190695272.18878.TMDA@tmda.severn.wwwdotorg.org> <0bc501c7ff64$c9f72be0$5de583a0$@com.au> <1190734752.4212.TMDA@tmda.severn.wwwdotorg.org> <46F937C7.3080401@probo.com> Message-ID: <1190743296.7741.TMDA@tmda.severn.wwwdotorg.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Tim Roberts wrote: > Stephen Warren wrote: >> Ah, so just so I understand - the full version of VC packages the >> platform SDK into the install so that it's automatically available >> without user action? > > Yes, a Platform SDK is installed with the package. It's an older one > (April 2005), so it's not entirely clear that it is a benefit for them > to do so... OK. So, for the official Python builds, which platform SDK is used? When I edit the docs to note that it's required, I guess I should specify which one to use! Also, my eventual desire is to submit a patch to implement hard-link functionality for Win32 via CreateHardLink. I'm not sure if this kind of thing influences the version of the Platform SDK that's required. I suspect that in order to allow for backwards-compatibility (i.e. Python still runs on e.g. Win95), I should follow the same trick used for other optional API functions, and not statically link against the library/function, but instead acquire the function's address at run-time. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFG+Uz/hk3bo0lNTrURArenAKDnL+wMfqAJBU371CUL35kJ/N86UQCeMBd+ Al8Ko9vg2FT1U6jmxaq2Axc= =Nqhy -----END PGP SIGNATURE----- From timr at probo.com Tue Sep 25 23:30:06 2007 From: timr at probo.com (Tim Roberts) Date: Tue, 25 Sep 2007 14:30:06 -0700 Subject: [python-win32] VS.NET2005; missing include/lib paths and libraries In-Reply-To: <1190743296.7741.TMDA@tmda.severn.wwwdotorg.org> References: <1190695272.18878.TMDA@tmda.severn.wwwdotorg.org> <0bc501c7ff64$c9f72be0$5de583a0$@com.au> <1190734752.4212.TMDA@tmda.severn.wwwdotorg.org> <46F937C7.3080401@probo.com> <1190743296.7741.TMDA@tmda.severn.wwwdotorg.org> Message-ID: <46F97DDE.2040604@probo.com> Stephen Warren wrote: > > > OK. So, for the official Python builds, which platform SDK is used? When > I edit the docs to note that it's required, I guess I should specify > which one to use! Well, I'm just being particularly catty. I doubt that Python is using anything Vista-only, so the one included with VS2005 (which is the "Windows Server 2003 SP1 SDK") should be just fine. > Also, my eventual desire is to submit a patch to implement hard-link > functionality for Win32 via CreateHardLink. I'm not sure if this kind of > thing influences the version of the Platform SDK that's required. It shouldn't. CreateHardLink has existed since Windows 2000. However, remember that it only works on an NTFS filesystem. > I suspect that in order to allow for backwards-compatibility (i.e. Python > still runs on e.g. Win95), I should follow the same trick used for other > optional API functions, and not statically link against the > library/function, but instead acquire the function's address at run-time. Right. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Tue Sep 25 23:37:36 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 26 Sep 2007 07:37:36 +1000 Subject: [python-win32] VS.NET2005; missing include/lib paths and libraries In-Reply-To: <1190743296.7741.TMDA@tmda.severn.wwwdotorg.org> References: <1190695272.18878.TMDA@tmda.severn.wwwdotorg.org> <0bc501c7ff64$c9f72be0$5de583a0$@com.au> <1190734752.4212.TMDA@tmda.severn.wwwdotorg.org> <46F937C7.3080401@probo.com> <1190743296.7741.TMDA@tmda.severn.wwwdotorg.org> Message-ID: <0c8d01c7ffbc$4d9da4e0$e8d8eea0$@com.au> > Tim Roberts wrote: > > Stephen Warren wrote: > >> Ah, so just so I understand - the full version of VC packages the > >> platform SDK into the install so that it's automatically available > >> without user action? > > > > Yes, a Platform SDK is installed with the package. It's an older one > > (April 2005), so it's not entirely clear that it is a benefit for > them > > to do so... > > OK. So, for the official Python builds, which platform SDK is used? As far as I know, the SDK bundled with VS2003 is used. Nothing in the core Python sources requires anything later. pywin32 generally uses a 'recent' one, with #ifdef's used of necessary to restrict certain functionality to later SDKs (which then makes it my responsibility to use the latest one referenced in the sources for the final distributions) > Also, my eventual desire is to submit a patch to implement hard-link > functionality for Win32 via CreateHardLink. win32file already exposes this function. Cheers, Mark From howard at eegsoftware.com Wed Sep 26 00:05:59 2007 From: howard at eegsoftware.com (Howard Lightstone) Date: Tue, 25 Sep 2007 15:05:59 -0700 Subject: [python-win32] VS.NET2005 In-Reply-To: <1190743296.7741.TMDA@tmda.severn.wwwdotorg.org> References: <1190695272.18878.TMDA@tmda.severn.wwwdotorg.org>, <46F937C7.3080401@probo.com>, <1190743296.7741.TMDA@tmda.severn.wwwdotorg.org> Message-ID: <46F923D7.7319.3A8F84@howard.eegsoftware.com> I have been a little remiss in reporting bugs but I DID have to modify 12 or 13 files to in order to build pywin32 using VS2005 (along with a change to the distutils msvccompiler.py module). I built from a 210 base but I suppose I really ought to make sure the changes make it into the next "stable" version - even though it seems Microsoft will have passed me by with their "new" compiler vs2008 by the time I can breathe again... Most of the changes are just to conform the the more rigid type-checking VS2005 imposes but I did have to get help on a templating problem (solution provided by Alexandar Kabanets, thank you). I'll try to diff these out and submit them next week. From s-t-python-win32 at wwwdotorg.org Wed Sep 26 04:18:16 2007 From: s-t-python-win32 at wwwdotorg.org (Stephen Warren) Date: Tue, 25 Sep 2007 20:18:16 -0600 Subject: [python-win32] VS.NET2005; missing include/lib paths and libraries In-Reply-To: <0c8d01c7ffbc$4d9da4e0$e8d8eea0$@com.au> References: <1190695272.18878.TMDA@tmda.severn.wwwdotorg.org> <0bc501c7ff64$c9f72be0$5de583a0$@com.au> <1190734752.4212.TMDA@tmda.severn.wwwdotorg.org> <46F937C7.3080401@probo.com> <1190743296.7741.TMDA@tmda.severn.wwwdotorg.org> <0c8d01c7ffbc$4d9da4e0$e8d8eea0$@com.au> Message-ID: <1190773101.19521.TMDA@tmda.severn.wwwdotorg.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Mark Hammond wrote: > Stephen Warren wrote: >> Also, my eventual desire is to submit a patch to implement hard-link >> functionality for Win32 via CreateHardLink. > > win32file already exposes this function. So it does; I'd forgotten about the pywin32 stuff. Is there a reason that this is in pywin32 and not os.link()? i.e. if I were to put the code in posixmodule.c (in a backwards compatible way) would the patch be acceptable, or is there some disadvantage to implementing it in the os module? Thanks for all the pointers. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFG+cFohk3bo0lNTrURAkbJAJ0RZrR4EvQfhCyOHspv9zIc9uN2QwCgmqJE nnr8RqiVPw2UWPdjXrsA1fk= =i2F1 -----END PGP SIGNATURE----- From victor_lebrun at yahoo.fr Wed Sep 26 12:28:01 2007 From: victor_lebrun at yahoo.fr (victor LEBRUN) Date: Wed, 26 Sep 2007 12:28:01 +0200 (CEST) Subject: [python-win32] Re : activeX persistent properties Message-ID: <463975.38214.qm@web27611.mail.ukl.yahoo.com> Hello pywin32 users :) Finally I found that all the method I need to use for my activeX are in the oca file and not in the ocx file. For Visual studio it easy to access to the cache of the activeX control (oca file) but it seems that creating a container for an oca object do not work with pywin32, I have an error if I try to put the oca object instead of putting the ocx in my wxwidget container ( I am using MakeActiveXclass in wxpython which call the pywin32 functions). Is there a way to access oca properties with pywin32 or is it a limitation of pywin32 createcontrol ? If I can see the methods and properties in the oca file and I can not use it on the ocx object, does it mean that those properties are ready only or in a way hidden to the user ? thanks a lot, regards, Victor ----- Message d'origine ---- De : victor LEBRUN ? : python-win32 at python.org Envoy? le : Mardi, 11 Septembre 2007, 12h06mn 46s Objet : [python-win32] activeX persistent properties Hello python win32 users ! I would lik to know if it is possible to access persistent properties of an ole object (activeX control) with pywin ? tkank you for your help. regards, Victor _____________________________________________________________________________ Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 ____________________________________________________________________________________________ D?couvrez le blog Yahoo! Mail : derni?res nouveaut?s, astuces, conseils.. et vos r?actions ! http://blog.mail.yahoo.fr From victor_lebrun at yahoo.fr Wed Sep 26 14:49:38 2007 From: victor_lebrun at yahoo.fr (victor LEBRUN) Date: Wed, 26 Sep 2007 14:49:38 +0200 (CEST) Subject: [python-win32] Request to be added to approved list Message-ID: <716631.7476.qm@web27613.mail.ukl.yahoo.com> Hello pywin32 users :) Finally I found that all the method I need to use for my activeX are in the oca file and not in the ocx file. For Visual studio it easy to access to the cache of the activeX control (oca file) but it seems that creating a container for an oca object do not work with pywin32, I have an error if I try to put the oca object instead of putting the ocx in my wxwidget container ( I am using MakeActiveXclass in wxpython which call the pywin32 functions). Is there a way to access oca properties with pywin32 or is it a limitation of pywin32 createcontrol ? If I can see the methods and properties in the oca file and I can not use it on the ocx object, does it mean that those properties are ready only or in a way hidden to the user ? thanks a lot, regards, Victor ----- Message d'origine ---- De : victor LEBRUN ? : python-win32 at python.org Envoy? le : Mardi, 11 Septembre 2007, 12h06mn 46s Objet : [python-win32] activeX persistent properties Hello python win32 users ! I would lik to know if it is possible to access persistent properties of an ole object (activeX control) with pywin ? tkank you for your help. regards, Victor _____________________________________________________________________________ Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 ____________________________________________________________________________________________ D?couvrez le blog Yahoo! Mail : derni?res nouveaut?s, astuces, conseils.. et vos r?actions ! http://blog.mail.yahoo.fr _____________________________________________________________________________ Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail From howard at eegsoftware.com Wed Sep 26 16:55:32 2007 From: howard at eegsoftware.com (howard at eegsoftware.com) Date: Wed, 26 Sep 2007 07:55:32 -0700 Subject: [python-win32] Request to be added to approved list Message-ID: <46FA1074.22917.13DE52B1@howard.eegsoftware.com> Hmmm, I USED to able to post. Perhaps I got lost in the name changeover. Anyway, I have some discussion/changes to post regarding building win32 stuff under VS2005. Thanks From timr at probo.com Wed Sep 26 19:02:48 2007 From: timr at probo.com (Tim Roberts) Date: Wed, 26 Sep 2007 10:02:48 -0700 Subject: [python-win32] VS.NET2005; missing include/lib paths and libraries In-Reply-To: <1190773101.19521.TMDA@tmda.severn.wwwdotorg.org> References: <1190695272.18878.TMDA@tmda.severn.wwwdotorg.org> <0bc501c7ff64$c9f72be0$5de583a0$@com.au> <1190734752.4212.TMDA@tmda.severn.wwwdotorg.org> <46F937C7.3080401@probo.com> <1190743296.7741.TMDA@tmda.severn.wwwdotorg.org> <0c8d01c7ffbc$4d9da4e0$e8d8eea0$@com.au> <1190773101.19521.TMDA@tmda.severn.wwwdotorg.org> Message-ID: <46FA90B8.3050409@probo.com> Stephen Warren wrote: > Mark Hammond wrote: > > Stephen Warren wrote: > >> Also, my eventual desire is to submit a patch to implement hard-link > >> functionality for Win32 via CreateHardLink. > > win32file already exposes this function. > > So it does; I'd forgotten about the pywin32 stuff. > > Is there a reason that this is in pywin32 and not os.link()? i.e. if I > were to put the code in posixmodule.c (in a backwards compatible way) > would the patch be acceptable, or is there some disadvantage to > implementing it in the os module? One issue is that the os module is part of the Python standard library, not the Python-Win32 add-on. There's an entirely different bureaucracy for submitting and vetting submissions for the standard library. Further, you're talking about a function that is specific to a very narrow subset of the operating system universe, and further one that is supported on a subset of the available file systems. For better or for worse, the Python mindset is still a Unix-based mindset, and there is a tendency to eschew Windows-specific changes in the core library. Having said that, there is certainly nothing to stop you from submitting a patch to python.org. I wouldn't expect the pywin32 version to go away; win32file is intended to expose the file APIs from the Win32 SDK, and CreateHardLink certainly qualifies. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From randy.tucker7 at gmail.com Thu Sep 27 23:04:00 2007 From: randy.tucker7 at gmail.com (Randy Tucker) Date: Thu, 27 Sep 2007 23:04:00 +0200 Subject: [python-win32] Converting event.time from pyhook Message-ID: <78c8ac180709271404k1ed17dd2ib51bf101fdadee3b@mail.gmail.com> Hi all, I use pyhook to monitor user usage of keyboard and mouse. According to pyhook specs, event.time hold the number of seconds since the epoch. However, when I use the example source code I get numbers like 358054093, which translates to 07 May 1981.. Can anyone explain to me what am I doing wrong? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070927/5c258592/attachment.htm From timr at probo.com Fri Sep 28 01:03:27 2007 From: timr at probo.com (Tim Roberts) Date: Thu, 27 Sep 2007 16:03:27 -0700 Subject: [python-win32] Converting event.time from pyhook In-Reply-To: <78c8ac180709271404k1ed17dd2ib51bf101fdadee3b@mail.gmail.com> References: <78c8ac180709271404k1ed17dd2ib51bf101fdadee3b@mail.gmail.com> Message-ID: <46FC36BF.80403@probo.com> Randy Tucker wrote: > Hi all, > > I use pyhook to monitor user usage of keyboard and mouse. According to > pyhook specs, event.time hold the number of seconds since the epoch. > However, when I use the example source code I get numbers like > 358054093, which translates to 07 May 1981.. It's not "number of seconds since the epoch". It comes straight from the "time" member of the Win32 EVENTMSG struct, which is in units of "milliseconds since last boot". Your machine last booted about 4 days ago? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From matherbe at cisco.com Fri Sep 28 19:31:52 2007 From: matherbe at cisco.com (Matt Herbert) Date: Fri, 28 Sep 2007 13:31:52 -0400 Subject: [python-win32] Network Bindings Message-ID: <46FD3A88.5070901@cisco.com> Hello all, I've been trying to figure out how to change the bindings on a network adapter. I've used Google extensively and haven't found anything useful (or I haven't been searching for the right things). What I have found, leads me to believe that the only way to do this is via the INetCfg Interface (http://msdn2.microsoft.com/en-us/library/ms805265.aspx). It seems as though nobody out there has actually used this interface with python yet. So according to the MSDN docs, the interface is already implemented in netcfgx.dll. So I thought I would just use ctypes, and access it that way. But I took a look at the netcfgx.h file and got scared. I'm not a very competent C/C++ programmer (only dable here and there) and that header file has things I don't understand. Which has lead me to the path of building the interface via comtypes (because pythoncom cannot support arbitrary interfaces). This seems like it's going to be a lot of work, for what I want to achieve: being able to change binding paths for a network adapter. So I'm wondering, if anybody out there knows of an easier way this can be accomplished? -Matt From da6d.fierbaugh at gmail.com Fri Sep 28 20:30:20 2007 From: da6d.fierbaugh at gmail.com (David) Date: Fri, 28 Sep 2007 11:30:20 -0700 Subject: [python-win32] type mismatch using win32com.client.GetObject Message-ID: <9ba59fb50709281130r176ec3c3nac7cbf836242231e@mail.gmail.com> So I have a Visual Basic script in Excel which connects via com to programX and retrieves data. The COM function takes 7 required arguments. arg1-6 are set equal to values to determine what data to fetch. arg7 is the variant in which the function returns the fetched data. In VB it works like this: Private Function functionX(arg1 As Long, arg2 As Integer, arg3 As Long, arg4 As Long, arg5 As Boolean, arg6 As Long) As Variant Dim px As Object Dim status As Boolean Dim arg8 As Integer Dim arg9 As Integer Dim arg10 As Integer Dim arg7 As Variant Set px = GetObject("programx.activex.interface") status = px.functionX(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) If Not status Then data = "wait" End If If a = 0 And b = 0 And c = 0 Then data = arg7 The end of which the variable 'data' is set to the value returned by the com interface. So when I call the function, I get: arg1 = ... setting all arg# variables ... x1 = functionX(arg1, arg2, arg3, arg4, arg5, arg6) and x1 = the returned value When I try this in python, I get a type mismatch, for the apparent reason that arg7 is not a variant. Of course, python being the wonderful language it is, arg7 can be any type I want, whenever I want to change it.... except there is no 'variant' type because of this. >>> arg1 = .... setting all arg# variables ... >>> x1 = win32com.client.GetObject("programX.activex.interface") >>> `x1` '' >>> x1.FunctionX(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) Traceback (most recent call last): File "", line 1, in File "", line 2, in FunctionX com_error: (-2147352571, 'Type mismatch.', None, 7) >>> So I'm at a loss as to how to force passing arg7 as a variant type. From what I gather in researching this, win32com.client is supposed to handle typing automagically. Somehow I'm missing something. HELP!?!? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070928/1d663715/attachment.htm From timr at probo.com Fri Sep 28 21:01:49 2007 From: timr at probo.com (Tim Roberts) Date: Fri, 28 Sep 2007 12:01:49 -0700 Subject: [python-win32] type mismatch using win32com.client.GetObject In-Reply-To: <9ba59fb50709281130r176ec3c3nac7cbf836242231e@mail.gmail.com> References: <9ba59fb50709281130r176ec3c3nac7cbf836242231e@mail.gmail.com> Message-ID: <46FD4F9D.2070200@probo.com> David wrote: > So I have a Visual Basic script in Excel which connects via com to > programX and retrieves data. The COM function takes 7 required > arguments. arg1-6 are set equal to values to determine what data to > fetch. arg7 is the variant in which the function returns the fetched > data. > ... > The end of which the variable 'data' is set to the value returned by > the com interface. > So when I call the function, I get: > > arg1 = ... > setting all arg# variables > ... > x1 = functionX(arg1, arg2, arg3, arg4, arg5, arg6) > > and x1 = the returned value > > When I try this in python, I get a type mismatch, for the apparent > reason that arg7 is not a variant. Of course, python being the > wonderful language it is, arg7 can be any type I want, whenever I want > to change it.... except there is no 'variant' type because of this. > >>> arg1 = .... > setting all arg# variables > ... > >>> x1 = win32com.client.GetObject("programX.activex.interface ") > >>> `x1` > '' > >>> x1.FunctionX(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, > arg10) > Traceback (most recent call last): > File "", line 1, in > File "", line 2, in FunctionX > com_error: (-2147352571, 'Type mismatch.', None, 7) > >>> > > So I'm at a loss as to how to force passing arg7 as a variant type. > From what I gather in researching this, win32com.client is supposed to > handle typing automagically. Somehow I'm missing something. If arg7 is the output argument, then you probably want: arg7 = x1.FunctionX(arg1, arg2, arg3, arg4, arg5, arg6, arg8, arg9, arg10) I'm not sure if it will handle functions where the output argument is not the final argument. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From da6d.fierbaugh at gmail.com Fri Sep 28 21:13:43 2007 From: da6d.fierbaugh at gmail.com (David) Date: Fri, 28 Sep 2007 12:13:43 -0700 Subject: [python-win32] type mismatch using win32com.client.GetObject In-Reply-To: <46FD4F9D.2070200@probo.com> References: <9ba59fb50709281130r176ec3c3nac7cbf836242231e@mail.gmail.com> <46FD4F9D.2070200@probo.com> Message-ID: <9ba59fb50709281213h23f086cet2e365a8c0af00b7f@mail.gmail.com> The last 3 args are optional. I've tried dropping them, same results. x1.FunctionX(arg1, arg2, arg3, arg4, arg5, arg6, arg7) which yields the same error message. x1.FunctionX(arg1, arg2, arg3, arg4, arg5, arg6) Yields an argument not optional error message (not at the machine this runs on, so can't give exact message.) Changing the type of another argument yields the same result ie--- >>> arg6 323 >>> arg6 = "true" >>> x1.FunctionX(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) Traceback (most recent call last): File "", line 1, in File "", line 2, in FunctionX com_error: (-2147352571, 'Type mismatch.', None, 6) >>> On 9/28/07, Tim Roberts wrote: > > > If arg7 is the output argument, then you probably want: > > arg7 = x1.FunctionX(arg1, arg2, arg3, arg4, arg5, arg6, arg8, arg9, > arg10) > > I'm not sure if it will handle functions where the output argument is > not the final argument. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070928/da1ee22c/attachment.htm From matherbe at cisco.com Fri Sep 28 22:01:46 2007 From: matherbe at cisco.com (Matt Herbert) Date: Fri, 28 Sep 2007 16:01:46 -0400 Subject: [python-win32] Network Bindings In-Reply-To: <46FD5583.3060407@timgolden.me.uk> References: <46FD3A88.5070901@cisco.com> <46FD5583.3060407@timgolden.me.uk> Message-ID: <46FD5DAA.10608@cisco.com> Tim Golden wrote: > OK, I'm not entirely sure what "bindings on a network adapter are". Network Bindings are simply a list of Clients, Protocols, and Services that can be bound to particular adapters in particular orders. This is most easily visualized by brining up your Network Connections control panel (Start->run->ncpa.cpl). If you right click on any network adapter, and select properties, you will see a list of items that have check boxes next to them. Each item in that list is bound to that network adapter. Un-checking the box, unbinds that item (be it a service, protocol, or client). I am trying to find a way to check, and un-check those boxes programatically. > If you can find a WMI-based solution then I'm quite happy to help > translating it from VBS or whatever into Python. But I'm not sure > that there is one. I wish I could go this route, it would be much easier :). My searches haven't revealed any way to do it with WMI either. Thanks -Matt From mail at timgolden.me.uk Fri Sep 28 22:05:04 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 28 Sep 2007 21:05:04 +0100 Subject: [python-win32] Network Bindings In-Reply-To: <46FD3A88.5070901@cisco.com> References: <46FD3A88.5070901@cisco.com> Message-ID: <46FD5E70.7050101@timgolden.me.uk> Matt Herbert wrote: > Hello all, > > I've been trying to figure out how to change the bindings on a network > adapter. I've used Google extensively and haven't found anything useful > (or I haven't been searching for the right things). > > What I have found, leads me to believe that the only way to do this is > via the INetCfg Interface > (http://msdn2.microsoft.com/en-us/library/ms805265.aspx). It seems as > though nobody out there has actually used this interface with python yet. I'm too ignorant of the networking area in general to know whether there's a WMI solution for this, but if a search for WMI network binding turns up anything useful I'm very happy to advise on getting it to work in Python. TJG From carl at personnelware.com Sat Sep 29 02:25:34 2007 From: carl at personnelware.com (Carl Karsten) Date: Fri, 28 Sep 2007 19:25:34 -0500 Subject: [python-win32] Network Bindings In-Reply-To: <46FD5DAA.10608@cisco.com> References: <46FD3A88.5070901@cisco.com> <46FD5583.3060407@timgolden.me.uk> <46FD5DAA.10608@cisco.com> Message-ID: <46FD9B7E.7090707@personnelware.com> Matt Herbert wrote: > Tim Golden wrote: >> OK, I'm not entirely sure what "bindings on a network adapter are". > > Network Bindings are simply a list of Clients, Protocols, and Services > that can be bound to particular adapters in particular orders. This is > most easily visualized by brining up your Network Connections control > panel (Start->run->ncpa.cpl). If you right click on any network adapter, > and select properties, you will see a list of items that have check > boxes next to them. Each item in that list is bound to that network > adapter. Un-checking the box, unbinds that item (be it a service, > protocol, or client). I am trying to find a way to check, and un-check > those boxes programatically. > Sounds like config options. I bet they are registry entries. run regmon, change a binding, see what happens. if I am right... Here is a quick excerpt from my AddToPath.py (search this list for the full source if you want it.) from _winreg import * hive = HKEY_LOCAL_MACHINE key=r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment" subkey = 'Path' h = OpenKeyEx( hive, key, 0, KEY_READ ) curPath = QueryValueEx(h, subkey)[0] CloseKey(h) print "adding dir %s" % DirToAdd h = OpenKeyEx( hive, key, 0, KEY_SET_VALUE ) NewPath = curPath + ';' + DirToAdd SetValueEx(h, 'path', 0, REG_EXPAND_SZ, NewPath ) CloseKey(h) Carl K