From brian@assess.net Mon Dec 2 15:59:46 2002 From: brian@assess.net (Brian Brown) Date: Mon, 2 Dec 2002 08:59:46 -0700 Subject: [python-win32] ASP strangeness Message-ID: <1038844786.3deb83727b48f@www.teuton.org> Greetings! I'm using python 2.2 with the current released win32 extentions (148 I believe) on a Win XP Pro box. I'm putting most of my business logic in modules that I import from the ASP pages and just do formatting in ASP. Most of the time, things seem to be working great, but I noticed that if I don't do an http POST to the python asp page, the python classes that I instantiate won't initialize. If I post to the pages, they work as expected. These seems very odd; no errors are generated whatsoever. Anyone have any ideas? thanks! Brian From mhammond@skippinet.com.au Mon Dec 2 22:28:49 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Tue, 3 Dec 2002 09:28:49 +1100 Subject: [python-win32] ASP strangeness In-Reply-To: <1038844786.3deb83727b48f@www.teuton.org> Message-ID: Check win32all-150 - it has some ASP problems fixed. If you still have a problem, please send me a small complete (should-be) working sample. Mark. > Greetings! > > I'm using python 2.2 with the current released win32 extentions (148 I > believe) on a Win XP Pro box. I'm putting most of my business > logic in modules > that I import from the ASP pages and just do formatting in ASP. > Most of the > time, things seem to be working great, but I noticed that if I > don't do an > http POST to the python asp page, the python classes that I > instantiate won't > initialize. If I post to the pages, they work as expected. These > seems very > odd; no errors are generated whatsoever. > > Anyone have any ideas? > > thanks! > > Brian > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > From nils@paragon.no Tue Dec 3 00:00:19 2002 From: nils@paragon.no (Nils R Grotnes) Date: Tue, 3 Dec 2002 01:00:19 +0100 Subject: [python-win32] Can anyone reproduce this crash? Message-ID: Hi. I'm using win32all-148, Python 2.2.2 and wxPython 2.3.2.1 on Windows 2000. When I try the following from a PythonWin window >>> from wxPython.wx import * >>> dir() I get an application error. Subject of messagebox say: "_GSocket_Internal_Window_Name: PythonWin.exe - Application Error" while the body of the messagebox say: "The instruction at "0x0155125c" referenced memory at "0x00149000". The memory could not be "read"." Pressing OK shows that seven items in the list output has been written ('EVT_ACTIVATE' to 'EVT_CHECKBOX') before the program termination. Trying the same from a Command Window running Python.exe gives no such problems. This problem is reproducible here. But can anyone else make it happen? Nils -- Quality links: http://lists.gpick.com/ http://dmoz.org/ or http://directory.google.com/ From mhammond@skippinet.com.au Tue Dec 3 07:51:31 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Tue, 3 Dec 2002 18:51:31 +1100 Subject: [python-win32] Can anyone reproduce this crash? In-Reply-To: Message-ID: > I'm using win32all-148, Python 2.2.2 and wxPython 2.3.2.1 on Windows 2000. > > When I try the following from a PythonWin window > > >>> from wxPython.wx import * > >>> dir() You can probably also get it by doing "from win32con import *" too. I think it will be a "long line" bug in scintilla, since fixed in win32all-150. Mark. From nils@paragon.no Tue Dec 3 09:02:07 2002 From: nils@paragon.no (Nils R Grotnes) Date: Tue, 3 Dec 2002 10:02:07 +0100 Subject: [python-win32] Can anyone reproduce this crash? References: Message-ID: Hi Mark! >> I'm using win32all-148, Python 2.2.2 and wxPython 2.3.2.1 on Windows 2000. >> When I try the following from a PythonWin window >>>>> from wxPython.wx import * >>>>> dir() > You can probably also get it by doing "from win32con import *" too. I think > it will be a "long line" bug in scintilla, since fixed in win32all-150. I uninstalled win32all-148 and installed win32all-150, and the crash no longer happens. The fix looks a little "unfinished" though, since this time the listing just showed: (I've replaced the middle part with "...") >>> from wxPython.wx import * >>> dir() ['EVT_ACTIVATE', ... , 'EVT_TOOL_RCLICKED_RANGE', 'EVT_TREE_BEGIN_ Selecting and doing a Ctrl-c on this output did however reveal a strange thing. The text copied was not what was shown in the window, but the complete list. I suppose since this is likely (still) a scintilla bug, I'm OT here. Pointers to where I should report it would be appreciated. Nils From mikael-l@engdahl.com Wed Dec 4 15:35:10 2002 From: mikael-l@engdahl.com (Mikael Engdahl) Date: Wed, 04 Dec 2002 16:35:10 +0100 Subject: [python-win32] Python CGI problem Message-ID: <3DEE20AE.6010807@engdahl.com> Hello. I'm having trouble setting up Python for CGI use on IIS. I think I have done the Application Extension Mapping right, mapping the extension .cgi to C:\Python22\python.exe -u -%s -%s. But when I try to view it I get this reply: CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are: Unknown option: -D usage: C:\Python22\python.exe [option] ... [-c cmd | file | -] [arg] ... Try `python -h' for more information. It seems to me that IIS adds a -D option when executing python. Why? And how do I avoid this? Thanks! Mikael Engdahl From brian@assess.net Wed Dec 4 17:27:02 2002 From: brian@assess.net (Brian Brown) Date: Wed, 4 Dec 2002 10:27:02 -0700 Subject: [python-win32] ASP strangeness In-Reply-To: References: Message-ID: <1039022822.3dee3ae6d2c09@www.teuton.org> Quoting Mark Hammond : > Check win32all-150 - it has some ASP problems fixed. If you still have a > problem, please send me a small complete (should-be) working sample. > > Mark. More followup... The problem seems to be only related to database connections. If I enter a page via a GET, the python code in my imported modules gets run, but database queries return nothing. Even doing it with POST, if I enter a page, all works fine, then I go to another page and back (via a POST) and the problem crops up again, no data returning from queries. I suspected in might be something to do with ADO, so I have tried it with mxODBC to the same (Access) databases, and the problem is the same. I'll try to come up with a small sample example that demonstrates the problem. BTW, this is now using win32all-150. > > > Greetings! > > > > I'm using python 2.2 with the current released win32 extentions (148 I > > believe) on a Win XP Pro box. I'm putting most of my business > > logic in modules > > that I import from the ASP pages and just do formatting in ASP. > > Most of the > > time, things seem to be working great, but I noticed that if I > > don't do an > > http POST to the python asp page, the python classes that I > > instantiate won't > > initialize. If I post to the pages, they work as expected. These > > seems very > > odd; no errors are generated whatsoever. > > > > Anyone have any ideas? > > > > thanks! > > > > Brian > > > > > > _______________________________________________ > > Python-win32 mailing list > > Python-win32@python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > From brian@assess.net Wed Dec 4 17:35:08 2002 From: brian@assess.net (Brian Brown) Date: Wed, 4 Dec 2002 10:35:08 -0700 Subject: [python-win32] Object access in ASP In-Reply-To: References: Message-ID: <1039023308.3dee3cccb5a48@www.teuton.org> Please help me understand some things about the environment if you can :) >From what I understand, the ActiveX Scripting Engine caches the python interpreter; if so, then objects should stay around between page accesses, right? If so, is there any way to get access to instantiated objects? You can't store them in Session variables, so I don't know how else you would do it... I believe that I would also have to handle concurrent accesses to my objects... but that is another issue ;) Any thoughts? If I can access instantiated object between page accesses, then performance could be dramatically increased (not that its bad) and Session vars could probably be eliminated from an ASP perspective. thanks! Brian From dond@advancedmp.com Thu Dec 5 00:45:43 2002 From: dond@advancedmp.com (Don Dwiggins) Date: 04 Dec 2002 16:45:43 -0800 Subject: [python-win32] Re: Object access in ASP References: <1039023308.3dee3cccb5a48@www.teuton.org> Message-ID: Brian Brown writes: > Please help me understand some things about the environment if you can :) > From what I understand, the ActiveX Scripting Engine caches the python > interpreter; if so, then objects should stay around between page accesses, > right? If so, is there any way to get access to instantiated objects? You > can't store them in Session variables, so I don't know how else you would > do it... I believe that I would also have to handle concurrent accesses to > my objects... but that is another issue ;) Objects don't stick around (they live in an execution context that disappears when the page execution is done), but if you import modules, they'll stay loaded in the interpreter between requests (which is a minor pain for debugging, of course, but a win for production). > Any thoughts? If I can access instantiated object between page accesses, > then performance could be dramatically increased (not that its bad) and > Session vars could probably be eliminated from an ASP perspective. There are many ways to avoid rebuilding objects on new requests; all have tradeoffs and complications. I'd avoid getting into that until you've done enough stress testing and profiling to know where the bottlenecks are. HTH, -- Don Dwiggins "The truth will make you free, d.l.dwiggins@computer.org but first it will make you miserable" -- Tom DeMarco From mhammond@skippinet.com.au Thu Dec 5 23:44:45 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Fri, 6 Dec 2002 10:44:45 +1100 Subject: [python-win32] Python CGI problem In-Reply-To: <3DEE20AE.6010807@engdahl.com> Message-ID: I don't think you want the '-' before either %s My guess is that your script file is on your D: - thus, Python will see python -u -D:\.... Mark. > -----Original Message----- > From: python-win32-admin@python.org > [mailto:python-win32-admin@python.org]On Behalf Of Mikael Engdahl > Sent: Thursday, 5 December 2002 2:35 AM > To: python-win32@python.org > Subject: [python-win32] Python CGI problem > > > Hello. > > I'm having trouble setting up Python for CGI use on IIS. I think I have > done the Application Extension Mapping right, mapping the extension .cgi > to C:\Python22\python.exe -u -%s -%s. But when I try to view it I get > this reply: > > CGI Error > The specified CGI application misbehaved by not returning a complete set > of HTTP headers. The headers it did return are: > > Unknown option: -D > usage: C:\Python22\python.exe [option] ... [-c cmd | file | -] [arg] ... > Try `python -h' for more information. > > > It seems to me that IIS adds a -D option when executing python. Why? And > how do I avoid this? > > Thanks! > > Mikael Engdahl > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > From tony@tcapp.com Sat Dec 7 08:27:02 2002 From: tony@tcapp.com (Tony Cappellini) Date: Sat, 07 Dec 2002 00:27:02 -0800 Subject: [python-win32] PythonWin - crash Message-ID: <5.1.0.14.0.20021207002057.043fa9a0@wheresmymailserver.com> After opening and reading a 69KB text file into a list, PythonWin crashed when I tried to display list, as in L1=[] input = open('myfile.txt') L1= input.readlines() L1 crashed here I'm running PythonWin build 148, on Windows 2000, SP3. I entered the same code into IPython (another Python IDE), and was able to see the entire list. Has anyone else seen this problem- or does anyone know if it's been fixed ? thanks Tony From robinjim@earthlink.net Sat Dec 7 11:47:31 2002 From: robinjim@earthlink.net (robin and jim) Date: Sat, 7 Dec 2002 04:47:31 -0700 Subject: [python-win32] PythonWin - crash References: <5.1.0.14.0.20021207002057.043fa9a0@wheresmymailserver.com> Message-ID: <003b01c29de6$6e1eb3e0$ad06f5d1@robinjim> Hello Tony, I just tried it on my Windows XP-home edition box running PythonWin build 150 and there was no problem. ----- Original Message ----- From: "Tony Cappellini" To: Cc: Sent: Saturday, December 07, 2002 1:27 AM Subject: [python-win32] PythonWin - crash > > After opening and reading a 69KB text file into a list, PythonWin crashed > when I tried to display list, as in > > L1=[] > input = open('myfile.txt') > L1= input.readlines() > L1 > > crashed here > > I'm running PythonWin build 148, on Windows 2000, SP3. > > I entered the same code into IPython (another Python IDE), and was able to > see the entire list. > > Has anyone else seen this problem- or does anyone know if it's been fixed ? > > thanks > > Tony > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From magnus@thinkware.se Sat Dec 7 15:32:37 2002 From: magnus@thinkware.se (Magnus Lycka) Date: Sat, 07 Dec 2002 16:32:37 +0100 Subject: [python-win32] PythonWin - crash In-Reply-To: <003b01c29de6$6e1eb3e0$ad06f5d1@robinjim> References: <5.1.0.14.0.20021207002057.043fa9a0@wheresmymailserver.com> Message-ID: <5.1.0.14.0.20021207163110.0518a270@www.thinkware.se> At 04:47 2002-12-07 -0700, robin and jim wrote: >I just tried it on my Windows XP-home edition box running PythonWin build >150 and there was no problem. But not with Tony's file I guess... Maybe there is some strange byte that bites... In general, it seems PythonWin has problems with long lines. A line wrapping function would be great. -- Magnus Lycka, Thinkware AB Alvans vag 99, SE-907 50 UMEA, SWEDEN phone: int+46 70 582 80 65, fax: int+46 70 612 80 65 http://www.thinkware.se/ mailto:magnus@thinkware.se From tony@tcapp.com Sun Dec 8 01:39:53 2002 From: tony@tcapp.com (Tony Cappellini) Date: Sat, 07 Dec 2002 17:39:53 -0800 Subject: [python-win32] PythonWin - crash Message-ID: <5.1.0.14.0.20021207173844.03576228@wheresmymailserver.com> Mark Hammond just told me that this problem was fixed in build 150 Tony Date: Sat, 07 Dec 2002 16:32:37 +0100 To: "robin and jim" , , "Tony Cappellini" From: Magnus Lycka Subject: Re: [python-win32] PythonWin - crash Cc: At 04:47 2002-12-07 -0700, robin and jim wrote: >I just tried it on my Windows XP-home edition box running PythonWin build >150 and there was no problem. But not with Tony's file I guess... Maybe there is some strange byte that bites... In general, From tony@tcapp.com Sun Dec 8 08:16:06 2002 From: tony@tcapp.com (Tony Cappellini) Date: Sun, 08 Dec 2002 00:16:06 -0800 Subject: [python-win32] Python-w32 startup configuration In-Reply-To: <20021207170009.793.95726.Mailman@mail.python.org> Message-ID: <5.1.0.14.0.20021208000707.025b5048@tcapp.com> Ok- sorry everyone, newbie time again (and you thought you were safe ..) I want to configure python-w32 to startup in the directory where I have my python scripts,as well as change the default background editor color, but don't know which startup script to edit,. After browsing the Python Path, from the PythonWin IDE, I see many potential files that look like typical initialization files. E:\apps\Python\Lib\site-packages\Pythonwin\pywin\__init__.py E:\apps\Python\Lib\site-packages\Pythonwin\pywin\framework\startup.py E:\apps\Python\Lib\site-packages\Pythonwin\start_pythonwin.pw Which if these is the correct one to edit, and should I merely make my changes to the very end of one of these files ? thanks Tony From Wilbert, Matt (ENV)" Hi, I am trying to do some work with Active Directory from python (ActivePython 2.2.1), but I am having a couple of problems. Connecting to the domain root using an LDAP:// name works fine, I can see various properties of the object thus named, , but I cannot figure out a way to enumerate its children--it appears to be unimplemented. Is that correct? Should I just use ADO? Also, I can't figure out how I would apply a filter, assuming that I could do an enumeration. Thanks, Matt Wilbert matt.wilbert@state.ma.us From jens.jorgensen@tallan.com Mon Dec 9 16:26:13 2002 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Mon, 09 Dec 2002 10:26:13 -0600 Subject: [python-win32] enumerating children of an active directory container In-Reply-To: References: Message-ID: <3DF4C425.2050000@tallan.com> This is a multi-part message in MIME format. --------------040008070605010407060102 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Attached is a very short script that demonstrates child enumeration. You give it a path and it prints out everything in that node and all child nodes. matt wilbert wrote: >Hi, > >I am trying to do some work with Active Directory from python >(ActivePython 2.2.1), but I am having a couple of problems. > >Connecting to the domain root using an LDAP:// name works fine, >I can see various properties of the object thus named, , but I >cannot figure out a way to enumerate its children--it appears to >be unimplemented. Is that correct? Should I just use ADO? > >Also, I can't figure out how I would apply a filter, assuming >that I could do an enumeration. > >Thanks, > >Matt Wilbert >matt.wilbert@state.ma.us > > > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" --------------040008070605010407060102 Content-Type: text/plain; name="walkads.py" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="walkads.py" from win32com.client import GetObject import sys if len(sys.argv) < 2 : print 'usage: %s ' % sys.argv[0] print 'example: %s WinNT://localhost' % sys.argv[0] sys.exit(1) o = GetObject(sys.argv[1]) def walk(obj, ind) : print '%s%s %s' % (' ' * ind, obj.ADsPath, obj.Class) en = obj._NewEnum() # ok, we'll print out the Properties sch = GetObject(obj.Schema) for i in sch.MandatoryProperties : try : print '%s%s = %s' % (' ' * (ind+2), i, obj.Get(i)) except Exception, e : pass for i in sch.OptionalProperties : try : print '%s%s = %s' % (' ' * (ind+2), i, obj.Get(i)) except Exception, e : pass if en : while 1 : i = en.Next() if len(i) > 0 : walk(i[0], ind+2) else : break walk(o, 0) --------------040008070605010407060102-- From Wilbert, Matt (ENV)" Jens, Thanks for the timely assistance. It was the obj. _NewEnum() method that I was missing. Matt Wilbert ---------- Original Text ---------- From: , on 12/09/2002 12:00 PM: Send Python-win32 mailing list submissions to python-win32@python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/python-win32 or, via email, send a message with subject or body 'help' to python-win32-request@python.org You can reach the person managing the list at python-win32-admin@python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Python-win32 digest..." Today's Topics: 1. enumerating children of an active directory container (matt wilbert) 2. Re: enumerating children of an active directory container (Jens B. Jorgensen) --__--__-- Message: 1 Date: Sun, 8 Dec 2002 19:09:29 EST To: From: "matt wilbert" Reply-To: "Wilbert, Matt (ENV)" Subject: [python-win32] enumerating children of an active directory container Hi, I am trying to do some work with Active Directory from python (ActivePython 2.2.1), but I am having a couple of problems. Connecting to the domain root using an LDAP:// name works fine, I can see various properties of the object thus named, , but I cannot figure out a way to enumerate its children--it appears to be unimplemented. Is that correct? Should I just use ADO? Also, I can't figure out how I would apply a filter, assuming that I could do an enumeration. Thanks, Matt Wilbert matt.wilbert@state.ma.us --__--__-- Message: 2 Date: Mon, 09 Dec 2002 10:26:13 -0600 From: "Jens B. Jorgensen" To: "Wilbert, Matt (ENV)" CC: python-win32@python.org Subject: Re: [python-win32] enumerating children of an active directory container This is a multi-part message in MIME format. --------------040008070605010407060102 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Attached is a very short script that demonstrates child enumeration. You give it a path and it prints out everything in that node and all child nodes. matt wilbert wrote: >Hi, > >I am trying to do some work with Active Directory from python >(ActivePython 2.2.1), but I am having a couple of problems. > >Connecting to the domain root using an LDAP:// name works fine, >I can see various properties of the object thus named, , but I >cannot figure out a way to enumerate its children--it appears to >be unimplemented. Is that correct? Should I just use ADO? > >Also, I can't figure out how I would apply a filter, assuming >that I could do an enumeration. > >Thanks, > >Matt Wilbert >matt.wilbert@state.ma.us > > > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" --------------040008070605010407060102 Content-Type: text/plain; name="walkads.py" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="walkads.py" from win32com.client import GetObject import sys if len(sys.argv) < 2 : print 'usage: %s ' % sys.argv[0] print 'example: %s WinNT://localhost' % sys.argv[0] sys.exit(1) o = GetObject(sys.argv[1]) def walk(obj, ind) : print '%s%s %s' % (' ' * ind, obj.ADsPath, obj.Class) en = obj._NewEnum() # ok, we'll print out the Properties sch = GetObject(obj.Schema) for i in sch.MandatoryProperties : try : print '%s%s = %s' % (' ' * (ind+2), i, obj.Get(i)) except Exception, e : pass for i in sch.OptionalProperties : try : print '%s%s = %s' % (' ' * (ind+2), i, obj.Get(i)) except Exception, e : pass if en : while 1 : i = en.Next() if len(i) > 0 : walk(i[0], ind+2) else : break walk(o, 0) --------------040008070605010407060102-- --__--__-- _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 End of Python-win32 Digest From toru@oldriver.org Mon Dec 9 21:54:55 2002 From: toru@oldriver.org (Toru Furukawa) Date: Mon, 09 Dec 2002 15:54:55 -0600 Subject: [python-win32] win32file.CreateHardLink() crashes Message-ID: <20021209154505.117E.TORU@oldriver.org> I ran the following script, on Windows2000 SP2 + Python2.2.2 + win32-149; >>> import win32file >>> win32file.CreateHardLink("b", "a") "a" is a text file containing single line "foo", and the hardlink "b" seems correctly created. However, I got a window saying; python - Application Error The instruction at "0x00000003" referenced memmory at "0x00000003". The memory could not be "read". What did I make wrong? Toru From mhammond@skippinet.com.au Tue Dec 10 02:07:07 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Tue, 10 Dec 2002 13:07:07 +1100 Subject: [python-win32] win32file.CreateHardLink() crashes In-Reply-To: <20021209154505.117E.TORU@oldriver.org> Message-ID: This is a (non-obvious) bug in win32all :( I just checked in a fix. Mark. > -----Original Message----- > From: python-win32-admin@python.org > [mailto:python-win32-admin@python.org]On Behalf Of Toru Furukawa > Sent: Tuesday, 10 December 2002 8:55 AM > To: python-win32@python.org > Subject: [python-win32] win32file.CreateHardLink() crashes > > > I ran the following script, on Windows2000 SP2 + Python2.2.2 + win32-149; > > >>> import win32file > >>> win32file.CreateHardLink("b", "a") > > "a" is a text file containing single line "foo", and the hardlink "b" > seems correctly created. However, I got a window saying; > > python - Application Error > The instruction at "0x00000003" referenced memmory at "0x00000003". > The memory could not be "read". > > What did I make wrong? > > Toru > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From Jim.Vickroy@noaa.gov Wed Dec 11 21:49:11 2002 From: Jim.Vickroy@noaa.gov (Jim Vickroy) Date: Wed, 11 Dec 2002 14:49:11 -0700 Subject: [python-win32] pipes and processes Message-ID: <3DF7B2D6.4B9899DF@noaa.gov> Howdy, I'm using a process to create a few (~5) processes via win32process.CreateProcess(). I would like to have the parent process create a unique pipe for each child process. Is this a reasonable use of "anonymous" pipes? How do I pass the pipe (read, write) handles to a child process? Thanks, -- jv From dond@advancedmp.com Thu Dec 12 02:27:49 2002 From: dond@advancedmp.com (Don Dwiggins) Date: 11 Dec 2002 18:27:49 -0800 Subject: [python-win32] Getting the current user's email address Message-ID: It seems that this ought to be relatively simple, but I've been frustrated at every turn I've tried. I'm running under an ASP process under IIS, which is impersonating an intranet web client, and I want to get the user's email address. I can get the user's login name with win32api.GetUserName, but I haven't succeeded in getting from there to having ADSI get me to the right object to ask for the EmailAddress. If GetUserNameEx were provided in win32api, I'd be home free -- but it's not (at least not in the 2.2.1 ActiveState distro). I've looked at the Python ADSI documentation, but I can't decipher it enough to figure out how to get to the user's entry, given just the login name (I haven't seen any way to get the password, and I'm not sure it would help). Anyone have any good words? Thanks, -- Don Dwiggins "The truth will make you free, d.l.dwiggins@computer.org but first it will make you miserable" -- Tom DeMarco From b.hall@irl.cri.nz Thu Dec 12 03:23:20 2002 From: b.hall@irl.cri.nz (Blair Hall) Date: Thu, 12 Dec 2002 16:23:20 +1300 Subject: [python-win32] VB Interfaces Message-ID: <5.1.0.14.1.20021212154037.00a408d0@pop.wgtn.irl.cri.nz> This is really my first foray into the world of Python and COM so I may be asking a dumb question. Here goes. I have been trying to write client code for a collection of small automation objects written in VB (by me). The VB code uses an interface to support polymorphic behaviour from a number of different classes. Unfortunately, Python is not handling this interface the way I expected it to. The following is not the actual code, but it shows where my thinking about this comes unstuck: >>>>>>>>>> VB classes (complied into a dll): ' Interface class ...... INumber .cls Function setn(ByVal i As Integer) ' Set the numerical value End Function Function getn() As Integer ' Return the numerical value End Function ' Concrete number class........ Number.cls Implements INumber Dim n As Integer Function INumber_setn(ByVal i As Integer) n = i End Function Function INumber_getn() As Integer getn = n End Function ' Class with a factory function ......... test.cls Function makeNumber(ByVal i As Integer) As INumber Dim n As INumber Set n = New Number n.setn i Set makeN = n Set n = Nothing End Function >>>>>>>>>> Now if I run makepy on this automation object, I can use these objects from Python. For example, >>> t = Dispatch("MyDllName.test") >>> n = t.makeNumber( 4 ) >>> n.getn() >>> 0 which is not the answer expected! If I re-write makeNumber to use only Number objects the Python code above works. Now, I may be wrong, but it seems that an INumber object can be created without being a reference to a Number object. e.g.: >>> i = Dispatch("MyDllName.INumber") >>> i.setn(3) >>> i.getn() >>> 0 So I presume that when makeNumber is called it creates an INumber object in Python that is not being correctly initialised. How should I proceed, IN GENERAL, to achieve the polymorphic behaviour in Python that the VB code is designed to support? From mhammond@skippinet.com.au Thu Dec 12 08:14:41 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Thu, 12 Dec 2002 19:14:41 +1100 Subject: [python-win32] pipes and processes In-Reply-To: <3DF7B2D6.4B9899DF@noaa.gov> Message-ID: Check out the c++ sources to win32pipe/posixmodule for popen/popen2/3/4 etc. These show how to do that. It can be directly translated to Python, but I know of no one who has done so and made it public. A great place to start would be a .py implementation of popen(), a-la these sources, then send them to me, and I will include them in win32all as a demo! Mark. > -----Original Message----- > From: python-win32-admin@python.org > [mailto:python-win32-admin@python.org]On Behalf Of Jim Vickroy > Sent: Thursday, 12 December 2002 8:49 AM > To: python-win32@python.org > Subject: [python-win32] pipes and processes > > > Howdy, > > I'm using a process to create a few (~5) processes via > win32process.CreateProcess(). > > I would like to have the parent process create a unique pipe for each > child process. > > Is this a reasonable use of "anonymous" pipes? > > How do I pass the pipe (read, write) handles to a child process? > > Thanks, > > -- jv > > > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From mhammond@skippinet.com.au Thu Dec 12 08:20:49 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Thu, 12 Dec 2002 19:20:49 +1100 Subject: [python-win32] VB Interfaces In-Reply-To: <5.1.0.14.1.20021212154037.00a408d0@pop.wgtn.irl.cri.nz> Message-ID: I agree this should work ;) However, VB does strange things. Can you demonstrate some VBScript code against this that works correctly? If so, then mail me and we can work through it. Mark. > -----Original Message----- > From: python-win32-admin@python.org > [mailto:python-win32-admin@python.org]On Behalf Of Blair Hall > Sent: Thursday, 12 December 2002 2:23 PM > To: python-win32@python.org > Subject: [python-win32] VB Interfaces > > > This is really my first foray into the world of Python and COM > so I may be asking a dumb question. Here goes. > > I have been trying to write client code for a > collection of small automation objects written in VB (by me). > > The VB code uses an interface to support polymorphic behaviour > from a number of different classes. Unfortunately, Python > is not handling this interface the way I expected it to. > > The following is not the actual code, but it shows > where my thinking about this comes unstuck: > > >>>>>>>>>> VB classes (complied into a dll): > > ' Interface class ...... INumber .cls > Function setn(ByVal i As Integer) > ' Set the numerical value > End Function > > Function getn() As Integer > ' Return the numerical value > End Function > > ' Concrete number class........ Number.cls > Implements INumber > Dim n As Integer > Function INumber_setn(ByVal i As Integer) > n = i > End Function > > Function INumber_getn() As Integer > getn = n > End Function > > ' Class with a factory function ......... test.cls > Function makeNumber(ByVal i As Integer) As INumber > Dim n As INumber > Set n = New Number > n.setn i > Set makeN = n > Set n = Nothing > End Function > > >>>>>>>>>> > > Now if I run makepy on this automation object, I can use these > objects from > Python. > For example, > > >>> t = Dispatch("MyDllName.test") > >>> n = t.makeNumber( 4 ) > >>> n.getn() > >>> 0 > > which is not the answer expected! > If I re-write makeNumber to use only Number objects > the Python code above works. > > Now, I may be wrong, but it seems that an > INumber object can be created without > being a reference to a Number object. > e.g.: > > >>> i = Dispatch("MyDllName.INumber") > >>> i.setn(3) > >>> i.getn() > >>> 0 > > So I presume that when makeNumber is called > it creates an INumber object in Python that is not being > correctly initialised. > > How should I proceed, IN GENERAL, to achieve the polymorphic > behaviour in Python that the VB code is designed to support? > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From jens.jorgensen@tallan.com Thu Dec 12 15:51:04 2002 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Thu, 12 Dec 2002 09:51:04 -0600 Subject: [python-win32] Getting the current user's email address In-Reply-To: References: Message-ID: <3DF8B068.8080600@tallan.com> Actually I wouldn't think this would be simple at all. Why would an IIS server know the email address of the user that connected to it? If the server is part of a native win2k domain with Active Directory then the directory service *might* have the user's email address. Which is to say that by coincidence user principal name might be the same as the user's email address. That's what you can get from GetUserNameEx but is not the same as a user's email address even though it looks like one. On the other hand if you're running Exchange you may be able to get the user's email address through the ADSI interface to Exchange. If your Domain user names are mapped 1-to-1 to Mailbox names in exchange then you should be able to get the email address with: adsi_obj = GetObject('LDAP:///cn=,cn=Recipients,ou=,o=') email_addr = adsi_obj.Get('mail') The code would be similar if you're lookup up the user in Active Directory. I don't have AD set up so I couldn't say exactly what the DN would need to look like, probably something similar to the above minues the 'cn=Recipients' part. Don Dwiggins wrote: >It seems that this ought to be relatively simple, but I've been frustrated >at every turn I've tried. I'm running under an ASP process under IIS, which >is impersonating an intranet web client, and I want to get the user's email >address. > >I can get the user's login name with win32api.GetUserName, but I haven't >succeeded in getting from there to having ADSI get me to the right object to >ask for the EmailAddress. > >If GetUserNameEx were provided in win32api, I'd be home free -- but it's not >(at least not in the 2.2.1 ActiveState distro). I've looked at the Python >ADSI documentation, but I can't decipher it enough to figure out how to get >to the user's entry, given just the login name (I haven't seen any way to >get the password, and I'm not sure it would help). > >Anyone have any good words? > >Thanks, > > -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" From dond@advancedmp.com Thu Dec 12 17:38:19 2002 From: dond@advancedmp.com (Don Dwiggins) Date: 12 Dec 2002 09:38:19 -0800 Subject: [python-win32] Re: Getting the current user's email address References: <3DF8B068.8080600@tallan.com> Message-ID: Jens B Jorgensen writes: > Actually I wouldn't think this would be simple at all. Why would an IIS > server know the email address of the user that connected to it? If the > server is part of a native win2k domain with Active Directory then the > directory service *might* have the user's email address. I probably should have been clearer that this is exactly my situation; the ASP process is part of an intranet, impersonating a local user (via Integrated Authentication). Effectively, the process belongs to the user, and the idea is to get at "my" Exchange account. > Which is to say that by coincidence user principal name might be the same > as the user's email address. That's what you can get from GetUserNameEx > but is not the same as a user's email address even though it looks like > one. Right; what I wanted from GetUserNameEx is the "Fully Qualified DN", from which I can get the LDAP string I need. > On the other hand if you're running Exchange you may be able to get the > user's email address through the ADSI interface to Exchange. If your > Domain user names are mapped 1-to-1 to Mailbox names in exchange then you > should be able to get the email address with: > adsi_obj = GetObject('LDAP:///cn= name)>,cn=Recipients,ou=,o= organization name>') > email_addr = adsi_obj.Get('mail') I can indeed get there with a string of that form; the trouble is that (here at least) the CN has to be the user's full name ("Don Dwiggins" in my case); the login name (which I can get from GetUserName) doesn't work as the CN. So, aside from GetUserNameEx, do you know any good way to get the full name of the current user? Or another way to get the FQDN? -- Don Dwiggins "The truth will make you free, d.l.dwiggins@computer.org but first it will make you miserable" -- Tom DeMarco From mkatz@tapstone.com Thu Dec 12 20:23:16 2002 From: mkatz@tapstone.com (Martin Katz) Date: Thu, 12 Dec 2002 12:23:16 -0800 Subject: [python-win32] I need to walk the Windows registry Message-ID: <3DF8F034.4030609@tapstone.com> I need to retrieve all of the values in a subtree of the registry. I am using _winreg.EnumKey() and _winreg.EnumValue(). My problem is that the key and value names in the registry are not ASCII. Value names can contain any 2-byte character from 1 through 65535. Key names have an additional restriction that they cannot contain a backslash. _winreg.EnumValue doesn't return value names correctly if any of the characters are above 255. _winreg.QueryValueEx raises an exception if it is passed a name with values above 127. Anybody have any suggestions? Do I have to patch _winreg or is there a better alternative? Martin Katz, Ph.D. mkatz@tapstone.com From mkatz@tapstone.com Thu Dec 12 19:39:52 2002 From: mkatz@tapstone.com (Martin Katz) Date: Thu, 12 Dec 2002 11:39:52 -0800 Subject: [python-win32] I need to walk the Windows registry Message-ID: <3DF8E608.1030105@tapstone.com> I need to retrieve all of the values in a subtree of the registry. I am using _winreg.EnumKey() and _winreg.EnumValue(). My problem is that the key and value names in the registry are not ASCII. Value names can contain any 2-byte character from 1 through 65535. Key names have an additional restriction that they cannot contain a backslash. _winreg.EnumValue doesn't return value names correctly if any of the characters are above 255. _winreg.QueryValueEx raises an exception if it is passed a name with values above 127. Anybody have any suggestions? Do I have to patch _winreg or is there a better alternative? Martin From mhammond@skippinet.com.au Thu Dec 12 22:23:10 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Fri, 13 Dec 2002 09:23:10 +1100 Subject: [python-win32] Re: Getting the current user's email address In-Reply-To: Message-ID: > So, aside from GetUserNameEx, do you know any good way to get the > full name > of the current user? Or another way to get the FQDN? You could try the win32net.NetUserGetInfo() function. Mark. From mhammond@skippinet.com.au Thu Dec 12 22:29:15 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Fri, 13 Dec 2002 09:29:15 +1100 Subject: [python-win32] I need to walk the Windows registry In-Reply-To: <3DF8E608.1030105@tapstone.com> Message-ID: A patch to _winreg would be good, but you are probably finding that you are getting "MBCS" encoded values, and that you can pass MBCS back in. Eg: val = val.decode("mbcs") should get a Unicode string from a returned ASCII string, and passing unicode.encode("mbcs") should allow Unicode characters to be written. The best thing would be a _winreg patch, although I am not sure what the impact on Win9x will be. Mark. > -----Original Message----- > From: python-win32-admin@python.org > [mailto:python-win32-admin@python.org]On Behalf Of Martin Katz > Sent: Friday, 13 December 2002 6:40 AM > To: python-win32@python.org > Subject: [python-win32] I need to walk the Windows registry > > > I need to retrieve all of the values in a subtree of the registry. I am > using _winreg.EnumKey() and _winreg.EnumValue(). > > My problem is that the key and value names in the registry are not > ASCII. Value names can contain any 2-byte character from 1 through > 65535. Key names have an additional restriction that they cannot contain > a backslash. > > _winreg.EnumValue doesn't return value names correctly if any of the > characters are above 255. _winreg.QueryValueEx raises an exception if > it is passed a name with values above 127. > > Anybody have any suggestions? Do I have to patch _winreg or is there a > better alternative? > > Martin > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > From b.hall@irl.cri.nz Thu Dec 12 23:02:00 2002 From: b.hall@irl.cri.nz (Blair Hall) Date: Fri, 13 Dec 2002 12:02:00 +1300 Subject: [python-win32] VB Interfaces Message-ID: <5.1.0.14.1.20021213113834.00a419b0@pop.wgtn.irl.cri.nz> Well I'm afraid that my first posting contained a mistake. I've been able to get a little closer to the problem that is occuring in my actual VB DLL code. Here, then is an update on my problem. The following VB classes are compiled into a DLL ' ...... INumber.cls (an Interface class) Function setn(ByVal i As Integer) 'n = i End Function Function getn() As Integer 'getn = n End Function '..........Number.cls (a concrete class) Implements INumber Private n As Integer Function INumber_setn(ByVal i As Integer) n = i End Function Function INumber_getn() As Integer INumber_getn = n End Function '................. test.cls ' A factory for making Number objects Function makeN(ByVal i As Integer) As INumber Dim n As INumber Set n = New Number n.setn i Set makeN = n Set n = Nothing End Function ' A way of displaying the value of an arbitrary number of INumber objects Function val(ParamArray n()) On Error GoTo err Dim inf As INumber Dim i As Integer For i = LBound(n) To UBound(n) ' Set inf = n(i) ' MsgBox "1. Value = " & inf.getn MsgBox "2. Value = " & n(i).getn Next Exit Function err: MsgBox "error" & err.Description End Function Now this code can be called from a VB script, e.g.: ' .......... main.bas Sub Main() Dim t As New test Dim n As INumber Set n = t.makeN(5) t.val n, n However, from Python it fails: >>> t = Dispatch("TestDll16.test") >>> n = t.makeN( 23 ) >>> t.val( n,n ) The VB error MsgBox says that the object does not support the method requested. Now, if one exchanges the two commented lines inside the For loop of the val function above with the single line (MsgBox "2. Value = " & n(i).getn) then the Python code does work (and so does the original VB script). This seems to be the crux of my problem. In the VB DLL I am trying to use from Python, there are a number of such VB 'short cuts'. Why is it that when VB is calling this code it works, but a Python client makes the VB code fail? It seems that a rewrite of the VB code will fix this, but I am reluctant to do that unless I understand the failure mechanism better and understand precisely what should be changed. Thanks for helping. From dond@advancedmp.com Fri Dec 13 00:48:57 2002 From: dond@advancedmp.com (Don Dwiggins) Date: 12 Dec 2002 16:48:57 -0800 Subject: [python-win32] Re: Getting the current user's email address References: Message-ID: Mark Hammond writes: >> So, aside from GetUserNameEx, do you know any good way to get the >> full name >> of the current user? Or another way to get the FQDN? > You could try the win32net.NetUserGetInfo() function. Thanks, that worked. It took a while, though, because I was first trying to get domain user info from the Exchange server. Turns out you have to use the domain controller name as the first argument (is that obvious?). -- Don Dwiggins "When you're losing the game, d.l.dwiggins@computer.org change the rules." -- Seen on an office wall From mhammond@skippinet.com.au Fri Dec 13 03:05:34 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Fri, 13 Dec 2002 14:05:34 +1100 Subject: [python-win32] RE: VB Interfaces In-Reply-To: <5.1.0.14.1.20021213113834.00a419b0@pop.wgtn.irl.cri.nz> Message-ID: Can you try the test code from VBScript - NOT VB. It would then look just like the Python one: test.vbs: t = CreateObject("TestDll16.test") n = t.makeN( 23 ) t.val( n,n ) See how that goes. Mark. From b.hall@irl.cri.nz Fri Dec 13 04:20:16 2002 From: b.hall@irl.cri.nz (Blair Hall) Date: Fri, 13 Dec 2002 17:20:16 +1300 Subject: [python-win32] RE: VB Interfaces In-Reply-To: References: <5.1.0.14.1.20021213113834.00a419b0@pop.wgtn.irl.cri.nz> Message-ID: <5.1.0.14.1.20021213171544.00a3b750@pop.wgtn.irl.cri.nz> Mark, I didn't know what VBScript was to be honest. Now I only know that I don't know much about it! Anyway, the following code worked as a .vbs script dim t,n set t = CreateObject("TestDll17.test") set n = t.makeN( 23 ) t.val n,n That is the code, which fails when Python calls it, runs with VBScript. Hope this helps! Blair At 14:05 13/12/02 +1100, Mark Hammond wrote: >Can you try the test code from VBScript - NOT VB. > >It would then look just like the Python one: > >test.vbs: > >t = CreateObject("TestDll16.test") >n = t.makeN( 23 ) >t.val( n,n ) > >See how that goes. > > >Mark. From Alan.Frankel@dictaphone.com Fri Dec 13 15:09:12 2002 From: Alan.Frankel@dictaphone.com (Alan.Frankel@dictaphone.com) Date: Fri, 13 Dec 2002 10:09:12 -0500 Subject: [python-win32] Alan Frankel is out of the office. Message-ID: I will be out of the office starting 12/12/2002 and will not return until 12/16/2002. I will respond to your message when I return. ******************************************************************************************** This message, together with any attachments, is intended only for the use of the individual or entity to which it is addressed. It may contain information that is confidential and prohibited from disclosure. If you are not the intended recipient, you are hereby notified that any dissemination or copying of this message or any attachment is strictly prohibited. If you have received this message in error, please notify the original sender immediately by telephone or by return e-mail and delete this message along with any attachments, from your computer.Thank you. ******************************************************************************************** From jtownsen@adobe.com Fri Dec 13 20:22:55 2002 From: jtownsen@adobe.com (jtownsen) Date: Fri, 13 Dec 2002 12:22:55 -0800 Subject: [python-win32] Fwd: Re: [Python-Help] Python script to click OK Message-ID: <4.3.2.7.2.20021213122226.00cb5af0@mailsea.sea.adobe.com> I'm hoping someone on the Win32 list can help me out. See below for details and an initial result. >From: Matthew Dixon Cowles >To: jtownsen >Cc: help@python.org >Reply-To: help@python.org >Subject: Re: [Python-Help] Python script to click OK >Date: Thu, 12 Dec 2002 19:54:01 -0600 (CST) > > > First off, I'm fairly new to Python but have been using Perl for > > some time. > >Welcome to Python! > > > I'd like to have a Python script click a Windows' OK button. I'd > > appreciate any suggestions. > >I'm sorry but I'm not much of a Windows guy and I don't know how to >do that. If someone else here knows better than I do, I'm sure that >they'll jump in and tell us both. > >There's probably something in Mark Hammond's win32all extensions that >will do it. They're at: > >http://starship.python.net/crew/mhammond/win32/Downloads.html > >but I don't know just what. The folks on the python-win32 list >probably know the details. There's more information about that list >at: > >http://mail.python.org/mailman/listinfo/python-win32 > >I wish I had a better answer for you. > >Regards, >Matt From jens.jorgensen@tallan.com Sat Dec 14 04:03:40 2002 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Fri, 13 Dec 2002 22:03:40 -0600 Subject: [python-win32] Fwd: Re: [Python-Help] Python script to click OK In-Reply-To: <4.3.2.7.2.20021213122226.00cb5af0@mailsea.sea.adobe.com> References: <4.3.2.7.2.20021213122226.00cb5af0@mailsea.sea.adobe.com> Message-ID: <3DFAAD9C.5090207@tallan.com> This can certainly be done. You need to know the id of the button you need to send the message to and then you can call the win32 SendMessage call to deliver the click message or perhaps just ID_OK. At any rate the tougher part is finding the right window on the screen to send the message to. This isn't too hard to since you can probably figure out which window is by its text property. You'll definitely want the win32all extensions (or just install ActiveState's distribution which includes this). You can start from the root window and enumerate all the windows on the screen to find the right one. It helps to have an understanding of how the win32 api calls work. I can help further, but I don't have the code handy that enumerates through the windows but I have done something just like this. Start looking at the win32 api calls. Post back here and tell us how far you've gotten and we'll help you get there. jtownsen wrote: > I'm hoping someone on the Win32 list can help me out. See below for > details and an initial result. > >> From: Matthew Dixon Cowles >> To: jtownsen >> Cc: help@python.org >> Reply-To: help@python.org >> Subject: Re: [Python-Help] Python script to click OK >> Date: Thu, 12 Dec 2002 19:54:01 -0600 (CST) >> >> > First off, I'm fairly new to Python but have been using Perl for >> > some time. >> >> Welcome to Python! >> >> > I'd like to have a Python script click a Windows' OK button. I'd >> > appreciate any suggestions. >> >> I'm sorry but I'm not much of a Windows guy and I don't know how to >> do that. If someone else here knows better than I do, I'm sure that >> they'll jump in and tell us both. >> >> There's probably something in Mark Hammond's win32all extensions that >> will do it. They're at: >> >> http://starship.python.net/crew/mhammond/win32/Downloads.html >> >> but I don't know just what. The folks on the python-win32 list >> probably know the details. There's more information about that list >> at: >> >> http://mail.python.org/mailman/listinfo/python-win32 >> >> I wish I had a better answer for you. >> >> Regards, >> Matt > > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" From mvmisha@yahoo.com Sat Dec 14 21:53:15 2002 From: mvmisha@yahoo.com (Misha Verplak) Date: Sat, 14 Dec 2002 21:53:15 -0000 Subject: [python-win32] Fwd: Re: [Python-Help] Python script to clickOK References: <4.3.2.7.2.20021213122226.00cb5af0@mailsea.sea.adobe.com> <3DFAAD9C.5090207@tallan.com> Message-ID: <000e01c2a3bb$3cc2b3c0$bec1b7ac@grunt> I have written functions for this and related actions as part of a python-based windows automation & testing tool, coming soon to a sourceforge near you :) Anyway to do this try the following, after installing win32all: #---------------------------------------------------------- # sample script to push the OK button on notepad's Font dialog box import win32api, win32gui, win32con # find the parent window (eg. dialog box), # replace the last two parameters to match the appropriate window hwnd = win32gui.FindWindowEx(0, 0, "#32770", "Font") # find the OK button hbutton = win32gui.FindWindowEx(hwnd, 0, "Button", "OK") # mouse button click on the OK button, WM_COMMAND may work too win32api.PostMessage(hbutton, win32con.WM_LBUTTONDOWN, 0, 0) win32api.PostMessage(hbutton, win32con.WM_LBUTTONUP, 0, 0) #---------------------------------------------------------- Kind regards, Misha ----- Original Message ----- From: Jens B. Jorgensen To: jtownsen Cc: Sent: 14 December 2002 04:03 Subject: Re: [python-win32] Fwd: Re: [Python-Help] Python script to clickOK This can certainly be done. You need to know the id of the button you need to send the message to and then you can call the win32 SendMessage call to deliver the click message or perhaps just ID_OK. At any rate the tougher part is finding the right window on the screen to send the message to. This isn't too hard to since you can probably figure out which window is by its text property. You'll definitely want the win32all extensions (or just install ActiveState's distribution which includes this). You can start from the root window and enumerate all the windows on the screen to find the right one. It helps to have an understanding of how the win32 api calls work. I can help further, but I don't have the code handy that enumerates through the windows but I have done something just like this. Start looking at the win32 api calls. Post back here and tell us how far you've gotten and we'll help you get there. jtownsen wrote: > I'm hoping someone on the Win32 list can help me out. See below for > details and an initial result. > >> From: Matthew Dixon Cowles >> To: jtownsen >> Cc: help@python.org >> Reply-To: help@python.org >> Subject: Re: [Python-Help] Python script to click OK >> Date: Thu, 12 Dec 2002 19:54:01 -0600 (CST) >> >> > First off, I'm fairly new to Python but have been using Perl for >> > some time. >> >> Welcome to Python! >> >> > I'd like to have a Python script click a Windows' OK button. I'd >> > appreciate any suggestions. >> >> I'm sorry but I'm not much of a Windows guy and I don't know how to >> do that. If someone else here knows better than I do, I'm sure that >> they'll jump in and tell us both. >> >> There's probably something in Mark Hammond's win32all extensions that >> will do it. They're at: >> >> http://starship.python.net/crew/mhammond/win32/Downloads.html >> >> but I don't know just what. The folks on the python-win32 list >> probably know the details. There's more information about that list >> at: >> >> http://mail.python.org/mailman/listinfo/python-win32 >> >> I wish I had a better answer for you. >> >> Regards, >> Matt > > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" From BTaylor@harlandfs.com Wed Dec 18 22:20:56 2002 From: BTaylor@harlandfs.com (Bill Taylor) Date: Wed, 18 Dec 2002 14:20:56 -0800 Subject: [python-win32] Process creation hang up Message-ID: <342DB6B3FE8BD5119D0F0090273C2364312218@EX_PORTLAND1> This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C2A6E3.BC1A6A70 Content-Type: text/plain; charset="iso-8859-1" Hi all, Sorry this is lengthy and wordy... but does anyone have experience with process creation? I'm having problems with my child process hanging. Could be I'm a rookie (I am) missing the boat on something simple... or I'm just an idiot... or both (likely) :) Here's my scenario: I need to call an executable within my Python code - let's call this program.exe. Program.exe in turn calls a login executable - let's call this login.exe. Program.exe calls login.exe opening a DDE channel. Login.exe presents a login window to a user. The user enters user ID and password and then program.exe logs into a server database. Once connected, program.exe gathers database information and writes it to a text file named result.txt back on the calling machine. Here's my problem: When I use win32api.WinExec(programPathName), program.exe is called, login.exe is called, login window is presented to the user, user enters login information, and then program.exe hangs. Immediately after calling program.exe, my code goes into a time.sleep loop looking for result.exe. When result.exe is not found within a specified time, I present a message to the user to terminate. As soon as this message is presented, program.exe "un-hangs" and completes execution, writing result.txt to the calling machine. So, it appears my code has some sort of lock on the processor (possibly my time.sleep loop) preventing program.exe from processing. Any clues on this? Also, I've tried the os.spawn functions, win32api.ShellExecute, and win32process.CreateProcess with several different parameter settings on each and I get similar behavior except with all of these I don't get as far as with WinExec in that login.exe's login window never even displays. Here's my basic calls: Spawnl ================================================== os.spawnl(os.P_WAIT, programPathName) ================================================== ShellExecute ================================================== win32api.ShellExecute(0, None, programPathName, "", programPath, 1) ================================================== CreateProcess ================================================== si = win32process.STARTUPINFO() win32process.CreateProcess(None, # module programPathName, #command line None, #process security attributes None, #thread security attributes 0, #handle inheritance flag win32con.NORMAL_PRIORITY_CLASS, #creation flags None, # process new environment setting programPath, #start directory si) #STARTUPINFO object specifying window appearance ================================================== wait loop ================================================== while not os.path.exists(fileName) and wait < maxWait: wait += 1 time.sleep(1) if wait >= maxWait: #Timeout error message = "Cannot find file " + fileName + "\nDo you want to continue searching?" ret = DisplayMessageBox(message, "File Search Timeout Message", "YESNO") if ret == 1: wait = 0 else: #terminate ================================================== Any suggestions/help are/is much appreciated! Thanks in advance folks, Bill Taylor ------_=_NextPart_001_01C2A6E3.BC1A6A70 Content-Type: text/html; charset="iso-8859-1"
Hi all,
 
Sorry this is lengthy and wordy... but does anyone have experience with process creation?  I’m having problems with my child process hanging.  Could be I’m a rookie (I am) missing the boat on something simple… or I’m just an idiot… or both (likely) :)
 
