From mhammond@skippinet.com.au Tue Oct 1 05:23:11 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Tue, 1 Oct 2002 14:23:11 +1000 Subject: [python-win32] COM question In-Reply-To: <3D987992.5090604@tallan.com> Message-ID: > Robert Olson wrote: > > > I've tried on and off to use pythonCOM to access the control software > > for a Gentner AP device (cf www.clearone.com). I ran into problems, > > and ended up getting the following response from the vendor: > > > >> We have looked at the problem and and it relates to how > automation works > >> with late binding languages such as VB. APServe was not written to be > >> friendly with these languages. The call "Unit.CreateMeter(CHANNEL_1, > >> METERTYPE_LVL, GRP_I, Meter)" last argument (meter) is passed in > >> "ByVal". > >> VB's code completion sees this APServe COM interface method as ByVal > >> because > >> VB does not allow the Interface pointer, Meter, to be "Set" through the > >> argument list via instantiation of the COM object, COMAPMeter. > >> > >> The call will work fine with launguges such as Visual C++ or Delphi. > >> We did > >> not intend to have users writing software utilizing that interface and > >> therefore did not add the support in APServe. Unfortunutly, I do not > >> know > >> of a work around for this problem. I am not familiar enough with > >> Python to > >> make any recomendations there either. > > > > > > I'm wondering if that explanation makes sense, and if there's a way > > python could still be used (I'm pretty shaky on the actual details of > > COM under the covers). > > Python could certainly still be used. I'm pretty COM-savvy and I'm not > sure I understand at all the explanation above. I think it may be saying that as the param is "ByVal", VB uses normal object assignment "Let" semantics rather than "Set" for the param. Eg, kinda like saying: ob = Param CallFunc(ob) Rather than: Set ob = Param CallFunc(ob) People unlucky enough to be familiar with VB will recognise the sad, subtle difference. However, if this is true, I can see no reason why Python would fail - what error did you get? > However if you want to > get it working in Python you could always write a C++ extension module. > That should work just dandy. Naturally the problem is that if the > interface above is complex (and I'm guessing it is) you'll have a lot of > code to write although none of it should be that difficult. If you want to get dirty enough, you can coerce pythoncom to pass *any* type through IDispatch interfaces. makepy generated code calls _ApplyTypes_ - a cleverly crafted call to this function can almost certainly pass the object with the correct semantics, even if the IDL does not match the way the code actually operates. Of course, it is simply possible that win32com has never ever seen a "byval object" before. Mark. From olson@mcs.anl.gov Tue Oct 1 05:35:23 2002 From: olson@mcs.anl.gov (Bob Olson) Date: Mon, 30 Sep 2002 23:35:23 -0500 (CDT) Subject: [python-win32] COM question In-Reply-To: Message-ID: > However, if this is true, I can see no reason why Python would fail - what > error did you get? I didn't get an error, but I didn't get a value returned back (as I recall; it's been a couple months since I poked at this). > If you want to get dirty enough, you can coerce pythoncom to pass *any* type > through IDispatch interfaces. makepy generated code calls _ApplyTypes_ - a > cleverly crafted call to this function can almost certainly pass the object > with the correct semantics, even if the IDL does not match the way the code > actually operates. Of course, it is simply possible that win32com has never > ever seen a "byval object" before. Hm, I'll have to poke at this some more (later, am off on vacation for three weeks, whee!) --bob From mhammond@skippinet.com.au Tue Oct 1 06:11:57 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Tue, 1 Oct 2002 15:11:57 +1000 Subject: [python-win32] COM question In-Reply-To: Message-ID: > > However, if this is true, I can see no reason why Python would > > fail - what error did you get? > > I didn't get an error, but I didn't get a value returned back (as I > recall; it's been a couple months since I poked at this). Well, their IDL is at fault, and it clearly should be marked as [in,out]. All we should need to do is to get the makepy generated code for this function, and change the last "type tuple" for this function. It will be a tuple of, eg (pythoncom.VT_OBJECT, pythoncom.PARAMFLAG_FIN). Telling Python it is really _FIN | _FOUT should do the trick. Mark. From olson@mcs.anl.gov Tue Oct 1 06:14:15 2002 From: olson@mcs.anl.gov (Bob Olson) Date: Tue, 1 Oct 2002 00:14:15 -0500 (CDT) Subject: [python-win32] COM question In-Reply-To: Message-ID: cool - I will try that when I get back. thanks much! --bob On Tue, 1 Oct 2002, Mark Hammond wrote: > > > However, if this is true, I can see no reason why Python would > > > fail - what error did you get? > > > > I didn't get an error, but I didn't get a value returned back (as I > > recall; it's been a couple months since I poked at this). > > Well, their IDL is at fault, and it clearly should be marked as [in,out]. > All we should need to do is to get the makepy generated code for this > function, and change the last "type tuple" for this function. It will be a > tuple of, eg (pythoncom.VT_OBJECT, pythoncom.PARAMFLAG_FIN). Telling Python > it is really _FIN | _FOUT should do the trick. > > Mark. > > From cherry314159@yahoo.com Sat Oct 5 18:24:00 2002 From: cherry314159@yahoo.com (Jose Vasconcellos) Date: Sat, 5 Oct 2002 10:24:00 -0700 (PDT) Subject: [python-win32] Missing classes in TAPI COM type library Message-ID: <20021005172400.30722.qmail@web14310.mail.yahoo.com> I'm trying to interface to the TAPI COM interface and I noticed that there are several classes missing from the output of makepy.py. In particular, no class is generated for ITFileTerminalEvent even though there are references to it in the generated. Note: My development platform is Windows XP with TAPI 3.1 and python 2.2.1. Out of desperation, I used OCaml's olegen to see if it had the same problem but it generates the module interface correctly. Jose Vasconcellos __________________________________________________ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos & More http://faith.yahoo.com From dond@advancedmp.com Mon Oct 14 22:34:42 2002 From: dond@advancedmp.com (Don Dwiggins) Date: 14 Oct 2002 14:34:42 -0700 Subject: [python-win32] Re: Unable to use win32com on Ecco COM server despite success with VB and Perl COM References: <3CCC77CD.5F596EB1@uclink.berkeley.edu> Message-ID: Raymond: a couple of suggestions: - Get a copy of Microsoft's OleView (if you don't have it) -- among other things, it'll show you the type library for the server, and you can check the interfaces at a lower level than VB shows you. - Ask the question on the Yahoo EccoPro mailing list -- there are some developers there, including some Pythonistas. Happy hunting, -- Don Dwiggins "The capacity to blunder slightly is the d.l.dwiggins@computer.org real marvel of DNA." Lewis Thomas, The Medusa and the Snail From dond@advancedmp.com Mon Oct 14 23:12:12 2002 From: dond@advancedmp.com (Don Dwiggins) Date: 14 Oct 2002 15:12:12 -0700 Subject: [python-win32] Strange problem with CoUninitialize using threads and COM objects Message-ID: I have a COM component that contains a bunch of "agents", and a driver application that takes a list of agent names, fires off threads to call the requested agents, and collects the results as they finish. The problem I'm having is that about 90% of the time, when the first thread to finish calls CoUninitialize(), the application just dies quietly, I've wrapped everything in try...except blocks, and put print statements before almost every statement (with calls to flush the output) -- nothing gets printed after the offending call. If, however, I comment out the call to CoUninitialize(), everything works fine; I can run several agents, and they'll all complete properly, and the application will exit as it should. To go a little deeper, the thread logic is something like this (resultq is a Queue object passed in): class MyAgent(Thread): "The agent thread class" def __init__(self, name, info, resultq): Thread.__init__(self) self.name = name self.objname = name self.info = info self.resultq = resultq def run(self): "Get an agent object and run it" CoInitialize() # Let COM know we're here obj = GetAgent(self.objname) results = obj.GetResults(self.info['param']) self.resultq.put((self.info['URLDesc'], results)) CoUninitialize() # Tell COM we're done ... and the main thread does essentially: activeAgents = 0 resultQ = Queue() for name in namelist: info = {....} SearchAgent(name, info, resultQ).start() activeAgents += 1 while activeAgents > 0: agentname, results = resultQ.get() db.recordResults(agentname, results) activeAgents -= 1 sys.exit() (I've omitted the print statements and the try blocks, along with some other local processing code.) Any suggestions as to what I should try here, or why CoUninitialize should cause python to drop out the back door? I suppose I could just leave out the troublesome CoUninitialize, but I'm wondering what might bite me if I do. One more data point: when I run the app with "python -i", it still exits without taking me to the post-mortem prompt. Regards, -- Don Dwiggins "The truth will make you free, d.l.dwiggins@computer.org but first it will make you miserable" -- Tom DeMarco From victorh@nuix.com.au Tue Oct 15 01:33:20 2002 From: victorh@nuix.com.au (Victor Hadianto) Date: Tue, 15 Oct 2002 10:33:20 +1000 Subject: [python-win32] Closing Excel object. Message-ID: <000901c273e2$76b45c90$3cdea8c0@win2ksvr11> I have a python script running in an Apache web server that receives a binary file using form-post, convert it into a text file and print the result back to the browser. The code is like this: form = cgi.FieldStorage() item = form["file1"] value = tempfile.mktemp(".xls") convertedValue = tempfile.mktemp(".txt") ### Save files into disk ### x = win32com.client.Dispatch("Excel.Application") x.Workbooks.Open(value) x.ActiveWorkbook.SaveAs(convertedValue, -4158, 0) x.Quit() del x ### Print text file to browser os.remove(value) os.remove(convertedValue) Now the problem is even if I did x.Quit(), I can't actually "close" the Excel application. In my TaskManager I still see the Excel process running. The same trick works fine with Microsoft Word! Does anyone has any idea how to close Excel object using Python? Any help will be greatly appreciated. Victor From LEIYU1@motorola.com Fri Oct 18 23:23:52 2002 From: LEIYU1@motorola.com (Yu Lei-LEIYU1) Date: Fri, 18 Oct 2002 17:23:52 -0500 Subject: [python-win32] Asynchronous UDP socket programming Message-ID: Hi, Everyone, I tried to write asynchrous UDP socket program but failed. All the examples I found on the web for asynrhous socket programming is for TCP socket. Does UDP or TCP make a difference? Does anyone have any example code for asynchronous UDP socket program on Windows? Is there any other solutions than using select? Thanks. Lei From jens.jorgensen@tallan.com Fri Oct 18 23:41:27 2002 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Fri, 18 Oct 2002 17:41:27 -0500 Subject: [python-win32] Asynchronous UDP socket programming References: Message-ID: <3DB08E17.30002@tallan.com> The "Windows" way to do asynchronous sockets is to either call WSAAsyncSelect to tell winsock to post a windows message to a windows message queue (you pass an HWND) or you can call WSAEventSelect to have an Event object signalled. It looks liek WSAAsyncSelect is not available in the win32 extensions but WSAEventSelect is. However, select should work fine for you. I say that because I have written a fair amount of socket code (both UDP and TCP) that uses select and runs "asynchronously" (in the sense that the code would use select() rather than just calling recv() and waiting indeterminately). It worked fine for me. What's your problem exactly? Could you be a little more specific than just saying you failed? Could you perhaps send us code examples? Help us help you! Yu Lei-LEIYU1 wrote: >Hi, Everyone, > I tried to write asynchrous UDP socket program but failed. All the examples >I found on the web for asynrhous socket programming is for TCP socket. Does >UDP or TCP make a difference? Does anyone have any example code for >asynchronous UDP socket program on Windows? Is there any other solutions >than using select? > >Thanks. > >Lei > >_______________________________________________ >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 miracle@paradise.net.nz Sun Oct 20 19:27:48 2002 From: miracle@paradise.net.nz (Matthew Sherborne) Date: Mon, 21 Oct 2002 07:27:48 +1300 Subject: [python-win32] Asynchronous UDP socket programming References: Message-ID: <003701c27866$679ec190$0e01a8c0@JONAH> I know one difference between TCP and UDP. TCP has no size limitations to how much you can send in one go, and is guarunteed to arrive at the other side or error; UDP uses packets of some length (I don't know how much, I think it's not very big though, like the max is less than 1k), it is guarunteed that either all of each packet will arrive or none of each packet will arrive, but you don't get to find out unless you explicitly make the other end tell you some how. GBU Matthew Sherborne ----- Original Message ----- From: "Yu Lei-LEIYU1" To: Sent: Saturday, October 19, 2002 11:23 AM Subject: [python-win32] Asynchronous UDP socket programming > Hi, Everyone, > I tried to write asynchrous UDP socket program but failed. All the examples > I found on the web for asynrhous socket programming is for TCP socket. Does > UDP or TCP make a difference? Does anyone have any example code for > asynchronous UDP socket program on Windows? Is there any other solutions > than using select? > > Thanks. > > Lei > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From mhammond@skippinet.com.au Mon Oct 21 08:21:56 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Mon, 21 Oct 2002 17:21:56 +1000 Subject: [python-win32] Asynchronous UDP socket programming In-Reply-To: <3DB08E17.30002@tallan.com> Message-ID: > The "Windows" way to do asynchronous sockets is to either call > WSAAsyncSelect to tell winsock to post a windows message to a windows > message queue (you pass an HWND) or you can call WSAEventSelect to have > an Event object signalled. It looks liek WSAAsyncSelect is not available > in the win32 extensions but WSAEventSelect is. WSAAsyncSelect is in (recent, at least) win32file. Not that I know anything about socket programming, let alone async socket programming Mark. From Bill Witherspoon" I had a quick scan through the 2002 archive and couldn't find anything on this one. Please point me in the right direction. I'm automating some label printing out of a database. Basically, its about 7 lines on info on a 4"x4" label. I need to control the formating by line. ie. Line 1 font = 22, line 2 font = 18, etc. I've gotten the code to work if I use: myRange.InsertAfter(detailinfo['materialnumber']) myRange.Sentences(2).Font.Size = 18 myRange.Sentences(2).Font.Bold = 0 myRange.Sentences(2).Font.Name = "Arial" myRange.Sentences(2).ParagraphFormat.Alignment = 1 myRange.InsertAfter("\n") Unfortunately, the sentences property increments whenever a period or a newline occurs. Sometimes there's periods in the data which really screw up the output. I figured there's got to be an easier way. How can set the formatting line by line? Thanks, Bill. From dond@advancedmp.com Wed Oct 23 21:59:50 2002 From: dond@advancedmp.com (Don Dwiggins) Date: 23 Oct 2002 13:59:50 -0700 Subject: [python-win32] sys.path strangeness under IIS/ASP Message-ID: I have a local site setup, using a .pth file to point to my site files directory. This works fine under command line invocation of python, but not under ASP. There, none of my site directories show up. I've tried "import site" with no results. Any idea what's going on, and how to fix it? I don't want to hardcode the pathname of the site directory in my script, because it'll be deployed on a couple of machines with different setups. Thanks, -- Don Dwiggins "Experience is what you get when d.l.dwiggins@computer.org you were expecting something else." -- Seen on an office wall From gtalvola@nameconnector.com Wed Oct 23 22:53:10 2002 From: gtalvola@nameconnector.com (Geoffrey Talvola) Date: Wed, 23 Oct 2002 17:53:10 -0400 Subject: [python-win32] sys.path strangeness under IIS/ASP Message-ID: <61957B071FF421419E567A28A45C7FE5400F91@mailbox.nameconnector.com> Are you using Python 2.1.X? There was a bug like this that was fixed in Python 2.2. - Geoff > -----Original Message----- > From: Don Dwiggins [mailto:dond@advancedmp.com] > Sent: Wednesday, October 23, 2002 5:00 PM > To: python-win32@python.org > Subject: [python-win32] sys.path strangeness under IIS/ASP > > > I have a local site setup, using a .pth file to point to my site files > directory. This works fine under command line invocation of > python, but not > under ASP. There, none of my site directories show up. > > I've tried "import site" with no results. Any idea what's > going on, and how > to fix it? I don't want to hardcode the pathname of the site > directory in my > script, because it'll be deployed on a couple of machines > with different > setups. > > Thanks, > -- > > Don Dwiggins "Experience is what you get when > d.l.dwiggins@computer.org you were expecting something else." > -- Seen on an office wall > > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > From magnus@thinkware.se Wed Oct 23 23:16:07 2002 From: magnus@thinkware.se (Magnus Lycka) Date: Thu, 24 Oct 2002 00:16:07 +0200 Subject: [python-win32] Word Automation Question In-Reply-To: <005801c27ab9$70e74ba0$1833a8c0@plant02> Message-ID: <5.1.0.14.0.20021023235413.04332910@www.thinkware.se> At 13:27 2002-10-23 -0400, Bill Witherspoon wrote: >How can set the formatting line by line? I don't know enough of VB for Word to help with exactly what you ask for, but I have a few ideas on how to avoid your problem. I could possibly imagine that using "paragraph" instead of "sentence" might do the thing? I typically record macros interactively in word to see how things work. Then I either translate that to Python *OR* I run the Word macro from Python. In this case I might make a Word macro that typed a label with dummy values and did search and replace on that with my values from Python. --=20 Magnus Lyck=E5, Thinkware AB =C4lvans v=E4g 99, SE-907 50 UME=C5 tel: 070-582 80 65, fax: 070-612 80 65 http://www.thinkware.se/ mailto:magnus@thinkware.se From Bill Witherspoon" Message-ID: <00d601c27ae2$1d13a720$1833a8c0@plant02> Thanks for the reply. Here's the best I've come up with so far: (warning: ugly and not pythonic.... but it seems to work) ... myRange.SetRange(totallength,totallength) myRange.InsertAfter (labelinfo['metricsize'] + "\n") totallength = totallength + len(labelinfo['metricsize'] + "\n") myRange.Font.Size = 14 myRange.Font.Bold = 0 myRange.ParagraphFormat.Alignment = 1 myRange.Font.Name = "Arial" myRange.SetRange(totallength,totallength) myRange.InsertAfter (labelinfo['imperialsize'] + "\n") totallength = totallength + len(labelinfo['imperialsize'] + "\n") myRange.Font.Size = 14 myRange.Font.Bold = 0 myRange.ParagraphFormat.Alignment = 1 myRange.Font.Name = "Arial" and so on......... I basically repeat the same forumula over and over. I'll probably bury some of the repetition in a function, but I'd still like to believe there's a better way. I thought something like: myRange.Lines(1).Font.Size = 22 myRange.Lines(2).Font.Size = 50 #for lines 1, and 2 resp. or myDoc.Lines(1).... myDoc.Lines(2).... Thanks, Bill. ----- Original Message ----- From: "Magnus Lycka" To: "Bill Witherspoon" ; Sent: Wednesday, October 23, 2002 6:16 PM Subject: Re: [python-win32] Word Automation Question At 13:27 2002-10-23 -0400, Bill Witherspoon wrote: >How can set the formatting line by line? I don't know enough of VB for Word to help with exactly what you ask for, but I have a few ideas on how to avoid your problem. I could possibly imagine that using "paragraph" instead of "sentence" might do the thing? I typically record macros interactively in word to see how things work. Then I either translate that to Python *OR* I run the Word macro from Python. In this case I might make a Word macro that typed a label with dummy values and did search and replace on that with my values from Python. -- Magnus Lyckå, Thinkware AB Älvans väg 99, SE-907 50 UMEÅ tel: 070-582 80 65, fax: 070-612 80 65 http://www.thinkware.se/ mailto:magnus@thinkware.se _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From magnus@thinkware.se Wed Oct 23 23:43:30 2002 From: magnus@thinkware.se (Magnus Lycka) Date: Thu, 24 Oct 2002 00:43:30 +0200 Subject: [python-win32] Word Automation Question In-Reply-To: <00d601c27ae2$1d13a720$1833a8c0@plant02> References: <5.1.0.14.0.20021023235413.04332910@www.thinkware.se> Message-ID: <5.1.0.14.0.20021024003752.043355e0@www.thinkware.se> At 18:18 2002-10-23 -0400, Bill Witherspoon wrote: > myRange.InsertAfter (labelinfo['metricsize'] + "\n") Does the '\n' correspond to typing Shift-Enter? If you could make a paragraph break (like typing Enter in Word)? I think this would be: myRange.InsertAfter(labelinfo['metricsize']) myRange.InsertParagraphAfter() Then I think you could... >myRange.Lines(1).Font.Size =3D 22 >myRange.Lines(2).Font.Size =3D 50 #for lines 1, and 2 resp. ...use myRange.Paragraphs(1).Font.Size =3D 22 --=20 Magnus Lyck=E5, Thinkware AB =C4lvans v=E4g 99, SE-907 50 UME=C5 tel: 070-582 80 65, fax: 070-612 80 65 http://www.thinkware.se/ mailto:magnus@thinkware.se From dond@advancedmp.com Thu Oct 24 01:58:31 2002 From: dond@advancedmp.com (Don Dwiggins) Date: 23 Oct 2002 17:58:31 -0700 Subject: [python-win32] Re: sys.path strangeness under IIS/ASP References: <61957B071FF421419E567A28A45C7FE5400F91@mailbox.nameconnector.com> Message-ID: Geoffrey Talvola writes: > Are you using Python 2.1.X? There was a bug like this that was fixed in > Python 2.2. > - Geoff Bingo! I am indeed; thanks for the heads up. This'll probably drive me to take the hit of upgrading. -- Don Dwiggins, Beta Version 0.8 (Version 1.0 due for release Real Soon Now) d.l.dwiggins@computer.org From Kerim Borchaev Fri Oct 25 13:48:12 2002 From: Kerim Borchaev (Kerim Borchaev) Date: Fri, 25 Oct 2002 16:48:12 +0400 Subject: [python-win32] Trying to use DirectX Message-ID: <65158667609.20021025164812@hotbox.ru> This is a multi-part message in MIME format... ------------=_1035550187-47558-0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello! Is it possible to use DirectX typelibrary with Python? When I try this script: import win32com.client win32com.client.Dispatch('DIRECT.DirectX8.0') I get this error: Traceback (most recent call last): File "test.py", line 2, in ? win32com.client.Dispatch('DIRECT.DirectX8.0') File "C:\Python22\lib\site-packages\win32com\client\__init__.py", line 92, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) 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.IID_IDispatch) pywintypes.com_error: (-2147467262, 'No such interface supported', None, None) Can someone kindly explain me what happens here? Best regards, Kerim mailto:warkid@hotbox.ru ------------------ Get free mailbox 20 Mb at http://www.hotbox.ru ------------=_1035550187-47558-0-- From jeff@ccvcorp.com Fri Oct 25 17:37:38 2002 From: jeff@ccvcorp.com (Jeff Shannon) Date: Fri, 25 Oct 2002 09:37:38 -0700 Subject: [python-win32] Re: Trying to use DirectX References: <20021025160021.12398.16491.Mailman@mail.python.org> Message-ID: <3DB97352.676458C5@ccvcorp.com> > > From: Kerim Borchaev > > Is it possible to use DirectX typelibrary with Python? > > When I try this script: > > import win32com.client > win32com.client.Dispatch('DIRECT.DirectX8.0') > > I get this error: > [...] > pywintypes.com_error: (-2147467262, 'No such interface supported', None, None) If I'm not mistaken, the PythonCOM framework currently only supports COM servers that offer Automation -- that is, they expose an IDispatch interface. DirectX does not offer such an interface, so it's not really possible to use it. IIRC, automatic support of arbitrary COM interfaces was deemed to be too difficult to be practical. I seem to remember seeing some discussion, quite a while back, about the possibilities of custom-coding a PythonCOM wrapper for specific interfaces. If you were to do that for every DirectX interface you needed, then presumably you could use the rest of the win32com framework with those interfaces. Jeff Shannon Technician/Programmer Credit International From pavlos@gaaros.com Mon Oct 28 12:07:29 2002 From: pavlos@gaaros.com (pavlos@gaaros.com) Date: Mon, 28 Oct 2002 12:07:29 GMT Subject: [python-win32] Creating an installer for a COM server. Message-ID: <20021028120729.26881.qmail@mail.yifansoft.com> Hello everyone We are trying to create an installer that installs and registers 4-5 COM servers on win2000/nt machines. We would like to ship a single installer that contains a custom python distro plus all the required external modules including win32com support. The scale/requirements of our app do not fit well the already available ones like the Installer app by Gordon McMillan therefore we need to create the appropriate path/configuration modifications to both python and to win32all so that the COM servers will be registered appropriately. Additionally we do not want to modify or affect in any way existing python installations on the client machines. So far we have figured out the following: * python sets up its sys.path attribute from a number of sources. One is a hardcoded registry key. This we can modify to point to an appropriate subkey under our application's root key. As far as we can tell the following registry keys need to be set appropriately: SOFTWARE\\Python\PythonCore\2.2\InstallPath SOFTWARE\\Python\PythonCore\2.2\InstallPath\InstallGroup SOFTWARE\\Python\PythonCore\2.2\Modules\pythoncom SOFTWARE\\Python\PythonCore\2.2\Modules\pywintypes SOFTWARE\\Python\PythonCore\2.2\PythonPath SOFTWARE\\Python\PythonCore\2.2\PythonPath\win32com SOFTWARE\\Python\PythonCore\2.2\PythonPath\win32 * If the shiped python is modified to look in the above registry keys the COM servers work fine as long as pywintypes22.dll and pythoncom22.dll exist in the winnt/system32/ dir. We do not want to overwrite existing python installations in any way (in case users are running modified versions of pythoncom22.dll ...). However if we modify the above registry keys for pythoncom22.dll and pywintypes22.dll paths, then the COM servers no longer work. A few *.py files in the win32all distro contain hardwired references to registry keys. Modifying those does not fix the problem. Any ideas/pointers? Thanks in advance ===== Pavlos Christoforou From robin@reportlab.com Mon Oct 28 17:57:59 2002 From: robin@reportlab.com (Robin Becker) Date: Mon, 28 Oct 2002 17:57:59 +0000 Subject: [python-win32] Creating an installer for a COM server. In-Reply-To: <20021028120729.26881.qmail@mail.yifansoft.com> References: <20021028120729.26881.qmail@mail.yifansoft.com> Message-ID: <4T7fjKAnqXv9EwDR@jessikat.demon.co.uk> ReportLab is shipping and exe demo that controls exactly the bits that you are concerned about. So far as I can tell we are using the following registry keys Root: HKCU; Subkey: "Software\ReportLab\Demo"; Flags: uninsdeletekey Root: HKCU; Subkey: "Software\ReportLab\Demo"; ValueType: string; ValueName: "InstallPath"; ValueData: "{app}" Root: HKCU; Subkey: "Software\ReportLab\Demo"; ValueType: string; ValueName: "Version"; ValueData: "1.16" Root: HKLM; Subkey: "Software\ReportLab\Demo"; Flags: uninsdeletekey Root: HKLM; Subkey: "Software\ReportLab\Demo"; ValueType: string; ValueName: "InstallPath"; ValueData: "{app}" Root: HKLM; Subkey: "Software\ReportLab\Demo"; ValueType: string; ValueName: "Version"; ValueData: "1.16" and we have a modified python.c that controls the startup fairly rigorously. It looks at the registry installpath and then the python.exe location to establish a HOMEPATH then it searches for and dynamically loads the pythonx.x dll it finds underneath HOMEPATH\DLLs. During the startup to eliminate leakage we're doing things like pypath = (char*)malloc(strlen(homepath)+13); strcpy(pypath,"PYTHONHOME="); strcpy(pypath+11,homepath); i = strlen(pypath)-1; if(pypath[i]=='\\' || pypath[i]=='/') pypath[i]=0; VS1("Set %s\n",pypath); _putenv( pypath ); free(pypath); VS("Setting Python vars\n"); orgNoSiteFlag = *Py_NoSiteFlag; *Py_NoSiteFlag = 1; Py_SetProgramName(argv[0]); VS("Initializing Python\n"); Py_Initialize(); Py_GetPath(); _putenv( "PYTHONPATH="); VS("Importing module sys\n"); PyRun_SimpleStringFlags("import sys;sys.path=filter(lambda x: not x or x.find(sys.exec_prefix)==0, sys.path)", &cf); VS("Installing import hooks\n"); pypath = malloc(strlen(_rl_startup)+strlen(homepath)+100); sprintf(pypath,_rl_startup,homepath); if(PyRun_SimpleStringFlags(pypath, &cf)){ FATALERROR("Cannot start up importing.\n"); return -1; } free(pypath); if(!orgNoSiteFlag){ VS("Importing module site\n"); *Py_NoSiteFlag = 0; PyRun_SimpleStringFlags("import site;" _RL_RESTORE_PYZ, &cf); } if (*Py_VerboseFlag || (command == NULL && filename == NULL && stdin_is_interactive)) fprintf(stderr, "Python %s on %s\n%s\n", Py_GetVersion(), Py_GetPlatform(), COPYRIGHT); I know we have used this framework OK with a simple Excel+COM framework (ie not all of Pythonwin was in the demo) so I think the above is sufficient to make stuff work with COM. Anyhow Gordon's latest stuff makes pretty good COM servers so is there a special reason to not use his approach? -- Robin Becker From pavlos@gaaros.com Mon Oct 28 19:48:38 2002 From: pavlos@gaaros.com (pavlos@gaaros.com) Date: Mon, 28 Oct 2002 19:48:38 GMT Subject: [python-win32] Re: Creating an installer for a COM server. In-Reply-To: <4T7fjKAnqXv9EwDR@jessikat.demon.co.uk> References: <20021028120729.26881.qmail@mail.yifansoft.com> <4T7fjKAnqXv9EwDR@jessikat.demon.co.uk> Message-ID: <20021028194838.10504.qmail@mail.yifansoft.com> Robin, Thanks for the detailed info. It seems you are not messing around with any stuff from the win32all distro, just the python sources. We will follow your suggestions and see if we can make it work. . Last I have checked Gordon's installer, we could not get the 'look' and features (like running scripts at the end of an installation etc) that we were getting with INNO Setup. I will download his latest release and give it a try. Thanks a lot. Pavlos