From gabrielcnr at gmail.com Fri Jun 2 20:19:05 2006 From: gabrielcnr at gmail.com (Gabriel Reis) Date: Fri, 2 Jun 2006 15:19:05 -0300 Subject: [python-win32] win32ras / Create PhonebookEntry Message-ID: <1f2e8c720606021119r1b74baewb13a625c722038e4@mail.gmail.com> Hi, I want to create a DIAL-UP connection AND a DIAL-IN connection using WIN32 API (PyWin32) without GUI interaction with the user. The function CreatePhonebookEntry available in win32ras module uses that kind of GUI interaction. I'd like to know if there's a silent or user-transparently way to do that. I've already read a considerable amount of documentation (msdn, python maillist, etc) and I didn't find anything that does exactly what I need. Thanks! -- Att, Gabriel de Carvalho Nogueira Reis E-mail: gabrielcnr at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060602/1da55b3c/attachment.html From rwupole at msn.com Sat Jun 3 15:24:13 2006 From: rwupole at msn.com (Roger Upole) Date: Sat, 3 Jun 2006 09:24:13 -0400 Subject: [python-win32] Re: win32ras / Create PhonebookEntry References: <1f2e8c720606021119r1b74baewb13a625c722038e4@mail.gmail.com> Message-ID: Gabriel Reis wrote: > Hi, > > I want to create a DIAL-UP connection AND a DIAL-IN connection using WIN32 > API (PyWin32) without GUI interaction with the user. The function > CreatePhonebookEntry available in win32ras module uses that kind of GUI > interaction. I'd like to know if there's a silent or user-transparently way > to do that. I've already read a considerable amount of documentation (msdn, > python maillist, etc) and I didn't find anything that does exactly what I > need. > > Thanks! > Looks like the function to create an entry is RasSetEntryProperties. Unfortunately, it's not wrapped in win32ras. It would take a good bit of effort since one the params is the huge RASENTRY struct, with 40-odd members. Roger From MKC at Stowers-Institute.org Mon Jun 5 21:34:12 2006 From: MKC at Stowers-Institute.org (Coleman, Michael) Date: Mon, 5 Jun 2006 14:34:12 -0500 Subject: [python-win32] problem with reference parameter to COM function (makepy) Message-ID: Hi, I'm trying to use win32com to drive a COM object. I ran makepy to create the interface and am (apparently) able to run some of the object's functions. I'm having problem, though, with functions that have reference parameters (e.g., pointer to bool). I saw in some documentation (on oreilly.com) that makepy was supposed to arrange things so that these returned values are returned as a tuple from the function, but that seems not to have happened in this case. Is there something I can do to force this? Or, am I doing something else wrong? Here's the documented signature: long IsError(BOOL FAR* pbIsError); and here's what makepy generated: def IsError(self, pbIsError=defaultNamedNotOptArg): """method IsError""" return self._oleobj_.InvokeTypes(7, LCID, 1, (24, 0), ((16387, 0),),pbIsError ) (The COM object is some vendor thing--no source code and probably poorly implemented.) Any ideas? Mike Mike Coleman, Scientific Programmer, +1 816 926 4419 Stowers Institute for Biomedical Research 1000 E. 50th St., Kansas City, MO 64110, USA From riltim at gmail.com Mon Jun 5 23:53:25 2006 From: riltim at gmail.com (Tim Riley) Date: Mon, 5 Jun 2006 17:53:25 -0400 Subject: [python-win32] Adding AutoCAD Points. Message-ID: Has anyone come up with a way to add AutoCAD points using Python and win32? Do I have to use Makepy on the type library? For example adding a line to Modelspace requires you to call the AddLine method that accepts two arrays of doubles. Any help/tips would be greatly appreciated. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060605/617cfaaf/attachment.html From mhammond at skippinet.com.au Tue Jun 6 03:51:37 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 6 Jun 2006 11:51:37 +1000 Subject: [python-win32] problem with reference parameter to COM function(makepy) In-Reply-To: Message-ID: <007c01c6890b$bfe158e0$090a0a0a@enfoldsystems.local> > I'm trying to use win32com to drive a COM object. I ran makepy to > create the interface and am (apparently) able to run some of the > object's functions. I'm having problem, though, with functions that > have reference parameters (e.g., pointer to bool). > > I saw in some documentation (on oreilly.com) that makepy was > supposed to > arrange things so that these returned values are returned as a tuple > from the function, but that seems not to have happened in > this case. That is true in most cases - but its not obvious from the makepy generated file - did you actually call the function? > Is there something I can do to force this? Or, am I doing something else > wrong? > > Here's the documented signature: > > long IsError(BOOL FAR* pbIsError); Its not clear what the true IDL signature is for the function. If the long is actually the HRESULT, then pywin32 will *not* return that value (but will instead throw an exception if a failure code is returned). Indeed, this is what I believe is happening... > and here's what makepy generated: > > def IsError(self, pbIsError=defaultNamedNotOptArg): > """method IsError""" > return self._oleobj_.InvokeTypes(7, LCID, 1, (24, 0), > ((16387, 0),),pbIsError > ) makepy has decided the return value from the function is VT_VOID (the 24). As a result, pywin32 considers this function to have only 1 return value - so a tuple will *not* be returned - just 'pbIsError' (if the function fails, an exception is thrown - hence the 'long' is not considered a return value as such.) I also note that the first param appears to be missing the [out] qualifer in the IDL (reflected in the second tuple item being 0). If the single value you get returned is always None, that will be the reason. I'm afraid I can't recall exactly what pywin32 will do in such a case. Hope this helps... Mark -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 2680 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20060606/28b0c53d/attachment.bin From dan.glassman at charter.net Tue Jun 6 04:55:59 2006 From: dan.glassman at charter.net (Dan Glassman) Date: Mon, 05 Jun 2006 21:55:59 -0500 Subject: [python-win32] Adding AutoCAD Points. In-Reply-To: References: Message-ID: <4484EEBF.7070900@charter.net> Tim Riley wrote: > Has anyone come up with a way to add AutoCAD points using Python and > win32? Do I have to use Makepy on the type library? For example adding a > line to Modelspace requires you to call the AddLine method that accepts > two arrays of doubles. > > Any help/tips would be greatly appreciated. AutoCAD underspecifies the type of variant it's expecting for such functions -- the type library requests only a variant instead of an array of doubles (whereas the documentation is quite clear about what is needed.) I've been sitting for **way too long** on a patch that allows you to specify the type of variant you'd like, permitting something like: import pythoncom import win32com.client from win32com.client.variant import MakeVariant acad = win32com.client.Dispatch('autocad.application') dwg = acad.ActiveDocument ms = dwg.ModelSpace point1 = (0,0,0) point2 = (1,1,0) point1 = MakeVariant(pythoncom.VT_ARRAY | pythoncom.VT_R4, point1) point2 = MakeVariant(pythoncom.VT_ARRAY | pythoncom.VT_R4, point2) line = ms.AddLine(point1, point2) Since I'd last looked at this, AutoCAD 2007 got released and the issue wasn't resolved on their end. Unfortunately, Open Design Alliance' DWGDirectX library duplicates that bug. I *finally* started looking at this again just last week and am in the process of writing a test suite for it. I'll be emailing Mark Hammond with my progress (initial efforts way back when were overly rigid and testing wasn't up to snuff). I'll copy you on that update when I send it tomorrow. It's so nice to have a break from CAD work. :) Mark and I had taken that discussion off the list way back in February, and I'll leave it to him if he wants it back on the list. Cheers! -drg From mhammond at skippinet.com.au Tue Jun 6 05:43:28 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 6 Jun 2006 13:43:28 +1000 Subject: [python-win32] Adding AutoCAD Points. In-Reply-To: <4484EEBF.7070900@charter.net> Message-ID: <00c601c6891b$5fca17c0$090a0a0a@enfoldsystems.local> Hi Dan, I was wondering what happened to that patch - I'm glad it still lives :) > Mark and I had taken that discussion off the list way back in > February, > and I'll leave it to him if he wants it back on the list. I'm happy for all 'functionality' discussions to happen on list - but if it is just a bit of to-ing and fro-ing about the specific patch details I don't see a need to bore everyone else with it :) ie, either way works for me... Cheers, Mark From MKC at Stowers-Institute.org Tue Jun 6 20:00:05 2006 From: MKC at Stowers-Institute.org (Coleman, Michael) Date: Tue, 6 Jun 2006 13:00:05 -0500 Subject: [python-win32] problem with reference parameter to COM function(makepy) Message-ID: > That is true in most cases - but its not obvious from the > makepy generated file - did you actually call the function? Yes. It seems the function requires one (Python) argument to be present, even though conceptually this value is not used. The function always returns the value of this argument (as long as it's an 'int'). It sort of makes sense except that there seems to be a disconnect where this value never actually gets set by the function call. Actually, in calling the various object methods, I guess I don't really have proof yet that the COM object is actually being called. The python code is requiring correct types for the arguments, etc., but since I'm not yet getting any return values (and the object has no visible side-effects), I'm not sure what's happening. > > Is there something I can do to force this? Or, am I doing > something else > > wrong? > > > > Here's the documented signature: > > > > long IsError(BOOL FAR* pbIsError); > > Its not clear what the true IDL signature is for the > function. If the long is actually the HRESULT, then pywin32 > will *not* return that value (but will instead throw an > exception if a failure code is returned). Indeed, this is > what I believe is happening... Is there an easy way to determine the true IDL signature? Here's some corresponding (apparently auto-generated) code from a Visual C++ example program that uses this object: long CXRawfile::IsError(BOOL* pbIsError) { long result; static BYTE parms[] = VTS_PBOOL; InvokeHelper(0x7, DISPATCH_METHOD, VT_I4, (void*)&result, parms, pbIsError); return result; } My COM is pretty stale, so I have no idea what this was generated from. Could I use this information to tweak the makepy output to make this work correctly? > I also note that the first param appears to be missing the > [out] qualifer in the IDL (reflected in the second tuple item > being 0). If the single value you get returned is always > None, that will be the reason. I'm afraid I can't recall > exactly what pywin32 will do in such a case. This sounds like it might be a good lead. Is there some way I can adjust for this? Thanks again for any ideas. Mike From MKC at Stowers-Institute.org Wed Jun 7 22:45:43 2006 From: MKC at Stowers-Institute.org (Coleman, Michael) Date: Wed, 7 Jun 2006 15:45:43 -0500 Subject: [python-win32] slightly OT: missing windows.h/afxwin.h--how do I get them? Message-ID: Hi, I know this is off-topic, but I'm trying to compile some of the Python COM examples (and some other COM code) with the latest Visual C++ Express Edition, and it's complaining that it can't find the headers 'windows.h' and 'afxwin.h'. It's been several years since I used VC++, but these files seem fundamental, as best as I can recall. I did a search and they aren't present on my machine anywhere. Googling isn't turning up anything helpful either. What am I missing? How can I get the basic headers and libraries necessary to do Windows development? Thanks for your help, Mike From mhammond at skippinet.com.au Thu Jun 8 01:36:15 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 8 Jun 2006 09:36:15 +1000 Subject: [python-win32] slightly OT: missing windows.h/afxwin.h--how do Iget them? In-Reply-To: Message-ID: <07e501c68a8b$2b16f590$090a0a0a@enfoldsystems.local> I'm surprised windows.h doesn't come with Express Edition - but I'm fairly sure it comes with the "platform sdk" - which is necessary for many of the modules anyway. afxwin.h is an MFC header, and IIUC, that is not available without the full-blown MSVC. This will prevent you building pythonwin/win32ui - but should not prevent the COM and win32 packages building... Cheers, Mark > -----Original Message----- > From: python-win32-bounces+mhammond=keypoint.com.au at python.org > [mailto:python-win32-bounces+mhammond=keypoint.com.au at python.org]On > Behalf Of Coleman, Michael > Sent: Thursday, 8 June 2006 6:46 AM > To: python-win32 at python.org > Subject: [python-win32] slightly OT: missing > windows.h/afxwin.h--how do > Iget them? > > > Hi, > > I know this is off-topic, but I'm trying to compile some of the Python > COM examples (and some other COM code) with the latest Visual C++ > Express Edition, and it's complaining that it can't find the headers > 'windows.h' and 'afxwin.h'. It's been several years since I > used VC++, > but these files seem fundamental, as best as I can recall. I did a > search and they aren't present on my machine anywhere. Googling isn't > turning up anything helpful either. > > What am I missing? How can I get the basic headers and libraries > necessary to do Windows development? > > Thanks for your help, > Mike > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 2472 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20060608/25066a5b/attachment.bin From primmer at google.com Tue Jun 13 00:54:58 2006 From: primmer at google.com (David Primmer) Date: Mon, 12 Jun 2006 15:54:58 -0700 Subject: [python-win32] wrapping adsi objects Message-ID: <448DF0C2.8010406@google.com> I'm going to be writing a lot of ADSI scripts in python and I thought I'd wrap the IADsUser object. Right now, my custom user object "myUser", simply looks up the user in AD, does a GetObject() on it and the resulting IADsUser is a member of the class. So, if I want to get the name of the user in AD, I access it with "myUser.IADsUser.Name". However, I'd really like to simply subclass IADsUser and add a few attributes of my own, so myUser.Name is actually pointing to the IADsUser object's name. I don't have the skills to do anything as dynamic as Tim Golden's WMI wrapper. How would I do this subclassing? Thanks. From tim.golden at viacom-outdoor.co.uk Tue Jun 13 10:19:10 2006 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue, 13 Jun 2006 09:19:10 +0100 Subject: [python-win32] wrapping adsi objects Message-ID: [David Primmer] | I'm going to be writing a lot of ADSI scripts in python and I thought | I'd wrap the IADsUser object. Right now, my custom user | object "myUser", | simply looks up the user in AD, does a GetObject() on it and the | resulting IADsUser is a member of the class. So, if I want to get the | name of the user in AD, I access it with "myUser.IADsUser.Name". | | However, I'd really like to simply subclass IADsUser and add a few | attributes of my own, so myUser.Name is actually pointing to the | IADsUser object's name. I don't have the skills to do anything as | dynamic as Tim Golden's WMI wrapper. How would I do this subclassing? Without answering your actual question, what the WMI wrapper does is broadly known as delegation or proxying. There's nothing terribly difficult about doing it -- luckily, or I'd never have managed! -- so, depending on your exact requirements, something like this may serve your needs: # # This could well be someone else's class # outside your control, eg IADsUser. # class UsefulClass: def __init__ (self, x, y, z): self.x = x self.y = y self.z = z def do_stuff (self, stuff): print stuff class MyOwnClass: def __init__ (self, x, y, z, a, b): self.__dict__["_useful"] = UsefulClass (x, y, z) self.a = a self.b = b def __getattr__ (self, attribute): return getattr (self._useful, attribute) mine = MyOwnClass (1, 2, 3, 4, 5) print mine.a, mine.b print mine.x, mine.y, mine.z print mine.x is mine._useful.x mine.do_stuff ("blahblah") Notes: 1) __getattr__ *only* fires when an unknown attribute is referenced; ie it won't fire for mine.a or mine.b since these are recognised attributed of the "mine" instance. 2) The self.__dict__ stuff at the top of the __init__ for MyOwnClass is because the __getattr__ will fail with a recursion overflow error until you've defined an attribute _useful for the MyOwnClass instance. (Try it and see). The self.__dict__ stuff is a sneaky way of getting something into the instance's namespace while bypassing the __getattr__ mechanism. If there's some more elegant way to do this, I'm happy to hear about it! This basic approach is quite straightforward and, clearing away the clutter, comes down to holding an instance of the "other" class inside your own and setting up a __getattr__ to proxy attribute calls across. Of course you can get fancy with filtering which calls get passed etc. but this basic approach is sufficient for many needs. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From Pierre_Rouleau at ImpathNetworks.com Wed Jun 14 00:08:39 2006 From: Pierre_Rouleau at ImpathNetworks.com (Pierre Rouleau) Date: Tue, 13 Jun 2006 17:08:39 -0500 Subject: [python-win32] Is pure-win32 GetWindowPlacement() available ? Message-ID: Hi all, I have been looking for a wrapper for the Win32 function GetWindowPlacement() but could not find it in the latest version of Python for Windows extension (version 208). I saw a reference to PyCWnd.GetWindowPlacement() where a MFC CWnd is needed but could not find a pure Win32 version. Does anyone know if this is/will be wrapped? What I want to do is to be able to detect the state of a window (is it maximized, minimized, etc...) and I would use GetWindowPlacement() in Win32 code. Aside from doing my own wrapper, does anyone know if there is another wrapper function to perform the same action? Thanks in advance! -- Pierre Rouleau From mc at mclaveau.com Wed Jun 14 09:00:38 2006 From: mc at mclaveau.com (Michel Claveau) Date: Wed, 14 Jun 2006 09:00:38 +0200 Subject: [python-win32] Problem after MS update (scripting References: <00c601c6891b$5fca17c0$090a0a0a@enfoldsystems.local> Message-ID: <002601c68f80$409796a0$0701a8c0@PORTABLES> Hi! I updated my windows-scripting-system, next of a security-alarm of MS : http://www.microsoft.com/downloads/details.aspx?displaylang=fr&FamilyID=d28c02be-cac3-4579-9b93-939fd5d3cde6 (Sorry, it's the french MS link) Now, many scripts, who worked correctly yesterday, has errors. Example of error obtained : Attribute Error! '' object has no attribute 'inner Html' Other personns in the same case? @+ Michel Claveau -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060614/dab4163b/attachment.html From bamanzi at gmail.com Wed Jun 14 16:15:45 2006 From: bamanzi at gmail.com (Bamanzi) Date: Wed, 14 Jun 2006 22:15:45 +0800 Subject: [python-win32] Failed to invoke ActiveScripting debugger Message-ID: <22bb4a9b0606140715x3bf11053y97e3b1cfe97822f0@mail.gmail.com> Hi, guys I am tring to integrate the Python into our application, which already had support for VBScript, JScript via the MS Active Scripting interface. I executed E:\Python23\Lib\site-packages\win32comext\axscript\client\pyscript.py and now I can execute python scripts from our app. But I failed to invoke the debugger. When I execute (directly from Windows Prompt) win32comext\axdebug\debugger.py, I got the following errors: --------------------------------------------------------- E:\Python23\Lib\site-packages\win32comext\axdebug>debugger.py About to test the debugging interfaces! Traceback (most recent call last): File "E:\Python23\Lib\site-packages\win32comext\axdebug\debugger.py", line 201, in ? test() File "E:\Python23\Lib\site-packages\win32comext\axdebug\debugger.py", line 194, in test Break() File "E:\Python23\Lib\site-packages\win32comext\axdebug\debugger.py", line 179, in Break _GetCurrentDebugger().Break() File "E:\Python23\Lib\site-packages\win32comext\axdebug\debugger.py", line 175, in _GetCurrentDebu gger currentDebugger = AXDebugger() File "E:\Python23\Lib\site-packages\win32comext\axdebug\debugger.py", line 125, in __init__ contProvider = CodeContainerProvider(self) File "E:\Python23\Lib\site-packages\win32comext\axdebug\debugger.py", line 70, in __init__ self.axdebugger.RefreshAllModules(self.nodes, self) File "E:\Python23\Lib\site-packages\win32comext\axdebug\debugger.py", line 155, in RefreshAllModul es RefreshAllModules(nodes, self.root, self.CreateApplicationNode, (containerProvider,)) File "E:\Python23\Lib\site-packages\win32comext\axdebug\debugger.py", line 59, in RefreshAllModule s BuildModule(module, builtItems, rootNode, create_node, create_node_args) File "E:\Python23\Lib\site-packages\win32comext\axdebug\debugger.py", line 54, in BuildModule parentNode = built_nodes[parentModule].realNode KeyError: -------------------------------------------------- I tried to add a line before line 54: + if built_nodes.get(parentModule): parentNode = built_nodes[parentModule].realNode Now MS InterDev shows up, but there's no script window, which ususally shows the code and indicates the error line/break line. Is there anything wrong in my usage? best regards Ralgh Young From chris.botos at gmail.com Thu Jun 15 01:45:03 2006 From: chris.botos at gmail.com (Chris Botos) Date: Wed, 14 Jun 2006 19:45:03 -0400 Subject: [python-win32] Building win32 extensions to Python Message-ID: <44909F7F.7020304@gmail.com> Hello List, I've been using Python for a couple of months, primarily through wxPython, so I'm relatively new at the game, and to this list. I have a need to interface a wxPython application to some C (and perhaps C++), functions (and classes) that return the results of various computations. I am not a windows programmer - our app is targeted for Solaris, but we are creating some Windows demos, so I need to first get this working for win32. For a few days now I've been surfing, searching python archives, other archives, online books, and trying but failing to build a sample extension for Python on Windows XP, SP2. The documentation and discussions on this have been confusing to me (doing the same task on Unix looks more straightforward.). The Python version that I have is: "Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32". I've described what I've done up to now below. I will continue hacking, but I am hoping one of the Python gurus will be able to steer me onto the right or better path (no pun intended)! Thanks in advance for your advice! Chris Botos --------------------------------------------------------------- 1) I copied the example setup.py and elemlist.c from: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66509 2) ... and made modifications recommended at: http://www.vrplumber.com/programming/mstoolkit/index.html It seems that a lot of recommendations I've read about are based somewhat on this site., but it is a few years out of date. 3) I downloaded and installed: .NET Framework SDK Version 1.1 Visual C++ 2005 Express Edition, that first installs .NET Framework 2.0 (note that I could not get to a download for the 2003 version on Microsoft's site and the only other download site I found was at softpedia, and the download link there is broken ) 4) I ran VC++ once to set up the environment. 5) Downloaded Windows Server 2003 R2 Platform SDK - this replaced the version that the link in 2) pointed to. 6) At a regular command prompt, executed >python setup.py install It could not find cl.exe. 7) After playing with the environment and getting a little farther, I found "Start --> ... --> Visual Studio 2005 Command Prompt" that sets its own environment: C:\Program Files\Microsoft Visual Studio 8\VC>set ALLUSERSPROFILE=C:\Documents and Settings\All Users APPDATA=C:\Documents and Settings\Chris Botos\Application Data CLIENTNAME=Console CommonProgramFiles=C:\Program Files\Common Files COMPUTERNAME=DIPLOID ComSpec=C:\WINDOWS\system32\cmd.exe DevEnvDir=C:\Program Files\Microsoft Visual Studio 8\Common7\IDE FP_NO_HOST_CHECK=NO FrameworkDir=C:\WINDOWS\Microsoft.NET\Framework FrameworkSDKDir=C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0 FrameworkVersion=v2.0.50727 HOMEDRIVE=C: HOMEPATH=\Documents and Settings\Chris Botos IBMSHARE=C:\IBMSHARE INCLUDE=C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE; LIB=C:\Program Files\Microsoft Visual Studio 8\VC\LIB;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\lib; LIBPATH=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 LOGONSERVER=\\DIPLOID NUMBER_OF_PROCESSORS=1 OS=Windows_NT Path=C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;C:\Program Files\Mic rosoft Visual Studio 8\VC\BIN;C:\Program Files\Microsoft Visual Studio 8\Common7 \Tools;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin;C:\WINDOWS\Micros oft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\VC\VCPac kages;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBEM;C:\Program Files\T hinkPad\Utilities;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\PC-Doctor for Windows\;C:\Program Files\IBM ThinkVantage\Client Security Solution;C:\Program Files\ThinkPad\ConnectUtilities;C:\Python24; PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH PROCESSOR_ARCHITECTURE=x86 PROCESSOR_IDENTIFIER=x86 Family 6 Model 13 Stepping 8, GenuineIntel PROCESSOR_LEVEL=6 PROCESSOR_REVISION=0d08 ProgramFiles=C:\Program Files PROMPT=$P$G RR=C:\Program Files\IBM ThinkVantage\Rescue and Recovery SESSIONNAME=Console SMA=C:\Program Files\IBM ThinkVantage\SMA\ SonicCentral=c:\Program Files\Common Files\Sonic Shared\Sonic Central\ SystemDrive=C: SystemRoot=C:\WINDOWS TEMP=C:\DOCUME~1\CHRISB~1\LOCALS~1\Temp TMP=C:\DOCUME~1\CHRISB~1\LOCALS~1\Temp tvdumpflags=8 TVT=C:\Program Files\IBM ThinkVantage TVTPYDIR=C:\Program Files\IBM ThinkVantage\Common\Python24 USERDOMAIN=DIPLOID USERNAME=Chris Botos USERPROFILE=C:\Documents and Settings\Chris Botos VCINSTALLDIR=C:\Program Files\Microsoft Visual Studio 8\VC VS80COMNTOOLS=C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\ VSINSTALLDIR=C:\Program Files\Microsoft Visual Studio 8 windir=C:\WINDOWS 8) I repeated ">python setup.py install" and got the following error: c:\python24\include\pyconfig.h(130) : fatal error C1083: Cannot open include file: 'basetsd.h': No such file or directory error: command '"C:\Program Files\Microsoft Visual Studio 8\VC\BIN\cl.exe"' failed with exit status 2 From rwupole at msn.com Thu Jun 15 04:51:32 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 14 Jun 2006 22:51:32 -0400 Subject: [python-win32] Re: Is pure-win32 GetWindowPlacement() available ? Message-ID: Pierre Rouleau wrote: > Hi all, > > I have been looking for a wrapper for the Win32 function > GetWindowPlacement() but could not find it in the latest version of > Python for Windows extension (version 208). I saw a reference to > PyCWnd.GetWindowPlacement() where a MFC CWnd is needed but could not > find a pure Win32 version. > > Does anyone know if this is/will be wrapped? > > What I want to do is to be able to detect the state of a window (is it > maximized, minimized, etc...) and I would use GetWindowPlacement() in > Win32 code. Aside from doing my own wrapper, does anyone know if there > is another wrapper function to perform the same action? > > Thanks in advance! > > -- > Pierre Rouleau You can use win32ui.CreateWindowFromHandle to wrap a raw window handle in a PyCWnd, and then use its GetWindowPlacement method. It would be relatively simple to wrap this function in win32gui also, mostly cut-n-paste from win32ui. Roger From rwupole at msn.com Thu Jun 15 05:36:51 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 14 Jun 2006 23:36:51 -0400 Subject: [python-win32] Re: Problem after MS update (scripting Message-ID: Michel Claveau wrote: > Example of error obtained : > Attribute Error! '' object has no > attribute 'inner Html' > > Other personns in the same case? With the same update installed here, I can still access this attribute for a select box. Once you've generated the makepy file for the HTML object library, attributes are case-sensitive. You'd need innerHTML.instead. Also, it appears there's a space in the middle of the attribute name in the error msg. Is this a direct copy/paste ? Roger From p.f.moore at gmail.com Thu Jun 15 11:57:02 2006 From: p.f.moore at gmail.com (Paul Moore) Date: Thu, 15 Jun 2006 10:57:02 +0100 Subject: [python-win32] Building win32 extensions to Python In-Reply-To: <44909F7F.7020304@gmail.com> References: <44909F7F.7020304@gmail.com> Message-ID: <79990c6b0606150257w68a6e0b8u93db201f70ecd97e@mail.gmail.com> On 6/15/06, Chris Botos wrote: > 3) I downloaded and installed: > .NET Framework SDK Version 1.1 > Visual C++ 2005 Express Edition, that first installs .NET Framework 2.0 > (note that I could not get to a download for the 2003 version on > Microsoft's site and the only other download site I found was at > softpedia, and the download link there is broken ) I've only skimmed your post briefly, but this is likely your problem. Python extensions cannot be built with Visual C++ 2005 (incompatible C runtime), so this doesn't work. You need the Visual C++ Toolkit Edition, but MS no longer seem to supply this :-( If you can get someone who has a copy to send it to you, that would be one option - but it's a 32MB file, and I don't know the redistribution conditions, it's probably not allowed, so you may have problems there). The other option is to install Mingw (from www.mingw.org), and build using setup.py build --compiler=mingw32. This works fine, unless your extension code uses MSVC specific extensions. The instructions in the Python docs are a little out of date, I believe. With Python 2.4, you shouldn't need to do anything more than install mingw, make sure gcc is on your path, and run setup.py as above. You can even edit the distutils config file (I can't remember its location offhand, sorry) to specify that distutils should use mingw by default. Hope this helps, Paul. From chris.botos at gmail.com Thu Jun 15 13:04:38 2006 From: chris.botos at gmail.com (chris botos) Date: Thu, 15 Jun 2006 07:04:38 -0400 Subject: [python-win32] Building win32 extensions to Python In-Reply-To: <79990c6b0606150257w68a6e0b8u93db201f70ecd97e@mail.gmail.com> References: <44909F7F.7020304@gmail.com> <79990c6b0606150257w68a6e0b8u93db201f70ecd97e@mail.gmail.com> Message-ID: <4da1a0c50606150404m5337b08ao13c29b7fe7b3f542@mail.gmail.com> This sounds like a plan. I'll give it a try. Thanks, Paul. Chris On 6/15/06, Paul Moore wrote: > > On 6/15/06, Chris Botos wrote: > > 3) I downloaded and installed: > > .NET Framework SDK Version 1.1 > > Visual C++ 2005 Express Edition, that first installs .NET Framework 2.0 > > (note that I could not get to a download for the 2003 version on > > Microsoft's site and the only other download site I found was at > > softpedia, and the download link there is broken ) > > I've only skimmed your post briefly, but this is likely your problem. > Python extensions cannot be built with Visual C++ 2005 (incompatible C > runtime), so this doesn't work. You need the Visual C++ Toolkit > Edition, but MS no longer seem to supply this :-( If you can get > someone who has a copy to send it to you, that would be one option - > but it's a 32MB file, and I don't know the redistribution conditions, > it's probably not allowed, so you may have problems there). > > The other option is to install Mingw (from www.mingw.org), and build > using setup.py build --compiler=mingw32. This works fine, unless your > extension code uses MSVC specific extensions. The instructions in the > Python docs are a little out of date, I believe. With Python 2.4, you > shouldn't need to do anything more than install mingw, make sure gcc > is on your path, and run setup.py as above. You can even edit the > distutils config file (I can't remember its location offhand, sorry) > to specify that distutils should use mingw by default. > > Hope this helps, > Paul. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060615/83a65e94/attachment.htm From mrmaple at gmail.com Thu Jun 15 14:57:31 2006 From: mrmaple at gmail.com (James Carroll) Date: Thu, 15 Jun 2006 08:57:31 -0400 Subject: [python-win32] Building win32 extensions to Python In-Reply-To: <4da1a0c50606150404m5337b08ao13c29b7fe7b3f542@mail.gmail.com> References: <44909F7F.7020304@gmail.com> <79990c6b0606150257w68a6e0b8u93db201f70ecd97e@mail.gmail.com> <4da1a0c50606150404m5337b08ao13c29b7fe7b3f542@mail.gmail.com> Message-ID: Hi Chris, I would recommend buying Visual Studio. It's what python 2.4 is built with, and it makes compiling extensions nice and easy. My favorite examples of extending python include: - screengrabber extension for the python imaging library http://effbot.org/downloads/ 1) download and install the Python imaging library (PIL) 2) download the screengrabber source and uncompress to a directory. 3) look at the _screengrab.c (or whatever it is called) to see how it accepts and returns python argumetns, but does win32 calls inbetween. 4) run " python setup.py build " to invoke Visual C++ (or mingw if detected.) 5) run " python setup.py install " to try it interactively. - My second favorote example is on the wxPython Wiki, it shows how to extend wxPython with commercial VC++ http://wiki.wxpython.org/index.cgi/C%2B%2BExtensions I wrote the pages for VisualStudioExtenions and SconsExtensions, so let me know if you need them to be more helpful. I wrote them hastily, but I think I got the important parts right. -Jim On 6/15/06, chris botos wrote: > > This sounds like a plan. I'll give it a try. Thanks, Paul. > > Chris > > > > > On 6/15/06, Paul Moore wrote: > > On 6/15/06, Chris Botos wrote: > > > 3) I downloaded and installed: > > > .NET Framework SDK Version 1.1 > > > Visual C++ 2005 Express Edition, that first installs .NET Framework 2.0 > > > (note that I could not get to a download for the 2003 version on > > > Microsoft's site and the only other download site I found was at > > > softpedia, and the download link there is broken ) > > > > I've only skimmed your post briefly, but this is likely your problem. > > Python extensions cannot be built with Visual C++ 2005 (incompatible C > > runtime), so this doesn't work. You need the Visual C++ Toolkit > > Edition, but MS no longer seem to supply this :-( If you can get > > someone who has a copy to send it to you, that would be one option - > > but it's a 32MB file, and I don't know the redistribution conditions, > > it's probably not allowed, so you may have problems there). > > > > The other option is to install Mingw (from www.mingw.org), and build > > using setup.py build --compiler=mingw32. This works fine, unless your > > extension code uses MSVC specific extensions. The instructions in the > > Python docs are a little out of date, I believe. With Python 2.4, you > > shouldn't need to do anything more than install mingw, make sure gcc > > is on your path, and run setup.py as above. You can even edit the > > distutils config file (I can't remember its location offhand, sorry) > > to specify that distutils should use mingw by default. > > > > Hope this helps, > > Paul. > > > > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > From kevin.horn at gmail.com Thu Jun 15 15:56:56 2006 From: kevin.horn at gmail.com (Kevin Horn) Date: Thu, 15 Jun 2006 08:56:56 -0500 Subject: [python-win32] Fwd: Building win32 extensions to Python In-Reply-To: <562bcc10606150656m778d61a3o8677be127213ba@mail.gmail.com> References: <44909F7F.7020304@gmail.com> <79990c6b0606150257w68a6e0b8u93db201f70ecd97e@mail.gmail.com> <4da1a0c50606150404m5337b08ao13c29b7fe7b3f542@mail.gmail.com> <562bcc10606150656m778d61a3o8677be127213ba@mail.gmail.com> Message-ID: <562bcc10606150656hdd14cb1ucbf92623d61a15ec@mail.gmail.com> Another option might be to wrap your C code using the ctypes module ( http://starship.python.net/crew/theller/ctypes/). This might be especially attractive if this code is mostly for demo purposes (at least for demo purposes on win32). Ctypes basically allows you to call C code from python, but rather than handling the data type translations in C (like in a "normal" extension), you handle the translations in Python. For C++ code you might check out boost.python. I haven't used it but I've heard good things. Kevin H. On 6/15/06, James Carroll < mrmaple at gmail.com> wrote: > > Hi Chris, > > I would recommend buying Visual Studio. It's what python 2.4 is built > with, and it makes compiling extensions nice and easy. > > My favorite examples of extending python include: > > - screengrabber extension for the python imaging library > http://effbot.org/downloads/ > > 1) download and install the Python imaging library (PIL) > 2) download the screengrabber source and uncompress to a directory. > 3) look at the _screengrab.c (or whatever it is called) to see how it > accepts and returns python argumetns, but does win32 calls inbetween. > 4) run " python setup.py build " to invoke Visual C++ (or mingw if > detected.) > 5) run " python setup.py install " to try it interactively. > > - My second favorote example is on the wxPython Wiki, it shows how to > extend wxPython with commercial VC++ > > http://wiki.wxpython.org/index.cgi/C%2B%2BExtensions > > I wrote the pages for VisualStudioExtenions and SconsExtensions, so > let me know if you need them to be more helpful. I wrote them > hastily, but I think I got the important parts right. > > -Jim > > > > > On 6/15/06, chris botos wrote: > > > > This sounds like a plan. I'll give it a try. Thanks, Paul. > > > > Chris > > > > > > > > > > On 6/15/06, Paul Moore wrote: > > > On 6/15/06, Chris Botos wrote: > > > > 3) I downloaded and installed: > > > > .NET Framework SDK Version 1.1 > > > > Visual C++ 2005 Express Edition, that first installs .NET Framework > 2.0 > > > > (note that I could not get to a download for the 2003 version on > > > > Microsoft's site and the only other download site I found was at > > > > softpedia, and the download link there is broken ) > > > > > > I've only skimmed your post briefly, but this is likely your problem. > > > Python extensions cannot be built with Visual C++ 2005 (incompatible C > > > runtime), so this doesn't work. You need the Visual C++ Toolkit > > > Edition, but MS no longer seem to supply this :-( If you can get > > > someone who has a copy to send it to you, that would be one option - > > > but it's a 32MB file, and I don't know the redistribution conditions, > > > it's probably not allowed, so you may have problems there). > > > > > > The other option is to install Mingw (from www.mingw.org), and build > > > using setup.py build --compiler=mingw32. This works fine, unless your > > > extension code uses MSVC specific extensions. The instructions in the > > > Python docs are a little out of date, I believe. With Python 2.4, you > > > shouldn't need to do anything more than install mingw, make sure gcc > > > is on your path, and run setup.py as above. You can even edit the > > > distutils config file (I can't remember its location offhand, sorry) > > > to specify that distutils should use mingw by default. > > > > > > Hope this helps, > > > Paul. > > > > > > > > > _______________________________________________ > > Python-win32 mailing list > > Python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060615/3b93d154/attachment.htm From chris.botos at gmail.com Thu Jun 15 23:33:35 2006 From: chris.botos at gmail.com (Chris Botos) Date: Thu, 15 Jun 2006 17:33:35 -0400 Subject: [python-win32] Building win32 extensions to Python In-Reply-To: References: <44909F7F.7020304@gmail.com> <79990c6b0606150257w68a6e0b8u93db201f70ecd97e@mail.gmail.com> <4da1a0c50606150404m5337b08ao13c29b7fe7b3f542@mail.gmail.com> Message-ID: <4491D22F.3090902@gmail.com> James Carroll wrote: > Hi Chris, > > I would recommend buying Visual Studio. It's what python 2.4 is built > with, and it makes compiling extensions nice and easy. > > My favorite examples of extending python include: > > - screengrabber extension for the python imaging library > http://effbot.org/downloads/ > ... > - My second favorote example is on the wxPython Wiki, it shows how to > extend wxPython with commercial VC++ > > http://wiki.wxpython.org/index.cgi/C%2B%2BExtensions > > I wrote the pages for VisualStudioExtenions and SconsExtensions, so > let me know if you need them to be more helpful. I wrote them > hastily, but I think I got the important parts right. > > -Jim > I still need to look at these. I'll let you know if I need help understanding them. Thanks! >> > The other option is to install Mingw (from www.mingw.org), and build >> > using setup.py build --compiler=mingw32. This works fine, unless your >> > extension code uses MSVC specific extensions. ... >> > Paul. Hi Jim and Paul, Thanks for your responses. I went ahead and tried MinGW. I was able to build and use screengrabber and other examples. I also used it as an example and created successfully a very simple "hello python" extension. What am I or will I be losing by using MinGW instead of Visual Studio? I've noted the warnings suggesting using the compiler that built python, but I haven't understood the reasons so far. Chris From primmer at google.com Fri Jun 16 02:40:23 2006 From: primmer at google.com (David Primmer) Date: Thu, 15 Jun 2006 17:40:23 -0700 Subject: [python-win32] Unit testing COM clients and Servers Message-ID: <4491FDF7.1010400@google.com> I'd like to use Test Drive Development when using ADSI, WMI and other COM libraries on Windows with Python. Can anyone give some hints as to how to get started or how they do it? I'm fairly new to it and it seems like to write tests, you have to simulate the responses ADSI or WMI. I can find lots of help doing standard python unit testing but how does this change when using COM? thanks. From mrmaple at gmail.com Fri Jun 16 14:27:36 2006 From: mrmaple at gmail.com (James Carroll) Date: Fri, 16 Jun 2006 08:27:36 -0400 Subject: [python-win32] Building win32 extensions to Python In-Reply-To: <4491D22F.3090902@gmail.com> References: <44909F7F.7020304@gmail.com> <79990c6b0606150257w68a6e0b8u93db201f70ecd97e@mail.gmail.com> <4da1a0c50606150404m5337b08ao13c29b7fe7b3f542@mail.gmail.com> <4491D22F.3090902@gmail.com> Message-ID: > Thanks for your responses. I went ahead and tried MinGW. I was able to > build and use screengrabber and other examples. I also used it as an > example and created successfully a very simple "hello python" extension. Fantastic! they must be more (binary) compatable than I thought. > What am I or will I be losing by using MinGW instead of Visual Studio? The only thing that I've read consistently is that VisualStudio does a better job of optimizing code. Otherwise, you might not be losing anything. (I have no love for the IDE itself.) Have fun with wxWidgets + C++ extensions. I think it's a killer combination. I'm doing some work with live video plus antialised rendering plus the html virtual list control that is coming together very well. My only hurdle is py2exe can't make a single executable out of it... Py2exe can create a package with a dozen files, but I was hoping for a nice tiny bundle. -Jim From Pierre_Rouleau at ImpathNetworks.com Fri Jun 16 15:32:57 2006 From: Pierre_Rouleau at ImpathNetworks.com (Pierre Rouleau) Date: Fri, 16 Jun 2006 08:32:57 -0500 Subject: [python-win32] Is pure-win32 GetWindowPlacement() available ? In-Reply-To: References: Message-ID: Roger Upole wrote: > Pierre Rouleau wrote: > >>I have been looking for a wrapper for the Win32 function >>GetWindowPlacement() but could not find it in the latest version of >>Python for Windows extension (version 208). I saw a reference to >>PyCWnd.GetWindowPlacement() where a MFC CWnd is needed but could not >>find a pure Win32 version. >> >>Does anyone know if this is/will be wrapped? >> > > You can use win32ui.CreateWindowFromHandle to wrap a raw > window handle in a PyCWnd, and then use its GetWindowPlacement > method. > It would be relatively simple to wrap this function in > win32gui also, mostly cut-n-paste from win32ui. > > Roger That's what I'll do, thanks! -- Pierre Rouleau From chris.botos at gmail.com Fri Jun 16 19:49:42 2006 From: chris.botos at gmail.com (Chris Botos) Date: Fri, 16 Jun 2006 13:49:42 -0400 Subject: [python-win32] Building win32 extensions to Python - crash In-Reply-To: References: <44909F7F.7020304@gmail.com> <79990c6b0606150257w68a6e0b8u93db201f70ecd97e@mail.gmail.com> <4da1a0c50606150404m5337b08ao13c29b7fe7b3f542@mail.gmail.com> <4491D22F.3090902@gmail.com> Message-ID: <4492EF36.5030709@gmail.com> James Carroll wrote: >> Thanks for your responses. I went ahead and tried MinGW. I was able to >> build and use screengrabber and other examples. I also used it as an >> example and created successfully a very simple "hello python" extension. > > Fantastic! they must be more (binary) compatable than I thought. Well, ... I've managed to crash python by using an "ostream" rather than "printf". The code is below. If I replace the std::cout with a printf the code works fine. The symptom is that the cout is flushed to the console as it should be, then the python shell hangs. A few seconds later a "send error report to microsoft" dialog comes up. Here's some of the information it provided, in addition to saying it was an unhandled exception: Error Signature: AppName: python.exe AppVer: 0.0.0.0 ModName: ntdll.dll ModVer: 5.1.2600.2180 Offset: 00018fea I'm using Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32; MinGW Developer Studio 2.05. Does anyone know what I'm doing wrong? - Chris #include #include static PyObject* spam_boo(PyObject* self, PyObject* args) { std::cout << "Boo!\n" << std::endl; // PYTHON CRASHES HERE <<<<<<<<<<<<<<<<<<<<<<<<< return Py_BuildValue("s", "boo: I'm done.\n"); } static PyMethodDef SpamMethods[] = { {"boo", (PyCFunction)spam_boo, METH_VARARGS, ""}, {NULL, NULL, 0, NULL} }; PyMODINIT_FUNC initspam(void) { Py_InitModule("spam", SpamMethods); } From mrmaple at gmail.com Fri Jun 16 20:41:12 2006 From: mrmaple at gmail.com (James Carroll) Date: Fri, 16 Jun 2006 14:41:12 -0400 Subject: [python-win32] Fwd: Building win32 extensions to Python - crash In-Reply-To: References: <44909F7F.7020304@gmail.com> <79990c6b0606150257w68a6e0b8u93db201f70ecd97e@mail.gmail.com> <4da1a0c50606150404m5337b08ao13c29b7fe7b3f542@mail.gmail.com> <4491D22F.3090902@gmail.com> <4492EF36.5030709@gmail.com> Message-ID: > Well, ... I've managed to crash python by using an "ostream" rather than > "printf". The code is below. If I replace the std::cout with a printf > the code works fine. The symptom is that the cout is flushed to the > console as it should be, then the python shell hangs. A few seconds > later a "send error report to microsoft" dialog comes up. Here's some Hmm... I'm not sure why one would work and the other would fail. I bet the cout << method would work with some python interpreters, but not others. I just put a cout << " luminance set to " << luminance; in my extension (of a wxPython gui app.) and it worked fine. I'm running mine from Visual Slickedit, so my stdout is getting redirected in a passive way to an output window in slickedit. The command line interpreter you get when you just type python at a command prompt is pretty simple and forgiving about things like these, but it does assume it has control of stdout. Other times, the gui command lines like Pythonwin or wxWidgets PyCrust seem more forgiving. PyCrust actually (if I remember right) redirects stdout so your cout << "hi" might end up in a tab at the bottom of PyCrust (the output window.) I do usually keep my C++ extensions from doing anything but returning values to python. Since I'm using wxWidgets in C++ and wxPython too, I can do wx.LogTrace or wx.LogError at both the C++ and python levels when I want to avoid trying to set up a debugger. Another trick is to use C++ test projects (using cppunitlite) until I get the C++ code working just right, and then create my swig .i files, and then test a bit more interactively from Python, and I'm done. If I have to debug something or print to stdout, then I'll do it from the C++ unit tests. It's not too strange to crash the python interpreter from an extension. My most common problem is to create a C++ class (A) from python, hand it to another C++ class (B), and then return from the function. Python doesn't know that Class B has a pointer to class A, so it thinks it should delete class A, and then I get a crash when class B tries to dereference it. There are two solutions, if you want python to handle class A's lifetime, then you just hold on to a variable that points to it. If you want C++ to manage its lifetime, then you can do a = A(); a.thisown=False. Thisown is a swig thing that keeps python from deleting the C++ class. But you aren't using swig (yet) so this is only relevent as far as showing the one thing you have to be aware of. Without swig, it's just being concious of when to Refrence and Unref() certain variables. -Jim On 6/16/06, Chris Botos wrote: > James Carroll wrote: > >> Thanks for your responses. I went ahead and tried MinGW. I was able to > >> build and use screengrabber and other examples. I also used it as an > >> example and created successfully a very simple "hello python" extension. > > > > Fantastic! they must be more (binary) compatable than I thought. > > Well, ... I've managed to crash python by using an "ostream" rather than > "printf". The code is below. If I replace the std::cout with a printf > the code works fine. The symptom is that the cout is flushed to the > console as it should be, then the python shell hangs. A few seconds > later a "send error report to microsoft" dialog comes up. Here's some > of the information it provided, in addition to saying it was an > unhandled exception: > Error Signature: > AppName: python.exe AppVer: 0.0.0.0 ModName: ntdll.dll > ModVer: 5.1.2600.2180 Offset: 00018fea > > I'm using > Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on > win32; MinGW Developer Studio 2.05. > Does anyone know what I'm doing wrong? > - Chris > > > #include > #include > > static PyObject* > spam_boo(PyObject* self, PyObject* args) > { > std::cout << "Boo!\n" << std::endl; > // PYTHON CRASHES HERE <<<<<<<<<<<<<<<<<<<<<<<<< > return Py_BuildValue("s", "boo: I'm done.\n"); > } > > static PyMethodDef SpamMethods[] = { > {"boo", (PyCFunction)spam_boo, METH_VARARGS, ""}, > {NULL, NULL, 0, NULL} > }; > > PyMODINIT_FUNC > initspam(void) > { > Py_InitModule("spam", SpamMethods); > } > > From sjmachin at lexicon.net Sat Jun 17 00:41:53 2006 From: sjmachin at lexicon.net (John Machin) Date: Sat, 17 Jun 2006 08:41:53 +1000 Subject: [python-win32] Building win32 extensions to Python - crash In-Reply-To: <4492EF36.5030709@gmail.com> References: <44909F7F.7020304@gmail.com> <79990c6b0606150257w68a6e0b8u93db201f70ecd97e@mail.gmail.com> <4da1a0c50606150404m5337b08ao13c29b7fe7b3f542@mail.gmail.com> <4491D22F.3090902@gmail.com> <4492EF36.5030709@gmail.com> Message-ID: <449333B1.8080906@lexicon.net> On 17/06/2006 3:49 AM, Chris Botos wrote: > James Carroll wrote: >>> Thanks for your responses. I went ahead and tried MinGW. I was able to >>> build and use screengrabber and other examples. I also used it as an >>> example and created successfully a very simple "hello python" extension. >> Fantastic! they must be more (binary) compatable than I thought. > > Well, ... I've managed to crash python by using an "ostream" rather than > "printf". The code is below. If I replace the std::cout with a printf > the code works fine. The symptom is that the cout is flushed to the > console as it should be, then the python shell hangs. A few seconds > later a "send error report to microsoft" dialog comes up. Here's some > of the information it provided, in addition to saying it was an > unhandled exception: > Error Signature: > AppName: python.exe AppVer: 0.0.0.0 ModName: ntdll.dll > ModVer: 5.1.2600.2180 Offset: 00018fea > > I'm using > Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on > win32; MinGW Developer Studio 2.05. > Does anyone know what I'm doing wrong? You said it yourself: """using an "ostream" rather than "printf"""". My guess would be that the MinGW C++ cout data structures are not initialised. My experiences, FWIW: I've been using both MinGW and Borland 5.5 for ages, for extensions that I've written myself in C, and also using Borland to compile the C code generated by Pyrex. I've never tried to wrap an existing C library. Here are my rules for staying out of trouble: 1. Use C, not C++. 2. If there is a function in the Python/C API that does the job, use it in preference to an RTL function. This applies especially to malloc() and free(). 3. Don't try to use resources across RTL boundaries e.g. trying MinGW fwrite() on a (FILE *) that was opened by the MSC RTL and obtained by calling PyFile_AsFile() HTH John From billburns at pennswoods.net Sat Jun 17 02:45:39 2006 From: billburns at pennswoods.net (Bill Burns) Date: Fri, 16 Jun 2006 20:45:39 -0400 Subject: [python-win32] Building win32 extensions to Python (OT) In-Reply-To: References: <44909F7F.7020304@gmail.com> <79990c6b0606150257w68a6e0b8u93db201f70ecd97e@mail.gmail.com> <4da1a0c50606150404m5337b08ao13c29b7fe7b3f542@mail.gmail.com> <4491D22F.3090902@gmail.com> Message-ID: <449350B3.4090003@pennswoods.net> Jim wrote: > My only hurdle is py2exe can't make a single executable > out of it... Py2exe can create a package with a dozen files, but I was > hoping for a nice tiny bundle. > Hi Jim, Have you tried bundling an app with py2exe and... 1). The resulting exe did not run properly or 2). You didn't know that py2exe can create single file executables? If the the answer is #1 then I can't help, but if the answer is #2 then keep reading ;-) Using py2exe 0.6.5 (and python 2.4.3), I have a setup file like this: setup(windows = [{'script':'ManageExe.py','icon_resources':[(1,'go-jump.ico')]}], zipfile=None)) Take note of the line 'zipfile=None'. Then, from the command line I do this: C:\ManageExe>python setup.py py2exe -b1 Note the bundle option '-b1' (you can use 1, 2 or 3). Running the above will create a single file executable. It won't wind up being 'nice & tiny' :-) but it will be bundled into one exe. Also as a test - I just bundled the single file wxPython sample in ...\site-packages\py2exe\samples\singlefile\gui and it works fine. If your resulting executable works OK, you could also try running UPX [1] over it to make it even smaller.... Using UPX, I was able to reduce the size of the wxPython sample (above) by 22%. HTH, Bill [1] http://upx.sourceforge.net From mattc at freedombox.cc Sat Jun 17 19:56:06 2006 From: mattc at freedombox.cc (Matt Campbell) Date: Sat, 17 Jun 2006 12:56:06 -0500 Subject: [python-win32] Unicode build of win32gui outside of WinCE? Message-ID: <44944236.2050700@freedombox.cc> Hello: Are there any plans to support a Unicode build of win32gui in PyWin32 outside of Windows CE? Perhaps the winxpgui module could be built with UNICODE defined while the win32gui module is not. Alternatively, both could be built with UNICODE defined and use the Microsoft Layer for Unicode to remain compatible with 9x. Any thoughts? Thanks. -- Matt Campbell Lead Programmer Serotek Corporation www.freedombox.info "The Accessibility Anywhere People" From chris.botos at gmail.com Sun Jun 18 02:10:39 2006 From: chris.botos at gmail.com (chris botos) Date: Sat, 17 Jun 2006 20:10:39 -0400 Subject: [python-win32] Building win32 extensions to Python - crash In-Reply-To: References: <44909F7F.7020304@gmail.com> <79990c6b0606150257w68a6e0b8u93db201f70ecd97e@mail.gmail.com> <4da1a0c50606150404m5337b08ao13c29b7fe7b3f542@mail.gmail.com> <4491D22F.3090902@gmail.com> <4492EF36.5030709@gmail.com> Message-ID: <4da1a0c50606171710v48be969an342ce10967de207c@mail.gmail.com> On 6/16/06, James Carroll wrote: > > > But you aren't using swig (yet) so this is only relevent as far as > showing the one thing you have to be aware of. Without swig, it's > just being concious of when to Refrence and Unref() certain variables. > > -Jim > > It looks like I should be looking at swig. Thanks for the advice, Jim. Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060617/12474c07/attachment.html From mhammond at skippinet.com.au Sun Jun 18 09:53:11 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 18 Jun 2006 17:53:11 +1000 Subject: [python-win32] Unicode build of win32gui outside of WinCE? In-Reply-To: <44944236.2050700@freedombox.cc> Message-ID: <0df801c692ac$3fe60ff0$0200a8c0@enfoldsystems.local> > Are there any plans to support a Unicode build of win32gui in PyWin32 > outside of Windows CE? Perhaps the winxpgui module could be > built with > UNICODE defined while the win32gui module is not. > Alternatively, both > could be built with UNICODE defined and use the Microsoft Layer for > Unicode to remain compatible with 9x. Any thoughts? Thanks. I'd certainly be up for the former, and possibly even the latter - particularly if patches were supplied and an undertaking they had been extensively tested in some real app or another ;) Cheers, Mark From mhammond at skippinet.com.au Sun Jun 18 10:04:08 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 18 Jun 2006 18:04:08 +1000 Subject: [python-win32] Unit testing COM clients and Servers In-Reply-To: <4491FDF7.1010400@google.com> Message-ID: <0dfc01c692ad$c754aa90$0200a8c0@enfoldsystems.local> > I'm fairly new to it and it seems like to write tests, you have to > simulate the responses ADSI or WMI. I can find lots of help doing > standard python unit testing but how does this change when using COM? The only advice I can offer is to not think of this as a COM problem. All apps that talk to servers beyond there control suffer the same problem (eg, a program talking LDAP on any platform, or written against Oracle, etc). When possible, I just tend to use unittest based tests, with setUp and tearDown methods that hit a test server, and try not leave too much of a mess behind...) Mark From mattc at freedombox.cc Sun Jun 18 15:32:14 2006 From: mattc at freedombox.cc (Matt Campbell) Date: Sun, 18 Jun 2006 08:32:14 -0500 Subject: [python-win32] Unicode build of win32gui outside of WinCE? In-Reply-To: <0df801c692ac$3fe60ff0$0200a8c0@enfoldsystems.local> References: <0df801c692ac$3fe60ff0$0200a8c0@enfoldsystems.local> Message-ID: <449555DE.7040207@freedombox.cc> On further consideration, I think the best choice would be to define UNICODE and link with MSLU for winxpgui, and not define UNICODE for win32gui. That way, existing apps using win32gui which expect MBCS will still work, and new apps which use winxpgui can use Unicode (though they'll break in the presence of non-ASCII text if they assume MBCS). I'll work on this when time permits, testing my work in FreedomBox System Access (see my signature for the URL), which uses win32gui for menus, dialogs, and a tray icon. -- Matt Campbell Lead Programmer Serotek Corporation www.freedombox.info "The Accessibility Anywhere People" From mrmaple at gmail.com Mon Jun 19 14:37:09 2006 From: mrmaple at gmail.com (James Carroll) Date: Mon, 19 Jun 2006 08:37:09 -0400 Subject: [python-win32] Building win32 extensions to Python (OT) In-Reply-To: <449350B3.4090003@pennswoods.net> References: <44909F7F.7020304@gmail.com> <79990c6b0606150257w68a6e0b8u93db201f70ecd97e@mail.gmail.com> <4da1a0c50606150404m5337b08ao13c29b7fe7b3f542@mail.gmail.com> <4491D22F.3090902@gmail.com> <449350B3.4090003@pennswoods.net> Message-ID: Hi Bill > 1). The resulting exe did not run properly or > 2). You didn't know that py2exe can create single file executables? > Unfortunately it's #1. I get a crash with the single file bundled with no zipfile... My post on the py2exe mailing list didn't get any replies: http://article.gmane.org/gmane.comp.python.py2exe/1554 It's a difficult thing to debug, since the code that needs to be fixed is generating the code that has trouble, and it's probably microsoft's code loading that's interacting with the generated code that's causing the trouble. -Jim From fuzzyman at voidspace.org.uk Tue Jun 20 11:40:38 2006 From: fuzzyman at voidspace.org.uk (Fuzzyman) Date: Tue, 20 Jun 2006 10:40:38 +0100 Subject: [python-win32] Pure Python Pythonwin.exe Message-ID: <4497C296.40805@voidspace.org.uk> Hello all, Pythonwin the IDE has many fans, and I would like to get it working with Movable Python [#]_. Pythonwin is launched with 'pythonwin.exe'. Presumably (I speak from ignorance here) this uses the registry to determine the installed Python. When I run Pythonwin.exe on a computer with no installed Python (but a working Movpy setup) I get the message : The application can not locate win32ui.pyd (or python) (126) The specified module could not be found. This is after putting the Pythonwin directory on the path [#]_ - and win32ui.pyd exists in the current directory (same directory as pythonwin.exe). I see that the Pythonwin source code is C++, so I guess there is no way of creating a Pure Python version. :-) Is there anyway I can tell Pythonwin which Python interpreter to use, without having to make registry settings ? All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml .. [#] http://www.voidspace.org.uk/python/movpy/ .. [#] This was necessary to get it to find mfc71.dll From mhammond at skippinet.com.au Thu Jun 22 01:50:37 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 22 Jun 2006 09:50:37 +1000 Subject: [python-win32] Pure Python Pythonwin.exe In-Reply-To: <4497C296.40805@voidspace.org.uk> Message-ID: <0d2701c6958d$7f9c39b0$0a0a0a0a@enfoldsystems.local> > Pythonwin the IDE has many fans, and I would like to get it > working with > Movable Python [#]_. Great! > Pythonwin is launched with 'pythonwin.exe'. Presumably (I speak from > ignorance here) this uses the registry to determine the > installed Python. Nope - it uses some old code that really should die. > > When I run Pythonwin.exe on a computer with no installed Python (but a > working Movpy setup) I get the message : > > The application can not locate win32ui.pyd (or python) (126) > The specified module could not be found. > > This is after putting the Pythonwin directory on the path [#]_ - and > win32ui.pyd exists in the current directory (same directory as > pythonwin.exe). That surprises me. win32ui.pyd next to pythonwin.exe should work fine - that is the first thing checked by the code (which FYI is in pythonwin/win32uiHostGlue.h) > I see that the Pythonwin source code is C++, so I guess there > is no way > of creating a Pure Python version. :-) But there is :) import sys import win32ui # importing 'intpyapp' automatically registers an app object. from pywin.framework import intpyapp # Remove this script name from sys.argv, else Pythonwin will try and open it! sys.argv = sys.argv[:-1] # Get the MFC "app" object and boot it up. app = win32ui.GetApp() app.InitInstance() app.Run() app.ExitInstance() The above code should boot a fully functioning Pythonwin - just execute it from pythonw.exe and you should be good to go. The only reason I haven't moved to something like this is that (a) pythonwin.exe already exists, and (b) having a .exe makes it more obvious to a casual user... Cheers, Mark From mhammond at skippinet.com.au Thu Jun 22 13:52:33 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 22 Jun 2006 21:52:33 +1000 Subject: [python-win32] Is pure-win32 GetWindowPlacement() available ? In-Reply-To: Message-ID: <0ed401c695f2$59f1a230$0a0a0a0a@enfoldsystems.local> > I have been looking for a wrapper for the Win32 function > GetWindowPlacement() but could not find it in the latest version of > Python for Windows extension (version 208). I saw a reference to > PyCWnd.GetWindowPlacement() where a MFC CWnd is needed but could not > find a pure Win32 version. > > Does anyone know if this is/will be wrapped? As predicted by Roger, a version almost identical to the one in win32ui has now been checked into win32gui. Cheers, Mark From stefan.rank at ofai.at Thu Jun 22 14:28:40 2006 From: stefan.rank at ofai.at (Stefan Rank) Date: Thu, 22 Jun 2006 14:28:40 +0200 Subject: [python-win32] SafeTerminateProcess and request for CreateRemoteThread() Message-ID: <449A8CF8.7010002@ofai.at> Hi, I spent some time finding a safe way to kill/terminate a process on Windows. Attached is my current version, modelled after a DDJ article. It should work for gui and console applications, has lots of unnecessary print output, uses ctypes for a call to CreateRemoteThread, and bypasses (I think ?) any signal handlers that might be registered. I hope this is useful for someone. Two questions: - The first is the request to include CreateRemoteThread in win32api (which I will post on sourceforge) - Does anyone know a similarly safe way for terminating a process so that a SIGINT/SIGTERM handler will still be called (without the need for a shared console or process group ids)? cheers, stefan -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: win32helper.py Url: http://mail.python.org/pipermail/python-win32/attachments/20060622/2a459df2/attachment.asc From Pierre_Rouleau at ImpathNetworks.com Thu Jun 22 14:58:53 2006 From: Pierre_Rouleau at ImpathNetworks.com (Pierre Rouleau) Date: Thu, 22 Jun 2006 07:58:53 -0500 Subject: [python-win32] Is pure-win32 GetWindowPlacement() available ? In-Reply-To: <0ed401c695f2$59f1a230$0a0a0a0a@enfoldsystems.local> References: <0ed401c695f2$59f1a230$0a0a0a0a@enfoldsystems.local> Message-ID: Mark Hammond wrote: >>I have been looking for a wrapper for the Win32 function >>GetWindowPlacement() but could not find it in the latest version of >>Python for Windows extension (version 208). I saw a reference to >>PyCWnd.GetWindowPlacement() where a MFC CWnd is needed but could not >>find a pure Win32 version. >> >>Does anyone know if this is/will be wrapped? > > > As predicted by Roger, a version almost identical to the one in win32ui has > now been checked into win32gui. > Thanks Mark! -- Pierre Rouleau From fuzzyman at voidspace.org.uk Thu Jun 22 15:02:30 2006 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Thu, 22 Jun 2006 14:02:30 +0100 Subject: [python-win32] Pure Python Pythonwin.exe In-Reply-To: <0d2701c6958d$7f9c39b0$0a0a0a0a@enfoldsystems.local> References: <0d2701c6958d$7f9c39b0$0a0a0a0a@enfoldsystems.local> Message-ID: <449A94E6.2010608@voidspace.org.uk> Mark Hammond wrote: >> Pythonwin the IDE has many fans, and I would like to get it >> working with >> Movable Python [#]_. >> > > Great! > > >> Pythonwin is launched with 'pythonwin.exe'. Presumably (I speak from >> ignorance here) this uses the registry to determine the >> installed Python. >> > > Nope - it uses some old code that really should die. > > >> When I run Pythonwin.exe on a computer with no installed Python (but a >> working Movpy setup) I get the message : >> >> The application can not locate win32ui.pyd (or python) (126) >> The specified module could not be found. >> >> This is after putting the Pythonwin directory on the path [#]_ - and >> win32ui.pyd exists in the current directory (same directory as >> pythonwin.exe). >> > > That surprises me. win32ui.pyd next to pythonwin.exe should work fine - > that is the first thing checked by the code (which FYI is in > pythonwin/win32uiHostGlue.h) > > Maybe a generic error message when it fails to find Python ? Seeing as you posted Python code below I lost my motivation to go poking round in C++ files. :-) >> I see that the Pythonwin source code is C++, so I guess there >> is no way >> of creating a Pure Python version. :-) >> > > But there is :) > > This is great, it runs fine with Movable Python. (Although I have yet to find a machine *without* Python installed to try it properly, I need to get VMWare running again.) When it runs for the first time it prints the following message to the console (but works fine) : Failed to connect to Pythonwin|System. Error 0 Is this because there is no currently running version of pythonwin for it to connect to ? Anyway, many thanks. Fuzzyman http://www.voidspace.org.uk/python/index.shtml > import sys > import win32ui > # importing 'intpyapp' automatically registers an app object. > from pywin.framework import intpyapp > > # Remove this script name from sys.argv, else Pythonwin will try and open > it! > sys.argv = sys.argv[:-1] > # Get the MFC "app" object and boot it up. > app = win32ui.GetApp() > app.InitInstance() > app.Run() > app.ExitInstance() > > The above code should boot a fully functioning Pythonwin - just execute it > from pythonw.exe and you should be good to go. The only reason I haven't > moved to something like this is that (a) pythonwin.exe already exists, and > (b) having a .exe makes it more obvious to a casual user... > > Cheers, > > Mark > > > From dprovins at tridentexploration.ca Thu Jun 22 17:00:06 2006 From: dprovins at tridentexploration.ca (Dean Allen Provins) Date: Thu, 22 Jun 2006 09:00:06 -0600 Subject: [python-win32] pywintypes24.dll necessary?? follow-up info Message-ID: <449AB076.3040109@tridentexploration.ca> Hello again: I forgot to indicate versions etc. python-2.4.3 numpy-0.9.6r1.win32-py2.4 pywin32-208.win32-py2.4 plus my python code in several modules. Regards, Dean Confidentiality Notice: The information transmitted herein may contain confidential, proprietary and/or privileged material which belongs to Trident Exploration Corp. and its affiliates and is intended only for the addressee(s). Any unauthorized review, distribution or other use or the taking of any action in reliance upon this information is prohibited. If you received this email in error, please contact the sender or call (403) 770-1765 and delete this email and any copies. From dprovins at tridentexploration.ca Thu Jun 22 16:49:35 2006 From: dprovins at tridentexploration.ca (Dean Allen Provins) Date: Thu, 22 Jun 2006 08:49:35 -0600 Subject: [python-win32] pywintypes24.dll necessary?? Message-ID: <449AADFF.4060806@tridentexploration.ca> Hello: The user's requirement was for a batch program to process hundreds of files - so I wrote one on Linux, and ported it to WinXP Professional. It is a command line driven routine that works very well on Linux, but is hampered (as I discovered) by the MS treatment of DOS windows (no copy/paste allowed - as far as I can tell). It works fine, EXCEPT the python mainline (batch.py) suggests that it will NOT execute unless file 'pywintypes24.dll' is in the same directory. A dialog pops up to say that the application can't execute because a required component (the DLL) can't be found, but then it starts up with the message: "import testing -> failed: DLL load failed: The specified module could not be found." and continues, apparently normally. I'm not importing anything called "testing". The message is annoying and impacts the credibility of the code (and me). Since the user's data might be in different places (at different times) it is a little inconvenient for them to ensure that the mainline and the DLL are conveniently located to minimize typing long path names to the data. This results from Windows users being so used to "clicking" that they've forgotten how to work at the command line, so to cut down on the typing, it is necessary to move the mainline, and the DLL file to the data directory. Is there a way to eliminate the need for this DLL? Regards, Dean Confidentiality Notice: The information transmitted herein may contain confidential, proprietary and/or privileged material which belongs to Trident Exploration Corp. and its affiliates and is intended only for the addressee(s). Any unauthorized review, distribution or other use or the taking of any action in reliance upon this information is prohibited. If you received this email in error, please contact the sender or call (403) 770-1765 and delete this email and any copies. From bgailer at alum.rpi.edu Thu Jun 22 21:51:46 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Thu, 22 Jun 2006 12:51:46 -0700 Subject: [python-win32] pywintypes24.dll necessary?? In-Reply-To: <449AADFF.4060806@tridentexploration.ca> References: <449AADFF.4060806@tridentexploration.ca> Message-ID: <449AF4D2.3010808@alum.rpi.edu> Dean Allen Provins wrote: > Hello: > > The user's requirement was for a batch program to process hundreds of files - so > I wrote one on Linux, and ported it to WinXP Professional. It is a command line > driven routine that works very well on Linux, but is hampered (as I discovered) > by the MS treatment of DOS windows (no copy/paste allowed - as far as I can tell). > > It works fine, EXCEPT the python mainline (batch.py) suggests that it will NOT > execute unless file 'pywintypes24.dll' is in the same directory. A dialog pops > up to say that the application can't execute because a required component (the > DLL) can't be found, but then it starts up with the message: > > "import testing -> failed: DLL load failed: The specified module could not be > found." > > and continues, apparently normally. I'm not importing anything called > "testing". The message is annoying and impacts the credibility of the code (and > me). > > Since the user's data might be in different places (at different times) it is a > little inconvenient for them to ensure that the mainline and the DLL are > conveniently located to minimize typing long path names to the data. This > results from Windows users being so used to "clicking" that they've forgotten > how to work at the command line, so to cut down on the typing, it is necessary > to move the mainline, and the DLL file to the data directory. > 2 suggestions: 1 - DOS windows support copy/paste. Click the system menu, properties, options, edit options. Ensure both are checked. Click the system menu, edit, you will see Mark, Copy, Paste. You can Mark by dragging a selection rectangle with the mouse, Copy the selection by hitting Enter, and paste by right clicking. 2 - Create a batch file containing all the messy path and file names. Have the user run the batch file. User can do that from the Explorer if he does not need to provide any parameters. If user needs to see the results in the DOS window put PAUSE at the end of the batch file. -- Bob Gailer 510-978-4454 From mhammond at skippinet.com.au Fri Jun 23 02:35:10 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 23 Jun 2006 10:35:10 +1000 Subject: [python-win32] SafeTerminateProcess and request forCreateRemoteThread() In-Reply-To: <449A8CF8.7010002@ofai.at> Message-ID: <113001c6965c$e3584b90$0a0a0a0a@enfoldsystems.local> > - The first is the request to include CreateRemoteThread in win32api > (which I will post on sourceforge) Done. > - Does anyone know a similarly safe way for terminating a process so > that a SIGINT/SIGTERM handler will still be called (without > the need for > a shared console or process group ids)? Nope, and I've tried in the past. If CreateRemoteThread could call GenerateConsoleCtrlEvent in the target process, I expect that would help - assuming the default handler that kills the process was still setup. I haven't tried, but its not clear to me that calling a function with 2 args will work, nor is it clear how to work around this - but sadly I'm out of experimentation time today... Mark From f.g.- at gmx.de Fri Jun 23 07:12:03 2006 From: f.g.- at gmx.de (=?iso-8859-1?Q?Frank_G=FCnther?=) Date: Fri, 23 Jun 2006 07:12:03 +0200 Subject: [python-win32] python COM-Server and VBScript Message-ID: <000301c69683$90ecd480$0c01a8c0@ttddm02> Hi all, I found a strange behaviour when I use a python-COM-Server together with VB. It seems that the first argument of a COM-Method that is passed by a VB-variable is set to VB-Nothing after the Method call. For example if I use the code below: After calling testSrvObj.SetValue what, value what is deleted, but not value. But after calling testSrvObj.SetValue "ABC", value value is deleted. Has anybody an idea what is the problem? Ciao, Frank ------------------testcall.vbs---------------------------------- Dim testSrvObj, what, value, retvalue Set testSrvObj = CreateObject("TestSrv.Application") value = "ABCValue" what = "ABC" msgbox("before: what ="& what & " value ="& value) testSrvObj.SetValue what, value msgbox("after1: what ="& what & " value ="& value) testSrvObj.SetValue "ABC", value msgbox("after2: value ="& value) retvalue = testSrvObj.GetValue("ABC") msgbox("retvalue="& retvalue) ------------------testcall.vbs--------------------------------- -------------------testsrve.py-------------------------------- import pythoncom class TestSrv(object): _reg_clsid_ = '{C7B89AAC-99B7-48A1-8088-D77A867CBB0C}' _reg_desc_ = 'TestSrv COM+ Server' _reg_progid_ = 'TestSrv.Application' _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER _public_methods_ = ['SetValue', 'GetValue'] def __init__(self): self.ABC = '' def SetValue(self, what, newval): if what == 'ABC': self.ABC = newval def GetValue(self, what): if what == 'ABC': return self.ABC if __name__=='__main__': import win32com.server.register win32com.server.register.UseCommandLine(TestSrv, debug=0) -------------------testsrve.py-------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060623/2c9b67db/attachment.htm From nawalkg at esi-india.com Fri Jun 23 11:07:41 2006 From: nawalkg at esi-india.com (nawal) Date: Fri, 23 Jun 2006 14:37:41 +0530 Subject: [python-win32] Simple Com Event Handling for Multiple Com Objects Message-ID: <449BAF5D.2060108@esi-india.com> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060623/2fcf7760/attachment.htm From timr at probo.com Fri Jun 23 18:53:27 2006 From: timr at probo.com (Tim Roberts) Date: Fri, 23 Jun 2006 09:53:27 -0700 Subject: [python-win32] pywintypes24.dll necessary?? In-Reply-To: References: Message-ID: <449C1C87.8000307@probo.com> On Thu, 22 Jun 2006 12:51:46 -0700, Bob Gailer wrote: > >1 - DOS windows support copy/paste. Click the system menu, properties, >options, edit options. Ensure both are checked. Click the system menu, >edit, you will see Mark, Copy, Paste. You can Mark by dragging a >selection rectangle with the mouse, Copy the selection by hitting Enter, >and paste by right clicking. > Just for completness sake, I'd like to point out that, if both of those boxes are checked, it is not necessary to use "Edit->Mark" before dragging a selection rectangle. That's only if the boxes are clear. Also, for those of us who keep our hands on the keyboard most of the time, you can bring up the system menu with Alt-Space. Alt-Space, E, K (for mark) and Alt-Space, E, P (for paste). It is possible to drag a rectangle using the cursor keys and shift-cursor keys, but that's one occasion where the mouse really is much more efficient. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Fri Jun 23 18:59:22 2006 From: timr at probo.com (Tim Roberts) Date: Fri, 23 Jun 2006 09:59:22 -0700 Subject: [python-win32] pywintypes24.dll necessary?? In-Reply-To: References: Message-ID: <449C1DEA.50109@probo.com> On Thu, 22 Jun 2006 08:49:35 -0600, Dean Allen Provins wrote: >The user's requirement was for a batch program to process hundreds of files - so >I wrote one on Linux, and ported it to WinXP Professional. It is a command line >driven routine that works very well on Linux, but is hampered (as I discovered) >by the MS treatment of DOS windows (no copy/paste allowed - as far as I can tell). > >It works fine, EXCEPT the python mainline (batch.py) suggests that it will NOT >execute unless file 'pywintypes24.dll' is in the same directory. A dialog pops >up to say that the application can't execute because a required component (the >DLL) can't be found, but then it starts up with the message: > >"import testing -> failed: DLL load failed: The specified module could not be >found." > Are you using py2exe to run this on a machine that does not already have Python? If not, then pywintypes24.dll should be in \Windows\System32, and the default pywin32 installation should have put it there. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Fri Jun 23 19:27:40 2006 From: timr at probo.com (Tim Roberts) Date: Fri, 23 Jun 2006 10:27:40 -0700 Subject: [python-win32] python COM-Server and VBScript In-Reply-To: References: Message-ID: <449C248C.3010303@probo.com> On Fri, 23 Jun 2006 07:12:03 +0200, Frank G?nther wrote: > > >I found a strange behaviour when I use a python-COM-Server together with VB. > > Not VB, but rather VBS. They are two rather different languages. >It seems that the first argument of a COM-Method that is passed by a >VB-variable is set to VB-Nothing after the Method call. > > Actually, it is set to whatever is returned from the method. You happen to return None, which VBS translates to a Nothing. If you change it to return something, like a string, that's what you'll see in your VBS script. >For example if I use the code below: After calling > >testSrvObj.SetValue what, value > >what is deleted, but not value. But after calling > > testSrvObj.SetValue "ABC", value > >value is deleted. > >Has anybody an idea what is the problem? > > This is just a VBS weirdness when calling COM methods. Calling your COM server from Python works perfectly, and turning on the debug tracing shows nothing unusual. It gets two input parameters that are not modified. VBS does have some strange rules about COM method calls and return values. You can eliminate this problem by having your VBS code fetch the return value: WScript.Echo testSrvObj.SetValue( what, value ) WScript.Echo testSrvObj.SetValue( "ABC', value ) --or-- retvalue = testSrvObj.SetValue( what, value ) retvalue = testSrvObj.SetValue( "ABC', value ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From newsham at lava.net Sat Jun 24 01:07:02 2006 From: newsham at lava.net (Tim Newsham) Date: Fri, 23 Jun 2006 13:07:02 -1000 (HST) Subject: [python-win32] gui inheritance? clumsy com inheritance? Message-ID: I have two comments. First, it appears that the GUI object elements are hidden. I can create the objects through a CreateName() function, but I cannot otherwise access the objects (take PyCToolBarCtrl for example). It would often be useful to be able to subclass an object (rather than simply wrap it in another class). Is there a reason this isn't supported? Second, it appears that I have to manually keep track of a lot of settings when building a COM class. It would be much easier if the system automatically accumulated some of these settings during inheritance. As an example, when I inherit a class with a _public_methods_ setting, I should get all of those methods in the new class. Using metaclasses it is possible to have the system do this automatically for you. Is there a reason this hasn't been done yet? Below is a simple example that accumulates several fields, including a new _iid_ field that I invented to simplify my code. I definitely overlooked some fields; a more complete implementation would have to handle attributes for example. class _COMMeta(type) : """ This metaclass will walk all the supers and pull out all the win32com metadata and compose it in the new object. This makes inheritance work how you would expect it to. base._iid_ is accumulated into _com_interfaces_. base._public_methods_ is accumulated. base._com_interfaces_ is accumualted. """ def __new__(cls, name, bases, dict) : def inheritVals(vs, n) : if n not in dict : dict[n] = [] for v in vs : if v not in dict[n] : dict[n].append(v) def inheritBaseList(b, n) : inheritVals(getattr(b, n, []), n) def inheritBaseVal(b, n, ln) : if hasattr(b, n) : inheritVals([getattr(b, n)], ln) for b in bases : inheritBaseVal(b, '_iid_', '_com_interfaces_') inheritBaseList(b, '_com_interfaces_') inheritBaseList(b, '_public_methods_') return type.__new__(cls, name, bases, dict) class COM(object) : __metaclass__ = _COMMeta # the following clases make use of inheritance to simplify # specification... class IOleWindow(COM) : _public_methods_ = ['GetWindow', 'ContextSensitiveHelp'] class IDockingWindow(IOleWindow) : _public_methods_ = ['CloseDW', 'ResizeBorderDW', 'ShowDW'] class IDeskBand(IDockingWindow) : _iid_ = _shell.IID_IDeskBand _public_methods_ = ['GetBandInfo'] Tim Newsham http://www.lava.net/~newsham/ From newsham at lava.net Sat Jun 24 03:01:56 2006 From: newsham at lava.net (Tim Newsham) Date: Fri, 23 Jun 2006 15:01:56 -1000 (HST) Subject: [python-win32] com servers and py2exe Message-ID: Py2exe supports making com servers as dlls or as exes. After I create a com server with py2exe, how do I get it registered? If I need to register additional registry keys when the com server is registered, how is that handled? Tim Newsham http://www.lava.net/~newsham/ From mhammond at skippinet.com.au Mon Jun 26 04:07:25 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 26 Jun 2006 12:07:25 +1000 Subject: [python-win32] com servers and py2exe In-Reply-To: Message-ID: <19ab01c698c5$47005060$0a0a0a0a@enfoldsystems.local> > Py2exe supports making com servers as dlls or as exes. After I > create a com server with py2exe, how do I get it registered? If it is a .exe, you just run it. If it is a DLL, you use regsvr32.exe to register it - ie, you register them just like any other COM EXE or DLL files. > If I need to register additional registry keys when the > com server is registered, how is that handled? py2exe and pywin32 have special support for "DllRegisterServer" and "DLLUnregisterServer" functions - just create functions of this name in your main module, and py2exe will find and use them (see boot_com_servers.py in the py2exe distro). Your "normal" .py implemented COM objects can leverage the same thing by using something like: def DllRegisterServer(): ... def DllUnregisterServer(): ... if __name__=='__main__': win32com.server.register.HandleCommandLine(..., finalize_register=DllRegisterSe rver, finalize_unregister=DllUnregist erServer) Mark From nawalkg at esi-india.com Mon Jun 26 07:49:17 2006 From: nawalkg at esi-india.com (Nawal) Date: Mon, 26 Jun 2006 11:19:17 +0530 Subject: [python-win32] Simple Com Event Handling for Multiple Com Objects In-Reply-To: <449BAF5D.2060108@esi-india.com> References: <449BAF5D.2060108@esi-india.com> Message-ID: <449F755D.2010609@esi-india.com> Hello Everybody, Is there any simple way to handle all Com Events in a Simple Class? Nawal nawal wrote: > In activeX Scripting, I can Create Two Button Events Like > > OnButton1() > OnButton2() > > In Normal Python Com Event Handling: I have to declare two classes > > class ButtonEvent1 > OnButton() > ... > > > class ButtonEvent2 > OnButton() > ... > > and then attach this event handler to the Com Objects. Is there any > way I can achieve it > just like the ActiveX Scripting without creating more EventHandlerClasses? > > Thanks in advance. > > Nawal > > > > > >------------------------------------------------------------------------ > >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 > > From f.g.- at gmx.de Mon Jun 26 13:40:47 2006 From: f.g.- at gmx.de (=?iso-8859-1?Q?Frank_G=FCnther?=) Date: Mon, 26 Jun 2006 13:40:47 +0200 Subject: [python-win32] python COM-Server and VBScript (Tim Roberts) In-Reply-To: Message-ID: <001d01c69915$5dde23c0$0c01a8c0@ttddm02> ... > > > >I found a strange behaviour when I use a python-COM-Server together with > VB. > > > > > > Not VB, but rather VBS. They are two rather different languages. > ... Hi Tim, Thanks for your answer. Actually the same problem arises if you use VB or VBA. So the difference between VB and VBS is at least for this problem not to wide. Ciao, Frank From floris.vannee at gmail.com Mon Jun 26 15:52:01 2006 From: floris.vannee at gmail.com (Floris van Nee) Date: Mon, 26 Jun 2006 15:52:01 +0200 Subject: [python-win32] com servers and py2exe In-Reply-To: <19ab01c698c5$47005060$0a0a0a0a@enfoldsystems.local> References: <19ab01c698c5$47005060$0a0a0a0a@enfoldsystems.local> Message-ID: <2302ac370606260652n67fb2b23we31cc41b9c398e20@mail.gmail.com> Ok, what you told me works for this simple program: class HelloWorld: _reg_clsid_ = "{4E5807E3-C445-4A3C-A4BC-FD81697B661A}" _reg_progid_ = "Python.TestServer" _public_methods_ = ['Hello'] def __init__(self): pass def Hello(self, who): return "Hello" + who regsvr32.exe tells me that registering the dll has succeeded and I can call the function Hello from a VB .Net application. But when I try to register another compiled dll, a more complicated one, then win32traceutil gives me the following error when I try to register the DLL: Traceback (most recent call last): File "", line 1, in ? File "boot_com_servers.py", line 62, in DllRegisterServer File "win32com\server\register.pyc", line 404, in RegisterCl AttributeError: Runescape instance has no attribute '__name__' The file I tried to compile/register uses the modules sys, Image, Imagechops, pythoncom and urllib.urlopen and works perfectly in non-compiled mode. I also tried running the exe I get when i set create_exe in the setup.pyscript to True; that gives me the following error: Traceback (most recent call last): File "boot_com_servers.py", line 44, in ? ImportError: dynamic module does not define init function (initrunescape) Do you know what I might have done wrong? Floris On 6/26/06, Mark Hammond wrote: > > > Py2exe supports making com servers as dlls or as exes. After I > > create a com server with py2exe, how do I get it registered? > > If it is a .exe, you just run it. If it is a DLL, you use regsvr32.exe to > register it - ie, you register them just like any other COM EXE or DLL > files. > > > If I need to register additional registry keys when the > > com server is registered, how is that handled? > > py2exe and pywin32 have special support for "DllRegisterServer" and > "DLLUnregisterServer" functions - just create functions of this name in > your > main module, and py2exe will find and use them (see boot_com_servers.py in > the py2exe distro). Your "normal" .py implemented COM objects can > leverage > the same thing by using something like: > > def DllRegisterServer(): > ... > def DllUnregisterServer(): > ... > if __name__=='__main__': > win32com.server.register.HandleCommandLine(..., > > finalize_register=DllRegisterSe > rver, > > finalize_unregister=DllUnregist > erServer) > > Mark > > _______________________________________________ > 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/20060626/2286ac30/attachment.htm From mhammond at skippinet.com.au Tue Jun 27 02:07:46 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 27 Jun 2006 10:07:46 +1000 Subject: [python-win32] Simple Com Event Handling for Multiple ComObjects In-Reply-To: <449F755D.2010609@esi-india.com> Message-ID: <1d5601c6997d$b87365d0$0a0a0a0a@enfoldsystems.local> I'm afraid you probably need to pull win32com.client.WithEvents apart and manually setup your own event handler class. Different events do need different functions (although it should be possible to add the same event handler to 2 different event sources. Cheers, Mark > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org]On Behalf Of Nawal > Sent: Monday, 26 June 2006 3:49 PM > To: nawal > Cc: python-win32 at python.org > Subject: Re: [python-win32] Simple Com Event Handling for Multiple > ComObjects > > > Hello Everybody, > > Is there any simple way to handle all Com Events in a Simple Class? > > Nawal > > nawal wrote: > > > In activeX Scripting, I can Create Two Button Events Like > > > > OnButton1() > > OnButton2() > > > > In Normal Python Com Event Handling: I have to declare two classes > > > > class ButtonEvent1 > > OnButton() > > ... > > > > > > class ButtonEvent2 > > OnButton() > > ... > > > > and then attach this event handler to the Com Objects. Is there any > > way I can achieve it > > just like the ActiveX Scripting without creating more > EventHandlerClasses? > > > > Thanks in advance. > > > > Nawal > > > > > > > > > > > >------------------------------------------------------------- > ----------- > > > >_______________________________________________ > >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 nawalkg at esi-india.com Tue Jun 27 16:57:02 2006 From: nawalkg at esi-india.com (Nawal) Date: Tue, 27 Jun 2006 20:27:02 +0530 Subject: [python-win32] Simple Com Event Handling for Multiple ComObjects In-Reply-To: <1d5601c6997d$b87365d0$0a0a0a0a@enfoldsystems.local> References: <1d5601c6997d$b87365d0$0a0a0a0a@enfoldsystems.local> Message-ID: <44A1473E.3000600@esi-india.com> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060627/2fd3f25e/attachment.htm From timr at probo.com Tue Jun 27 18:50:38 2006 From: timr at probo.com (Tim Roberts) Date: Tue, 27 Jun 2006 09:50:38 -0700 Subject: [python-win32] python COM-Server and VBScript In-Reply-To: References: Message-ID: <44A161DE.2060703@probo.com> On Mon, 26 Jun 2006 13:40:47 +0200, Frank G?nther >... > > >>>> > >>>> >I found a strange behaviour when I use a python-COM-Server together with VB. >>> >>> >>> >>> Not VB, but rather VBS. They are two rather different languages. >>> >> >> >... > >Hi Tim, > >Thanks for your answer. >Actually the same problem arises if you use VB or VBA. So the difference >between VB and VBS is at least for this problem not to wide. > > I'll be darned, you're quite right. Even VB 2005 behaves this way. I checked the generated IL, and this weird behavior is definitely there. The compiled code is storing the return value in the first non-constant parameter. I've worked with COM for a long time, and I don't remember seeing that behavior written down anywhere. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Tue Jun 27 21:25:04 2006 From: timr at probo.com (Tim Roberts) Date: Tue, 27 Jun 2006 12:25:04 -0700 Subject: [python-win32] python COM-Server and VBScript In-Reply-To: References: Message-ID: <44A18610.3070804@probo.com> On Mon, 26 Jun 2006 13:40:47 +0200, Frank G?nther wrote: >... > >Hi Tim, > >Thanks for your answer. >Actually the same problem arises if you use VB or VBA. So the difference >between VB and VBS is at least for this problem not to wide. > > This has been nagging at me all morning. I can't find any documentation at all that refers to this behavior, and I've gone through at least two dozen articles on late binding in VB and VBS. The behavior cannot be duplicated in C#, because C# doesn't do the automatic late binding. You have to invoke the lower-level APIS directly. I was able to call the component from C#, but because it is up to me to handle the return value, the same problem does not occur. I did learn that you can work aroundthis issue by using parens in the VB/VBS code: Dim testSrvObj, what, value, retvalue Set testSrvObj = CreateObject("TestSrv.Application") value = "ABCValue" what = "ABC" WScript.Echo "What", what WScript.Echo "Value", value testSrvObj.SetValue (what), (value) WScript.Echo "What", what WScript.Echo "Value", value testSrvObj.SetValue "ABC", (value) WScript.Echo "What", what WScript.Echo "Value", value retvalue = testSrvObj.GetValue("ABC") WScript.Echo "What", what WScript.Echo "Value", value WScript.Echo "Return", retvalue -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From newsham at lava.net Wed Jun 28 22:56:48 2006 From: newsham at lava.net (Tim Newsham) Date: Wed, 28 Jun 2006 10:56:48 -1000 (HST) Subject: [python-win32] com event question Message-ID: I have an IWebBrowserApp pointer and I want to get events from the DWebBrowserEvents interface (the BeforeNavigate2 event, in particular). If I understand correctly, I should make an event class: class EventHandler(object) : def BeforeNavigate2(self, *args) : print "before nav2 fired", args and then use DispatchWithEvents: provider = pUnkSite.QueryInterface(IID_IServiceProvider) webapp = provider.QueryService(IID_IWebBrowserApp, IID_IDispatch) ie = DispatchWithEvents(webapp, EventHandler) When I do this, I am not receiving any event callbacks. What am I doing wrong here? Tim Newsham http://www.lava.net/~newsham/ From newsham at lava.net Wed Jun 28 23:20:58 2006 From: newsham at lava.net (Tim Newsham) Date: Wed, 28 Jun 2006 11:20:58 -1000 (HST) Subject: [python-win32] com event question In-Reply-To: References: Message-ID: On Wed, 28 Jun 2006, Tim Newsham wrote: > I have an IWebBrowserApp pointer and I want to get events from > the DWebBrowserEvents interface (the BeforeNavigate2 event, > in particular). If I understand correctly, I should make an > event class: > > class EventHandler(object) : > def BeforeNavigate2(self, *args) : > print "before nav2 fired", args As usual, I figured this out right after asking (one of the best reasons to ask :). The gen_py/EAB22AC0-30C1-11CF-A7EB-0000C05BAE0Bx0x1x1.py file lists the method name as OnBeforeNavigate2. Using that name, I am receiving callbacks. Tim Newsham http://www.lava.net/~newsham/ From dprovins at tridentexploration.ca Wed Jun 28 23:25:03 2006 From: dprovins at tridentexploration.ca (Dean Allen Provins) Date: Wed, 28 Jun 2006 15:25:03 -0600 Subject: [python-win32] pywintypes24.dll necessary?? In-Reply-To: <449C1DEA.50109@probo.com> References: <449C1DEA.50109@probo.com> Message-ID: <44A2F3AF.4060705@tridentexploration.ca> Tim Roberts wrote: > On Thu, 22 Jun 2006 08:49:35 -0600, Dean Allen Provins > wrote: > > >>The user's requirement was for a batch program to process hundreds of files - so >>I wrote one on Linux, and ported it to WinXP Professional. It is a command line >>driven routine that works very well on Linux, but is hampered (as I discovered) >>by the MS treatment of DOS windows (no copy/paste allowed - as far as I can tell). >> >>It works fine, EXCEPT the python mainline (batch.py) suggests that it will NOT >>execute unless file 'pywintypes24.dll' is in the same directory. A dialog pops >>up to say that the application can't execute because a required component (the >>DLL) can't be found, but then it starts up with the message: >> >>"import testing -> failed: DLL load failed: The specified module could not be >>found." >> > > > Are you using py2exe to run this on a machine that does not already have > Python? If not, then pywintypes24.dll should be in \Windows\System32, > and the default pywin32 installation should have put it there. > Bob and Tim: Thanks for your help. Copy/Paste is functional (thankfully) and the DLL problem seems to have disappeared. Regards, Dean Confidentiality Notice: The information transmitted herein may contain confidential, proprietary and/or privileged material which belongs to Trident Exploration Corp. and its affiliates and is intended only for the addressee(s). Any unauthorized review, distribution or other use or the taking of any action in reliance upon this information is prohibited. If you received this email in error, please contact the sender or call (403) 770-1765 and delete this email and any copies. From dprovins at tridentexploration.ca Wed Jun 28 23:35:06 2006 From: dprovins at tridentexploration.ca (Dean Allen Provins) Date: Wed, 28 Jun 2006 15:35:06 -0600 Subject: [python-win32] ODBC and Oracle Message-ID: <44A2F60A.7090303@tridentexploration.ca> Hello: Is there a trick to adding a Python ODBC connection to Oracle? Under Windows, with Python's "odbc" module, I can see MS Access (twice), 2 system databases that the IT people created. and at various times. dbase and excel as data sources. Curiously, the list of sources varies with my attempts to see what's available. The code I used was: import odbc for i in range (100): try: odbc.SQLDataSources (i) print i except: continue This prints the data source and the index at which it was found. A sample listing looks like: ('PMO_RO', 'Oracle in OraHome92') 1 ('MS Access Database', 'Microsoft Access Driver (*.mdb)') 2 ('MS Access Database', 'Microsoft Access Driver (*.mdb)') 31 ('CMS', 'Oracle in OraHome92') 32 Note the repetition. Note also that while Access always appears, the other two may be replaced by 'dbase' or 'excel' (very curious). I've tried to add the Oracle odbc module to the "data source Administrator' for the database I want to access, but it refuses to appear. Any ideas? Regards, Dean Confidentiality Notice: The information transmitted herein may contain confidential, proprietary and/or privileged material which belongs to Trident Exploration Corp. and its affiliates and is intended only for the addressee(s). Any unauthorized review, distribution or other use or the taking of any action in reliance upon this information is prohibited. If you received this email in error, please contact the sender or call (403) 770-1765 and delete this email and any copies. From emlynj at gmail.com Fri Jun 30 21:21:56 2006 From: emlynj at gmail.com (Emlyn Jones) Date: Fri, 30 Jun 2006 20:21:56 +0100 Subject: [python-win32] Python/ASP Request data with non ascii characters Message-ID: Hello, I've just run into a snag and I'm wondering if anybody might be able to point me towards a solution. Normally, I get data from a submitted form like this: my_string = str(Request("formstring")) which is great until formstring contains a non ascii character. When it does I get a UnicodeEncodeError (i.e ascii codec .... ordinal out of range). I thought I would be able to do my_string = unicode(Request("formstring"),"ISO-8859-1") But i get: coercing to Unicode: need string or buffer, instance found. I'm guessing (and I mean guessing) this is because the CDispatch object doesn't have a __unicode__ function. Am I doing something fundamentally wrong? Other than modifying the Python win32 source is there a way to solve this? Any help/pointers/shouts that I'm being stupid greatfully recieved. Cheers, Emlyn.