Here’s my scenario:
I need to call an executable within my Python code – let’s call this program.exe.  Program.exe in turn calls a login executable – let’s call this login.exe.  Program.exe calls login.exe opening a DDE channel.  Login.exe presents a login window to a user.  The user enters user ID and password and then program.exe logs into a server database.  Once connected, program.exe gathers database information and writes it to a text file named result.txt back on the calling machine.
 
Here’s my problem:
When I use win32api.WinExec(programPathName), program.exe is called, login.exe is called, login window is presented to the user, user enters login information, and then program.exe hangs.  Immediately after calling program.exe, my code goes into a time.sleep loop looking for result.exe.  When result.exe is not found within a specified time, I present a message to the user to terminate.  As soon as this message is presented, program.exe “un-hangs” and completes execution, writing result.txt to the calling machine.  So, it appears my code has some sort of lock on the processor (possibly my time.sleep loop) preventing program.exe from processing.  Any clues on this?
 
Also, I’ve tried the os.spawn functions, win32api.ShellExecute, and win32process.CreateProcess with several different parameter settings on each and I get similar behavior except with all of these I don't get as far as with WinExec in that login.exe’s login window never even displays.  Here’s my basic calls:
 
Spawnl
==================================================
os.spawnl(os.P_WAIT, programPathName)
==================================================
 
ShellExecute
==================================================
win32api.ShellExecute(0, None, programPathName, "", programPath, 1)
==================================================
 
CreateProcess
==================================================
si = win32process.STARTUPINFO()
win32process.CreateProcess(None, # module
                                           programPathName, #command line
                                           None, #process security attributes
                                           None, #thread security attributes
                                           0, #handle inheritance flag
                                           win32con.NORMAL_PRIORITY_CLASS, #creation flags
                                           None, # process new environment setting
                                           programPath, #start directory
                                           si) #STARTUPINFO object specifying window appearance
==================================================
 
wait loop
==================================================
while not os.path.exists(fileName) and wait < maxWait:
        wait += 1
        time.sleep(1)
            
        if wait >= maxWait:
            #Timeout error
            message = "Cannot find file " + fileName + "\nDo you want to continue searching?"
            ret = DisplayMessageBox(message, "File Search Timeout Message", "YESNO")
            if ret == 1:
                wait = 0
            else:
                #terminate
==================================================
 
Any suggestions/help are/is much appreciated!

Thanks in advance folks,

Bill Taylor

------_=_NextPart_001_01C2A6E3.BC1A6A70-- From robinjim@earthlink.net Wed Dec 18 23:21:47 2002 From: robinjim@earthlink.net (robin and jim) Date: Wed, 18 Dec 2002 16:21:47 -0700 Subject: [python-win32] Process creation hang up References: <342DB6B3FE8BD5119D0F0090273C2364312218@EX_PORTLAND1> Message-ID: <000e01c2a6ec$3d4d6450$f73d3a41@robinjim> This is a multi-part message in MIME format. ------=_NextPart_000_000B_01C2A6B1.8FD3CD80 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Is it possible that program.exe is "blocking" because it is waiting for = some event (user input perhaps) that is cleared when the user responds = to the "terminate" query? ----- Original Message -----=20 From: Bill Taylor=20 To: 'python-win32@python.org'=20 Sent: Wednesday, December 18, 2002 3:20 PM Subject: [python-win32] Process creation hang up Hi all, Sorry this is lengthy and wordy... but does anyone have experience = with process creation? I'm having problems with my child process = hanging. Could be I'm a rookie (I am) missing the boat on something = simple. or I'm just an idiot. or both (likely) :) Here's my scenario: I need to call an executable within my Python code - let's call this = program.exe. Program.exe in turn calls a login executable - let's call = this login.exe. Program.exe calls login.exe opening a DDE channel. = Login.exe presents a login window to a user. The user enters user ID = and password and then program.exe logs into a server database. Once = connected, program.exe gathers database information and writes it to a = text file named result.txt back on the calling machine. Here's my problem: When I use win32api.WinExec(programPathName), program.exe is called, = login.exe is called, login window is presented to the user, user enters = login information, and then program.exe hangs. Immediately after = calling program.exe, my code goes into a time.sleep loop looking for = result.exe. When result.exe is not found within a specified time, I = present a message to the user to terminate. As soon as this message is = presented, program.exe "un-hangs" and completes execution, writing = result.txt to the calling machine. So, it appears my code has some sort = of lock on the processor (possibly my time.sleep loop) preventing = program.exe from processing. Any clues on this? Also, I've tried the os.spawn functions, win32api.ShellExecute, and = win32process.CreateProcess with several different parameter settings on = each and I get similar behavior except with all of these I don't get as = far as with WinExec in that login.exe's login window never even = displays. Here's my basic calls: Spawnl = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= os.spawnl(os.P_WAIT, programPathName) = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= ShellExecute = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= win32api.ShellExecute(0, None, programPathName, "", programPath, 1) = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= CreateProcess = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= si =3D win32process.STARTUPINFO() win32process.CreateProcess(None, # module programPathName, #command = line None, #process security = attributes None, #thread security = attributes 0, #handle inheritance flag = win32con.NORMAL_PRIORITY_CLASS, #creation flags None, # process new = environment setting programPath, #start = directory si) #STARTUPINFO object = specifying window appearance = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= wait loop = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= while not os.path.exists(fileName) and wait < maxWait: wait +=3D 1 time.sleep(1) =20 if wait >=3D maxWait: #Timeout error message =3D "Cannot find file " + fileName + "\nDo you = want to continue searching?" ret =3D DisplayMessageBox(message, "File Search Timeout = Message", "YESNO") if ret =3D=3D 1: wait =3D 0 else: #terminate = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= Any suggestions/help are/is much appreciated! Thanks in advance folks, Bill Taylor ------=_NextPart_000_000B_01C2A6B1.8FD3CD80 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Is it possible that = program.exe is=20 "blocking" because it is waiting for some event (user input perhaps) = that is=20 cleared when the user responds to the "terminate" query?
 
 
----- Original Message -----
From:=20 Bill=20 Taylor
Sent: Wednesday, December 18, = 2002 3:20=20 PM
Subject: [python-win32] Process = creation=20 hang up

Hi=20 all,
 
Sorry this is=20 lengthy and wordy... but does anyone have experience with process=20 creation?  I=92m having = problems=20 with my child process hanging.  = Could be I=92m a rookie (I am) missing the boat on something = simple=85 or=20 I=92m just an idiot=85 or both (likely) :)
 
Here=92s my=20 scenario:
I = need to call an=20 executable within my Python code =96 let=92s call this = program.exe.  Program.exe in turn calls a = login=20 executable =96 let=92s call this login.exe. =20 Program.exe calls login.exe opening a DDE channel.  Login.exe presents a login = window to a=20 user.  The user enters = user ID and=20 password and then program.exe logs into a server database.  Once connected, program.exe = gathers=20 database information and writes it to a text file named result.txt = back on the=20 calling machine.
 
Here=92s my=20 problem:
When = I use=20 win32api.WinExec(programPathName), program.exe is called, login.exe is = called,=20 login window is presented to the user, user enters login information, = and then=20 program.exe hangs.  = Immediately=20 after calling program.exe, my code goes into a time.sleep loop looking = for=20 result.exe.  When = result.exe is=20 not found within a specified time, I present a message to the user to=20 terminate.  As soon as = this=20 message is presented, program.exe =93un-hangs=94 and completes = execution, writing=20 result.txt to the calling machine. =20 So, it appears my code has some sort of lock on the processor = (possibly=20 my time.sleep loop) preventing program.exe from processing.  Any clues on = this?
 
Also, I=92ve tried=20 the os.spawn functions, win32api.ShellExecute, and = win32process.CreateProcess=20 with several different parameter settings on each and I get similar = behavior=20 except with all of these I don't get as far as with WinExec in that=20 login.exe=92s login window never even displays.  Here=92s my basic=20 calls:
 
Spawnl
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D
os.spawnl(os.P_WAIT,=20 programPathName)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D
 
ShellExecute
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D
win32api.ShellExecute(0, None, = programPathName, "",=20 programPath, 1)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D
 
CreateProcess
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D
si = =3D=20 win32process.STARTUPINFO()
win32process.CreateProcess(None, #=20 module
       &nbs= p;            = ;            =           =20 programPathName, #command line
       &nbs= p;            = ;            =           =20 None, #process security attributes
       &nbs= p;            = ;            =           =20 None, #thread security attributes
       &nbs= p;            = ;            =           =20 0, #handle inheritance flag
       &nbs= p;            = ;            =           =20 win32con.NORMAL_PRIORITY_CLASS, #creation flags
       &nbs= p;            = ;            =           =20 None, # process new environment setting
       &nbs= p;            = ;            =           =20 programPath, #start directory
       &nbs= p;            = ;            =           =20 si) #STARTUPINFO object specifying window = appearance
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D
 
wait = loop
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D
while not=20 os.path.exists(fileName) and wait <=20 maxWait:
        wait +=3D=20 1
       =20 = time.sleep(1)
         &n= bsp;  
       =20 if wait >=3D=20 = maxWait:
          &= nbsp;=20 #Timeout=20 = error
          &nbs= p;=20 message =3D "Cannot find file " + fileName + "\nDo you want to = continue=20 = searching?"
         &nbs= p; =20 ret =3D DisplayMessageBox(message, "File Search Timeout Message",=20 = "YESNO")
          &= nbsp;=20 if ret =3D=3D=20 = 1:
           &= nbsp;   =20 wait =3D = 0
           =20 else:
          &nbs= p;    =20 #terminate
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D
 
Any=20 suggestions/help are/is much appreciated!

Thanks in = advance folks,

Bill=20 Taylor

------=_NextPart_000_000B_01C2A6B1.8FD3CD80-- From mvmisha@yahoo.com Wed Dec 18 23:25:32 2002 From: mvmisha@yahoo.com (Misha Verplak) Date: Wed, 18 Dec 2002 23:25:32 -0000 Subject: [python-win32] Process creation hang up References: <342DB6B3FE8BD5119D0F0090273C2364312218@EX_PORTLAND1> Message-ID: <000f01c2a6ec$cc7afca0$7cc3b7ac@grunt> Hi Bill To help pin down the problem, you could try: os.startfile() I am guessing it will behave exactly the same. Simplify your wait routine by removing the os.path.exists() call, and just sleep for a fixed length of time before displaying the message. Does the problem still occur? Try a print statement in your loop, does that prevent the "hang"? Replace time.sleep() with win32api.Sleep(), still a problem? Try a different way of delaying, eg. a messagebox straight after running program.exe, see if program still hangs around after login. Choose a different way of indicating timeout, eg. win32api.MessageBox() or simply a print statement and get raw input, or another sleep... Your program.exe could be waiting on a file lock for the results, or on standard output to be flushed/released (whatever that might mean, but I've noticed something similar with this), or on the sleep statements. There are other possibilities, eg. your python program and program.exe both waiting on the same message loop, but this is rather unlikely from your description. Kind regards, Misha ----- Original Message ----- From: Bill Taylor To: 'python-win32@python.org' Sent: 18 December 2002 22:20 Subject: [python-win32] Process creation hang up Hi all, Sorry this is lengthy and wordy... but does anyone have experience with process creation? I'm having problems with my child process hanging. Could be I'm a rookie (I am) missing the boat on something simple. or I'm just an idiot. or both (likely) :) Here's my scenario: I need to call an executable within my Python code - let's call this program.exe. Program.exe in turn calls a login executable - let's call this login.exe. Program.exe calls login.exe opening a DDE channel. Login.exe presents a login window to a user. The user enters user ID and password and then program.exe logs into a server database. Once connected, program.exe gathers database information and writes it to a text file named result.txt back on the calling machine. Here's my problem: When I use win32api.WinExec(programPathName), program.exe is called, login.exe is called, login window is presented to the user, user enters login information, and then program.exe hangs. Immediately after calling program.exe, my code goes into a time.sleep loop looking for result.exe. When result.exe is not found within a specified time, I present a message to the user to terminate. As soon as this message is presented, program.exe "un-hangs" and completes execution, writing result.txt to the calling machine. So, it appears my code has some sort of lock on the processor (possibly my time.sleep loop) preventing program.exe from processing. Any clues on this? Also, I've tried the os.spawn functions, win32api.ShellExecute, and win32process.CreateProcess with several different parameter settings on each and I get similar behavior except with all of these I don't get as far as with WinExec in that login.exe's login window never even displays. Here's my basic calls: Spawnl ================================================== os.spawnl(os.P_WAIT, programPathName) ================================================== ShellExecute ================================================== win32api.ShellExecute(0, None, programPathName, "", programPath, 1) ================================================== CreateProcess ================================================== si = win32process.STARTUPINFO() win32process.CreateProcess(None, # module programPathName, #command line None, #process security attributes None, #thread security attributes 0, #handle inheritance flag win32con.NORMAL_PRIORITY_CLASS, #creation flags None, # process new environment setting programPath, #start directory si) #STARTUPINFO object specifying window appearance ================================================== wait loop ================================================== while not os.path.exists(fileName) and wait < maxWait: wait += 1 time.sleep(1) if wait >= maxWait: #Timeout error message = "Cannot find file " + fileName + "\nDo you want to continue searching?" ret = DisplayMessageBox(message, "File Search Timeout Message", "YESNO") if ret == 1: wait = 0 else: #terminate ================================================== Any suggestions/help are/is much appreciated! Thanks in advance folks, Bill Taylor From mhammond@skippinet.com.au Thu Dec 19 00:06:51 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Thu, 19 Dec 2002 11:06:51 +1100 Subject: [python-win32] Process creation hang up In-Reply-To: <342DB6B3FE8BD5119D0F0090273C2364312218@EX_PORTLAND1> Message-ID: <00c101c2a6f2$899e13d0$530f8490@eden> This is a multi-part message in MIME format. ------=_NextPart_000_00C2_01C2A74E.BD0E8BD0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit It sounds to me like program.exe needs to be running a message loop. As soon as it displays a window it stops freezing (and a window implies a message loop) and you are trying to use DDE, which is also message based. Mark. -----Original Message----- From: python-win32-admin@python.org [mailto:python-win32-admin@python.org]On Behalf Of Bill Taylor Sent: Thursday, 19 December 2002 9:21 AM To: 'python-win32@python.org' Subject: [python-win32] Process creation hang up Hi all, Sorry this is lengthy and wordy... but does anyone have experience with process creation? I’m having problems with my child process hanging. Could be I’m a rookie (I am) missing the boat on something simple… or I’m just an idiot… or both (likely) :) Here’s my scenario: I need to call an executable within my Python code – let’s call this program.exe. Program.exe in turn calls a login executable – let’s call this login.exe. Program.exe calls login.exe opening a DDE channel. Login.exe presents a login window to a user. The user enters user ID and password and then program.exe logs into a server database. Once connected, program.exe gathers database information and writes it to a text file named result.txt back on the calling machine. Here’s my problem: When I use win32api.WinExec(programPathName), program.exe is called, login.exe is called, login window is presented to the user, user enters login information, and then program.exe hangs. Immediately after calling program.exe, my code goes into a time.sleep loop looking for result.exe. When result.exe is not found within a specified time, I present a message to the user to terminate. As soon as this message is presented, program.exe “un-hangs” and completes execution, writing result.txt to the calling machine. So, it appears my code has some sort of lock on the processor (possibly my time.sleep loop) preventing program.exe from processing. Any clues on this? Also, I’ve tried the os.spawn functions, win32api.ShellExecute, and win32process.CreateProcess with several different parameter settings on each and I get similar behavior except with all of these I don't get as far as with WinExec in that login.exe’s login window never even displays. Here’s my basic calls: Spawnl ================================================== os.spawnl(os.P_WAIT, programPathName) ================================================== ShellExecute ================================================== win32api.ShellExecute(0, None, programPathName, "", programPath, 1) ================================================== CreateProcess ================================================== si = win32process.STARTUPINFO() win32process.CreateProcess(None, # module programPathName, #command line None, #process security attributes None, #thread security attributes 0, #handle inheritance flag win32con.NORMAL_PRIORITY_CLASS, #creation flags None, # process new environment setting programPath, #start directory si) #STARTUPINFO object specifying window appearance ================================================== wait loop ================================================== while not os.path.exists(fileName) and wait < maxWait: wait += 1 time.sleep(1) if wait >= maxWait: #Timeout error message = "Cannot find file " + fileName + "\nDo you want to continue searching?" ret = DisplayMessageBox(message, "File Search Timeout Message", "YESNO") if ret == 1: wait = 0 else: #terminate ================================================== Any suggestions/help are/is much appreciated! Thanks in advance folks, Bill Taylor ------=_NextPart_000_00C2_01C2A74E.BD0E8BD0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
It=20 sounds to me like program.exe needs to be running a message loop.  = As soon=20 as it displays a window it stops freezing (and a window implies a = message loop)=20 and you are trying to use DDE, which is also message = based.
 
Mark.
-----Original Message-----
From:=20 python-win32-admin@python.org = [mailto:python-win32-admin@python.org]On=20 Behalf Of Bill Taylor
Sent: Thursday, 19 December 2002 = 9:21=20 AM
To: 'python-win32@python.org'
Subject: = [python-win32]=20 Process creation hang up

Hi=20 all,
 
Sorry this is=20 lengthy and wordy... but does anyone have experience with process=20 creation?  I'm having = problems=20 with my child process hanging.  = Could be I'm a rookie (I am) missing the boat on something = simple... or=20 I'm just an idiot... or both (likely) :)
 
Here's my=20 scenario:
I = need to call an=20 executable within my Python code - let's call this program.exe.  Program.exe in turn calls a = login=20 executable - let's call this login.exe. =20 Program.exe calls login.exe opening a DDE channel.  Login.exe presents a login = window to a=20 user.  The user enters = user ID and=20 password and then program.exe logs into a server database.  Once connected, program.exe = gathers=20 database information and writes it to a text file named result.txt = back on the=20 calling machine.
 
Here's my=20 problem:
When = I use=20 win32api.WinExec(programPathName), program.exe is called, login.exe is = called,=20 login window is presented to the user, user enters login information, = and then=20 program.exe hangs.  = Immediately=20 after calling program.exe, my code goes into a time.sleep loop looking = for=20 result.exe.  When = result.exe is=20 not found within a specified time, I present a message to the user to=20 terminate.  As soon as = this=20 message is presented, program.exe "un-hangs" and completes execution, = writing=20 result.txt to the calling machine. =20 So, it appears my code has some sort of lock on the processor = (possibly=20 my time.sleep loop) preventing program.exe from processing.  Any clues on = this?
 
Also, I've tried=20 the os.spawn functions, win32api.ShellExecute, and = win32process.CreateProcess=20 with several different parameter settings on each and I get similar = behavior=20 except with all of these I don't get as far as with WinExec in that=20 login.exe's login window never even displays.  Here's my basic=20 calls:
 
Spawnl
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D
os.spawnl(os.P_WAIT,=20 programPathName)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D
 
ShellExecute
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D
win32api.ShellExecute(0, None, = programPathName, "",=20 programPath, 1)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D
 
CreateProcess
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D
si = =3D=20 win32process.STARTUPINFO()
win32process.CreateProcess(None, #=20 module
       &nbs= p;            = ;            =           =20 programPathName, #command line
       &nbs= p;            = ;            =           =20 None, #process security attributes
       &nbs= p;            = ;            =           =20 None, #thread security attributes
       &nbs= p;            = ;            =           =20 0, #handle inheritance flag
       &nbs= p;            = ;            =           =20 win32con.NORMAL_PRIORITY_CLASS, #creation flags
       &nbs= p;            = ;            =           =20 None, # process new environment setting
       &nbs= p;            = ;            =           =20 programPath, #start directory
       &nbs= p;            = ;            =           =20 si) #STARTUPINFO object specifying window = appearance
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D
 
wait = loop
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D
while not=20 os.path.exists(fileName) and wait <=20 maxWait:
        wait +=3D=20 1
       =20 = time.sleep(1)
         &n= bsp;  
       =20 if wait >=3D=20 = maxWait:
          &= nbsp;=20 #Timeout=20 = error
          &nbs= p;=20 message =3D "Cannot find file " + fileName + "\nDo you want to = continue=20 = searching?"
         &nbs= p; =20 ret =3D DisplayMessageBox(message, "File Search Timeout Message",=20 = "YESNO")
          &= nbsp;=20 if ret =3D=3D=20 = 1:
           &= nbsp;   =20 wait =3D = 0
           =20 else:
          &nbs= p;    =20 #terminate
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D
 
Any=20 suggestions/help are/is much appreciated!

Thanks in = advance folks,

Bill=20 Taylor

------=_NextPart_000_00C2_01C2A74E.BD0E8BD0-- From mvmisha@yahoo.com Thu Dec 19 01:01:48 2002 From: mvmisha@yahoo.com (Misha Verplak) Date: Thu, 19 Dec 2002 01:01:48 -0000 Subject: [python-win32] Process creation hang up References: <00c101c2a6f2$899e13d0$530f8490@eden> Message-ID: <000501c2a6fa$42bb4840$6908b4ac@grunt> So a solution for this might involve a simple message pump in the program, while waiting for the result file? Bill, I misread your first post to mean that program.exe is an external program to your python program :) Kind regards, Misha ----- Original Message ----- From: Mark Hammond To: 'Bill Taylor' ; python-win32@python.org Sent: 19 December 2002 00:06 Subject: RE: [python-win32] Process creation hang up It sounds to me like program.exe needs to be running a message loop. As soon as it displays a window it stops freezing (and a window implies a message loop) and you are trying to use DDE, which is also message based. Mark. -----Original Message----- From: python-win32-admin@python.org [mailto:python-win32-admin@python.org]On Behalf Of Bill Taylor Sent: Thursday, 19 December 2002 9:21 AM To: 'python-win32@python.org' Subject: [python-win32] Process creation hang up Hi all, Sorry this is lengthy and wordy... but does anyone have experience with process creation? I'm having problems with my child process hanging. Could be I'm a rookie (I am) missing the boat on something simple... or I'm just an idiot... or both (likely) :) Here's my scenario: I need to call an executable within my Python code - let's call this program.exe. Program.exe in turn calls a login executable - let's call this login.exe. Program.exe calls login.exe opening a DDE channel. Login.exe presents a login window to a user. The user enters user ID and password and then program.exe logs into a server database. Once connected, program.exe gathers database information and writes it to a text file named result.txt back on the calling machine. Here's my problem: When I use win32api.WinExec(programPathName), program.exe is called, login.exe is called, login window is presented to the user, user enters login information, and then program.exe hangs. Immediately after calling program.exe, my code goes into a time.sleep loop looking for result.exe. When result.exe is not found within a specified time, I present a message to the user to terminate. As soon as this message is presented, program.exe "un-hangs" and completes execution, writing result.txt to the calling machine. So, it appears my code has some sort of lock on the processor (possibly my time.sleep loop) preventing program.exe from processing. Any clues on this? Also, I've tried the os.spawn functions, win32api.ShellExecute, and win32process.CreateProcess with several different parameter settings on each and I get similar behavior except with all of these I don't get as far as with WinExec in that login.exe's login window never even displays. Here's my basic calls: Spawnl ================================================== os.spawnl(os.P_WAIT, programPathName) ================================================== ShellExecute ================================================== win32api.ShellExecute(0, None, programPathName, "", programPath, 1) ================================================== CreateProcess ================================================== si = win32process.STARTUPINFO() win32process.CreateProcess(None, # module programPathName, #command line None, #process security attributes None, #thread security attributes 0, #handle inheritance flag win32con.NORMAL_PRIORITY_CLASS, #creation flags None, # process new environment setting programPath, #start directory si) #STARTUPINFO object specifying window appearance ================================================== wait loop ================================================== while not os.path.exists(fileName) and wait < maxWait: wait += 1 time.sleep(1) if wait >= maxWait: #Timeout error message = "Cannot find file " + fileName + "\nDo you want to continue searching?" ret = DisplayMessageBox(message, "File Search Timeout Message", "YESNO") if ret == 1: wait = 0 else: #terminate ================================================== Any suggestions/help are/is much appreciated! Thanks in advance folks, Bill Taylor From unifoam@total.net Thu Dec 19 18:23:37 2002 From: unifoam@total.net (George Vestergom) Date: Thu, 19 Dec 2002 13:23:37 -0500 Subject: [python-win32] problems in returning parameters using a COM client References: <00c101c2a6f2$899e13d0$530f8490@eden> <000501c2a6fa$42bb4840$6908b4ac@grunt> Message-ID: <3E020EA9.8E90E4C7@total.net> Hello, Here's my problem: I'm writing routines to access the methods found in CorelDraw 6. I've used the MakePy utility to provide early-bound automation. Everything works fine, except I can't return values from certain methods. For example, one CorelDraw method returns 2 Long values: .GetPosition lngXPos, lngYPos where lngXPos and lngYPos are the x and y position of the currently selected object. Using Python 2.2 and win32all build 148: >>> from win32com.client import Dispatch >>> cd = Dispatch('CorelDraw.automation.6') >>> cd.Filenew() >>> cd.SetVisible(CDTrue) >>> ## everything ok here, CorelDraw starts up and a new drawing surface >>> ## is made visible. >>> ## now draw a rectangle using the following method: >>> ## .CreateRectangle lngTop, lngLeft, lngBottom, lngRight, 0 >>> ### (numbers are in CorelDraw units: tenths of a micron) >>> cd.CreateRectangle( 1500000, -1200000, 750000, -500000, 0) >>> ## a rectangle is drawn and becomes the current selected object. >>> ## now retrieve the current position of the rectangle: >>> x, y = cd.GetPosition() # it should return x = -1200000, y = 1500000 >>> ## the following error is printed: Traceback (most recent call last): File "", line 1, in ? cd.GetPosition() File "", line 2, in GetPosition com_error: (-2147352561, 'Parameter not optional.', None, None) >>> The following also do not work: >>> (x, y) = cd.GetPosition() >>> cd.GetPosition() >>> print cd.GetPosition() Here's an example using Excel 2000 VBA which works fine since the return variables must be defined: Public Sub CorelDraw() Dim lngXPos As Long Dim lngYPos As Long ' create an automation object Set cd = CreateObject("CorelDraw.Automation.6") ' create a rectangle and return current x, y position With cd .FileNew .SetVisible -1 .CreateRectangle 1500000, -1200000, 750000, -500000, 0 .GetPosition lngXPos, lngYPos Debug.Print lngXPos, lngYPos End With Set cd = Nothing End Sub My question is this: Is it possible to retrieve these values in another way, maybe using PyIDispatch.InvokeTypes()? I can't see anything mentionned in Hammond's & Robinson's "Python Programming on Win32" to resolve this problem. Here's the MakePy entry for this method: def GetPosition(self, XPos=defaultNamedNotOptArg, YPos=defaultNamedNotOptArg): return self._oleobj_.InvokeTypes(0x11, LCID, 1, (11,0),((16387, 0), (16387, 0)),XPos, YPos) One idea I have in mind is to create an COM object from Excel and have python call a method in Excel which calls the GetPosition method in CorelDraw and stores the results on a worksheet. Python can then retrieve the values from this sheet. Any suggestions would be appreciated. Thanks, George Vestergom From jens.jorgensen@tallan.com Thu Dec 19 19:39:41 2002 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Thu, 19 Dec 2002 13:39:41 -0600 Subject: [python-win32] problems in returning parameters using a COM client In-Reply-To: <3E020EA9.8E90E4C7@total.net> References: <00c101c2a6f2$899e13d0$530f8490@eden> <000501c2a6fa$42bb4840$6908b4ac@grunt> <3E020EA9.8E90E4C7@total.net> Message-ID: <3E02207D.8090601@tallan.com> Those parameters are most likely [in, out] params. This means you must pass something in. Try: xpos, ypos = cd.GetPosition(0, 0) George Vestergom wrote: >Hello, > >Here's my problem: > >I'm writing routines to access the methods found in CorelDraw 6. I've >used the MakePy utility to provide early-bound automation. Everything >works fine, except I can't return values from certain methods. > >For example, one CorelDraw method returns 2 Long values: > .GetPosition lngXPos, lngYPos > > where lngXPos and lngYPos are the x and y position of the currently >selected object. > > >Using Python 2.2 and win32all build 148: > > > >>>>from win32com.client import Dispatch >>>>cd = Dispatch('CorelDraw.automation.6') >>>>cd.Filenew() >>>>cd.SetVisible(CDTrue) >>>> >>>> > > > >>>>## everything ok here, CorelDraw starts up and a new drawing surface >>>>## is made visible. >>>> >>>> > > > >>>>## now draw a rectangle using the following method: >>>>## .CreateRectangle lngTop, lngLeft, lngBottom, lngRight, 0 >>>>### (numbers are in CorelDraw units: tenths of a micron) >>>> >>>> > > > >>>>cd.CreateRectangle( 1500000, -1200000, 750000, -500000, 0) >>>> >>>> > > > >>>>## a rectangle is drawn and becomes the current selected object. >>>>## now retrieve the current position of the rectangle: >>>> >>>> > > > >>>>x, y = cd.GetPosition() # it should return x = -1200000, y = 1500000 >>>> >>>> > > > >>>>## the following error is printed: >>>> >>>> >Traceback (most recent call last): > File "", line 1, in ? > cd.GetPosition() > File "", line 2, in >GetPosition >com_error: (-2147352561, 'Parameter not optional.', None, >None) > > > >The following also do not work: > > >>>>(x, y) = cd.GetPosition() >>>>cd.GetPosition() >>>>print cd.GetPosition() >>>> >>>> > > >Here's an example using Excel 2000 VBA which works fine since the return >variables must be defined: > >Public Sub CorelDraw() > > Dim lngXPos As Long > Dim lngYPos As Long > > ' create an automation object > Set cd = CreateObject("CorelDraw.Automation.6") > > ' create a rectangle and return current x, y position > With cd > .FileNew > .SetVisible -1 > .CreateRectangle 1500000, -1200000, 750000, -500000, 0 > .GetPosition lngXPos, lngYPos > Debug.Print lngXPos, lngYPos > End With > > Set cd = Nothing > >End Sub > > >My question is this: > >Is it possible to retrieve these values in another way, maybe using >PyIDispatch.InvokeTypes()? I can't see anything mentionned in Hammond's >& Robinson's "Python Programming on Win32" to resolve this problem. > >Here's the MakePy entry for this method: > def GetPosition(self, XPos=defaultNamedNotOptArg, >YPos=defaultNamedNotOptArg): > return self._oleobj_.InvokeTypes(0x11, LCID, 1, (11,0),((16387, >0), (16387, 0)),XPos, YPos) > > >One idea I have in mind is to create an COM object from Excel and have >python call a method in Excel which calls the GetPosition method in >CorelDraw and stores the results on a worksheet. Python can then >retrieve the values from this sheet. > >Any suggestions would be appreciated. > >Thanks, >George Vestergom > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" From nsis5@allstate.com Thu Dec 19 19:39:59 2002 From: nsis5@allstate.com (Sison, Nick) Date: Thu, 19 Dec 2002 13:39:59 -0600 Subject: [python-win32] Win32 COM starter book. Message-ID: <4DF4786A05BDCA4BA5AC00431981688009C0A0@a0001-xpo0113-s.hodc.ad.allstate.com> I just started with Python and with programming in the Win32 environment as well. The "Python programming with Win32" book by Mark Hammond & Andy Robinson seems to be a great book. (1/3 of the way through). I am struggling with the concepts presented by the COM world and wondered what a good resource (book) might be for the beginning programmer. Any advice is greatly appreciated. Thanks in Advance! Also, while not quite there yet. The .NET environment seems to be right around the corner (in acceptance and implementation). I know that some preliminary work was done in that environment but there is no .NET version of Python just yet. Will the investment (in time) with learning the ins and outs of the COM/DCOM/COM++ environments be useful? (just the frustration talking, :-) Nick Sison ps. I have more of a systems integration / network integration background and I am trying to move more into the developer world. From BTaylor@harlandfs.com Thu Dec 19 20:08:59 2002 From: BTaylor@harlandfs.com (Bill Taylor) Date: Thu, 19 Dec 2002 12:08:59 -0800 Subject: [python-win32] Process creation hang up - Part 2 Message-ID: <342DB6B3FE8BD5119D0F0090273C236431221E@EX_PORTLAND1> This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C2A79A.779DD5F0 Content-Type: text/plain; charset="iso-8859-1" I failed to give the complete scenario on this and also make clear a few other things. 1. This all begins with an MFC app launching my python scripts. So, again, the complete progression is: MFC app launches python scripts python scripts call program.exe program.exe calls login.exe login.exe presents login window to user user enters login info program.exe hangs python scripts timeout waiting for program.exe to write result.txt; python scripts present message window to user. program.exe "un-hangs"; writes result.txt 2. Program.exe and login.exe are third party apps in which I do not have access to that code. When program.exe is run as a stand alone app, it works fine, creating result.txt. Sorry for the omissions - thanks again for your suggestions. Bill -----Original Message----- From: Bill Taylor Sent: Wednesday, December 18, 2002 2:21 PM To: 'python-win32@python.org' Subject: Process creation hang up Hi all, Sorry this is lengthy and wordy... but does anyone have experience with process creation? I'm having problems with my child process hanging. Could be I'm a rookie (I am) missing the boat on something simple... or I'm just an idiot... or both (likely) :) Here's my scenario: I need to call an executable within my Python code - let's call this program.exe. Program.exe in turn calls a login executable - let's call this login.exe. Program.exe calls login.exe opening a DDE channel. Login.exe presents a login window to a user. The user enters user ID and password and then program.exe logs into a server database. Once connected, program.exe gathers database information and writes it to a text file named result.txt back on the calling machine. Here's my problem: When I use win32api.WinExec(programPathName), program.exe is called, login.exe is called, login window is presented to the user, user enters login information, and then program.exe hangs. Immediately after calling program.exe, my code goes into a time.sleep loop looking for result.exe. When result.exe is not found within a specified time, I present a message to the user to terminate. As soon as this message is presented, program.exe "un-hangs" and completes execution, writing result.txt to the calling machine. So, it appears my code has some sort of lock on the processor (possibly my time.sleep loop) preventing program.exe from processing. Any clues on this? Also, I've tried the os.spawn functions, win32api.ShellExecute, and win32process.CreateProcess with several different parameter settings on each and I get similar behavior except with all of these I don't get as far as with WinExec in that login.exe's login window never even displays. Here's my basic calls: Spawnl ================================================== os.spawnl(os.P_WAIT, programPathName) ================================================== ShellExecute ================================================== win32api.ShellExecute(0, None, programPathName, "", programPath, 1) ================================================== CreateProcess ================================================== si = win32process.STARTUPINFO() win32process.CreateProcess(None, # module programPathName, #command line None, #process security attributes None, #thread security attributes 0, #handle inheritance flag win32con.NORMAL_PRIORITY_CLASS, #creation flags None, # process new environment setting programPath, #start directory si) #STARTUPINFO object specifying window appearance ================================================== wait loop ================================================== while not os.path.exists(fileName) and wait < maxWait: wait += 1 time.sleep(1) if wait >= maxWait: #Timeout error message = "Cannot find file " + fileName + "\nDo you want to continue searching?" ret = DisplayMessageBox(message, "File Search Timeout Message", "YESNO") if ret == 1: wait = 0 else: #terminate ================================================== Any suggestions/help are/is much appreciated! Thanks in advance folks, Bill Taylor ------_=_NextPart_001_01C2A79A.779DD5F0 Content-Type: text/html; charset="iso-8859-1"
I failed to give the complete scenario on this and also make clear a few other things.
 
1. This all begins with an MFC app launching my python scripts.  So, again, the complete progression is:
MFC app launches python scripts
python scripts call program.exe
program.exe calls login.exe
login.exe presents login window to user
user enters login info
program.exe hangs
python scripts timeout waiting for program.exe to write result.txt; python scripts present message window to user.
program.exe "un-hangs"; writes result.txt
 
2. Program.exe and login.exe are third party apps in which I do not have access to that code.  When program.exe is run as a stand alone app, it works fine, creating result.txt.
 
Sorry for the omissions - thanks again for your suggestions.
 
Bill
-----Original Message-----
From: Bill Taylor
Sent: Wednesday, December 18, 2002 2:21 PM
To: 'python-win32@python.org'
Subject: Process creation hang up

Hi all,
 
Sorry this is lengthy and wordy... but does anyone have experience with process creation?  I’m having problems with my child process hanging.  Could be I’m a rookie (I am) missing the boat on something simple… or I’m just an idiot… or both (likely) :)
 
Here’s my scenario:
I need to call an executable within my Python code – let’s call this program.exe.  Program.exe in turn calls a login executable – let’s call this login.exe.  Program.exe calls login.exe opening a DDE channel.  Login.exe presents a login window to a user.  The user enters user ID and password and then program.exe logs into a server database.  Once connected, program.exe gathers database information and writes it to a text file named result.txt back on the calling machine.
 
Here’s my problem:
When I use win32api.WinExec(programPathName), program.exe is called, login.exe is called, login window is presented to the user, user enters login information, and then program.exe hangs.  Immediately after calling program.exe, my code goes into a time.sleep loop looking for result.exe.  When result.exe is not found within a specified time, I present a message to the user to terminate.  As soon as this message is presented, program.exe “un-hangs” and completes execution, writing result.txt to the calling machine.  So, it appears my code has some sort of lock on the processor (possibly my time.sleep loop) preventing program.exe from processing.  Any clues on this?
 
Also, I’ve tried the os.spawn functions, win32api.ShellExecute, and win32process.CreateProcess with several different parameter settings on each and I get similar behavior except with all of these I don't get as far as with WinExec in that login.exe’s login window never even displays.  Here’s my basic calls:
 
Spawnl
==================================================
os.spawnl(os.P_WAIT, programPathName)
==================================================
 
ShellExecute
==================================================
win32api.ShellExecute(0, None, programPathName, "", programPath, 1)
==================================================
 
CreateProcess
==================================================
si = win32process.STARTUPINFO()
win32process.CreateProcess(None, # module
                                           programPathName, #command line
                                           None, #process security attributes
                                           None, #thread security attributes
                                           0, #handle inheritance flag
                                           win32con.NORMAL_PRIORITY_CLASS, #creation flags
                                           None, # process new environment setting
                                           programPath, #start directory
                                           si) #STARTUPINFO object specifying window appearance
==================================================
 
wait loop
==================================================
while not os.path.exists(fileName) and wait < maxWait:
        wait += 1
        time.sleep(1)
            
        if wait >= maxWait:
            #Timeout error
            message = "Cannot find file " + fileName + "\nDo you want to continue searching?"
            ret = DisplayMessageBox(message, "File Search Timeout Message", "YESNO")
            if ret == 1:
                wait = 0
            else:
                #terminate
==================================================
 
Any suggestions/help are/is much appreciated!

Thanks in advance folks,

Bill Taylor

------_=_NextPart_001_01C2A79A.779DD5F0-- From dond@advancedmp.com Thu Dec 19 21:23:00 2002 From: dond@advancedmp.com (Don Dwiggins) Date: 19 Dec 2002 13:23:00 -0800 Subject: [python-win32] Re: problems in returning parameters using a COM client References: <00c101c2a6f2$899e13d0$530f8490@eden> <000501c2a6fa$42bb4840$6908b4ac@grunt> <3E020EA9.8E90E4C7@total.net> <3E02207D.8090601@tallan.com> Message-ID: Jens B Jorgensen writes: > Those parameters are most likely [in, out] params. This means you must pass > something in. Try: > xpos, ypos = cd.GetPosition(0, 0) Adding a bit to Jens' comments: [in, out] params need special treatment to avoid the need to modify a parameter in place. Python's approach is to have you pass in the initial value, then get the updated value as part of the result (which will be a sequence, beginning with the COM object's return value, and containing all [in, out] and [out] params in left-to-right order). For [out] params, it's a bit simpler: they'll just appear in the result sequence. Also, a useful tool for working with COM components is Microsoft's OLE/COM Object Viewer (http://www.microsoft.com/com/resources/oleview.asp). Enjoy, -- Don Dwiggins "In a time of drastic change it is the learners who d.l.dwiggins@computer.org survive; the 'learned' find themselves fully equipped to live in a world that no longer exists." -- Eric Hoffer From mhammond@skippinet.com.au Fri Dec 20 06:11:18 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Fri, 20 Dec 2002 17:11:18 +1100 Subject: [python-win32] Win32 COM starter book. In-Reply-To: <4DF4786A05BDCA4BA5AC00431981688009C0A0@a0001-xpo0113-s.hodc.ad.allstate.com> Message-ID: <005901c2a7ee$9cfa4e60$530f8490@eden> > I just started with Python and with programming in the Win32 > environment as > well. The "Python programming with Win32" book by Mark Hammond & Andy > Robinson seems to be a great book. (1/3 of the way through). Thanks! > I am > struggling with the concepts presented by the COM world and > wondered what a > good resource (book) might be for the beginning programmer. > Any advice is > greatly appreciated. Thanks in Advance! Nope, sorry - but you could try comp.lang.python. So long as you keep it vaguely Python related, plenty of people there will be more than happy to help you out with the non-Python specific COM concepts (along with lots of "get a real OS" comments, but that's life ) > Also, while not quite there yet. The .NET environment seems > to be right > around the corner (in acceptance and implementation). I know > that some > preliminary work was done in that environment but there is no > .NET version > of Python just yet. Will the investment (in time) with > learning the ins and > outs of the COM/DCOM/COM++ environments be useful? (just the > frustration > talking, :-) Yes, it certainly will be useful. COM isn't going away any time soon, and .NET is really just a cleaner COM. Mark. From mhammond@skippinet.com.au Fri Dec 20 06:15:10 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Fri, 20 Dec 2002 17:15:10 +1100 Subject: [python-win32] Process creation hang up - Part 2 In-Reply-To: <342DB6B3FE8BD5119D0F0090273C236431221E@EX_PORTLAND1> Message-ID: <005a01c2a7ef$275cca10$530f8490@eden> This is a multi-part message in MIME format. ------=_NextPart_000_005B_01C2A84B.5ACD4210 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit It sounds like your Python app needs to be running the message pump (maybe as it is the "parent" of a DDE hosted app) - as soon as your Python script displays a UI (and therefore starts a loop) everything springs to life, so this sounds like the problem. First try a "busy" wait loop - ie: while 1: win32gui.PumpWaitingMessages() # check for result.txt, but dont wait if check(): break If that works, you can then work on a more efficient wait loop. Mark. -----Original Message----- From: python-win32-admin@python.org [mailto:python-win32-admin@python.org]On Behalf Of Bill Taylor Sent: Friday, 20 December 2002 7:09 AM To: 'python-win32@python.org' Subject: [python-win32] Process creation hang up - Part 2 I failed to give the complete scenario on this and also make clear a few other things. 1. This all begins with an MFC app launching my python scripts. So, again, the complete progression is: MFC app launches python scripts python scripts call program.exe program.exe calls login.exe login.exe presents login window to user user enters login info program.exe hangs python scripts timeout waiting for program.exe to write result.txt; python scripts present message window to user. program.exe "un-hangs"; writes result.txt 2. Program.exe and login.exe are third party apps in which I do not have access to that code. When program.exe is run as a stand alone app, it works fine, creating result.txt. Sorry for the omissions - thanks again for your suggestions. Bill -----Original Message----- From: Bill Taylor Sent: Wednesday, December 18, 2002 2:21 PM To: 'python-win32@python.org' Subject: Process creation hang up Hi all, Sorry this is lengthy and wordy... but does anyone have experience with process creation? I’m having problems with my child process hanging. Could be I’m a rookie (I am) missing the boat on something simple… or I’m just an idiot… or both (likely) :) Here’s my scenario: I need to call an executable within my Python code – let’s call this program.exe. Program.exe in turn calls a login executable – let’s call this login.exe. Program.exe calls login.exe opening a DDE channel. Login.exe presents a login window to a user. The user enters user ID and password and then program.exe logs into a server database. Once connected, program.exe gathers database information and writes it to a text file named result.txt back on the calling machine. Here’s my problem: When I use win32api.WinExec(programPathName), program.exe is called, login.exe is called, login window is presented to the user, user enters login information, and then program.exe hangs. Immediately after calling program.exe, my code goes into a time.sleep loop looking for result.exe. When result.exe is not found within a specified time, I present a message to the user to terminate. As soon as this message is presented, program.exe “un-hangs” and completes execution, writing result.txt to the calling machine. So, it appears my code has some sort of lock on the processor (possibly my time.sleep loop) preventing program.exe from processing. Any clues on this? Also, I’ve tried the os.spawn functions, win32api.ShellExecute, and win32process.CreateProcess with several different parameter settings on each and I get similar behavior except with all of these I don't get as far as with WinExec in that login.exe’s login window never even displays. Here’s my basic calls: Spawnl ================================================== os.spawnl(os.P_WAIT, programPathName) ================================================== ShellExecute ================================================== win32api.ShellExecute(0, None, programPathName, "", programPath, 1) ================================================== CreateProcess ================================================== si = win32process.STARTUPINFO() win32process.CreateProcess(None, # module programPathName, #command line None, #process security attributes None, #thread security attributes 0, #handle inheritance flag win32con.NORMAL_PRIORITY_CLASS, #creation flags None, # process new environment setting programPath, #start directory si) #STARTUPINFO object specifying window appearance ================================================== wait loop ================================================== while not os.path.exists(fileName) and wait < maxWait: wait += 1 time.sleep(1) if wait >= maxWait: #Timeout error message = "Cannot find file " + fileName + "\nDo you want to continue searching?" ret = DisplayMessageBox(message, "File Search Timeout Message", "YESNO") if ret == 1: wait = 0 else: #terminate ================================================== Any suggestions/help are/is much appreciated! Thanks in advance folks, Bill Taylor ------=_NextPart_000_005B_01C2A84B.5ACD4210 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
It=20 sounds like your Python app needs to be running the message pump (maybe = as it is=20 the "parent" of a DDE hosted app) - as soon as your Python script = displays a UI=20 (and therefore starts a loop) everything springs to life, so this sounds = like=20 the problem.
 
First=20 try a "busy" wait loop - ie:
 
while=20 1:
 =20 win32gui.PumpWaitingMessages()
 =20 # check for result.txt, but dont wait
 =20 if check():
    break
 
If=20 that works, you can then work on a more efficient wait = loop.
 
Mark.
-----Original Message-----
From:=20 python-win32-admin@python.org = [mailto:python-win32-admin@python.org]On=20 Behalf Of Bill Taylor
Sent: Friday, 20 December 2002 = 7:09=20 AM
To: 'python-win32@python.org'
Subject: = [python-win32]=20 Process creation hang up - Part 2

I=20 failed to give the complete scenario on this and also make clear a few = other=20 things.
 
1.=20 This all begins with an MFC app launching my python = scripts.  So,=20 again, the complete progression = is:
MFC=20 app launches python scripts
python scripts call = program.exe
program.exe calls = login.exe
login.exe presents login window to=20 user
user=20 enters login info
program.exe hangs
python scripts timeout waiting for = program.exe to=20 write result.txt; python scripts present message window to=20 user.
program.exe "un-hangs"; writes=20 result.txt
 
2. Program.exe and login.exe are third = party apps in=20 which I do not have access to that code.  When program.exe is run = as a=20 stand alone app, it works fine, creating=20 result.txt.
 
Sorry for the omissions - thanks again for = your=20 suggestions.
 
Bill
-----Original Message-----
From: Bill Taylor =
Sent:=20 Wednesday, December 18, 2002 2:21 PM
To:=20 'python-win32@python.org'
Subject: Process creation hang=20 up

Hi=20 all,
 
Sorry this is=20 lengthy and wordy... but does anyone have experience with process=20 creation?  I'm having = problems=20 with my child process hanging.  = Could be I'm a rookie (I am) missing the boat on something = simple... or=20 I'm just an idiot... or both (likely) :)
 
Here's my=20 scenario:
I = need to call an=20 executable within my Python code - let's call this program.exe.  Program.exe in turn calls a = login=20 executable - let's call this login.exe. =20 Program.exe calls login.exe opening a DDE channel.  Login.exe presents a login = window to a=20 user.  The user enters = user ID and=20 password and then program.exe logs into a server database.  Once connected, program.exe = gathers=20 database information and writes it to a text file named result.txt = back on the=20 calling machine.
 
Here's my=20 problem:
When = I use=20 win32api.WinExec(programPathName), program.exe is called, login.exe is = called,=20 login window is presented to the user, user enters login information, = and then=20 program.exe hangs.  = Immediately=20 after calling program.exe, my code goes into a time.sleep loop looking = for=20 result.exe.  When = result.exe is=20 not found within a specified time, I present a message to the user to=20 terminate.  As soon as = this=20 message is presented, program.exe "un-hangs" and completes execution, = writing=20 result.txt to the calling machine. =20 So, it appears my code has some sort of lock on the processor = (possibly=20 my time.sleep loop) preventing program.exe from processing.  Any clues on = this?
 
Also, I've tried=20 the os.spawn functions, win32api.ShellExecute, and = win32process.CreateProcess=20 with several different parameter settings on each and I get similar = behavior=20 except with all of these I don't get as far as with WinExec in that=20 login.exe's login window never even displays.  Here's my basic=20 calls:
 
Spawnl
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D
os.spawnl(os.P_WAIT,=20 programPathName)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D
 
ShellExecute
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D
win32api.ShellExecute(0, None, = programPathName, "",=20 programPath, 1)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D
 
CreateProcess
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D
si = =3D=20 win32process.STARTUPINFO()
win32process.CreateProcess(None, #=20 module
       &nbs= p;            = ;            =           =20 programPathName, #command line
       &nbs= p;            = ;            =           =20 None, #process security attributes
       &nbs= p;            = ;            =           =20 None, #thread security attributes
       &nbs= p;            = ;            =           =20 0, #handle inheritance flag
       &nbs= p;            = ;            =           =20 win32con.NORMAL_PRIORITY_CLASS, #creation flags
       &nbs= p;            = ;            =           =20 None, # process new environment setting
       &nbs= p;            = ;            =           =20 programPath, #start directory
       &nbs= p;            = ;            =           =20 si) #STARTUPINFO object specifying window = appearance
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D
 
wait = loop
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D
while not=20 os.path.exists(fileName) and wait <=20 maxWait:
        wait +=3D=20 1
       =20 = time.sleep(1)
         &n= bsp;  
       =20 if wait >=3D=20 = maxWait:
          &= nbsp;=20 #Timeout=20 = error
          &nbs= p;=20 message =3D "Cannot find file " + fileName + "\nDo you want to = continue=20 = searching?"
         &nbs= p; =20 ret =3D DisplayMessageBox(message, "File Search Timeout Message",=20 = "YESNO")
          &= nbsp;=20 if ret =3D=3D=20 = 1:
           &= nbsp;   =20 wait =3D = 0
           =20 else:
          &nbs= p;    =20 #terminate
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D
 
Any=20 suggestions/help are/is much appreciated!

Thanks in = advance folks,

Bill=20 Taylor

------=_NextPart_000_005B_01C2A84B.5ACD4210-- From Paul.Moore@atosorigin.com Fri Dec 20 09:25:42 2002 From: Paul.Moore@atosorigin.com (Moore, Paul) Date: Fri, 20 Dec 2002 09:25:42 -0000 Subject: [python-win32] Access to .NET components from Python (Was: Win32 COM starter book) Message-ID: <16E1010E4581B049ABC51D4975CEDB880113D7FE@UKDCX001.uk.int.atosorigin.com> From: Mark Hammond [mailto:mhammond@skippinet.com.au] > Yes, it certainly will be useful. COM isn't going away any > time soon, and .NET is really just a cleaner COM. This reminded me of something I wondered about the other day. Is there any extension available which allows Python to access .NET components? I'm not talking about Python.NET - just something which lets normal CPython get access to .NET libraries (much like Win32all allows access to COM). If there isn't anything, maybe it would be an interesting project for me to have a look at... Paul. From mhammond@skippinet.com.au Fri Dec 20 09:44:43 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Fri, 20 Dec 2002 20:44:43 +1100 Subject: [python-win32] Access to .NET components from Python (Was: Win32 COM starter book) In-Reply-To: <16E1010E4581B049ABC51D4975CEDB880113D7FE@UKDCX001.uk.int.atosorigin.com> Message-ID: <000b01c2a80c$6d7b8280$530f8490@eden> This is a multi-part message in MIME format. ------=_NextPart_000_000C_01C2A868.A0EBFA80 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit [Paul] > From: Mark Hammond [mailto:mhammond@skippinet.com.au] > > Yes, it certainly will be useful. COM isn't going away any > > time soon, and .NET is really just a cleaner COM. > > This reminded me of something I wondered about the other day. Is there > any extension available which allows Python to access .NET components? Yes - win32com . The COM interop is very good, and there are tools to create typelibs etc from .NET assemblies. And speaking of books, this is even discussed in a new book I helped write! http://www.awprofessional.com/catalog/product.asp?product_id={8423366F-7738- 4400-A753-E51AF122689F} Mark. ------=_NextPart_000_000C_01C2A868.A0EBFA80 Content-Type: application/ms-tnef; name="winmail.dat" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="winmail.dat" eJ8+IiwJAQaQCAAEAAAAAAABAAEAAQeQBgAIAAAA5AQAAAAAAADoAAEIgAcAGAAAAElQTS5NaWNy b3NvZnQgTWFpbC5Ob3RlADEIAQ2ABAACAAAAAgACAAEGgAMADgAAANIHDAAUABQALAAAAAUAPgEB A5AGAGgHAAAlAAAACwACAAEAAAALACMAAAAAAAMAJgAAAAAACwApAAAAAAADAC4AAAAAAAMANgAA AAAAHgBwAAEAAABTAAAAW3B5dGhvbi13aW4zMl0gQWNjZXNzIHRvIC5ORVQgY29tcG9uZW50cyBm cm9tIFB5dGhvbiAoV2FzOiBXaW4zMiBDT00gc3RhcnRlciBib29rKQAAAgFxAAEAAAAWAAAAAcKo DGy/JTBvTXvfQnG/PKT45U0DAQAAAgEdDAEAAAAfAAAAU01UUDpNSEFNTU9OREBTS0lQUElORVQu Q09NLkFVAAALAAEOAAAAAEAABg4A8K1SDKjCAQIBCg4BAAAAGAAAAAAAAABxxECJg7CyT4hj7mao 95r/wooAAAMAFA4BAAAACwAfDgEAAAACAQkQAQAAAOkCAADlAgAAywMAAExaRnUucu3UAwAKAHJj cGcxMjXiMgNDdGV4BUEBAwH3/wqAAqQD5AcTAoAP8wBQBFY/CFUHshElDlEDAQIAY2jhCsBzZXQy BgAGwxEl9jMERhO3MBIsETMI7wn3tjsYHw4wNREiDGBjAFAzCwkBZDM2FlALpiBbYFBhdWxdCqIK gD40IEYDYToF0ArAayDISGFtBGBuZBzgAMBhAxB0bzptE+Aeo0C0c2sFIHALgBQgLgWgXG0uHRAd Rx2wWQeQLHQgaQVAYwSQAZALgGwUeSAD8GwDIGJlIEp1FBBmHSAuIBIgTyJNIgBzbicFQGdvwQuA ZyBhd2EiwABwinkhKHQHcSBzbwIghyHwAHAe4C5ORVQkIW4gGCAHQCKxaiNgBUBhvSIwbCeQIHAF wCPxLh1W6R1WVGgnU20LgAEAHuDZJjFvZiZRB4B0KjAkwf5JItAewQSQKtEBoAhgBUBvK6ArES0R BcBkJRAjwEnbBCAtYmUdViVBIA7BCfD3AJACICTgdh8hAaAocCLQTyowE9Ak4CMAb3cEIFDeeSug L7EfUCTgYyJABBEbJwMgsXACIAnwdHM/Jx1UHVQhwSAtItFuM5IyILEgPDSBaz4jwZ8qICNAI/MC MASQb3AnQv52BJAiwCSQBHAmpC4zJOD/N/EfUAbwLhEx0AUAJ5AOsIEmAHlwZWxpYgQg2RQgYyAD Uib0YQQQKoArAmAIkHMjwDwLUHVn1D5BHtFzOYBhICAkwfMrMQbgb2sh4SuhBCAnUdZlNtADoGQE AGMjYBQQ/x7gC4AoMSBwB+A88ivxLSA2bDmAHuB3BRAOsCE8Fi87ozNqaAJAcDovTC93QkAg4Hdw A2BmzzIhL6EHQCCiL2M5IAdA7G9nQLADYGQa0CCQOtAEcD9ENV9pZD1cIHs4NDIzHCA2RgAtNzcz OC00NAAwMC1BNzUzLSBFNTFBRg4gMjbgODlGXH0zah4yKRUCfUmgAAAAHgBCEAEAAABKAAAAPDE2 RTEwMTBFNDU4MUIwNDlBQkM1MUQ0OTc1Q0VEQjg4MDExM0Q3RkVAVUtEQ1gwMDEudWsuaW50LmF0 b3NvcmlnaW4uY29tPgAAAAMACVkBAAAACwALgAggBgAAAAAAwAAAAAAAAEYAAAAAA4UAAAAAAAAD AAyACCAGAAAAAADAAAAAAAAARgAAAAAQhQAAAAAAAAMADYAIIAYAAAAAAMAAAAAAAABGAAAAAFKF AAB9bgEAHgAOgAggBgAAAAAAwAAAAAAAAEYAAAAAVIUAAAEAAAAEAAAAOS4wAAsAEoAIIAYAAAAA AMAAAAAAAABGAAAAAA6FAAAAAAAAAwATgAggBgAAAAAAwAAAAAAAAEYAAAAAEYUAAAAAAAADABSA CCAGAAAAAADAAAAAAAAARgAAAAAYhQAAAAAAAAsAFYAIIAYAAAAAAMAAAAAAAABGAAAAAAaFAAAA AAAAAwAWgAggBgAAAAAAwAAAAAAAAEYAAAAAAYUAAAAAAAACAfgPAQAAABAAAABxxECJg7CyT4hj 7mao95r/AgH6DwEAAAAQAAAAccRAiYOwsk+IY+5mqPea/wIB+w8BAAAAkgAAAAAAAAA4obsQBeUQ GqG7CAArKlbCAABtc3BzdC5kbGwAAAAAAE5JVEH5v7gBAKoAN9luAAAARTpcRG9jdW1lbnRzIGFu ZCBTZXR0aW5nc1xza2lwXExvY2FsIFNldHRpbmdzXEFwcGxpY2F0aW9uIERhdGFcTWljcm9zb2Z0 XE91dGxvb2tcb3V0bG9vay5wc3QAAAADAP4PBQAAAAMADTT9NwAAAgF/AAEAAAAxAAAAMDAwMDAw MDA3MUM0NDA4OTgzQjBCMjRGODg2M0VFNjZBOEY3OUFGRkE0ODI4NTAwAAAAAAMABhCYLpZzAwAH EAACAAADABAQAQAAAAMAERABAAAAHgAIEAEAAABlAAAAUEFVTEZST006TUFSS0hBTU1PTkRNQUlM VE86TUhBTU1PTkRAU0tJUFBJTkVUQ09NQVVZRVMsSVRDRVJUQUlOTFlXSUxMQkVVU0VGVUxDT01J U05UR09JTkdBV0FZQU5ZVElNRQAAAAAeyg== ------=_NextPart_000_000C_01C2A868.A0EBFA80-- From Paul.Moore@atosorigin.com Fri Dec 20 09:55:23 2002 From: Paul.Moore@atosorigin.com (Moore, Paul) Date: Fri, 20 Dec 2002 09:55:23 -0000 Subject: [python-win32] Access to .NET components from Python (Was: Win32 COM starter book) Message-ID: <16E1010E4581B049ABC51D4975CEDB880113D802@UKDCX001.uk.int.atosorigin.com> From: Mark Hammond [mailto:mhammond@skippinet.com.au] > > This reminded me of something I wondered about the other day. > > Is there any extension available which allows Python to access > > .NET components? > Yes - win32com . The COM interop is very good, [...] Ooh. Must have a look. > this is even discussed in a new book I helped write! Ooh. Must have a look. :-) Thanks for the reply. Paul. From Paul.Moore@atosorigin.com Fri Dec 20 11:12:44 2002 From: Paul.Moore@atosorigin.com (Moore, Paul) Date: Fri, 20 Dec 2002 11:12:44 -0000 Subject: [python-win32] Access to .NET components from Python (Was: Win32 COM starter book) Message-ID: <16E1010E4581B049ABC51D4975CEDB88619995@UKDCX001.uk.int.atosorigin.com> From: Moore, Paul=20 >>> This reminded me of something I wondered about the other day. >>> Is there any extension available which allows Python to access >>> .NET components? >> Yes - win32com . The COM interop is very good, > Ooh. Must have a look. Hmm. Either I'm missing something, or it's not as easy as all that :-( I was going to try a simple use of System.Console, but AFAICT, System either isn't registered, or somehow doesn't work as I expected. OK, scrap that for now and write my own little assembly: using System; public class CTest { public void Test() { Console.Write("Hola "); Console.WriteLine("Mundo!"); Console.WriteLine("What is your name: "); String name =3D Console.ReadLine(); Console.Write("Buenos Dias, "); Console.Write(name); Console.WriteLine("!"); } } Compile with csc /target:library MyAssembly.cs, register with regasm MyAssembly.dll /tlb:MyAssembly.tlb, and try to test it. Nope, OLE error 0x80131522. Google tells me that this means I need my assembly in the same directory as the executable! (That's Python, not the script - so definitely not where I'd like to put my random DLLs). OK, copy the thing there for now. >>> from win32com.client import Dispatch >>> net =3D Dispatch("CTest") >>> net.Test() Hola Mundo! What is your name: kjhas Buenos Dias, kjhas! Traceback (most recent call last): File "", line 1, in ? TypeError: 'NoneType' object is not callable Pretty good - it works. But what is the TypeError at the bottom? My C# code has finished OK. Is it something "on the way back" from .NET to Python? So, a mixed success so far... Paul. From mhammond@skippinet.com.au Fri Dec 20 11:19:05 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Fri, 20 Dec 2002 22:19:05 +1100 Subject: [python-win32] Access to .NET components from Python (Was: Win32 COM starter book) In-Reply-To: <16E1010E4581B049ABC51D4975CEDB88619995@UKDCX001.uk.int.atosorigin.com> Message-ID: <000c01c2a819$9c17cf10$530f8490@eden> This is a multi-part message in MIME format. ------=_NextPart_000_000D_01C2A875.CF884710 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit > Compile with csc /target:library MyAssembly.cs, register with > regasm MyAssembly.dll /tlb:MyAssembly.tlb, and try to test it. Nope, > OLE error 0x80131522. Google tells me that this means I need my > assembly in the same directory as the executable! (That's Python, not > the script - so definitely not where I'd like to put my random DLLs). Yeah, this is .NET for you. If you want it publically available, you must create a strongly named assembly and stick it in the GAC. There are 2 choices - very public or very private. However, the "very public" isn't as bad as it sounds - you are guaranteed to get the *except* object you compiled against, regardless of naming clashes, etc. > OK, copy the thing there for now. > > >>> from win32com.client import Dispatch > >>> net = Dispatch("CTest") > >>> net.Test() > Hola Mundo! > What is your name: > kjhas > Buenos Dias, kjhas! > Traceback (most recent call last): > File "", line 1, in ? > TypeError: 'NoneType' object is not callable > > Pretty good - it works. But what is the TypeError at the bottom? My C# > code has finished OK. Is it something "on the way back" from .NET to > Python? Yep - we are seeing a VB friendly implementation - thus "net.Test" is actually making the call (even though it looks like a property reference!) This function returns None, and we are trying to call it. Use EnsureDispatch() or makepy manually to get it working. Mark. ------=_NextPart_000_000D_01C2A875.CF884710 Content-Type: application/ms-tnef; name="winmail.dat" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="winmail.dat" eJ8+IgYLAQaQCAAEAAAAAAABAAEAAQeQBgAIAAAA5AQAAAAAAADoAAEIgAcAGAAAAElQTS5NaWNy b3NvZnQgTWFpbC5Ob3RlADEIAQ2ABAACAAAAAgACAAEGgAMADgAAANIHDAAUABYAEwAAAAUAJwEB A5AGAGgJAAAlAAAACwACAAEAAAALACMAAAAAAAMAJgAAAAAACwApAAAAAAADAC4AAAAAAAMANgAA AAAAHgBwAAEAAABTAAAAW3B5dGhvbi13aW4zMl0gQWNjZXNzIHRvIC5ORVQgY29tcG9uZW50cyBm cm9tIFB5dGhvbiAoV2FzOiBXaW4zMiBDT00gc3RhcnRlciBib29rKQAAAgFxAAEAAAAWAAAAAcKo GZtUHdr4W0u0S3uHwbuSsDbpUAAAAgEdDAEAAAAfAAAAU01UUDpNSEFNTU9OREBTS0lQUElORVQu Q09NLkFVAAALAAEOAAAAAEAABg4A6iSYGajCAQIBCg4BAAAAGAAAAAAAAABxxECJg7CyT4hj7mao 95r/woAAAAMAFA4BAAAACwAfDgEAAAACAQkQAQAAAO4EAADqBAAALgcAAExaRnXSCVtuAwAKAHJj cGcxMjXiMgNDdGV4BUEBAwH3/wqAAqQD5AcTAoAP8wBQBFY/CFUHshElDlEDAQIAY2jhCsBzZXQy BgAGwxEl9jMERhO3MBIsETMI7wn3tjsYHw4wNREiDGBjAFAzCwkBZDM2FlALpiA+SRIhbXADEGUg A/B0SGggYwTwIC8BkHKCZxQgOmxpYnIKwFJ5BdB5QQQQZQbQbKR5Lh3gLCAYIGcEAH8OsAXAHZIK ogqAHPAgEWFkc20fGmRsAyAeIGw8YjofKSLRH/AAcGQg8nQe8XRvJEAHkAVAHaBCLgewb3BlLCDm TzhMRSAEkANgBcAweKA4MDEzMQ5AMiUw8Edvb2cdYQ6wIpAEIP8HgCRAE+AFQB2wBAAoQQYimEkg bgngJDBteSDmPyGQH2QlAAOgHbAdcHNh6ShRZGkYIGMkkB7xIZA3K0MOwAWQdQGRHWAhIJQoVCiR JwQgUHkdsOMCIB/wbm90IOYrUwUE/i0rgCSgAQELgB2gKAAfAN8usR2AK2AYIClwJyQwHqD2ayfR JKBwLTAp4SAAJBEBA3AgRExMcyku6yDkIORZKTBoH/Ao0yjxYC5ORVQgAhAFwHn3CGAlMClwZjXS HYAAcCTynzJhAmAN4AdAKvFhdgtwzwtgLWEf8DZybXUk4QUA/ykwDrAkACuAJFACICewMPG/K6Ek MCqXJBIgUA3gazby8SslR0FDNhEtwDFyCsB3HXAUQBPQbw3gB5EwEHb3BJAfADc0IAWxPjQFEDfw ww6wNhFIb3dlPjE0spUdcCI+OSI1EW4nBUC5LIFiYTqCNvIwMHUkIOc98jZyPTJndQrANsEpsnck kR5hK0MqDsA90AUwKvk+4GJqLBE2YwWgHTM6gX8hgAuAIFAf8wsRHWAEEW+3NlA6QQuAZx3QC2Bz K2DbH+EUIGMzqyYBSx/wBaD+cCRxK2Eo0UjhK1ExgTWi3S6wdzOlHPAg5j5N0DWQ4wNhHYFuMzJG oR/AHqD/CfAk8R0wF8EzQAQACrBJsC8g103SKaAFQD1PxygipENUJNEiKVBdLlIiPihSd0AQC2AF 0EMRbyF9IOZXKJIo8TXhTHEroTqpIOZrahPgcyDmQgpQfy6wBCBP0CGQH/BXM1UHVO8e0D3QQlA7 oSgEYCThLAHPTyI3gjHgIZB0KVanNiAyRh1SIjwgUCvgbj7OIh/wHqApoCAxH/ArISo/WTd5JXBF JnI6IO4nJVApoF6yJ0XmKPExEnc3gi1STN5QGCACQB8AZy8nkCQwMBA3AXcFsGtz/yUwWAAxMlW0 K1JetyQARQS3BuACQANwPx8REiAjIOb7BaABACBXUTWQMJFJQSQwu0rAJTBJQqUHgEuUIgIg/ytD NrAfAFoCQaBOEzVTJJDvYfcuQ14lNBZwMAFAMD0jzRQQZUjSOZBWQk4BTxF/IoArAR0wHWAHgAIw KKBp/2nBMBAdsDjgQNBTRkGiJABvLCBEEDeiAMBrS7VbFCh3QEErMghgZx3ANwEXsG//Y7Ax5DmQ P3AlYQAgMsEBEGUxcW490CEpPLIo8Wb/QxAsIHASYoEIcAYxX3Ij9H9tpSRRS7MkoFsjJREzulXZ FBAgRQCACHBlUXd2MO8FsXIxRaByEm5x1ES1Y1WrSNEzq00KwGszpX1/0AAAHgBCEAEAAABIAAAA PDE2RTEwMTBFNDU4MUIwNDlBQkM1MUQ0OTc1Q0VEQjg4NjE5OTk1QFVLRENYMDAxLnVrLmludC5h dG9zb3JpZ2luLmNvbT4AAwAJWQEAAAALAAuACCAGAAAAAADAAAAAAAAARgAAAAADhQAAAAAAAAMA DIAIIAYAAAAAAMAAAAAAAABGAAAAABCFAAAAAAAAAwANgAggBgAAAAAAwAAAAAAAAEYAAAAAUoUA AH1uAQAeAA6ACCAGAAAAAADAAAAAAAAARgAAAABUhQAAAQAAAAQAAAA5LjAACwASgAggBgAAAAAA wAAAAAAAAEYAAAAADoUAAAAAAAADABOACCAGAAAAAADAAAAAAAAARgAAAAARhQAAAAAAAAMAFIAI IAYAAAAAAMAAAAAAAABGAAAAABiFAAAAAAAACwAVgAggBgAAAAAAwAAAAAAAAEYAAAAABoUAAAAA AAADABaACCAGAAAAAADAAAAAAAAARgAAAAABhQAAAAAAAAIB+A8BAAAAEAAAAHHEQImDsLJPiGPu Zqj3mv8CAfoPAQAAABAAAABxxECJg7CyT4hj7mao95r/AgH7DwEAAACSAAAAAAAAADihuxAF5RAa obsIACsqVsIAAG1zcHN0LmRsbAAAAAAATklUQfm/uAEAqgA32W4AAABFOlxEb2N1bWVudHMgYW5k IFNldHRpbmdzXHNraXBcTG9jYWwgU2V0dGluZ3NcQXBwbGljYXRpb24gRGF0YVxNaWNyb3NvZnRc T3V0bG9va1xvdXRsb29rLnBzdAAAAAMA/g8FAAAAAwANNP03AAACAX8AAQAAADEAAAAwMDAwMDAw MDcxQzQ0MDg5ODNCMEIyNEY4ODYzRUU2NkE4Rjc5QUZGMjQ4Njg1MDAAAAAAAwAGEF6OG6IDAAcQ TAQAAAMAEBABAAAAAwAREAEAAAAeAAgQAQAAAGUAAABDT01QSUxFV0lUSENTQy9UQVJHRVQ6TElC UkFSWU1ZQVNTRU1CTFlDUyxSRUdJU1RFUldJVEhSRUdBU01NWUFTU0VNQkxZRExML1RMQjpNWUFT U0VNQkxZVExCLEFORFRSWVRPAAAAAPuF ------=_NextPart_000_000D_01C2A875.CF884710-- From mhammond@skippinet.com.au Fri Dec 20 12:13:43 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Fri, 20 Dec 2002 23:13:43 +1100 Subject: [python-win32] Access to .NET components from Python (Was: Win32 COM starter book) In-Reply-To: <000c01c2a819$9c17cf10$530f8490@eden> Message-ID: <002101c2a821$3da29ed0$530f8490@eden> This is a multi-part message in MIME format. ------=_NextPart_000_0022_01C2A87D.711316D0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit typo: > very private. However, the "very public" isn't as bad as it > sounds - you are guaranteed to get the *except* object you I meant *exact* Mark. ------=_NextPart_000_0022_01C2A87D.711316D0 Content-Type: application/ms-tnef; name="winmail.dat" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="winmail.dat" eJ8+IiwMAQaQCAAEAAAAAAABAAEAAQeQBgAIAAAA5AQAAAAAAADoAAEIgAcAGAAAAElQTS5NaWNy b3NvZnQgTWFpbC5Ob3RlADEIAQ2ABAACAAAAAgACAAEGgAMADgAAANIHDAAUABcADQAAAAUAIgEB A5AGAJwFAAAmAAAACwACAAEAAAALACMAAAAAAAMAJgAAAAAACwApAAAAAAADAC4AAAAAAAMANgAA AAAAHgBwAAEAAABTAAAAW3B5dGhvbi13aW4zMl0gQWNjZXNzIHRvIC5ORVQgY29tcG9uZW50cyBm cm9tIFB5dGhvbiAoV2FzOiBXaW4zMiBDT00gc3RhcnRlciBib29rKQAAAgFxAAEAAAAbAAAAAcKo GZtUHdr4W0u0S3uHwbuSsDbpUAAB4nkgAAIBHQwBAAAAHwAAAFNNVFA6TUhBTU1PTkRAU0tJUFBJ TkVULkNPTS5BVQAACwABDgAAAABAAAYOAK5VIyGowgECAQoOAQAAABgAAAAAAAAAccRAiYOwsk+I Y+5mqPea/8KAAAADABQOAQAAAAsAHw4BAAAAAgEJEAEAAAAgAQAAHAEAAMYBAABMWkZ11BqPqQMA CgByY3BnMTI14jIDQ3RleAVBAQMB9/8KgAKkA+QHEwKAD/MAUARWPwhVB7IRJQ5RAwECAGNo4QrA c2V0MgYABsMRJfYzBEYTtzASLBEzCO8J97Y7GB8OMDURIgxgYwBQMwsJAWQzNhZQC6YgdHB5cG86 CqIKhAqAPkQgdgSQeSBwBRB2AmEOsC4gIEhvdwplHiEsHOBoZSAiTR4kdQJgDeAiIAQAboonBUBh BCBiYWQhEpZpBUEdtXMIYG5kBCA4LSB5CGAhEBggIGe+dQrAAHAOsAmAHOBvI3BLFCAfkyoOwGNl BTAq8CBvYmoFkAVAIwIdSvxJIAeAI8Ek0gDQJUAdSlJNCsBrLh1EfSlQHgBCEAEAAAAmAAAAPDAw MGMwMWMyYTgxOSQ5YzE3Y2YxMCQ1MzBmODQ5MEBlZGVuPgAAAAMACVkBAAAACwALgAggBgAAAAAA wAAAAAAAAEYAAAAAA4UAAAAAAAADAAyACCAGAAAAAADAAAAAAAAARgAAAAAQhQAAAAAAAAMADYAI IAYAAAAAAMAAAAAAAABGAAAAAFKFAAB9bgEAHgAOgAggBgAAAAAAwAAAAAAAAEYAAAAAVIUAAAEA AAAEAAAAOS4wAAsAEoAIIAYAAAAAAMAAAAAAAABGAAAAAA6FAAAAAAAAAwATgAggBgAAAAAAwAAA AAAAAEYAAAAAEYUAAAAAAAADABSACCAGAAAAAADAAAAAAAAARgAAAAAYhQAAAAAAAAsAFYAIIAYA AAAAAMAAAAAAAABGAAAAAAaFAAAAAAAAAwAWgAggBgAAAAAAwAAAAAAAAEYAAAAAAYUAAAAAAAAL ABuACCAGAAAAAADAAAAAAAAARgAAAACChQAAAQAAAAIB+A8BAAAAEAAAAHHEQImDsLJPiGPuZqj3 mv8CAfoPAQAAABAAAABxxECJg7CyT4hj7mao95r/AgH7DwEAAACSAAAAAAAAADihuxAF5RAaobsI ACsqVsIAAG1zcHN0LmRsbAAAAAAATklUQfm/uAEAqgA32W4AAABFOlxEb2N1bWVudHMgYW5kIFNl dHRpbmdzXHNraXBcTG9jYWwgU2V0dGluZ3NcQXBwbGljYXRpb24gRGF0YVxNaWNyb3NvZnRcT3V0 bG9va1xvdXRsb29rLnBzdAAAAAMA/g8FAAAAAwANNP03AAACAX8AAQAAADEAAAAwMDAwMDAwMDcx QzQ0MDg5ODNCMEIyNEY4ODYzRUU2NkE4Rjc5QUZGRTQ4ODg1MDAAAAAAAwAGECTF6XgDAAcQdQAA AAMAEBAAAAAAAwAREAEAAAAeAAgQAQAAAGUAAABUWVBPOlZFUllQUklWQVRFSE9XRVZFUixUSEUi VkVSWVBVQkxJQyJJU05UQVNCQURBU0lUU09VTkRTLVlPVUFSRUdVQVJBTlRFRURUT0dFVFRIRSpF WENFUFQqT0JKRUNUWU9VAAAAAF4w ------=_NextPart_000_0022_01C2A87D.711316D0-- From unifoam@total.net Fri Dec 20 15:04:17 2002 From: unifoam@total.net (George Vestergom) Date: Fri, 20 Dec 2002 10:04:17 -0500 Subject: [python-win32] Re: problems in returning parameters using a COM client References: <00c101c2a6f2$899e13d0$530f8490@eden> <000501c2a6fa$42bb4840$6908b4ac@grunt> <3E020EA9.8E90E4C7@total.net> <3E02207D.8090601@tallan.com> Message-ID: <3E033171.A70380FC@total.net> Don Dwiggins wrote: > > Jens B Jorgensen writes: > > Those parameters are most likely [in, out] params. This means you must pass > > something in. Try: > > > xpos, ypos = cd.GetPosition(0, 0) > > Adding a bit to Jens' comments: [in, out] params need special treatment to > avoid the need to modify a parameter in place. Python's approach is to have > you pass in the initial value, then get the updated value as part of the > result (which will be a sequence, beginning with the COM object's return > value, and containing all [in, out] and [out] params in left-to-right > order). For [out] params, it's a bit simpler: they'll just appear in the > result sequence. > > Also, a useful tool for working with COM components is Microsoft's OLE/COM Object > Viewer (http://www.microsoft.com/com/resources/oleview.asp). > > Enjoy, > -- -------------------------------------- Much thanks to Don Dwiggins and Jens B Jorgensen for their advice; however, trying out Jens idea: >>> xpos, ypos = cd.GetPosition(0, 0) results in this error message: Traceback (most recent call last): File "", line 1, in ? xpos,ypos=cd.GetPosition(0,0) File "", line 2, in GetPosition com_error: (-2147352571, 'Type mismatch.', None, 1) Both parameters in GetPosition are 'out'. I've even tried the following, giving the same above error message: >>> x = 0 >>> y = 0 >>> xpos, ypos = cd.GetPosition(x, y) # error There are about a dozen or so of methods which return values such as current size, line width, fill colour, etc. As a workaround, I think I'm going to create a COM object from Excel and have Python call a method from Excel which will call the GetPosition method in CorelDraw and store the results on a worksheet. Python can then retrieve the values from this sheet. Speed is not an issue here, and besides, Draw routines implemented in Python are just as fast as those using Corel's version of Basic. Thanks for the help, George Vestergom From jens.jorgensen@tallan.com Fri Dec 20 16:15:28 2002 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Fri, 20 Dec 2002 10:15:28 -0600 Subject: [python-win32] Access to .NET components from Python (Was: Win32 COM starter book) In-Reply-To: <000c01c2a819$9c17cf10$530f8490@eden> References: <000c01c2a819$9c17cf10$530f8490@eden> Message-ID: <3E034220.8030901@tallan.com> Mark Hammond wrote: >>Compile with csc /target:library MyAssembly.cs, register with >>regasm MyAssembly.dll /tlb:MyAssembly.tlb, and try to test it. Nope, >>OLE error 0x80131522. Google tells me that this means I need my >>assembly in the same directory as the executable! (That's Python, not >>the script - so definitely not where I'd like to put my random DLLs). >> >> > >Yeah, this is .NET for you. If you want it publically available, you must create a strongly named assembly and stick it in the GAC. There are 2 choices - very public or very private. However, the "very public" isn't as bad as it sounds - you are guaranteed to get the *except* object you compiled against, regardless of naming clashes, etc. > As an aside I was trying to do this same thing just to try it. I run regasm but I *still* can't get the object to create itself. It doesn't matter if the object is in the current directory or the python directory (same dir as python.exe). It still doesn't find it and I get 'Class not registered'. Is it absolutely necessary to stick it in the gac in order to be able to create it? This doesn't make sense to me because then why bother with regasm? I had regasm first do the .tlb thing and that didn't work so I generated the reg file and added it manually. The contents of the reg file show: REGEDIT4 [HKEY_CLASSES_ROOT\JTest] @="JTest" [HKEY_CLASSES_ROOT\JTest\CLSID] @="{AD4D463B-FC29-3FE5-B82D-569A34325989}" [HKEY_CLASSES_ROOT\CLSID\{AD4D463B-FC29-3FE5-B82D-569A34325989}] @="JTest" [HKEY_CLASSES_ROOT\CLSID\{AD4D463B-FC29-3FE5-B82D-569A34325989}\InprocServer32] @="C:\WINNT\System32\mscoree.dll" "ThreadingModel"="Both" "Class"="JTest" "Assembly"="JTest, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" "RuntimeVersion"="v1.0.3705" [HKEY_CLASSES_ROOT\CLSID\{AD4D463B-FC29-3FE5-B82D-569A34325989}\ProgId] @="JTest" [HKEY_CLASSES_ROOT\CLSID\{AD4D463B-FC29-3FE5-B82D-569A34325989}\Implemented Cate gories\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}] I checked in the registry to make sure it was really in there and sure enough it is. Looking at what gets registered I imagine mscoree.dll must peek back into the registry when CoGetClass is called so it can get the Class, Assembly, and Runtime Version vars. At that point I guess it would search the current directory for JTest.dll. It does not find it for me though: >>> from win32com.client import Dispatch >>> o = Dispatch('JTest') Traceback (most recent call last): File "", line 1, in ? File "C:\Python22\Lib\site-packages\win32com\client\__init__.py", line 92, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,c lsctx) File "C:\Python22\Lib\site-packages\win32com\client\dynamic.py", line 81, in _ GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python22\Lib\site-packages\win32com\client\dynamic.py", line 72, in _ GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.II D_IDispatch) pywintypes.com_error: (-2147221164, 'Class not registered', None, None) >>> and like I say I have a copy in the current directory where above was run from as well as a copy in c:\Python22 where python.exe is installed. Shouldn't the assembly get found? > > > >>OK, copy the thing there for now. >> >> >> >>>>>from win32com.client import Dispatch >>>>>net = Dispatch("CTest") >>>>>net.Test() >>>>> >>>>> >>Hola Mundo! >>What is your name: >>kjhas >>Buenos Dias, kjhas! >>Traceback (most recent call last): >> File "", line 1, in ? >>TypeError: 'NoneType' object is not callable >> >>Pretty good - it works. But what is the TypeError at the bottom? My C# >>code has finished OK. Is it something "on the way back" from .NET to >>Python? >> >> > >Yep - we are seeing a VB friendly implementation - thus "net.Test" is actually making the call (even though it looks like a property reference!) This function returns None, and we are trying to call it. > >Use EnsureDispatch() or makepy manually to get it working. > >Mark. > > -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" From kfarmer@thuban.org Fri Dec 20 19:45:35 2002 From: kfarmer@thuban.org (Keith J. Farmer) Date: Fri, 20 Dec 2002 11:45:35 -0800 Subject: [python-win32] Python.NET (was: Access to .NET components from Python) Message-ID: <8D9EC381F9E67E44B1A28256698D966B5FB5@nostromo.thuban.org> So has any work been done on a CLR version of Python, beyond rewriting the interpreter in C#? As I recall, the language would need to be changed a bit. From jens.jorgensen@tallan.com Fri Dec 20 20:33:16 2002 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Fri, 20 Dec 2002 14:33:16 -0600 Subject: [python-win32] Access to .NET components from Python (Was: Win32 COM starter book) In-Reply-To: <3E034220.8030901@tallan.com> References: <000c01c2a819$9c17cf10$530f8490@eden> <3E034220.8030901@tallan.com> Message-ID: <3E037E8C.2030806@tallan.com> Jens B. Jorgensen wrote: > Mark Hammond wrote: > >>> Compile with csc /target:library MyAssembly.cs, register with >>> regasm MyAssembly.dll /tlb:MyAssembly.tlb, and try to test it. Nope, >>> OLE error 0x80131522. Google tells me that this means I need my >>> assembly in the same directory as the executable! (That's Python, not >>> the script - so definitely not where I'd like to put my random DLLs). >>> >> >> >> Yeah, this is .NET for you. If you want it publically available, you >> must create a strongly named assembly and stick it in the GAC. There >> are 2 choices - very public or very private. However, the "very >> public" isn't as bad as it sounds - you are guaranteed to get the >> *except* object you compiled against, regardless of naming clashes, etc. >> > As an aside I was trying to do this same thing just to try it. I run > regasm but I *still* can't get the object to create itself. It doesn't > matter if the object is in the current directory or the python > directory (same dir as python.exe). It still doesn't find it and I get > 'Class not registered'. Is it absolutely necessary to stick it in the > gac in order to be able to create it? This doesn't make sense to me > because then why bother with regasm? I had regasm first do the .tlb > thing and that didn't work so I generated the reg file and added it > manually. [snip] Ok, sorry, sorry. Jumped the gun. I take it all back. Apparently I only *thought* I copied the .Net assembly .dll into c:\Python22. I must not have because after messing around with everything else in the world (and learning all about the GAC and signing keys and such in the process) I went back and /again/ copied the assembly .dll into c:\Python22\ and of course this time all works just fine. Doh. Well, at least I learned a bunch of other stuff in the process. -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" From avainder@codonics.com Fri Dec 20 21:12:11 2002 From: avainder@codonics.com (Adam Vainder) Date: Fri, 20 Dec 2002 16:12:11 -0500 Subject: [python-win32] Tkinter question Message-ID: <3E0387AB.A5C8F048@codonics.com> Hi all, I'm working with a Tkinter GUI in Windows. I would like to bind an event to the "X" window button (that one in the upper-right corner of a window that closes it). I want it to be able to do a couple other things before closing the window. How do I overrride that button? Specifically, what is its default name so that I can bind to it? Thanks in advance =) Adam From mhammond@skippinet.com.au Fri Dec 20 23:11:11 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Sat, 21 Dec 2002 10:11:11 +1100 Subject: [python-win32] Re: problems in returning parameters using a COM client In-Reply-To: <3E033171.A70380FC@total.net> Message-ID: <007001c2a87d$16d918e0$530f8490@eden> Try running makepy over the Corel object, or better, use win32com.client.gencache.EnsureDispatch() in place of win32com.client.Dispatch to create the object. > File "", line 2, in This implies your object is not using makepy - EnsureDispatch() should force that. However, if upon doing that you still get the same error, with the COM object being printed as "", then corel sucks and you must jump some extra hoops. These hoops will look something like: cd_mod = gencache.EnsureModule(...) cd = Dispatch("CorelDraw.Automation") print repr(cd) # Will print "" cd = cd_mod.Application(cd) print repr(cd) # Will print "" cd should now work correctly. Lotus notes has this same problem, so googling for "EnsureModule notes" is likely to find some good hits - but hopefully just switching to EnsureDispatch() will get everything working with byrefs. Mark. From wu2000@ch.tum.de Sat Dec 21 14:41:58 2002 From: wu2000@ch.tum.de (Dr. Wu Tao) Date: Sat, 21 Dec 2002 15:41:58 +0100 Subject: [python-win32] wxPython: wxSplitterWindow can not Unsplit or ReplaceWindow? Message-ID: <02122115503600.12084@server.theo.chemie.tu-muenchen.de> Dear friends, I meet a problem recently that in Win98 box I can change the content for wxSplitterWindow. The thing is, for the wxSplitterWindow object, splitte= r, from document one could use : splitter.ReplaceWindow(winobj1, winobj2) to change one of its 2 childs, the winobj is changed, but then the applic= ation crashed because a win32 error. I also test another way from document of wxWindows,=20 splitter.Unsplit(winobj1) then I split the splitter obj again. Thing is the same. "the winobj is changed, but then the application crashed because a win32 error" :-( I do not know if it is an error of myself(looks like, I try to figure it = out) or a bug here. Does anyone have use this method in win32, or anyone know = about some work code for this two function?=20 best regards, Tao=20 --=20 ------------------------------------ Dr. Tao Wu Lehrstuhl fuer Theoretische Chemie TU Muenchen Lichtenbergstr. 4 85747 Garching =20 Tel.: +49 89 289 - 13609 Fax.: +49 89 289 - 13622 e-mail: wu2000@ch.tum.de ------------------------------------ From tony@tcapp.com Sun Dec 22 06:49:23 2002 From: tony@tcapp.com (Tony Cappellini) Date: Sat, 21 Dec 2002 22:49:23 -0800 Subject: [python-win32] Python-w32 startup configuration- repost Message-ID: <5.1.0.14.0.20021221224838.023c8808@smtp.sbcglobal.net> I want to configure python-w32 to startup in the directory where I have my python scripts,as well as change the default background editor color, but don't know which startup script to edit,. After browsing the Python Path, from the PythonWin IDE, I see many potential files that look like typical initialization files. E:\apps\Python\Lib\site-packages\Pythonwin\pywin\__init__.py E:\apps\Python\Lib\site-packages\Pythonwin\pywin\framework\startup.py E:\apps\Python\Lib\site-packages\Pythonwin\start_pythonwin.pw Which if these is the correct one to edit, and should I merely make my changes to the very end of one of these files ? thanks Tony From tony@tcapp.com Sun Dec 22 07:13:31 2002 From: tony@tcapp.com (Tony Cappellini) Date: Sat, 21 Dec 2002 23:13:31 -0800 Subject: [python-win32] Python Win32 build 150- bottom lines not visible when window is not maximized Message-ID: <5.1.0.14.0.20021221230833.00b14ce8@smtp.sbcglobal.net> I'm using build 150 on a WIn32 machine. If the Python Win32 IDE is not maximized, you cannot see that last few lines. Also, when I type a module name, followed by a '.', and let the command line completion window be displayed, the dropdown box is not fully displayed. Has anyone else seen these types of problems ? thanks Tony From arosado@softhome.net Tue Dec 24 01:05:11 2002 From: arosado@softhome.net (Andres Rosado) Date: Mon, 23 Dec 2002 21:05:11 -0400 Subject: [python-win32] Re: Tkinter question Message-ID: <5.1.0.14.0.20021223210509.00c01d28@mail.softhome.net> On 12:00 PM 12/21/2002 -0500, the keyboard of python-win32-request@python.org emitted: >I'm working with a Tkinter GUI in Windows. > >I would like to bind an event to the "X" window button (that one in the >upper-right corner of a window that closes it). I want it to be able to >do a couple other things before closing the window. > >How do I overrride that button? Specifically, what is its default name >so that I can bind to it? Overwrite the quit() method. And remember to call Frame.quit() at the end. :) -- Andres Rosado Email: andresr@despammed.com ICQ: 66750646 Homepage: http://andres980.tripod.com/ You said it once yourself. Once you said that a dream is an answer to a question we haven't learned how to ask yet. You do good work Mulder. -- Scully, "The X-Files: Paper Hearts" From d.l.dwiggins@computer.org Sun Dec 22 22:48:13 2002 From: d.l.dwiggins@computer.org (Don Dwiggins) Date: Sun, 22 Dec 2002 22:48:13 +0000 (UTC) Subject: [python-win32] Re: problems in returning parameters using a COM client References: <00c101c2a6f2$899e13d0$530f8490@eden> <000501c2a6fa$42bb4840$6908b4ac@grunt> <3E020EA9.8E90E4C7@total.net> <3E02207D.8090601@tallan.com> <3E033171.A70380FC@total.net> Message-ID: George Vestergom writes: > however, trying out Jens idea: >>>> xpos, ypos = cd.GetPosition(0, 0) > results in this error message: > Traceback (most recent call last): > File "", line 1, in ? > xpos,ypos=cd.GetPosition(0,0) > File "", line 2, in > GetPosition > com_error: (-2147352571, 'Type mismatch.', None, 1) > Both parameters in GetPosition are 'out'. I've even tried the following, > giving the same above error message: >>>> x = 0 >>>> y = 0 >>>> xpos, ypos = cd.GetPosition(x, y) # error If both params are 'out', try it like this: "xpos, ypos = cd.GetPosition()"; if my understanding is correct, you only want to include 'in' or 'in/out' params in the argument list. That may be what the 'Type mismatch.' was trying to tell you. Mark's advice about getting the type library info compiled in with makepy, Ensure..., etc. are also useful. If you do that, then try things like the above in Pythonwin, you'll get popup information about the available methods of objects and their expected input params. Where the type library info is available, it's by far the best way to fly. Good hunting and happy holidays, -- Don Dwiggins "Experience is what you get when d.l.dwiggins@computer.org you were expecting something else." -- Seen on an office wall From tony@tcapp.com Tue Dec 24 06:06:52 2002 From: tony@tcapp.com (Tony Cappellini) Date: Mon, 23 Dec 2002 22:06:52 -0800 Subject: [python-win32] Setting PYTHONSTARTUP Message-ID: <5.1.0.14.0.20021223220338.02416678@smtp.sbcglobal.net> I've added the PYTHONSTARTUP variable to control panel, on Win2000,and put a print statement in the file, so I know IF it's being executed. After launching PythonWin, I never see the print statement, nor the effects from changing directories, which I've also added to the file pointed to by PYTHONSTARTUP.. Strangely enough, neither IDLE, Ipython, nor PythonW32 see the startup file, so what am I doing wrong ? thanks From Petr Gladkikh" Hello. I have discovered a bug (at least I think it is a bug) in win32com.client module. One of minimal exploits is as follows <<< def a(): pass def b(): pass def c(): pass def d(): pass def A(): a = win32com.client.Dispatch("SourceSafe") def B(): b = win32com.client.Dispatch("MSDEV.APPLICATION") >>> This code causes access violation in python. (Note: with less number of procedures before "def A():" it forks normally) Other variations of this code throw following exception: <<< Traceback (most recent call last): File "autobuild.py", line 1, in ? import win32com.client File "C:\PROGRA~1\Python22\lib\site-packages\win32com\client\__init__.py", line 12, in ? import dynamic, gencache, pythoncom File "C:\PROGRA~1\Python22\lib\site-packages\win32com\client\dynamic.py", line 22, in ? import pythoncom File "C:\PROGRA~1\Python22\lib\site-packages\pythoncom.py", line 18, in ? __import("pythoncom") File "C:\PROGRA~1\Python22\lib\site-packages\pythoncom.py", line 10, in __import h = win32api.LoadLibrary(filename) pywintypes.error: (998, 'LoadLibrary', 'Invalid access to memory location.') >>> Do anyone know what is the problem? Thanks for your attention :) Petr From jens.jorgensen@tallan.com Tue Dec 24 15:06:53 2002 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Tue, 24 Dec 2002 09:06:53 -0600 Subject: [python-win32] Setting PYTHONSTARTUP In-Reply-To: <5.1.0.14.0.20021223220338.02416678@smtp.sbcglobal.net> References: <5.1.0.14.0.20021223220338.02416678@smtp.sbcglobal.net> Message-ID: <3E08780D.2040706@tallan.com> Just as a sanity check have you verified that the env variable is being passed to python? import os print os.environ['PYTHONSTARTUP'] Tony Cappellini wrote: > > I've added the PYTHONSTARTUP variable to control panel, on Win2000,and > put > a print statement in the file, so I know IF it's being executed. > After launching PythonWin, I never see the print statement, nor the > effects from changing directories, which I've also added to the file > pointed to by PYTHONSTARTUP.. > > Strangely enough, neither IDLE, Ipython, nor PythonW32 see the startup > file, so what am I doing wrong ? > > > thanks > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" From Jim.Vickroy@noaa.gov Tue Dec 24 15:39:06 2002 From: Jim.Vickroy@noaa.gov (Jim Vickroy) Date: Tue, 24 Dec 2002 08:39:06 -0700 Subject: [python-win32] Setting PYTHONSTARTUP References: <5.1.0.14.0.20021223220338.02416678@smtp.sbcglobal.net> Message-ID: <3E087F9A.F8FC8F60@noaa.gov> Tony, I believe PYTHONSTARTUP is only used by the interactive **command** line interpreter; if you enter *python* on a command line, you should see your print statement. Tony Cappellini wrote: > I've added the PYTHONSTARTUP variable to control panel, on Win2000,and put > a print statement in the file, so I know IF it's being executed. > After launching PythonWin, I never see the print statement, nor the effects > from changing directories, which I've also added to the file pointed to by > PYTHONSTARTUP.. > > Strangely enough, neither IDLE, Ipython, nor PythonW32 see the startup > file, so what am I doing wrong ? > > thanks > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From robin@jessikat.fsnet.co.uk Tue Dec 24 15:19:50 2002 From: robin@jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 24 Dec 2002 15:19:50 +0000 Subject: [python-win32] (no subject) In-Reply-To: References: Message-ID: <5TqfzWAWsHC+Ewny@jessikat.demon.co.uk> In message , Petr Gladkikh writes >Hello. ..... Your code has no effect on my machine, probably because nothing is being executed. Perhaps we should call A() and B()? Even if I insert import win32com.client at the top and A();B() at the bottom I just get a normal error because I don't have SourceSafe. -- Robin Becker From unifoam@total.net Tue Dec 24 18:26:34 2002 From: unifoam@total.net (George Vestergom) Date: Tue, 24 Dec 2002 13:26:34 -0500 Subject: [python-win32] Re: problems in returning parameters using a COM client References: <007001c2a87d$16d918e0$530f8490@eden> Message-ID: <3E08A6DA.8B24F9@total.net> Mark Hammond wrote: > > Try running makepy over the Corel object, or better, use > win32com.client.gencache.EnsureDispatch() in place of > win32com.client.Dispatch to create the object. > > > File "", line 2, in > > This implies your object is not using makepy - EnsureDispatch() should force > that. However, if upon doing that you still get the same error, with the > COM object being printed as "", then corel sucks and you must > jump some extra hoops. These hoops will look something like: > > cd_mod = gencache.EnsureModule(...) > cd = Dispatch("CorelDraw.Automation") > print repr(cd) # Will print "" > cd = cd_mod.Application(cd) > print repr(cd) # Will print "" > > cd should now work correctly. Lotus notes has this same problem, so > googling for "EnsureModule notes" is likely to find some good hits - but > hopefully just switching to EnsureDispatch() will get everything working > with byrefs. ------------------------------------------------ Mark, Thanks for the tip. It WORKS! Here's what I ended up with: >>> from win32com.client import Dispatch, gencache >>> cdm = gencache.EnsureModule('{C8E9D4E1-181F-11CE-B115-00C0F002D9E5}', 0, 6, 0)) >>> d = Dispatch('CorelDraw.automation.6') >>> cd = cdm.IDrawAutomate(d) >>> print cd Now when I draw a rectangle, I can get the current position using: >>> cd.GetPosition() without problem. All the other methods such as GetSize, GetOutline, etc. which return various number of parameters work as well. For those who are using (still!) CorelDraw 6 like myself, the entry point is through the IDrawAutomate object. There is no Application object for this version. CorelDraw versions 9 and up uses Microsoft's Visual Basic for Applications and (I'm assuming) have an object model similar to MS Office applications such as Excel, Word, etc. Thanks to Don Dwiggins for his suggestions as well. Merry Christmas and best wishes for the New Year! Yours truly, George Vestergom From Petr Gladkikh" Hello. It seems that it is rare problem. But to be more precise I'd like to point out that crash is happen excactly when executing this code. That is I have file a.py containing excactly following 7 lines (and only these lines): import win32com.client def a(): pass def b(): pass def c(): pass def d(): pass def A(): a = win32com.client.Dispatch("") def B(): a = win32com.client.Dispatch("") Then at DOS prompt I type python.exe a.py then python interpreter chrashes due to access violation. Had I removed any single line nothing strange happens. My guess is that there are either some binary incompatibilities either it is (again :) bug in the module (more precise, in module initialisation). I have installed Python-2.2.2 and win32all-150 on Win2000. Following script (thanks to advise of "Jim Vickroy" ): def a(): pass def b(): pass def c(): pass def d(): pass import win32com.client def A(): a = win32com.client.Dispatch("") def B(): a = win32com.client.Dispatch("") Works fine on my machine too. But in the best of the worlds reason of this behaviour should be located. (I don't like workarounds :) Petr. From robin@reportlab.com Wed Dec 25 09:23:58 2002 From: robin@reportlab.com (Robin Becker) Date: Wed, 25 Dec 2002 09:23:58 +0000 Subject: [python-win32] Python crash In-Reply-To: References: Message-ID: <2DUcXJAukXC+Ewmm@jessikat.fsnet.co.uk> In message , Petr Gladkikh writes .... I tried your script exactly C:\Tmp>cat a.py import win32com.client def a(): pass def b(): pass def c(): pass def d(): pass def A(): a = win32com.client.Dispatch("") def B(): a = win32com.client.Dispatch("") C:\Tmp>python.exe a.py C:\Tmp> and no crash. I have win2000 sp3, Python 2.2.2, Pythonwin build 148 -- Robin Becker From Petr Gladkikh" Message-ID: Hello. If there is someone who still curious :) I have installed ActiveState's binaries from ActivePython-2.2.2-224-win32-ix86.msi. And now my program works fine. It was likely some binary incompatibilities in the code. Previous installation was: win32all.exe installed after Python-2.2.2.exe. Petr. From robin@reportlab.com Wed Dec 25 15:12:04 2002 From: robin@reportlab.com (Robin Becker) Date: Wed, 25 Dec 2002 15:12:04 +0000 Subject: [python-win32] Re: Python crash In-Reply-To: References: <5TqfzWAWsHC+Ewny@jessikat.demon.co.uk> Message-ID: <5ouv9LAErcC+Ew0h@jessikat.fsnet.co.uk> In message , Petr Gladkikh writes >Hello. > >If there is someone who still curious :) > >I have installed ActiveState's binaries from ActivePython- >2.2.2-224-win32-ix86.msi. >And now my program works fine. It was likely some binary incompatibilities in >the code. Previous installation was: win32all.exe installed after Python- >2.2.2.exe. > > Petr. must've been a glitchoid! -- Robin Becker From thomas_barket@yahoo.com Thu Dec 26 09:45:18 2002 From: thomas_barket@yahoo.com (Thomas Barket) Date: Thu, 26 Dec 2002 01:45:18 -0800 (PST) Subject: [python-win32] exactly how to pass a vb6 form to python Message-ID: <20021226094518.50231.qmail@web40811.mail.yahoo.com> hello, ive seen lots of examples, esp in the python win32 book) of how to access a python COM server by a VB6 COM client to create nice gui that uses python as its core analytical engine. however, i am interested in the reverse: to control a VB6 gui from python. i have read people say they pass a VB6 form to python, however i am not able to do this. for instance, in a VB6 project, i have a form called "SomeForm" and a class called "SomeClass" (see below). when i compile this as an activex exe, i can successfully load the activex control and i can successfully display the form by running the "ShowForm" method of the "SomeClass" class. My problem is that i cant figure out how to pass the form back to python so python can control it directly. i tried the "GiveAccess" method for "SomeClass" below but i get a compilation error telling me that i cannot use private object modules in public object modules as a return type. VB6's object browser definitely says the SomeForm is a Private class, and i cannot figure out how to make it public. what am i doing wrong here? is there some simple, contrived example for how to successfully pass a VB6 form into python, so python can control its methods and attributes? (Ive seen Andy Robinson's nice Doubletalk example but that doesnt help me bc that is based on using python as a COM server and VB6 as the COM client. I see how he manages to pass a form back to the python COM server but that isnt what i want bc i dont want a python COM server.) TIA, Tom Barket thomas_barket@yahoo.com ***** SomeClass has the following methods: ***** Public Function ShowForm() SomeForm.Visible = True End Function 'The following wont compile: 'Public Function GiveAccess() As Form ' GiveAccess2 = SomeForm 'End Function ***** The module has the following: ***** Sub Main() Dim obj As New SomeClass obj.ShowForm End Sub __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From tbarket@OptOnline.net Thu Dec 26 09:34:19 2002 From: tbarket@OptOnline.net (Thomas Barket) Date: Thu, 26 Dec 2002 01:34:19 -0800 (PST) Subject: [python-win32] exactly how to pass a vb6 form to python Message-ID: <20021226093419.78149.qmail@web40804.mail.yahoo.com> hello, ive seen lots of examples, esp in the python win32 book) of how to access a python COM server by a VB6 COM client to create nice gui that uses python as its core analytical engine. however, i am interested in the reverse: to control a VB6 gui from python. i have read people say they pass a VB6 form to python, however i am not able to do this. for instance, in a VB6 project, i have a form called "SomeForm" and a class called "SomeClass" (see below). when i compile this as an activex exe, i can successfully load the activex control and i can successfully display the form by running the "ShowForm" method of the "SomeClass" class. My problem is that i cant figure out how to pass the form back to python so python can control it directly. i tried the "GiveAccess" method for "SomeClass" below but i get a compilation error telling me that i cannot use private object modules in public object modules as a return type. VB6's object browser definitely says the SomeForm is a Private class, and i cannot figure out how to make it public. what am i doing wrong here? is there some simple, contrived example for how to successfully pass a VB6 form into python, so python can control its methods and attributes? (Ive seen Andy Robinson's nice Doubletalk example but that doesnt help me bc that is based on using python as a COM server and VB6 as the COM client. I see how he manages to pass a form back to the python COM server but that isnt what i want bc i dont want a python COM server.) TIA, Tom Barket thomas_barket@yahoo.com ***** SomeClass has the following methods: ***** Public Function ShowForm() SomeForm.Visible = True End Function 'The following wont compile: 'Public Function GiveAccess() As Form ' GiveAccess2 = SomeForm 'End Function ***** The module has the following: ***** Sub Main() Dim obj As New SomeClass obj.ShowForm End Sub __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From Jim.Vickroy@noaa.gov Thu Dec 26 15:35:20 2002 From: Jim.Vickroy@noaa.gov (Jim Vickroy) Date: Thu, 26 Dec 2002 08:35:20 -0700 Subject: [python-win32] Python crash References: Message-ID: <3E0B21B8.D2B90FAA@noaa.gov> Hello Petr, I ran your **exact** example (5 times) on a Win 2000 machine (with service pack 3 installed), and it did not crash. I am puzzled as to why the position of the import statement should make a difference in this case. During these tests, I had 17 other processes active on the machine. Petr Gladkikh wrote: > Hello. > > It seems that it is rare problem. But to be more precise I'd like to point out that crash is happen excactly when executing this code. That is I have file a.py containing excactly following 7 lines (and only these lines): > import win32com.client > def a(): pass > def b(): pass > def c(): pass > def d(): pass > def A(): a = win32com.client.Dispatch("") > def B(): a = win32com.client.Dispatch("") > > Then at DOS prompt I type > python.exe a.py > > then python interpreter chrashes due to access violation. > Had I removed any single line nothing strange happens. My guess is that there are either some binary incompatibilities either it is (again :) bug in the module (more precise, in module initialisation). > I have installed Python-2.2.2 and win32all-150 on Win2000. > > Following script (thanks to advise of "Jim Vickroy" ): > def a(): pass > def b(): pass > def c(): pass > def d(): pass > import win32com.client > def A(): a = win32com.client.Dispatch("") > def B(): a = win32com.client.Dispatch("") > > Works fine on my machine too. But in the best of the worlds reason of this behaviour should be located. (I don't like workarounds :) > > Petr. > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From rothwell@holly-springs.nc.us Thu Dec 26 22:20:47 2002 From: rothwell@holly-springs.nc.us (Michael Rothwell) Date: Thu, 26 Dec 2002 17:20:47 -0500 Subject: [python-win32] ASP, Python 2.2 Message-ID: <3E0B80BF.4060303@holly-springs.nc.us> Hi all, I'm using Python 2.2 (ActiveState version) with IIS/ASP on Windows 2000 and NT4. I'm having a pair of problems I've not been able to resolve satisfactorily, but I imagine someone here has a solution. 1) sys.path doesn't include the current directory I cannot import a module in the local directory of the ASP script unless I first sys.path.append() the current directory. 2) page displays once, then doesn't display again. The first time a access an ASP page from a browser, it runs properly and displays the contents I would expect. The second time, it doesn't return anything but this: updating the timestamp on the .asp file makes it work again -- once. What can I do to fix this? Thanks, Michael From rothwell@holly-springs.nc.us Thu Dec 26 22:17:46 2002 From: rothwell@holly-springs.nc.us (Michael Rothwell) Date: Thu, 26 Dec 2002 17:17:46 -0500 Subject: [python-win32] ASP, Python 2.2 Message-ID: <3E0B800A.2030305@holly-springs.nc.us> I'm using Python 2.2 (ActiveState version) with IIS/ASP on Windows 2000 and NT4. I'm having a pair of problems I've not been able to resolve satisfactorily. 1) sys.path doesn't include the current directory I cannot import a module in the local directory of the ASP script unless I first sys.path.append() the current directory. 2) page displays once, then doesn't display again. The first time a access an ASP page from a browser, it runs properly and displays the contents I would expect. The second time, it doesn't return anything but this: updating the timestamp on the .asp file makes it work again -- once. What can I do to fix this? Thanks, Michael From tony@tcapp.com Fri Dec 27 07:44:32 2002 From: tony@tcapp.com (Tony Cappellini) Date: Thu, 26 Dec 2002 23:44:32 -0800 Subject: [python-win32] Dual posts ?? (was exactly how to pass a vb6 form to python) Message-ID: <5.1.0.14.0.20021226234313.04b26de0@smtp.sbcglobal.net> From: Thomas Barket To: python-win32@python.org exactly how to pass a vb6 form to python Why is it that many messages a posted to the lit twice ??? Can the list administrators fix this ? Thanks Tony From thomas_barket@yahoo.com Sat Dec 28 10:46:38 2002 From: thomas_barket@yahoo.com (Thomas Barket) Date: Sat, 28 Dec 2002 02:46:38 -0800 (PST) Subject: [python-win32] number of arguments to CreateControl Message-ID: <20021228104638.75917.qmail@web40808.mail.yahoo.com> ive noticed that the function call CreateControl, used to instantiate activex controls, permits only 6 arguments instead of the usual 10. class Control (in activex.py) has the following: def CreateControl(self, windowTitle, style, rect, parent, id): clsid = str(self._GetControlCLSID()) self.__dict__["_obj_"] = win32ui.CreateControl(clsid, windowTitle, style, rect, parent, id) ===== tbarket@OptOnline.net __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From thomas_barket@yahoo.com Sat Dec 28 10:46:39 2002 From: thomas_barket@yahoo.com (Thomas Barket) Date: Sat, 28 Dec 2002 02:46:39 -0800 (PST) Subject: [python-win32] number of arguments to CreateControl Message-ID: <20021228104639.75921.qmail@web40808.mail.yahoo.com> ive noticed that the function call CreateControl, used to instantiate activex controls, permits only 6 arguments instead of the usual 10. class Control (in activex.py) has the following: def CreateControl(self, windowTitle, style, rect, parent, id): clsid = str(self._GetControlCLSID()) self.__dict__["_obj_"] = win32ui.CreateControl(clsid, windowTitle, style, rect, parent, id) ===== tbarket@OptOnline.net __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From thomas_barket@yahoo.com Sat Dec 28 11:51:19 2002 From: thomas_barket@yahoo.com (Thomas Barket) Date: Sat, 28 Dec 2002 03:51:19 -0800 (PST) Subject: [python-win32] number of arguments to CreateControl Message-ID: <20021228115119.96289.qmail@web40807.mail.yahoo.com> sorry, i accidently sent this message a moment ago before it was composed. thats what happens at 6 am. here is what i mean to submit: ive noticed that the CreateControl, used to instantiate activex controls, permits only 6 arguments instead of the usual 9. the class Control (in activex.py) has the following: def CreateControl(self, windowTitle, style, rect, parent, id): clsid = str(self._GetControlCLSID()) self.__dict__["_obj_"] = win32ui.CreateControl(clsid, windowTitle, style, rect, parent, id) although in the win32win.cpp file, the !pWnd->CreateControl(clsid, szWndName, style, rect, pWndParent, id, NULL, bStorage, T2OLE(szLicKey)) call attempts to use all 9 arguments, and is already written to correctly parse these extra parameters from python. i wonder if it would be okay (ie, not break anything), to make a v small change to activex.py: def CreateControl(self, windowTitle, style, rect, parent, id, lic_string=None): clsid = str(self._GetControlCLSID()) self.__dict__["_obj_"] = win32ui.CreateControl(clsid, windowTitle, style, rect, parent, id, lic_string) klass = self._GetDispatchClass() dispobj = klass(win32uiole.GetIDispatchForWindow(self._obj_)) self.HookOleEvents() self.__dict__["_dispobj_"] = dispobj im only adding the lic_string=None as the last argument and adding lic_string to the win32ui.CreateControl call. however, i cannot verify it actually does anything. i have an activex control that requires a license string that will work fine without one under pythonwin, but i cant get it to work at all (even with the license string) under straight console python (it shows me a win32ui module message box that says the control could not be created.) has anyone seen something like this before? Tom thomas_barket@yahoo.com __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From d.l.dwiggins@computer.org Mon Dec 30 02:42:20 2002 From: d.l.dwiggins@computer.org (Don Dwiggins) Date: Mon, 30 Dec 2002 02:42:20 +0000 (UTC) Subject: [python-win32] Re: ASP, Python 2.2 References: <3E0B800A.2030305@holly-springs.nc.us> Message-ID: Michael Rothwell writes: > 2) page displays once, then doesn't display again. > The first time a access an ASP page from a browser, it runs properly and > displays the contents I would expect. The second time, it doesn't return > anything but this: > > updating the timestamp on the .asp file makes it work again -- once. What > can I do to fix this? This is a known problem in win32all; you can probably find a discussion of it in the archives. The short answer is: get the file "framework.py" from win32all build 133 (do a search to find the directory it's in) to replace the one in the distribution. Mark recommended 150, but that one didn't work for me. Sorry I don't have more explicit info; I'm away from the office. -- Don Dwiggins "The truth will make you free, d.l.dwiggins@computer.org but first it will make you miserable" -- Tom DeMarco From d.l.dwiggins@computer.org Mon Dec 30 02:48:01 2002 From: d.l.dwiggins@computer.org (Don Dwiggins) Date: Mon, 30 Dec 2002 02:48:01 +0000 (UTC) Subject: [python-win32] Re: number of arguments to CreateControl References: <20021228115119.96289.qmail@web40807.mail.yahoo.com> Message-ID: Thomas Barket writes: > ive noticed that the CreateControl, used > to instantiate activex controls, permits only 6 > arguments instead of the usual 9. > the class Control (in activex.py) has the following: > def CreateControl(self, windowTitle, style, rect, > parent, id): > clsid = str(self._GetControlCLSID()) > self.__dict__["_obj_"] = > win32ui.CreateControl(clsid, windowTitle, style, rect, > parent, id) > although in the win32win.cpp file, the > !pWnd->CreateControl(clsid, szWndName, style, rect, > pWndParent, id, NULL, bStorage, T2OLE(szLicKey)) call > attempts to use all 9 arguments, and is already > written to correctly parse these extra parameters from > python. Just a thought: are the "missing" arguments declared "out" in the interface? If so, it's right that they're not passed in -- the win32 UI package will return a sequence from a call to that function, which includes the values of all "in/out" and "out" arguments. If that's not the case, just ignore my ramblings... -- Don Dwiggins "Solvitur Ambulando" d.l.dwiggins@computer.org From tony@tcapp.com Mon Dec 30 03:08:15 2002 From: tony@tcapp.com (Tony Cappellini) Date: Sun, 29 Dec 2002 19:08:15 -0800 Subject: [python-win32] Setting PYTHONSTARTUP In-Reply-To: <3E08780D.2040706@tallan.com> References: <5.1.0.14.0.20021223220338.02416678@smtp.sbcglobal.net> <5.1.0.14.0.20021223220338.02416678@smtp.sbcglobal.net> Message-ID: <5.1.0.14.0.20021229190700.00b1bfd0@tcapp.com> > > >>Just as a sanity check have you verified that the env variable is being > passed to python? > > >>import os > >>print os.environ['PYTHONSTARTUP'] Yes. PythonWin see's the file I've created which is specified by this variable. But the effects are not seen. Any suggestions ? >Tony Cappellini wrote: > >> >>I've added the PYTHONSTARTUP variable to control panel, on Win2000,and put >>a print statement in the file, so I know IF it's being executed. >>After launching PythonWin, I never see the print statement, nor the >>effects from changing directories, which I've also added to the file >>pointed to by PYTHONSTARTUP.. >> >>Strangely enough, neither IDLE, Ipython, nor PythonW32 see the startup >>file, so what am I doing wrong ? >> >> >>thanks >> >> >>_______________________________________________ >>Python-win32 mailing list >>Python-win32@python.org >>http://mail.python.org/mailman/listinfo/python-win32 > > >-- >Jens B. Jorgensen >jens.jorgensen@tallan.com > >"With a focused commitment to our clients and our people, we deliver value >through customized technology solutions" > > From tony@tcapp.com Mon Dec 30 07:13:11 2002 From: tony@tcapp.com (Tony Cappellini) Date: Sun, 29 Dec 2002 23:13:11 -0800 Subject: [python-win32] Broken PythonWin environment Message-ID: <5.1.0.14.0.20021229231130.00b1d7f0@smtp.sbcglobal.net> In an effort to get PythonWin to cd to my scripts directory on startup, I've broken something in the environment. Now when I launch PythonWin, I see this error message, but no PythonWin IDE exceptions.ImportError: No module named string> Would someone please help ?? From robinjim@earthlink.net Mon Dec 30 10:56:16 2002 From: robinjim@earthlink.net (robin and jim) Date: Mon, 30 Dec 2002 03:56:16 -0700 Subject: [python-win32] Broken PythonWin environment References: <5.1.0.14.0.20021229231130.00b1d7f0@smtp.sbcglobal.net> Message-ID: <001901c2aff2$14d735f0$b8279c40@robinjim> Hi Tony, Is there some reason why you can not uninstall PythonWin and then reinstall it? ----- Original Message ----- From: "Tony Cappellini" To: Sent: Monday, December 30, 2002 12:13 AM Subject: [python-win32] Broken PythonWin environment > > > In an effort to get PythonWin to cd to my scripts directory on startup, > I've broken something in the environment. > Now when I launch PythonWin, I see this error message, but no PythonWin IDE > > exceptions.ImportError: No > module named string> > > Would someone please help ?? > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From BreuerA@paxfn.net Mon Dec 30 13:33:49 2002 From: BreuerA@paxfn.net (Breuer, Andre (Germany)) Date: Mon, 30 Dec 2002 08:33:49 -0500 Subject: [python-win32] (no subject) Message-ID: <8118B701F247D21191CE0000F81EDEFD0B435B6D@nems06.nawcad.navy.mil> Hey folks, I'd like to use Excel spread sheets for some .csv data files. Here is my problem. I gathered few commands e.g. start Excel, open new spread sheet, etc. It was not easy to get each single command. Do you have any idea how to get a lists,etc. which includes most of the useful commands for using Excel? I am also interested in commands for Acrobat Reader and MSWord. I would appreciate some help. Thanks Andre' Breuer <<...OLE_Obj...>> German Aerospace Engineer Assigned to PMA-261 Phone (301) 757 5760 FAX (301) 757 5109 <<...OLE_Obj...>> From AddisonN@iti-ab.com Mon Dec 30 18:09:55 2002 From: AddisonN@iti-ab.com (Nick Addison - IT (International)) Date: Mon, 30 Dec 2002 18:09:55 -0000 Subject: [python-win32] [Newbie] win32service.OpenService... Message-ID: <6995CDA63A54D511B8B80006291686FB28A810@ISI01> Where can I find the values acceptable for the 'DesiredAccess' arguement? I thought it would be obvious from scanning win32con... but it didn't turn out like that. ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. Information Systems International (ISI) +44 (0)20 7315 8500 **********************************************************************